feature/conn25: connect the ExtraWireguardAllowedIPs hook (#19140)
The hook calls into the client assigned addresses to return a view of the transit IPs associated with that connector. Fixes tailscale/corp#38125 Signed-off-by: George Jones <george@tailscale.com>
This commit is contained in:
@@ -127,6 +127,7 @@ func (e *extension) Init(host ipnext.Host) error {
|
|||||||
|
|
||||||
host.Hooks().OnSelfChange.Add(e.onSelfChange)
|
host.Hooks().OnSelfChange.Add(e.onSelfChange)
|
||||||
host.Hooks().ExtraRouterConfigRoutes.Set(e.getMagicRange)
|
host.Hooks().ExtraRouterConfigRoutes.Set(e.getMagicRange)
|
||||||
|
host.Hooks().ExtraWireGuardAllowedIPs.Set(e.extraWireGuardAllowedIPs)
|
||||||
ctx, cancel := context.WithCancelCause(context.Background())
|
ctx, cancel := context.WithCancelCause(context.Background())
|
||||||
e.ctxCancel = cancel
|
e.ctxCancel = cancel
|
||||||
go e.sendLoop(ctx)
|
go e.sendLoop(ctx)
|
||||||
@@ -187,6 +188,10 @@ func (e *extension) onSelfChange(selfNode tailcfg.NodeView) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *extension) extraWireGuardAllowedIPs(k key.NodePublic) views.Slice[netip.Prefix] {
|
||||||
|
return e.conn25.client.extraWireGuardAllowedIPs(k)
|
||||||
|
}
|
||||||
|
|
||||||
func (e *extension) registerDNSHook() error {
|
func (e *extension) registerDNSHook() error {
|
||||||
e.mu.Lock()
|
e.mu.Lock()
|
||||||
defer e.mu.Unlock()
|
defer e.mu.Unlock()
|
||||||
@@ -660,6 +665,16 @@ func (c *client) enqueueAddressAssignment(addrs addrs) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *client) extraWireGuardAllowedIPs(k key.NodePublic) views.Slice[netip.Prefix] {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
tips, ok := c.assignments.lookupTransitIPsByConnKey(k)
|
||||||
|
if !ok {
|
||||||
|
return views.Slice[netip.Prefix]{}
|
||||||
|
}
|
||||||
|
return views.SliceOf(tips)
|
||||||
|
}
|
||||||
|
|
||||||
func makePeerAPIReq(ctx context.Context, httpClient *http.Client, urlBase string, as addrs) error {
|
func makePeerAPIReq(ctx context.Context, httpClient *http.Client, urlBase string, as addrs) error {
|
||||||
url := urlBase + "/v0/connector/transit-ip"
|
url := urlBase + "/v0/connector/transit-ip"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user