Feature: back off client startup after a forbidden command
A banned host receives COMMAND_FORBIDDEN and exits, but relaunching it immediately makes it reconnect and receive the command again in a tight loop. Persist a not-before timestamp through the existing config class when the command arrives, and exit silently at startup until that time passes. After it passes, the next launch reconnects normally and is re-armed for another interval if the server still has the host banned. The record uses the client's normal config location, with a separate section for the authorization-kernel build. Management commands (-cmd=) and the local test client are exempt. Verified with Debug x64 builds of ghost and ServerDll. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
85f7f1aa67
commit
082860de8f
3 files changed
+72
No files matched your search
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <time.h>
|
||||
#include <string>
|
||||
#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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user