mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 16:26:38 +00:00
Deduplicate STUN package sending. Originally, because every peer shared the same UDP address, the library could not distinguish which STUN message was associated with which candidate. As a result, the Pion library responded from all candidates for every STUN message.
23 lines
548 B
Go
23 lines
548 B
Go
//go:build !ios
|
|
|
|
package udpmux
|
|
|
|
import (
|
|
nbnet "github.com/netbirdio/netbird/util/net"
|
|
)
|
|
|
|
func (m *SingleSocketUDPMux) notifyAddressRemoval(addr string) {
|
|
// Kernel mode: direct nbnet.PacketConn (SharedSocket wrapped with nbnet)
|
|
if conn, ok := m.params.UDPConn.(*nbnet.PacketConn); ok {
|
|
conn.RemoveAddress(addr)
|
|
return
|
|
}
|
|
|
|
// Userspace mode: UDPConn wrapper around nbnet.PacketConn
|
|
if wrapped, ok := m.params.UDPConn.(*UDPConn); ok {
|
|
if conn, ok := wrapped.GetPacketConn().(*nbnet.PacketConn); ok {
|
|
conn.RemoveAddress(addr)
|
|
}
|
|
}
|
|
}
|