mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-29 23:15:56 -04:00
cleanup the implementation and make it build properly
This commit is contained in:
+22
-12
@@ -404,7 +404,7 @@ UdpManager::~UdpManager()
|
||||
TerminateOperatingSystem();
|
||||
|
||||
delete mAddressHashTable;
|
||||
delete mIpConnectionCount;
|
||||
mIpConnectionCount.clear();
|
||||
delete mConnectCodeHashTable;
|
||||
delete mPriorityQueue;
|
||||
for (int i = 0; i < mParams.packetHistoryMax; i++)
|
||||
@@ -561,7 +561,17 @@ void UdpManager::RemoveConnection(UdpConnection *con)
|
||||
mPriorityQueue->Remove(con);
|
||||
|
||||
mAddressHashTable->Remove(con, AddressHashValue(con->mIp, con->mPort));
|
||||
mIpConnectionCount.erase(con->mIp);
|
||||
|
||||
unsigned int addy = con->mIp.GetAddress();
|
||||
if (mIpConnectionCount[addy] > 1)
|
||||
{
|
||||
mIpConnectionCount[addy]--;
|
||||
}
|
||||
else
|
||||
{
|
||||
mIpConnectionCount.erase(addy);
|
||||
}
|
||||
|
||||
mConnectCodeHashTable->Remove(con, con->mConnectCode);
|
||||
}
|
||||
|
||||
@@ -577,7 +587,7 @@ void UdpManager::AddConnection(UdpConnection *con)
|
||||
mConnectionListCount++;
|
||||
|
||||
mAddressHashTable->Insert(con, AddressHashValue(con->mIp, con->mPort));
|
||||
mIpConnectionCount[con->mIp]++;
|
||||
mIpConnectionCount[con->mIp.GetAddress()]++;
|
||||
mConnectCodeHashTable->Insert(con, con->mConnectCode);
|
||||
}
|
||||
|
||||
@@ -1008,19 +1018,19 @@ void UdpManager::ProcessRawPacket(const PacketHistoryEntry *e)
|
||||
// connection establish packet must always be at least 6 bytes long as we must have a version number, no matter how it changes
|
||||
if (e->mBuffer[0] == 0 && e->mBuffer[1] == UdpConnection::cUdpPacketConnect && e->mLen == UdpConnection::cUdpPacketConnectSize)
|
||||
{
|
||||
if (mParams.maxConnectionsPerIP > 0)
|
||||
{
|
||||
if (mIpConnectionCount[e->mIp] >= mParams.maxConnectionsPerIP)
|
||||
{
|
||||
printf("Possible DoS attempt? Client %s attempted more connections than the limit (%i). Dropping!\n", e->mIp.GetV4Address(), mParams.maxConnectionsPerIP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mParams.maxConnectionsPerIP > 0)
|
||||
{
|
||||
if (mIpConnectionCount[e->mIp.GetAddress()] >= mParams.maxConnectionsPerIP)
|
||||
{
|
||||
printf("Possible DoS attempt? Client %s attempted more connections than the limit (%i). Dropping!\n", e->mIp.GetV4Address(), mParams.maxConnectionsPerIP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mConnectionListCount >= mParams.maxConnections)
|
||||
{
|
||||
return; // can't handle any more connections, so ignore this request entirely
|
||||
}
|
||||
}
|
||||
|
||||
int protocolVersion = UdpMisc::GetValue32(e->mBuffer + 2);
|
||||
if (protocolVersion == cProtocolVersion)
|
||||
|
||||
+1
-1
@@ -1041,7 +1041,7 @@ class UdpManager
|
||||
// typically it is recommended that all UdpConnection objects be destroyed before destroying this manager object
|
||||
|
||||
int mRefCount;
|
||||
unordered_map <unsigned int, int> mIpConnectionCount;
|
||||
std::unordered_map<unsigned int, int> mIpConnectionCount;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user