summaryrefslogtreecommitdiffhomepage
path: root/tstest/integration/testcontrol
diff options
context:
space:
mode:
authorChristine Dodrill <xe@tailscale.com>2021-07-09 13:58:01 -0400
committerChristine Dodrill <xe@tailscale.com>2021-07-12 10:38:36 -0400
commit77c856c0f5566223061904f0ce90435bee383d34 (patch)
treec7c8e22191e297d459c86a7bf2556e18901dee90 /tstest/integration/testcontrol
parentafbd35482d23e9df28ae2f036df43c6bf8f2aeea (diff)
downloadtailscale-Xe/testcontrol-v6.tar.xz
tailscale-Xe/testcontrol-v6.zip
tstest/integration/testcontrol: ipv6 supportXe/testcontrol-v6
And a bunch of IPv6 tests! Signed-off-by: Christine Dodrill <xe@tailscale.com>
Diffstat (limited to 'tstest/integration/testcontrol')
-rw-r--r--tstest/integration/testcontrol/testcontrol.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/tstest/integration/testcontrol/testcontrol.go b/tstest/integration/testcontrol/testcontrol.go
index 1870517d6..099d1f615 100644
--- a/tstest/integration/testcontrol/testcontrol.go
+++ b/tstest/integration/testcontrol/testcontrol.go
@@ -28,6 +28,7 @@ import (
"github.com/klauspost/compress/zstd"
"golang.org/x/crypto/nacl/box"
"inet.af/netaddr"
+ "tailscale.com/net/tsaddr"
"tailscale.com/smallzstd"
"tailscale.com/tailcfg"
"tailscale.com/types/logger"
@@ -406,8 +407,12 @@ func (s *Server) serveRegister(w http.ResponseWriter, r *http.Request, mkey tail
machineAuthorized := true // TODO: add Server.RequireMachineAuth
+ v4Prefix := netaddr.MustParseIPPrefix(fmt.Sprintf("100.64.%d.%d/32", uint8(tailcfg.NodeID(user.ID)>>8), uint8(tailcfg.NodeID(user.ID))))
+ v6Prefix := netaddr.IPPrefixFrom(tsaddr.Tailscale4To6(v4Prefix.IP()), 128)
+
allowedIPs := []netaddr.IPPrefix{
- netaddr.MustParseIPPrefix(fmt.Sprintf("100.64.%d.%d/32", uint8(tailcfg.NodeID(user.ID)>>8), uint8(tailcfg.NodeID(user.ID)))),
+ v4Prefix,
+ v6Prefix,
}
s.nodes[req.NodeKey] = &tailcfg.Node{
@@ -638,8 +643,12 @@ func (s *Server) MapResponse(req *tailcfg.MapRequest) (res *tailcfg.MapResponse,
}
}
+ v4Prefix := netaddr.MustParseIPPrefix(fmt.Sprintf("100.64.%d.%d/32", uint8(tailcfg.NodeID(user.ID)>>8), uint8(tailcfg.NodeID(user.ID))))
+ v6Prefix := netaddr.IPPrefixFrom(tsaddr.Tailscale4To6(v4Prefix.IP()), 128)
+
res.Node.Addresses = []netaddr.IPPrefix{
- netaddr.MustParseIPPrefix(fmt.Sprintf("100.64.%d.%d/32", uint8(node.ID>>8), uint8(node.ID))),
+ v4Prefix,
+ v6Prefix,
}
res.Node.AllowedIPs = res.Node.Addresses