diff options
| author | Brad Fitzpatrick <bradfitz@tailscale.com> | 2023-08-16 15:23:40 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@tailscale.com> | 2023-08-16 15:23:43 -0700 |
| commit | b256c319c08c50bd52e617c500a37e566fbbb432 (patch) | |
| tree | 5d5ee711ff693b81ac0a2f0fbff70c9c5cd4c929 | |
| parent | 57da1f150199957fbb3659df3a607cfb2af74317 (diff) | |
| download | tailscale-b256c319c08c50bd52e617c500a37e566fbbb432.tar.xz tailscale-b256c319c08c50bd52e617c500a37e566fbbb432.zip | |
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
| -rw-r--r-- | control/controlclient/direct.go | 19 | ||||
| -rw-r--r-- | ipn/backend.go | 22 | ||||
| -rw-r--r-- | types/netmap/netmap.go | 30 |
3 files changed, 50 insertions, 21 deletions
diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 1762c4eec..4f98fbf9b 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -1110,6 +1110,16 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap } nm := sess.netmapForResponse(&resp) + + // Occasionally print the netmap header. + // This is handy for debugging, and our logs processing + // pipeline depends on it. (TODO: Remove this dependency.) + // Code elsewhere prints netmap diffs every time they are received. + now := c.clock.Now() + if now.Sub(c.lastPrintMap) >= 5*time.Minute { + c.lastPrintMap = now + c.logf("[v1] new network map[%d]:\n%s", i, nm.VeryConcise()) + } if nm.SelfNode == nil { c.logf("MapResponse lacked node") return errors.New("MapResponse lacked node") @@ -1129,15 +1139,6 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap nm.SelfNode.Capabilities = nil } - // Occasionally print the netmap header. - // This is handy for debugging, and our logs processing - // pipeline depends on it. (TODO: Remove this dependency.) - // Code elsewhere prints netmap diffs every time they are received. - now := c.clock.Now() - if now.Sub(c.lastPrintMap) >= 5*time.Minute { - c.lastPrintMap = now - c.logf("[v1] new network map[%d]:\n%s", i, nm.VeryConcise()) - } newPersist := persist.AsStruct() newPersist.NodeID = nm.SelfNode.StableID newPersist.UserProfile = nm.UserProfiles[nm.User] diff --git a/ipn/backend.go b/ipn/backend.go index 806598aa2..7f13bf517 100644 --- a/ipn/backend.go +++ b/ipn/backend.go @@ -64,6 +64,7 @@ const ( NotifyInitialState // if set, the first Notify message (sent immediately) will contain the current State + BrowseToURL NotifyInitialPrefs // if set, the first Notify message (sent immediately) will contain the current Prefs NotifyInitialNetMap // if set, the first Notify message (sent immediately) will contain the current NetMap + NotifyGUINetMap // if set, only use the Notify.GUINetMap; Notify.Netmap will always be nil. Also impacts NotifyInitialNetMap. NotifyNoPrivateKeys // if set, private keys that would normally be sent in updates are zeroed out ) @@ -81,13 +82,14 @@ type Notify struct { // For State InUseOtherUser, ErrMessage is not critical and just contains the details. ErrMessage *string - LoginFinished *empty.Message // non-nil when/if the login process succeeded - State *State // if non-nil, the new or current IPN state - Prefs *PrefsView // if non-nil && Valid, the new or current preferences - NetMap *netmap.NetworkMap // if non-nil, the new or current netmap - Engine *EngineStatus // if non-nil, the new or current wireguard stats - BrowseToURL *string // if non-nil, UI should open a browser right now - BackendLogID *string // if non-nil, the public logtail ID used by backend + LoginFinished *empty.Message // non-nil when/if the login process succeeded + State *State // if non-nil, the new or current IPN state + Prefs *PrefsView // if non-nil && Valid, the new or current preferences + //NetMap *netmap.NetworkMap // if non-nil, the new or current netmap + GUINetMap *netmap.GUINetworkMap // if non-nil, the new or current netmap + Engine *EngineStatus // if non-nil, the new or current wireguard stats + BrowseToURL *string // if non-nil, UI should open a browser right now + BackendLogID *string // if non-nil, the public logtail ID used by backend // FilesWaiting if non-nil means that files are buffered in // the Tailscale daemon and ready for local transfer to the @@ -133,9 +135,9 @@ func (n Notify) String() string { if n.Prefs != nil && n.Prefs.Valid() { fmt.Fprintf(&sb, "%v ", n.Prefs.Pretty()) } - if n.NetMap != nil { - sb.WriteString("NetMap{...} ") - } + // if n.NetMap != nil { + // sb.WriteString("NetMap{...} ") + // } if n.Engine != nil { fmt.Fprintf(&sb, "wg=%v ", *n.Engine) } diff --git a/types/netmap/netmap.go b/types/netmap/netmap.go index b3a9df8ba..72ca82ac2 100644 --- a/types/netmap/netmap.go +++ b/types/netmap/netmap.go @@ -19,6 +19,34 @@ import ( "tailscale.com/wgengine/filter" ) +type NetworkMapView struct { + nm *NetworkMap +} + +type GUIPeerNode struct { + ID tailcfg.StableNodeID + BaseOrFQDNName string // no "." substring if in your tailnet, else FQDN + Owner tailcfg.UserID // user or fake userid for tagged nodes + IPv4 netip.Addr // may be be zero value (empty string in JSON) + IPv6 netip.Addr // may be be zero value (empty string in JSON) + MachineStatus tailcfg.MachineStatus + Hostinfo GUIHostInfo + + IsExitNode bool +} + +type GUIHostInfo struct { + ShareeNode bool `json:",omitempty"` // indicates this node exists in netmap because it's owned by a shared-to user +} + +type GUINetworkMap struct { + SelfNode *tailcfg.Node // TODO: GUISelfNode ? + Peers []*GUIPeerNode + UserProfiles map[tailcfg.UserID]tailcfg.UserProfile + + TKAEnabled bool +} + // NetworkMap is the current state of the world. // // The fields should all be considered read-only. They might @@ -70,8 +98,6 @@ type NetworkMap struct { // hash of the latest update message to tick through TKA). TKAHead tka.AUMHash - // ACLs - User tailcfg.UserID // Domain is the current Tailnet name. |
