Fixed mishandling of public/private IP addresses

This commit is contained in:
2024-11-17 07:18:03 +00:00
parent 0f259307df
commit db4542dd7a
9 changed files with 61 additions and 38 deletions

View File

@ -1145,9 +1145,10 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
return;
}
peer->SetChannel(p->bChannel);
peer->SetPublicIP(p->szPublicIP);
peer->SetChannel(p->bChannel);
peer->SetListenPort(p->wListenPort);
peer->SetInternalIP(p->szInternalIP);
peer->SetP2PPort(p->wP2PPort);
peer->SetMaps(p->alMaps);
@ -1264,9 +1265,9 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
SPDLOG_DEBUG("SETUP: channel {} listen {} p2p {} count {}", peer->GetChannel(), p->wListenPort, p->wP2PPort, bMapCount);
TPacketDGP2P p2pSetupPacket;
p2pSetupPacket.wPort = peer->GetP2PPort();
p2pSetupPacket.bChannel = peer->GetChannel();
strlcpy(p2pSetupPacket.szHost, peer->GetPublicIP(), sizeof(p2pSetupPacket.szHost));
strlcpy(p2pSetupPacket.szHost, peer->GetInternalIP(), sizeof(p2pSetupPacket.szHost));
p2pSetupPacket.wPort = peer->GetP2PPort();
for (itertype(m_peerList) i = m_peerList.begin(); i != m_peerList.end();++i)
{

View File

@ -38,15 +38,18 @@ class CPeer : public CPeerBase
DWORD GetUserCount();
void SetUserCount(DWORD dwCount);
void SetPublicIP(const char * ip) { m_stPublicIP = ip; }
const char * GetPublicIP() { return m_stPublicIP.c_str(); }
void SetChannel(BYTE bChannel) { m_bChannel = bChannel; }
BYTE GetChannel() { return m_bChannel; }
void SetPublicIP(const char * ip) { m_stPublicIP = ip; }
const char * GetPublicIP() { return m_stPublicIP.c_str(); }
void SetListenPort(WORD wPort) { m_wListenPort = wPort; }
WORD GetListenPort() { return m_wListenPort; }
void SetInternalIP(const char * ip) { m_stInternalIP = ip; }
const char * GetInternalIP() { return m_stInternalIP.c_str(); }
void SetP2PPort(WORD wPort);
WORD GetP2PPort() { return m_wP2PPort; }
@ -72,6 +75,7 @@ class CPeer : public CPeerBase
TItemIDRangeTable m_itemSpareRange;
std::string m_stPublicIP;
std::string m_stInternalIP;
};
#endif