feature/conn25: implement IPMapper
Rename variables to match their types after the server -> connector rename. Updates tailscale/corp#37144 Updates tailscale/corp#37145 Signed-off-by: Fran Bull <fran@tailscale.com>
This commit is contained in:
+15
-15
@@ -297,9 +297,9 @@ func (c *Conn25) handleConnectorTransitIPRequest(n tailcfg.NodeView, ctipr Conne
|
|||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *connector) handleTransitIPRequest(n tailcfg.NodeView, peerV4 netip.Addr, peerV6 netip.Addr, tipr TransitIPRequest) TransitIPResponse {
|
func (c *connector) handleTransitIPRequest(n tailcfg.NodeView, peerV4 netip.Addr, peerV6 netip.Addr, tipr TransitIPRequest) TransitIPResponse {
|
||||||
if tipr.TransitIP.Is4() != tipr.DestinationIP.Is4() {
|
if tipr.TransitIP.Is4() != tipr.DestinationIP.Is4() {
|
||||||
s.logf("[Unexpected] peer attempt to map a transit IP to dest IP did not have matching families: node: %s, tIPv4: %v dIPv4: %v",
|
c.logf("[Unexpected] peer attempt to map a transit IP to dest IP did not have matching families: node: %s, tIPv4: %v dIPv4: %v",
|
||||||
n.StableID(), tipr.TransitIP.Is4(), tipr.DestinationIP.Is4())
|
n.StableID(), tipr.TransitIP.Is4(), tipr.DestinationIP.Is4())
|
||||||
return TransitIPResponse{Code: AddrFamilyMismatch, Message: addrFamilyMismatchMessage}
|
return TransitIPResponse{Code: AddrFamilyMismatch, Message: addrFamilyMismatchMessage}
|
||||||
}
|
}
|
||||||
@@ -315,26 +315,26 @@ func (s *connector) handleTransitIPRequest(n tailcfg.NodeView, peerV4 netip.Addr
|
|||||||
|
|
||||||
// If we couldn't find a matching family, return an error.
|
// If we couldn't find a matching family, return an error.
|
||||||
if !peerAddr.IsValid() {
|
if !peerAddr.IsValid() {
|
||||||
s.logf("[Unexpected] peer attempt to map a transit IP did not have a matching address family: node: %s, IPv4: %v",
|
c.logf("[Unexpected] peer attempt to map a transit IP did not have a matching address family: node: %s, IPv4: %v",
|
||||||
n.StableID(), tipr.TransitIP.Is4())
|
n.StableID(), tipr.TransitIP.Is4())
|
||||||
return TransitIPResponse{NoMatchingPeerIPFamily, noMatchingPeerIPFamilyMessage}
|
return TransitIPResponse{NoMatchingPeerIPFamily, noMatchingPeerIPFamilyMessage}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.mu.Lock()
|
c.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
if _, ok := s.config.appsByName[tipr.App]; !ok {
|
if _, ok := c.config.appsByName[tipr.App]; !ok {
|
||||||
s.logf("[Unexpected] peer attempt to map a transit IP referenced unknown app: node: %s, app: %q",
|
c.logf("[Unexpected] peer attempt to map a transit IP referenced unknown app: node: %s, app: %q",
|
||||||
n.StableID(), tipr.App)
|
n.StableID(), tipr.App)
|
||||||
return TransitIPResponse{Code: UnknownAppName, Message: unknownAppNameMessage}
|
return TransitIPResponse{Code: UnknownAppName, Message: unknownAppNameMessage}
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.transitIPs == nil {
|
if c.transitIPs == nil {
|
||||||
s.transitIPs = make(map[netip.Addr]map[netip.Addr]appAddr)
|
c.transitIPs = make(map[netip.Addr]map[netip.Addr]appAddr)
|
||||||
}
|
}
|
||||||
peerMap, ok := s.transitIPs[peerAddr]
|
peerMap, ok := c.transitIPs[peerAddr]
|
||||||
if !ok {
|
if !ok {
|
||||||
peerMap = make(map[netip.Addr]appAddr)
|
peerMap = make(map[netip.Addr]appAddr)
|
||||||
s.transitIPs[peerAddr] = peerMap
|
c.transitIPs[peerAddr] = peerMap
|
||||||
}
|
}
|
||||||
peerMap[tipr.TransitIP] = appAddr{addr: tipr.DestinationIP, app: tipr.App}
|
peerMap[tipr.TransitIP] = appAddr{addr: tipr.DestinationIP, app: tipr.App}
|
||||||
return TransitIPResponse{}
|
return TransitIPResponse{}
|
||||||
@@ -869,10 +869,10 @@ func (c *connector) lookupBySrcIPAndTransitIP(srcIP, transitIP netip.Addr) (appA
|
|||||||
return v, ok
|
return v, ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *connector) reconfig(newCfg config) error {
|
func (c *connector) reconfig(newCfg config) error {
|
||||||
s.mu.Lock()
|
c.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
s.config = newCfg
|
c.config = newCfg
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user