From a5bd66513a824c81ba814494fc28cca9d4fb5ef9 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 26 Jan 2025 11:53:39 +0100 Subject: [PATCH] NetworkSystem: fix network address comparisons Network addresses should always be stored as base only (without their port numbers), since all additional data can change on reconnects which will make comparisons impossible. --- src/networksystem/bansystem.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/networksystem/bansystem.cpp b/src/networksystem/bansystem.cpp index cfc2cd57..ffe3acd7 100644 --- a/src/networksystem/bansystem.cpp +++ b/src/networksystem/bansystem.cpp @@ -324,7 +324,7 @@ void CBanSystem::AuthorPlayerByName(const char* playerName, const bool shouldBan { if (strcmp(playerName, pNetChan->GetName()) == NULL) // Our wanted name? { - if (shouldBan && AddEntry(pNetChan->GetAddress(), pClient->GetNucleusID()) && !bSave) + if (shouldBan && AddEntry(pNetChan->GetAddress(true), pClient->GetNucleusID()) && !bSave) bSave = true; pClient->Disconnect(REP_MARK_BAD, reason); @@ -389,7 +389,7 @@ void CBanSystem::AuthorPlayerById(const char* playerHandle, const bool shouldBan continue; } - if (shouldBan && AddEntry(pNetChan->GetAddress(), pClient->GetNucleusID()) && !bSave) + if (shouldBan && AddEntry(pNetChan->GetAddress(true), pClient->GetNucleusID()) && !bSave) bSave = true; pClient->Disconnect(REP_MARK_BAD, reason); @@ -397,10 +397,12 @@ void CBanSystem::AuthorPlayerById(const char* playerHandle, const bool shouldBan } else { - if (strcmp(playerHandle, pNetChan->GetAddress()) != NULL) + const char* const chanAddr = pNetChan->GetAddress(true); + + if (strcmp(playerHandle, chanAddr) != NULL) continue; - if (shouldBan && AddEntry(pNetChan->GetAddress(), pClient->GetNucleusID()) && !bSave) + if (shouldBan && AddEntry(chanAddr, pClient->GetNucleusID()) && !bSave) bSave = true; pClient->Disconnect(REP_MARK_BAD, reason);