Implement Forge protocol handshake support (#3869)
This commit is contained in:
@@ -124,21 +124,46 @@ cProtocol_1_9_0::cProtocol_1_9_0(cClientHandle * a_Client, const AString & a_Ser
|
||||
m_IsEncrypted(false)
|
||||
{
|
||||
|
||||
// BungeeCord handling:
|
||||
// If BC is setup with ip_forward == true, it sends additional data in the login packet's ServerAddress field:
|
||||
// hostname\00ip-address\00uuid\00profile-properties-as-json
|
||||
AStringVector Params;
|
||||
if (cRoot::Get()->GetServer()->ShouldAllowBungeeCord() && SplitZeroTerminatedStrings(a_ServerAddress, Params) && (Params.size() == 4))
|
||||
SplitZeroTerminatedStrings(a_ServerAddress, Params);
|
||||
|
||||
if (Params.size() >= 2)
|
||||
{
|
||||
LOGD("Player at %s connected via BungeeCord", Params[1].c_str());
|
||||
m_ServerAddress = Params[0];
|
||||
m_Client->SetIPString(Params[1]);
|
||||
|
||||
cUUID UUID;
|
||||
UUID.FromString(Params[2]);
|
||||
m_Client->SetUUID(UUID);
|
||||
if (Params[1] == "FML")
|
||||
{
|
||||
LOGD("Forge client connected!");
|
||||
m_Client->SetIsForgeClient();
|
||||
}
|
||||
else if (Params.size() == 4)
|
||||
{
|
||||
if (cRoot::Get()->GetServer()->ShouldAllowBungeeCord())
|
||||
{
|
||||
// BungeeCord handling:
|
||||
// If BC is setup with ip_forward == true, it sends additional data in the login packet's ServerAddress field:
|
||||
// hostname\00ip-address\00uuid\00profile-properties-as-json
|
||||
|
||||
m_Client->SetProperties(Params[3]);
|
||||
LOGD("Player at %s connected via BungeeCord", Params[1].c_str());
|
||||
|
||||
m_Client->SetIPString(Params[1]);
|
||||
|
||||
cUUID UUID;
|
||||
UUID.FromString(Params[2]);
|
||||
m_Client->SetUUID(UUID);
|
||||
|
||||
m_Client->SetProperties(Params[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("BungeeCord is disabled, but client sent additional data, set AllowBungeeCord=1 if you want to allow it");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("Unknown additional data sent in server address (BungeeCord/FML?): " SIZE_T_FMT " parameters", Params.size());
|
||||
// TODO: support FML + BungeeCord? (what parameters does it send in that case?) https://github.com/SpigotMC/BungeeCord/issues/899
|
||||
}
|
||||
}
|
||||
|
||||
// Create the comm log file, if so requested:
|
||||
@@ -2194,6 +2219,7 @@ void cProtocol_1_9_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
||||
ResponseValue["version"] = Version;
|
||||
ResponseValue["players"] = Players;
|
||||
ResponseValue["description"] = Description;
|
||||
m_Client->ForgeAugmentServerListPing(ResponseValue);
|
||||
if (!Favicon.empty())
|
||||
{
|
||||
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
|
||||
@@ -4204,6 +4230,7 @@ void cProtocol_1_9_1::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
||||
ResponseValue["version"] = Version;
|
||||
ResponseValue["players"] = Players;
|
||||
ResponseValue["description"] = Description;
|
||||
m_Client->ForgeAugmentServerListPing(ResponseValue);
|
||||
if (!Favicon.empty())
|
||||
{
|
||||
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
|
||||
@@ -4261,6 +4288,7 @@ void cProtocol_1_9_2::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
||||
ResponseValue["version"] = Version;
|
||||
ResponseValue["players"] = Players;
|
||||
ResponseValue["description"] = Description;
|
||||
m_Client->ForgeAugmentServerListPing(ResponseValue);
|
||||
if (!Favicon.empty())
|
||||
{
|
||||
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
|
||||
@@ -4318,6 +4346,7 @@ void cProtocol_1_9_4::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
||||
ResponseValue["version"] = Version;
|
||||
ResponseValue["players"] = Players;
|
||||
ResponseValue["description"] = Description;
|
||||
m_Client->ForgeAugmentServerListPing(ResponseValue);
|
||||
if (!Favicon.empty())
|
||||
{
|
||||
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
|
||||
|
||||
Reference in New Issue
Block a user