replace latency packet id name usage

This commit is contained in:
Tnze
2024-06-16 16:41:53 +08:00
parent de10351a91
commit 5f5db75a34
6 changed files with 19 additions and 19 deletions

View File

@ -79,7 +79,7 @@ func Encrypt(conn *net.Conn, name string, serverKey *rsa.PrivateKey) (*Resp, err
func encryptionRequest(conn *net.Conn, publicKey, verifyToken []byte) error {
return conn.WritePacket(pk.Marshal(
packetid.ClientboundLoginEncryptionRequest,
packetid.ClientboundLoginHello,
pk.String(""),
pk.ByteArray(publicKey),
pk.ByteArray(verifyToken),
@ -92,7 +92,7 @@ func encryptionResponse(conn *net.Conn, serverKey *rsa.PrivateKey, verifyToken [
if err != nil {
return nil, err
}
if packetid.ServerboundPacketID(p.ID) != packetid.ServerboundLoginEncryptionResponse {
if packetid.ServerboundPacketID(p.ID) != packetid.ServerboundLoginKey {
return nil, fmt.Errorf("0x%02X is not Encryption Response", p.ID)
}

View File

@ -96,8 +96,8 @@ func (d *MojangLoginHandler) AcceptLogin(conn *net.Conn, protocol int32) (name s
if err != nil {
return
}
if packetid.ServerboundPacketID(p.ID) != packetid.ServerboundLoginStart {
err = wrongPacketErr{expect: int32(packetid.ServerboundLoginStart), get: p.ID}
if packetid.ServerboundPacketID(p.ID) != packetid.ServerboundLoginHello {
err = wrongPacketErr{expect: int32(packetid.ServerboundLoginHello), get: p.ID}
return
}
@ -133,7 +133,7 @@ func (d *MojangLoginHandler) AcceptLogin(conn *net.Conn, protocol int32) (name s
// set compression
if d.Threshold >= 0 {
err = conn.WritePacket(pk.Marshal(
packetid.ClientboundLoginCompression,
packetid.ClientboundLoginLoginCompression,
pk.VarInt(d.Threshold),
))
if err != nil {
@ -152,7 +152,7 @@ func (d *MojangLoginHandler) AcceptLogin(conn *net.Conn, protocol int32) (name s
}
// send login success
err = conn.WritePacket(pk.Marshal(
packetid.ClientboundLoginSuccess,
packetid.ClientboundLoginGameProfile,
pk.UUID(id),
pk.String(name),
pk.Array(properties),
@ -163,8 +163,8 @@ func (d *MojangLoginHandler) AcceptLogin(conn *net.Conn, protocol int32) (name s
// receive login ack
err = conn.ReadPacket(&p)
if err == nil && packetid.ServerboundPacketID(p.ID) != packetid.ServerboundLoginAcknowledged {
err = wrongPacketErr{expect: int32(packetid.ServerboundLoginAcknowledged), get: p.ID}
if err == nil && packetid.ServerboundPacketID(p.ID) != packetid.ServerboundLoginLoginAcknowledged {
err = wrongPacketErr{expect: int32(packetid.ServerboundLoginLoginAcknowledged), get: p.ID}
}
return
}

View File

@ -60,7 +60,7 @@ func (s *Server) acceptListPing(conn *net.Conn, clientProtocol int32) {
}
switch packetid.ClientboundPacketID(p.ID) {
case packetid.ClientboundStatusResponse: // List
case packetid.ClientboundStatusStatusResponse: // List
var resp []byte
resp, err = s.listResp(clientProtocol)
if err != nil {

View File

@ -81,7 +81,7 @@ func (s *Server) AcceptConn(conn *net.Conn) {
var loginErr LoginFailErr
if errors.As(err, &loginErr) {
_ = conn.WritePacket(pk.Marshal(
packetid.ClientboundLoginDisconnect,
packetid.ClientboundLoginLoginDisconnect,
loginErr.reason,
))
}