This commit is contained in:
jdl
2026-06-15 06:25:47 +02:00
parent b4320c9330
commit fa933ae029
2 changed files with 14 additions and 17 deletions

View File

@@ -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())
}

View File

@@ -12,8 +12,8 @@ import (
type PeerState string
const (
StateRelayed = PeerState("RELAY")
StateProbing = PeerState("PROBE")
StateRelayed = PeerState("RELAY ")
StateProbing = PeerState("PROBE ")
StateDirect = PeerState("DIRECT")
)