fix: Get client public IP return a IPV6

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

View File

@@ -326,15 +326,12 @@ LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn)
std::string loc = cfg.GetStr("settings", "location", "");
std::string pubIP = cfg.GetStr("settings", "public_ip", "");
auto ip_time = cfg.GetInt("settings", "ip_time");
bool timeout = ip_time <= 0 || (time(0) - ip_time > 7 * 86400);
IPConverter cvt;
if (loc.empty()) {
std::string ip = cvt.getPublicIP();
if (pubIP.empty()) pubIP = ip;
if (loc.empty() || pubIP.empty() || timeout) {
pubIP = cvt.getPublicIP();
loc = cvt.GetGeoLocation(pubIP);
cfg.SetStr("settings", "location", loc);
}
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));
}