net/stun: unmap IPv4 addresses in 16 byte STUN replies

Updates #5602

Change-Id: I2276ad2bfb415b9ff52f37444f2a1d74b38543b1
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-09-12 11:37:56 -07:00
committed by Brad Fitzpatrick
parent eb5939289c
commit 024257ef5a
2 changed files with 16 additions and 17 deletions

View File

@ -6,11 +6,13 @@ package stun_test
import (
"bytes"
"encoding/hex"
"fmt"
"net/netip"
"testing"
"tailscale.com/net/stun"
"tailscale.com/util/must"
)
// TODO(bradfitz): fuzz this.
@ -175,6 +177,13 @@ var responseTests = []struct {
wantAddr: netip.AddrFrom4([4]byte{127, 0, 0, 1}),
wantPort: 61300,
},
{
name: "no-4in6",
data: must.Get(hex.DecodeString("010100182112a4424fd5d202dcb37d31fc773306002000140002cd3d2112a4424fd5d202dcb382ce2dc3fcc7")),
wantTID: []byte{79, 213, 210, 2, 220, 179, 125, 49, 252, 119, 51, 6},
wantAddr: netip.AddrFrom4([4]byte{209, 180, 207, 193}),
wantPort: 60463,
},
}
func TestParseResponse(t *testing.T) {