diff options
Diffstat (limited to 'ipn')
| -rw-r--r-- | ipn/ipnlocal/extension_host.go | 5 | ||||
| -rw-r--r-- | ipn/ipnlocal/local.go | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/ipn/ipnlocal/extension_host.go b/ipn/ipnlocal/extension_host.go index ca802ab89..f4ec86719 100644 --- a/ipn/ipnlocal/extension_host.go +++ b/ipn/ipnlocal/extension_host.go @@ -8,7 +8,9 @@ import ( "errors" "fmt" "maps" + "os" "reflect" + "runtime" "slices" "strings" "sync" @@ -570,6 +572,9 @@ func (h *ExtensionHost) shutdownWorkQueue() { // for in-flight callbacks associated with those operations to finish. if err := h.workQueue.Wait(ctx); err != nil { h.logf("work queue shutdown failed: %v", err) + b := make([]byte, 2<<20) + n := runtime.Stack(b, true) + os.WriteFile("/tmp/shutdown-hang-stacks.txt", b[:n], 0644) } } diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 72b230327..ce5ceec73 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -521,6 +521,8 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo b.currentNodeAtomic.Store(nb) nb.ready() + sys.Engine.Get().SetPeerByIPLookupFunc(b.lookupPeerByIP) + if sys.InitialConfig != nil { if err := b.initPrefsFromConfig(sys.InitialConfig); err != nil { return nil, err @@ -652,6 +654,25 @@ func (b *LocalBackend) currentNode() *nodeBackend { return b.currentNodeAtomic.Load() } +func (b *LocalBackend) lookupPeerByIP(ip netip.Addr) (peerKey key.NodePublic, ok bool) { + nb := b.currentNode() + nb.mu.Lock() + defer nb.mu.Unlock() + + nid, ok := nb.nodeByAddr[ip] + if !ok { + log.Printf("lookupPeerByIP: %v -> no node ID", ip) + return key.NodePublic{}, false + } + peer, ok := nb.peers[nid] + if !ok { + log.Printf("lookupPeerByIP: no node ID %v", nid) + return key.NodePublic{}, false + } + log.Printf("lookupPeerByIP: %v -> %v (%v)", ip, peer.Name(), peer.Key()) + return peer.Key(), true +} + // FindExtensionByName returns an active extension with the given name, // or nil if no such extension exists. func (b *LocalBackend) FindExtensionByName(name string) any { |
