Added new Addresses / AllowedIPs fields to testcontrol when creating new &tailcfg.Node

Signed-off-by: Simeng He <simeng@tailscale.com>
This commit is contained in:
Simeng He 2021-05-18 12:47:29 -04:00
parent 85df1b0fa7
commit 13b94cc4d7

View File

@ -307,6 +307,10 @@ func (s *Server) serveRegister(w http.ResponseWriter, r *http.Request, mkey tail
machineAuthorized := true // TODO: add Server.RequireMachineAuth machineAuthorized := true // TODO: add Server.RequireMachineAuth
allowedIPs := []netaddr.IPPrefix{
netaddr.MustParseIPPrefix(fmt.Sprintf("100.64.%d.%d/32", uint8(tailcfg.NodeID(user.ID)>>8), uint8(tailcfg.NodeID(user.ID)))),
}
s.nodes[req.NodeKey] = &tailcfg.Node{ s.nodes[req.NodeKey] = &tailcfg.Node{
ID: tailcfg.NodeID(user.ID), ID: tailcfg.NodeID(user.ID),
StableID: tailcfg.StableNodeID(fmt.Sprintf("TESTCTRL%08x", int(user.ID))), StableID: tailcfg.StableNodeID(fmt.Sprintf("TESTCTRL%08x", int(user.ID))),
@ -314,6 +318,8 @@ func (s *Server) serveRegister(w http.ResponseWriter, r *http.Request, mkey tail
Machine: mkey, Machine: mkey,
Key: req.NodeKey, Key: req.NodeKey,
MachineAuthorized: machineAuthorized, MachineAuthorized: machineAuthorized,
Addresses: allowedIPs,
AllowedIPs: allowedIPs,
} }
requireAuth := s.RequireAuth requireAuth := s.RequireAuth
if requireAuth && s.nodeKeyAuthed[req.NodeKey] { if requireAuth && s.nodeKeyAuthed[req.NodeKey] {