Check for stun packet with a fixed size

This commit is contained in:
braginini 2022-09-06 21:07:21 +02:00
parent 73b5f8d63b
commit f49c299d77
3 changed files with 3 additions and 3 deletions

View File

@ -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(),

View File

@ -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]...),
}

View File

@ -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]...),
}