Fix Poke timeout, input CommandLow handling, and add Poke Popup
This commit is contained in:
@@ -55,6 +55,46 @@ func (c *Client) handlePacket(pkt *protocol.Packet) error {
|
||||
|
||||
c.Conn.SendPacket(ack)
|
||||
|
||||
return c.handleCommand(pkt)
|
||||
case protocol.PacketTypeCommandLow:
|
||||
// Send ACK Low
|
||||
ackData := make([]byte, 2)
|
||||
binary.BigEndian.PutUint16(ackData, pkt.Header.PacketID)
|
||||
|
||||
ack := protocol.NewPacket(protocol.PacketTypeAckLow, ackData)
|
||||
// Spec/ts3j: AckLow has its own counter
|
||||
c.AckLowPacketID++
|
||||
ack.Header.PacketID = c.AckLowPacketID
|
||||
ack.Header.ClientID = c.ClientID
|
||||
// ACKs usually don't have NewProtocol flag set in Header byte
|
||||
ack.Header.Type &= ^uint8(protocol.PacketFlagNewProtocol)
|
||||
|
||||
// ACKs for Command packets after handshake must be encrypted
|
||||
key := protocol.HandshakeKey
|
||||
nonce := protocol.HandshakeNonce
|
||||
|
||||
if c.Handshake != nil && c.Handshake.Step >= 6 && len(c.Handshake.SharedIV) > 0 {
|
||||
crypto := &protocol.CryptoState{
|
||||
SharedIV: c.Handshake.SharedIV,
|
||||
SharedMac: c.Handshake.SharedMac,
|
||||
GenerationID: 0,
|
||||
}
|
||||
key, nonce = crypto.GenerateKeyNonce(&ack.Header, true) // Client->Server=true
|
||||
}
|
||||
|
||||
// Meta for Client->Server: PID(2) + CID(2) + PT(1) = 5 bytes
|
||||
meta := make([]byte, 5)
|
||||
binary.BigEndian.PutUint16(meta[0:2], ack.Header.PacketID)
|
||||
binary.BigEndian.PutUint16(meta[2:4], ack.Header.ClientID)
|
||||
meta[4] = ack.Header.Type
|
||||
|
||||
encData, mac, _ := protocol.EncryptEAX(key, nonce, meta, ack.Data)
|
||||
ack.Data = encData
|
||||
copy(ack.Header.MAC[:], mac)
|
||||
// log.Printf("Sending ACK Low for server CommandLow PID=%d", pkt.Header.PacketID)
|
||||
|
||||
c.Conn.SendPacket(ack)
|
||||
|
||||
return c.handleCommand(pkt)
|
||||
case protocol.PacketTypeVoice:
|
||||
c.handleVoice(pkt)
|
||||
|
||||
Reference in New Issue
Block a user