mirror of
https://github.com/tailscale/tailscale.git
synced 2026-05-05 12:16:44 +02:00
Added allowedIPs and Addresses to testcontrol nodes
This commit is contained in:
parent
7de0421f17
commit
744300ee96
@ -309,6 +309,10 @@ func (s *Server) serveRegister(w http.ResponseWriter, r *http.Request, mkey tail
|
||||
|
||||
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{
|
||||
ID: tailcfg.NodeID(user.ID),
|
||||
StableID: tailcfg.StableNodeID(fmt.Sprintf("TESTCTRL%08x", int(user.ID))),
|
||||
@ -316,6 +320,8 @@ func (s *Server) serveRegister(w http.ResponseWriter, r *http.Request, mkey tail
|
||||
Machine: mkey,
|
||||
Key: req.NodeKey,
|
||||
MachineAuthorized: machineAuthorized,
|
||||
Addresses: allowedIPs,
|
||||
AllowedIPs: allowedIPs,
|
||||
}
|
||||
requireAuth := s.RequireAuth
|
||||
if requireAuth && s.nodeKeyAuthed[req.NodeKey] {
|
||||
@ -543,6 +549,9 @@ func (s *Server) MapResponse(req *tailcfg.MapRequest) (res *tailcfg.MapResponse,
|
||||
|
||||
// Optional Ping Request, hardcode address for now, in the two nodes example we are accessing node4.
|
||||
res.PingRequest = &tailcfg.PingRequest{URL: s.BaseURL + "/ping", TestIP: netaddr.IPv4(100, 64, 0, 1), Types: "tsmp"}
|
||||
jsonRes, _ := json.MarshalIndent(res, "", " ")
|
||||
log.Println("jsonprint", string(jsonRes))
|
||||
log.Println("respeers", res.Peers)
|
||||
log.Println("allnodes", s.AllNodes(), res.Node.AllowedIPs)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -1088,6 +1088,7 @@ func (e *userspaceEngine) SetDERPMap(dm *tailcfg.DERPMap) {
|
||||
}
|
||||
|
||||
func (e *userspaceEngine) SetNetworkMap(nm *netmap.NetworkMap) {
|
||||
log.Println("SETNETMAP")
|
||||
e.magicConn.SetNetworkMap(nm)
|
||||
e.mu.Lock()
|
||||
e.netMap = nm
|
||||
@ -1295,9 +1296,11 @@ func (e *userspaceEngine) peerForIP(ip netaddr.IP) (n *tailcfg.Node, err error)
|
||||
// Check for exact matches before looking for subnet matches.
|
||||
var bestInNMPrefix netaddr.IPPrefix
|
||||
var bestInNM *tailcfg.Node
|
||||
log.Println("Scan starting : ", nm.Peers)
|
||||
log.Println("Scan starting : ", nm.Peers, len(nm.Peers), nm.Addresses)
|
||||
for _, p := range nm.Peers {
|
||||
log.Println("peerp", p.Addresses, p.AllowedIPs, p.ID)
|
||||
for _, a := range p.Addresses {
|
||||
log.Println("paddr", a)
|
||||
if a.IP() == ip && a.IsSingleIP() && tsaddr.IsTailscaleIP(ip) {
|
||||
return p, nil
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user