summaryrefslogtreecommitdiffstats
path: root/source/cServer.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-02 08:47:19 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-02 08:47:19 +0100
commit865216b15a4cfb836dddcb9bf66532b4f46497a3 (patch)
tree789c307051468c4aa0bf030e417fff03cac3a2a1 /source/cServer.cpp
parentRewritten cAuthenticator to make use of the new cIsThread architecture - now authentication runs in a single separate thread for all clients; (diff)
downloadcuberite-865216b15a4cfb836dddcb9bf66532b4f46497a3.tar
cuberite-865216b15a4cfb836dddcb9bf66532b4f46497a3.tar.gz
cuberite-865216b15a4cfb836dddcb9bf66532b4f46497a3.tar.bz2
cuberite-865216b15a4cfb836dddcb9bf66532b4f46497a3.tar.lz
cuberite-865216b15a4cfb836dddcb9bf66532b4f46497a3.tar.xz
cuberite-865216b15a4cfb836dddcb9bf66532b4f46497a3.tar.zst
cuberite-865216b15a4cfb836dddcb9bf66532b4f46497a3.zip
Diffstat (limited to 'source/cServer.cpp')
-rw-r--r--source/cServer.cpp22
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
}