diff --git a/gumble/gumble/udp15.go b/gumble/gumble/udp15.go index d7cd001..3cde238 100644 --- a/gumble/gumble/udp15.go +++ b/gumble/gumble/udp15.go @@ -452,7 +452,10 @@ func (c *Client) WriteAudioUDP15(data []byte, final bool) (bool, error) { if cs == nil || !cs.initialized { return false, nil } - if c.udpConn == nil { + + // Snapshot udpConn to avoid race with disconnect cleanup nil'ing it. + udpConn := c.udpConn + if udpConn == nil { return false, nil } @@ -461,9 +464,6 @@ func (c *Client) WriteAudioUDP15(data []byte, final bool) (bool, error) { // Build MumbleUDP.Audio protobuf. payload := encodeUDPAudio(0, frameNum, data, final) - log.Info("UDP15 send: frame=%d opus_len=%d proto_len=%d final=%v", - frameNum, len(data), len(payload), final) - // Encrypt with 1.5 format. encrypted, err := cs.encrypt15(payload) if err != nil { @@ -471,10 +471,10 @@ func (c *Client) WriteAudioUDP15(data []byte, final bool) (bool, error) { return false, err } - log.Info("UDP15 send: encrypted_len=%d hex=%s", - len(encrypted), hex.EncodeToString(encrypted)) + log.Debug("UDP15 send: frame=%d opus_len=%d enc_len=%d final=%v", + frameNum, len(data), len(encrypted), final) - _, err = c.udpConn.Write(encrypted) + _, err = udpConn.Write(encrypted) if err != nil { log.Error("UDP15 send write failed: %v", err) return false, err @@ -483,13 +483,18 @@ func (c *Client) WriteAudioUDP15(data []byte, final bool) (bool, error) { } // HandleUDPPacket15 processes an incoming Mumble 1.5 native UDP packet. +var firstUDP15Recv bool + func (c *Client) HandleUDPPacket15(packet []byte, pktNum uint64) { if len(packet) < udp15HeaderSize { log.Warn("UDP15 #%d: packet too short (%d bytes)", pktNum, len(packet)) return } - log.Info("UDP15 #%d: raw hex=%s", pktNum, hex.EncodeToString(packet)) + if !firstUDP15Recv { + firstUDP15Recv = true + log.Info("UDP15 #%d: first packet received! hex=%s", pktNum, hex.EncodeToString(packet)) + } cs := udp15Server if cs == nil || !cs.initialized { @@ -503,14 +508,11 @@ func (c *Client) HandleUDPPacket15(packet []byte, pktNum uint64) { return } - log.Info("UDP15 #%d: decrypt OK, plaintext hex=%s", pktNum, hex.EncodeToString(plaintext)) + log.Debug("UDP15 #%d: decrypt OK, plaintext_len=%d", pktNum, len(plaintext)) // Parse MumbleUDP.Audio protobuf. session, frameNum, opusData, terminator := decodeUDPAudio(plaintext) - log.Info("UDP15 #%d: session=%d frame=%d opus_len=%d term=%v", - pktNum, session, frameNum, len(opusData), terminator) - if len(opusData) == 0 && !terminator { return }