summaryrefslogtreecommitdiffstats
path: root/Tools/ProtoProxy
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-09-08 11:12:34 +0200
committermadmaxoft <github@xoft.cz>2013-09-08 11:12:34 +0200
commit273a53a75818360477b711e4442c7ceba7a308aa (patch)
tree8d6a9b88081e1d648738863b9eb82eea4322a6f3 /Tools/ProtoProxy
parentMerged branch 'Projectiles'. (diff)
downloadcuberite-273a53a75818360477b711e4442c7ceba7a308aa.tar
cuberite-273a53a75818360477b711e4442c7ceba7a308aa.tar.gz
cuberite-273a53a75818360477b711e4442c7ceba7a308aa.tar.bz2
cuberite-273a53a75818360477b711e4442c7ceba7a308aa.tar.lz
cuberite-273a53a75818360477b711e4442c7ceba7a308aa.tar.xz
cuberite-273a53a75818360477b711e4442c7ceba7a308aa.tar.zst
cuberite-273a53a75818360477b711e4442c7ceba7a308aa.zip
Diffstat (limited to 'Tools/ProtoProxy')
-rw-r--r--Tools/ProtoProxy/Connection.cpp41
1 files changed, 34 insertions, 7 deletions
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index fc8fceb99..55ba74a87 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -1636,7 +1636,8 @@ bool cConnection::HandleServerKick(void)
// Split by NULL chars (StringSplit() won't work here):
size_t Last = 0;
- for (size_t i = 0; i < Reason.size(); i++)
+ size_t Len = Reason.size();
+ for (size_t i = 0; i < Len; i++)
{
if (Reason[i] == 0)
{
@@ -1644,14 +1645,40 @@ bool cConnection::HandleServerKick(void)
Last = i + 1;
}
}
+ if (Last < Len)
+ {
+ Split.push_back(Reason.substr(Last));
+ }
- if (Split.size() == 5)
+ if (Split.size() == 6)
{
- Log(" Protocol version: \"%s\"", Split[0].c_str());
- Log(" Server version: \"%s\"", Split[1].c_str());
- Log(" MOTD: \"%s\"", Split[2].c_str());
- Log(" Cur players: \"%s\"", Split[3].c_str());
- Log(" Max players: \"%s\"", Split[4].c_str());
+ Log(" Preamble: \"%s\"", Split[0].c_str());
+ Log(" Protocol version: \"%s\"", Split[1].c_str());
+ Log(" Server version: \"%s\"", Split[2].c_str());
+ Log(" MOTD: \"%s\"", Split[3].c_str());
+ Log(" Cur players: \"%s\"", Split[4].c_str());
+ Log(" Max players: \"%s\"", Split[5].c_str());
+
+ // Modify the MOTD to show that it's being ProtoProxied:
+ Reason.assign(Split[0]);
+ Reason.push_back(0);
+ Reason.append(Split[1]);
+ Reason.push_back(0);
+ Reason.append(Split[2]);
+ Reason.push_back(0);
+ Reason.append(Printf("ProtoProxy: %s", Split[3].c_str()));
+ Reason.push_back(0);
+ Reason.append(Split[4]);
+ Reason.push_back(0);
+ Reason.append(Split[5]);
+ AString ReasonBE16;
+ UTF8ToRawBEUTF16(Reason.data(), Reason.size(), ReasonBE16);
+ AString PacketStart("\xff");
+ PacketStart.push_back((ReasonBE16.size() / 2) / 256);
+ PacketStart.push_back((ReasonBE16.size() / 2) % 256);
+ CLIENTSEND(PacketStart.data(), PacketStart.size());
+ CLIENTSEND(ReasonBE16.data(), ReasonBE16.size());
+ return true;
}
else
{