diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-30 10:19:19 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-30 10:19:19 +0200 |
commit | fa93c0cf5434384aac5a75aa3cb3910d3f7679a6 (patch) | |
tree | c29ab301118136e1ae5d36b820ddec57abc1346f /source/Protocol125.cpp | |
parent | Fixed the VC2010 project file (diff) | |
download | cuberite-fa93c0cf5434384aac5a75aa3cb3910d3f7679a6.tar cuberite-fa93c0cf5434384aac5a75aa3cb3910d3f7679a6.tar.gz cuberite-fa93c0cf5434384aac5a75aa3cb3910d3f7679a6.tar.bz2 cuberite-fa93c0cf5434384aac5a75aa3cb3910d3f7679a6.tar.lz cuberite-fa93c0cf5434384aac5a75aa3cb3910d3f7679a6.tar.xz cuberite-fa93c0cf5434384aac5a75aa3cb3910d3f7679a6.tar.zst cuberite-fa93c0cf5434384aac5a75aa3cb3910d3f7679a6.zip |
Diffstat (limited to 'source/Protocol125.cpp')
-rw-r--r-- | source/Protocol125.cpp | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/source/Protocol125.cpp b/source/Protocol125.cpp index d9faefb77..a50551c35 100644 --- a/source/Protocol125.cpp +++ b/source/Protocol125.cpp @@ -15,6 +15,8 @@ #include "cPlayer.h"
#include "cChatColor.h"
#include "cWindow.h"
+#include "cRoot.h"
+#include "cServer.h"
@@ -958,7 +960,26 @@ int cProtocol125::ParseEntityAction(void) int cProtocol125::ParseHandshake(void)
{
HANDLE_PACKET_READ(ReadBEUTF16String16, AString, Username);
- m_Client->HandleHandshake(Username);
+
+ AStringVector UserData = StringSplit(Username, ";"); // "FakeTruth;localhost:25565"
+ if (UserData.empty())
+ {
+ m_Client->Kick("Did not receive username");
+ return PARSE_OK;
+ }
+ m_Username = UserData[0];
+
+ LOGD("HANDSHAKE %s", Username.c_str());
+
+ if (cRoot::Get()->GetDefaultWorld()->GetNumPlayers() >= cRoot::Get()->GetDefaultWorld()->GetMaxPlayers())
+ {
+ m_Client->Kick("The server is currently full :(-- Try again later");
+ return PARSE_OK;
+ }
+
+ SendHandshake(cRoot::Get()->GetServer()->GetServerID());
+ LOGD("User \"%s\" was sent a handshake response", m_Username.c_str());
+
return PARSE_OK;
}
@@ -987,6 +1008,29 @@ int cProtocol125::ParseLogin(void) HANDLE_PACKET_READ(ReadChar, char, Difficulty);
HANDLE_PACKET_READ(ReadByte, Byte, WorldHeight);
HANDLE_PACKET_READ(ReadByte, Byte, MaxPlayers);
+
+ if (ProtocolVersion < 29)
+ {
+ m_Client->Kick("Your client is outdated!");
+ return PARSE_OK;
+ }
+ else if (ProtocolVersion > 29)
+ {
+ m_Client->Kick("Your client version is higher than the server!");
+ return PARSE_OK;
+ }
+
+ if (m_Username.compare(Username) != 0)
+ {
+ LOGWARNING("Login Username (\"%s\") does not match Handshake username (\"%s\") for client @ \"%s\", kicking",
+ Username.c_str(),
+ m_Username.c_str(),
+ m_Client->GetSocket().GetIPString().c_str()
+ );
+ m_Client->Kick("Hacked client"); // Don't tell them why we don't want them
+ return PARSE_OK;
+ }
+
m_Client->HandleLogin(ProtocolVersion, Username);
return PARSE_OK;
}
|