fix: Showing wrong IP while using Reverse Proxy

This commit is contained in:
yuanyuanxiang
2025-06-28 16:50:01 +08:00
parent 659f820fd1
commit 9aa5d589c4
11 changed files with 243 additions and 220 deletions

View File

@@ -190,6 +190,7 @@
<ClCompile Include="X264Encoder.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\location.h" />
<ClInclude Include="..\server\2015Remote\pwd_gen.h" />
<ClInclude Include="Audio.h" />
<ClInclude Include="AudioManager.h" />

View File

@@ -8,6 +8,7 @@
#include <NTSecAPI.h>
#include "common/skCrypter.h"
#include <common/iniFile.h>
#include <location.h>
// by ChatGPT
bool IsWindows11() {
@@ -284,6 +285,23 @@ LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn)
strcmp(conn.szFlag, skCrypt("Happy New Year!")) == 0;
const char* id = isDefault ? masterHash.c_str() : conn.szFlag;
memcpy(LoginInfor.szMasterID, id, min(strlen(id), 16));
iniFile cfg(CLIENT_PATH);
std::string loc = cfg.GetStr("settings", "location", "");
std::string pubIP = cfg.GetStr("settings", "public_ip", "");
IPConverter cvt;
if (loc.empty()) {
std::string ip = cvt.getPublicIP();
if (pubIP.empty()) pubIP = ip;
loc = cvt.GetGeoLocation(pubIP);
cfg.SetStr("settings", "location", loc);
}
if (pubIP.empty()) {
pubIP = cvt.getPublicIP();
cfg.SetStr("settings", "public_ip", pubIP);
}
LoginInfor.AddReserved(loc.c_str());
LoginInfor.AddReserved(pubIP.c_str());
return LoginInfor;
}