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

Method HandlePacketLoginStart

src/Protocol/Protocol17x.cpp:1574–1608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1572
1573
1574void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
1575{
1576 AString Username;
1577 a_ByteBuffer.ReadVarUTF8String(Username);
1578
1579 if (!m_Client->HandleHandshake(Username))
1580 {
1581 // The client is not welcome here, they have been sent a Kick packet already
1582 return;
1583 }
1584
1585 // If auth is required, then send the encryption request:
1586 if (cRoot::Get()->GetServer()->ShouldAuthenticate())
1587 {
1588 cPacketizer Pkt(*this, 0x01);
1589 Pkt.WriteString(cRoot::Get()->GetServer()->GetServerID());
1590 const AString & PubKeyDer = cRoot::Get()->GetServer()->GetPublicKeyDER();
1591 Pkt.WriteShort(PubKeyDer.size());
1592 Pkt.WriteBuf(PubKeyDer.data(), PubKeyDer.size());
1593 Pkt.WriteShort(4);
1594 Pkt.WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :)
1595 m_Client->SetUsername(Username);
1596 return;
1597 }
1598
1599 // Send login success:
1600 {
1601 cPacketizer Pkt(*this, 0x02); // Login success packet
1602 Pkt.WriteString(Printf("%d", m_Client->GetUniqueID())); // TODO: proper UUID
1603 Pkt.WriteString(Username);
1604 }
1605
1606 m_State = 3; // State = Game
1607 m_Client->HandleLogin(4, Username);
1608}
1609
1610
1611

Callers

nothing calls this directly

Calls 13

PrintfFunction · 0.85
ReadVarUTF8StringMethod · 0.80
HandleHandshakeMethod · 0.80
ShouldAuthenticateMethod · 0.80
GetServerMethod · 0.80
sizeMethod · 0.80
SetUsernameMethod · 0.80
HandleLoginMethod · 0.80
WriteStringMethod · 0.45
WriteShortMethod · 0.45
WriteBufMethod · 0.45
WriteIntMethod · 0.45

Tested by

no test coverage detected