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