mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 14:05:39 +00:00
cmd/tailscale, ipn/ipnstate: note which nodes are exit nodes in status
Fixes #3446 Change-Id: Ib41d588e7fa434c02d134fa449f85b0e15083683 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
deb2f5e793
commit
2a95ee4680
@ -148,6 +148,8 @@ func runStatus(ctx context.Context, args []string) error {
|
|||||||
if !ps.Active {
|
if !ps.Active {
|
||||||
if ps.ExitNode {
|
if ps.ExitNode {
|
||||||
f("idle; exit node")
|
f("idle; exit node")
|
||||||
|
} else if ps.ExitNodeOption {
|
||||||
|
f("idle; offers exit node")
|
||||||
} else if anyTraffic {
|
} else if anyTraffic {
|
||||||
f("idle")
|
f("idle")
|
||||||
} else {
|
} else {
|
||||||
@ -157,6 +159,8 @@ func runStatus(ctx context.Context, args []string) error {
|
|||||||
f("active; ")
|
f("active; ")
|
||||||
if ps.ExitNode {
|
if ps.ExitNode {
|
||||||
f("exit node; ")
|
f("exit node; ")
|
||||||
|
} else if ps.ExitNodeOption {
|
||||||
|
f("offers exit node; ")
|
||||||
}
|
}
|
||||||
if relay != "" && ps.CurAddr == "" {
|
if relay != "" && ps.CurAddr == "" {
|
||||||
f("relay %q", relay)
|
f("relay %q", relay)
|
||||||
|
@ -402,6 +402,9 @@ func (b *LocalBackend) populatePeerStatusLocked(sb *ipnstate.StatusBuilder) {
|
|||||||
tailscaleIPs = append(tailscaleIPs, addr.IP())
|
tailscaleIPs = append(tailscaleIPs, addr.IP())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
exitNodeOption := tsaddr.PrefixesContainsFunc(p.AllowedIPs, func(r netaddr.IPPrefix) bool {
|
||||||
|
return r.Bits() == 0
|
||||||
|
})
|
||||||
sb.AddPeer(p.Key, &ipnstate.PeerStatus{
|
sb.AddPeer(p.Key, &ipnstate.PeerStatus{
|
||||||
InNetworkMap: true,
|
InNetworkMap: true,
|
||||||
ID: p.StableID,
|
ID: p.StableID,
|
||||||
@ -416,6 +419,7 @@ func (b *LocalBackend) populatePeerStatusLocked(sb *ipnstate.StatusBuilder) {
|
|||||||
LastSeen: lastSeen,
|
LastSeen: lastSeen,
|
||||||
ShareeNode: p.Hostinfo.ShareeNode,
|
ShareeNode: p.Hostinfo.ShareeNode,
|
||||||
ExitNode: p.StableID != "" && p.StableID == b.prefs.ExitNodeID,
|
ExitNode: p.StableID != "" && p.StableID == b.prefs.ExitNodeID,
|
||||||
|
ExitNodeOption: exitNodeOption,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,7 @@ type PeerStatus struct {
|
|||||||
LastHandshake time.Time // with local wireguard
|
LastHandshake time.Time // with local wireguard
|
||||||
KeepAlive bool
|
KeepAlive bool
|
||||||
ExitNode bool // true if this is the currently selected exit node.
|
ExitNode bool // true if this is the currently selected exit node.
|
||||||
|
ExitNodeOption bool // true if this node can be an exit node (offered && approved)
|
||||||
|
|
||||||
// Active is whether the node was recently active. The
|
// Active is whether the node was recently active. The
|
||||||
// definition is somewhat undefined but has historically and
|
// definition is somewhat undefined but has historically and
|
||||||
@ -290,6 +291,9 @@ func (sb *StatusBuilder) AddPeer(peer key.NodePublic, st *PeerStatus) {
|
|||||||
if st.ExitNode {
|
if st.ExitNode {
|
||||||
e.ExitNode = true
|
e.ExitNode = true
|
||||||
}
|
}
|
||||||
|
if st.ExitNodeOption {
|
||||||
|
e.ExitNodeOption = true
|
||||||
|
}
|
||||||
if st.ShareeNode {
|
if st.ShareeNode {
|
||||||
e.ShareeNode = true
|
e.ShareeNode = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user