fix: support the agent querying itself
This commit is contained in:
parent
f464c42802
commit
af919b2d34
@ -14,7 +14,7 @@ import (
|
|||||||
// Returns the raw hostinfo for a peer based on node ID.
|
// Returns the raw hostinfo for a peer based on node ID.
|
||||||
func (s *TSAgent) GetStatusForPeer(id string) (*tailcfg.HostinfoView, error) {
|
func (s *TSAgent) GetStatusForPeer(id string) (*tailcfg.HostinfoView, error) {
|
||||||
if !strings.HasPrefix(id, "nodekey:") {
|
if !strings.HasPrefix(id, "nodekey:") {
|
||||||
return nil, fmt.Errorf("invalid node ID")
|
return nil, fmt.Errorf("invalid node ID: %s", id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Debug {
|
if s.Debug {
|
||||||
@ -29,8 +29,13 @@ func (s *TSAgent) GetStatusForPeer(id string) (*tailcfg.HostinfoView, error) {
|
|||||||
nodeKey, err := key.ParseNodePublicUntyped(mem.S(id[8:]))
|
nodeKey, err := key.ParseNodePublicUntyped(mem.S(id[8:]))
|
||||||
peer := status.Peer[nodeKey]
|
peer := status.Peer[nodeKey]
|
||||||
if peer == nil {
|
if peer == nil {
|
||||||
|
// Check if we are on Self.
|
||||||
|
if status.Self.PublicKey == nodeKey {
|
||||||
|
peer = status.Self
|
||||||
|
} else {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ip := peer.TailscaleIPs[0].String()
|
ip := peer.TailscaleIPs[0].String()
|
||||||
whois, err := s.Lc.WhoIs(context.Background(), ip)
|
whois, err := s.Lc.WhoIs(context.Background(), ip)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user