diff --git a/ipn/ipnstate/ipnstate.go b/ipn/ipnstate/ipnstate.go index 89c6d7e24..4494afb67 100644 --- a/ipn/ipnstate/ipnstate.go +++ b/ipn/ipnstate/ipnstate.go @@ -53,6 +53,9 @@ type Status struct { // If nil, an exit node is not in use. ExitNodeStatus *ExitNodeStatus `json:"ExitNodeStatus,omitempty"` + // DERPHomeRegionID is the current home DERP region ID. + DERPHomeRegionID int + // Health contains health check problems. // Empty means everything is good. (or at least that no known // problems are detected) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index a32867f72..e7e65b6ee 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -2892,11 +2892,15 @@ func (c *Conn) UpdateStatus(sb *ipnstate.StatusBuilder) { }) } - c.foreachActiveDerpSortedLocked(func(node int, ad activeDerp) { - // TODO(bradfitz): add a method to ipnstate.StatusBuilder - // to include all the DERP connections we have open - // and add it here. See the other caller of foreachActiveDerpSortedLocked. + sb.MutateStatus(func(s *ipnstate.Status) { + s.DERPHomeRegionID = c.myDerp + c.foreachActiveDerpSortedLocked(func(node int, ad activeDerp) { + // TODO(bradfitz): add a method to ipnstate.StatusBuilder + // to include all the DERP connections we have open + // and add it here. See the other caller of foreachActiveDerpSortedLocked. + }) }) + } // SetStatistics specifies a per-connection statistics aggregator.