ipn/ipnlocal: also accept service IP IPv6 literal in brackets for quad100

The fix in 4fc8538e2 was sufficient for IPv6. Browsers (can?) send the
IPv6 literal, even without a port number, in brackets.

Updates tailscale/corp#7948

Change-Id: I0e429d3de4df8429152c12f251ab140b0c8f6b77
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-11-16 11:38:25 -08:00
committed by Brad Fitzpatrick
parent 296e712591
commit e9c851b04b
3 changed files with 32 additions and 4 deletions

View File

@@ -57,10 +57,15 @@ func TailscaleServiceIP() netip.Addr {
//
// For IPv4, use TailscaleServiceIP.
func TailscaleServiceIPv6() netip.Addr {
serviceIPv6.Do(func() { mustPrefix(&serviceIPv6.v, "fd7a:115c:a1e0::53/128") })
serviceIPv6.Do(func() { mustPrefix(&serviceIPv6.v, TailscaleServiceIPv6String+"/128") })
return serviceIPv6.v.Addr()
}
const (
TailscaleServiceIPString = "100.100.100.100"
TailscaleServiceIPv6String = "fd7a:115c:a1e0::53"
)
// IsTailscaleIP reports whether ip is an IP address in a range that
// Tailscale assigns from.
func IsTailscaleIP(ip netip.Addr) bool {

View File

@@ -32,12 +32,26 @@ func TestInCrostiniRange(t *testing.T) {
}
}
func TestTailscaleServiceIP(t *testing.T) {
got := TailscaleServiceIP().String()
want := "100.100.100.100"
if got != want {
t.Errorf("got %q; want %q", got, want)
}
if TailscaleServiceIPString != want {
t.Error("TailscaleServiceIPString is not consistent")
}
}
func TestTailscaleServiceIPv6(t *testing.T) {
got := TailscaleServiceIPv6().String()
want := "fd7a:115c:a1e0::53"
if got != want {
t.Errorf("got %q; want %q", got, want)
}
if TailscaleServiceIPv6String != want {
t.Error("TailscaleServiceIPv6String is not consistent")
}
}
func TestChromeOSVMRange(t *testing.T) {