#pragma once #include #include #include "common/iniFile.h" namespace StartGate { constexpr const char* kValueName = "retry_after"; constexpr int kDefaultDelaySec = 60 * 60; inline std::string ConfigPath(bool isAuthKernel) { return isAuthKernel ? std::string(YAMA_PATH) : CLIENT_PATH; } inline const char* ConfigSection(bool isAuthKernel) { return isAuthKernel ? "auth" : "settings"; } inline int Get(config& cfg, const char* section) { return cfg.GetInt(section, kValueName, 0); } inline void Set(config& cfg, const char* section, int unixTime) { cfg.SetInt(section, kValueName, unixTime > 0 ? unixTime : 0); } inline void Delay(config& cfg, const char* section, int delaySec) { Set(cfg, section, (int)time(NULL) + delaySec); } inline bool AllowStartNow(config& cfg, const char* section) { const int t = Get(cfg, section); return t <= 0 || (int)time(NULL) >= t; } }