diff options
Diffstat (limited to 'source/cServer.cpp')
-rw-r--r-- | source/cServer.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/source/cServer.cpp b/source/cServer.cpp index 44dd365c2..f14a419a9 100644 --- a/source/cServer.cpp +++ b/source/cServer.cpp @@ -295,17 +295,23 @@ void cServer::StartListenClient() {
cSocket SClient = m_pState->SListenClient.Accept();
- if( SClient.IsValid() )
+ if (!SClient.IsValid())
{
- char * ClientIP = SClient.GetIPString();
- if( ClientIP == 0 )
- return;
+ return;
+ }
+
+ const AString & ClientIP = SClient.GetIPString();
+ if (ClientIP.empty())
+ {
+ LOGWARN("cServer: A client connected, but didn't present its IP, disconnecting.");
+ SClient.CloseSocket();
+ return;
+ }
- LOG("%s connected!", ClientIP);
+ LOG("%s connected!", ClientIP.c_str());
- cClientHandle *NewHandle = new cClientHandle( SClient );
- m_pState->Clients.push_back( NewHandle ); // TODO - lock list
- }
+ cClientHandle *NewHandle = new cClientHandle( SClient );
+ m_pState->Clients.push_back( NewHandle ); // TODO - lock list
}
|