mirror of
https://github.com/netbirdio/netbird.git
synced 2025-03-04 09:51:16 +01:00
Check for stun packet with a fixed size
This commit is contained in:
parent
73b5f8d63b
commit
f49c299d77
@ -114,7 +114,7 @@ func (b *ICEBind) makeReceiveIPv4(c net.PacketConn, bindMux BindMux) conn.Receiv
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
if !stun.IsMessage(buff[:n]) {
|
||||
if !stun.IsMessage(buff[:20]) {
|
||||
// WireGuard traffic
|
||||
return n, (*conn.StdNetEndpoint)(&net.UDPAddr{
|
||||
IP: e.Addr().AsSlice(),
|
||||
|
@ -85,7 +85,7 @@ func (m *UDPMuxDefault) HandlePacket(p []byte, n int, addr net.Addr) error {
|
||||
m.addressMapMu.Unlock()
|
||||
|
||||
// If we haven't seen this address before but is a STUN packet lookup by ufrag
|
||||
if destinationConn == nil && stun.IsMessage(p[:n]) {
|
||||
if destinationConn == nil && stun.IsMessage(p[:20]) {
|
||||
msg := &stun.Message{
|
||||
Raw: append([]byte{}, p[:n]...),
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ func (m *UniversalUDPMuxDefault) Type() string {
|
||||
}
|
||||
|
||||
func (m *UniversalUDPMuxDefault) HandlePacket(p []byte, n int, addr net.Addr) error {
|
||||
if stun.IsMessage(p[:n]) {
|
||||
if stun.IsMessage(p[:20]) {
|
||||
msg := &stun.Message{
|
||||
Raw: append([]byte{}, p[:n]...),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user