| 1572 | |
| 1573 | |
| 1574 | void 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 |
nothing calls this directly
no test coverage detected