mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
ipn/ipnlocal: actually fill out PeerAPIURLs in PeerStatus
The earlier 5f6d63936f
was not complete.
Updates tailscale/corp#7515
Change-Id: I35efca51d1584c48ef6834a7d29cd42d7c943628
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
063eeefdca
commit
a26f23d949
@ -672,13 +672,11 @@ func (b *LocalBackend) populatePeerStatusLocked(sb *ipnstate.StatusBuilder) {
|
|||||||
peerStatusFromNode(ps, p)
|
peerStatusFromNode(ps, p)
|
||||||
|
|
||||||
p4, p6 := peerAPIPorts(p)
|
p4, p6 := peerAPIPorts(p)
|
||||||
ip4 := nodeIP(p, netip.Addr.Is4)
|
if u := peerAPIURL(nodeIP(p, netip.Addr.Is4), p4); u != "" {
|
||||||
ip6 := nodeIP(p, netip.Addr.Is6)
|
ps.PeerAPIURL = append(ps.PeerAPIURL, u)
|
||||||
if p4 != 0 && ip4.IsValid() {
|
|
||||||
ps.PeerAPIURL = append(ps.PeerAPIURL, peerAPIURL(ip4, p4))
|
|
||||||
}
|
}
|
||||||
if p6 != 0 && ip6.IsValid() {
|
if u := peerAPIURL(nodeIP(p, netip.Addr.Is6), p6); u != "" {
|
||||||
ps.PeerAPIURL = append(ps.PeerAPIURL, peerAPIURL(ip6, p6))
|
ps.PeerAPIURL = append(ps.PeerAPIURL, u)
|
||||||
}
|
}
|
||||||
sb.AddPeer(p.Key, ps)
|
sb.AddPeer(p.Key, ps)
|
||||||
}
|
}
|
||||||
@ -3701,6 +3699,10 @@ func peerAPIPorts(peer *tailcfg.Node) (p4, p6 uint16) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// peerAPIURL returns an HTTP URL for the peer's peerapi service,
|
||||||
|
// without a trailing slash.
|
||||||
|
//
|
||||||
|
// If ip or port is the zero value then it returns the empty string.
|
||||||
func peerAPIURL(ip netip.Addr, port uint16) string {
|
func peerAPIURL(ip netip.Addr, port uint16) string {
|
||||||
if port == 0 || !ip.IsValid() {
|
if port == 0 || !ip.IsValid() {
|
||||||
return ""
|
return ""
|
||||||
|
@ -391,6 +391,9 @@ func (sb *StatusBuilder) AddPeer(peer key.NodePublic, st *PeerStatus) {
|
|||||||
if st.Active {
|
if st.Active {
|
||||||
e.Active = true
|
e.Active = true
|
||||||
}
|
}
|
||||||
|
if st.PeerAPIURL != nil {
|
||||||
|
e.PeerAPIURL = st.PeerAPIURL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type StatusUpdater interface {
|
type StatusUpdater interface {
|
||||||
|
Loading…
Reference in New Issue
Block a user