|
|
@ -78,6 +78,13 @@ func runStatus(ctx context.Context, args []string) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if statusArgs.json {
|
|
|
|
if statusArgs.json {
|
|
|
|
|
|
|
|
if statusArgs.active {
|
|
|
|
|
|
|
|
for peer, ps := range st.Peer {
|
|
|
|
|
|
|
|
if !peerActive(ps) {
|
|
|
|
|
|
|
|
delete(st.Peer, peer)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
j, err := json.MarshalIndent(st, "", " ")
|
|
|
|
j, err := json.MarshalIndent(st, "", " ")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -122,8 +129,7 @@ func runStatus(ctx context.Context, args []string) error {
|
|
|
|
f := func(format string, a ...interface{}) { fmt.Fprintf(&buf, format, a...) }
|
|
|
|
f := func(format string, a ...interface{}) { fmt.Fprintf(&buf, format, a...) }
|
|
|
|
for _, peer := range st.Peers() {
|
|
|
|
for _, peer := range st.Peers() {
|
|
|
|
ps := st.Peer[peer]
|
|
|
|
ps := st.Peer[peer]
|
|
|
|
// TODO: let server report this active bool instead
|
|
|
|
active := peerActive(ps)
|
|
|
|
active := !ps.LastWrite.IsZero() && time.Since(ps.LastWrite) < 2*time.Minute
|
|
|
|
|
|
|
|
if statusArgs.active && !active {
|
|
|
|
if statusArgs.active && !active {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -157,3 +163,10 @@ func runStatus(ctx context.Context, args []string) error {
|
|
|
|
os.Stdout.Write(buf.Bytes())
|
|
|
|
os.Stdout.Write(buf.Bytes())
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// peerActive reports whether ps has recent activity.
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// TODO: have the server report this bool instead.
|
|
|
|
|
|
|
|
func peerActive(ps *ipnstate.PeerStatus) bool {
|
|
|
|
|
|
|
|
return !ps.LastWrite.IsZero() && time.Since(ps.LastWrite) < 2*time.Minute
|
|
|
|
|
|
|
|
}
|
|
|
|