cmd/tailscale/cli,ipn/ipnstate,wgengine/magicsock: label peer-relay (#16510)

Updates tailscale/corp#30033

Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
Jordan Whited
2025-07-09 15:17:51 -07:00
committed by GitHub
parent d40b25326c
commit ae8641735d
4 changed files with 16 additions and 9 deletions

View File

@@ -183,10 +183,12 @@ func runStatus(ctx context.Context, args []string) error {
} else if ps.ExitNodeOption { } else if ps.ExitNodeOption {
f("offers exit node; ") f("offers exit node; ")
} }
if relay != "" && ps.CurAddr == "" { if relay != "" && ps.CurAddr == "" && ps.PeerRelay == "" {
f("relay %q", relay) f("relay %q", relay)
} else if ps.CurAddr != "" { } else if ps.CurAddr != "" {
f("direct %s", ps.CurAddr) f("direct %s", ps.CurAddr)
} else if ps.PeerRelay != "" {
f("peer-relay %s", ps.PeerRelay)
} }
if !ps.Online { if !ps.Online {
f("; offline") f("; offline")

View File

@@ -251,9 +251,10 @@ type PeerStatus struct {
PrimaryRoutes *views.Slice[netip.Prefix] `json:",omitempty"` PrimaryRoutes *views.Slice[netip.Prefix] `json:",omitempty"`
// Endpoints: // Endpoints:
Addrs []string Addrs []string
CurAddr string // one of Addrs, or unique if roaming CurAddr string // one of Addrs, or unique if roaming
Relay string // DERP region Relay string // DERP region
PeerRelay string // peer relay address (ip:port:vni)
RxBytes int64 RxBytes int64
TxBytes int64 TxBytes int64
@@ -451,6 +452,9 @@ func (sb *StatusBuilder) AddPeer(peer key.NodePublic, st *PeerStatus) {
if v := st.Relay; v != "" { if v := st.Relay; v != "" {
e.Relay = v e.Relay = v
} }
if v := st.PeerRelay; v != "" {
e.PeerRelay = v
}
if v := st.UserID; v != 0 { if v := st.UserID; v != 0 {
e.UserID = v e.UserID = v
} }

View File

@@ -1961,10 +1961,11 @@ func (de *endpoint) populatePeerStatus(ps *ipnstate.PeerStatus) {
ps.Active = now.Sub(de.lastSendExt) < sessionActiveTimeout ps.Active = now.Sub(de.lastSendExt) < sessionActiveTimeout
if udpAddr, derpAddr, _ := de.addrForSendLocked(now); udpAddr.ap.IsValid() && !derpAddr.IsValid() { if udpAddr, derpAddr, _ := de.addrForSendLocked(now); udpAddr.ap.IsValid() && !derpAddr.IsValid() {
// TODO(jwhited): if udpAddr.vni.isSet() we are using a Tailscale client if udpAddr.vni.isSet() {
// as a UDP relay; update PeerStatus and its interpretation by ps.PeerRelay = udpAddr.String()
// "tailscale status" to make this clear. } else {
ps.CurAddr = udpAddr.String() ps.CurAddr = udpAddr.String()
}
} }
} }

View File

@@ -3437,7 +3437,7 @@ func (c *Conn) onNodeMutationsUpdate(update NodeMutationsUpdate) {
} }
} }
// UpdateStatus implements the interface nede by ipnstate.StatusBuilder. // UpdateStatus implements the interface needed by ipnstate.StatusBuilder.
// //
// This method adds in the magicsock-specific information only. Most // This method adds in the magicsock-specific information only. Most
// of the status is otherwise populated by LocalBackend. // of the status is otherwise populated by LocalBackend.