From af919b2d3411e728714477bb951112c08a4958fd Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Fri, 10 Jan 2025 14:49:13 +0530 Subject: [PATCH] fix: support the agent querying itself --- agent/tsnet/peers.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/agent/tsnet/peers.go b/agent/tsnet/peers.go index 0c80a86..5011547 100644 --- a/agent/tsnet/peers.go +++ b/agent/tsnet/peers.go @@ -14,7 +14,7 @@ import ( // Returns the raw hostinfo for a peer based on node ID. func (s *TSAgent) GetStatusForPeer(id string) (*tailcfg.HostinfoView, error) { if !strings.HasPrefix(id, "nodekey:") { - return nil, fmt.Errorf("invalid node ID") + return nil, fmt.Errorf("invalid node ID: %s", id) } if s.Debug { @@ -29,7 +29,12 @@ func (s *TSAgent) GetStatusForPeer(id string) (*tailcfg.HostinfoView, error) { nodeKey, err := key.ParseNodePublicUntyped(mem.S(id[8:])) peer := status.Peer[nodeKey] if peer == nil { - return nil, nil + // Check if we are on Self. + if status.Self.PublicKey == nodeKey { + peer = status.Self + } else { + return nil, nil + } } ip := peer.TailscaleIPs[0].String()