MCPcopy Create free account
hub / github.com/cuberite/cuberite / HandleClientHandshake

Method HandleClientHandshake

Tools/ProtoProxy/Connection.cpp:778–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

776// packet handling, client-side, initial handshake:
777
778bool cConnection::HandleClientHandshake(void)
779{
780 // Read the packet from the client:
781 HANDLE_CLIENT_PACKET_READ(ReadVarInt, UInt32, ProtocolVersion);
782 HANDLE_CLIENT_PACKET_READ(ReadVarUTF8String, AString, ServerHost);
783 HANDLE_CLIENT_PACKET_READ(ReadBEShort, short, ServerPort);
784 HANDLE_CLIENT_PACKET_READ(ReadVarInt, UInt32, NextState);
785 m_ClientBuffer.CommitRead();
786
787 Log("Received an initial handshake packet from the client:");
788 Log(" ProtocolVersion = %u", ProtocolVersion);
789 Log(" ServerHost = \"%s\"", ServerHost.c_str());
790 Log(" ServerPort = %d", ServerPort);
791 Log(" NextState = %u", NextState);
792
793 // Send the same packet to the server, but with our port:
794 cByteBuffer Packet(512);
795 Packet.WriteVarInt(0); // Packet type - initial handshake
796 Packet.WriteVarInt(ProtocolVersion);
797 Packet.WriteVarUTF8String(ServerHost);
798 Packet.WriteBEShort(m_Server.GetConnectPort());
799 Packet.WriteVarInt(NextState);
800 AString Pkt;
801 Packet.ReadAll(Pkt);
802 cByteBuffer ToServer(512);
803 ToServer.WriteVarUTF8String(Pkt);
804 SERVERSEND(ToServer);
805
806 m_ClientProtocolState = (int)NextState;
807 m_ServerProtocolState = (int)NextState;
808
809 return true;
810}
811
812
813

Callers

nothing calls this directly

Calls 7

CommitReadMethod · 0.80
c_strMethod · 0.80
WriteBEShortMethod · 0.80
GetConnectPortMethod · 0.80
ReadAllMethod · 0.80
WriteVarIntMethod · 0.45
WriteVarUTF8StringMethod · 0.45

Tested by

no test coverage detected