Logging
This commit is contained in:
25
peer/app.go
25
peer/app.go
@@ -134,23 +134,20 @@ func (a *App) logNetworkState() {
|
||||
|
||||
for _, p := range peers {
|
||||
ip := p.VPNIP.As4()[3]
|
||||
up := "DOWN"
|
||||
if p.Up() {
|
||||
up = "UP "
|
||||
}
|
||||
|
||||
switch p.State {
|
||||
case StateDirect:
|
||||
if p.Role == control.Client {
|
||||
fmt.Fprintf(&b, " %24s %03d DIRECT @ %s rtt=%s\n",
|
||||
p.Name, ip, p.WGEndpoint(), p.RTT.Round(time.Millisecond))
|
||||
endpoint := p.WGEndpoint()
|
||||
if endpoint.IsValid() {
|
||||
fmt.Fprintf(&b, " %24s %03d %s %s seen=%s @ %s\n",
|
||||
p.Name, ip, p.State, up, time.Since(p.LastPing).Round(time.Millisecond), endpoint)
|
||||
} else {
|
||||
fmt.Fprintf(&b, " %24s %03d DIRECT @ %s\n",
|
||||
p.Name, ip, p.WGEndpoint())
|
||||
fmt.Fprintf(&b, " %24s %03d %s %s seen=%s\n",
|
||||
p.Name, ip, p.State, up, time.Since(p.LastPing).Round(time.Millisecond))
|
||||
}
|
||||
}
|
||||
|
||||
case StateProbing:
|
||||
fmt.Fprintf(&b, " %24s %03d PROBING @ %s\n",
|
||||
p.Name, ip, p.PreferredEndpoint())
|
||||
case StateRelayed:
|
||||
fmt.Fprintf(&b, " %24s %03d RELAYED\n", p.Name, ip)
|
||||
}
|
||||
}
|
||||
log.Print(b.String())
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
type PeerState string
|
||||
|
||||
const (
|
||||
StateRelayed = PeerState("RELAY")
|
||||
StateProbing = PeerState("PROBE")
|
||||
StateRelayed = PeerState("RELAY ")
|
||||
StateProbing = PeerState("PROBE ")
|
||||
StateDirect = PeerState("DIRECT")
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user