wgengine/wgcfg/nmcfg: consolidate exit node log lines
These were getting rate-limited for nodes with many peers. Consolate the output into single lines, which are nicer anyway. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
3d4d97601a
commit
07c95a0219
|
@ -6,6 +6,7 @@
|
||||||
package nmcfg
|
package nmcfg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -60,6 +61,11 @@ func WGCfg(nm *netmap.NetworkMap, logf logger.Logf, flags netmap.WGConfigFlags,
|
||||||
Peers: make([]wgcfg.Peer, 0, len(nm.Peers)),
|
Peers: make([]wgcfg.Peer, 0, len(nm.Peers)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logging buffers
|
||||||
|
skippedUnselected := new(bytes.Buffer)
|
||||||
|
skippedIPs := new(bytes.Buffer)
|
||||||
|
skippedSubnets := new(bytes.Buffer)
|
||||||
|
|
||||||
for _, peer := range nm.Peers {
|
for _, peer := range nm.Peers {
|
||||||
if controlclient.Debug.OnlyDisco && peer.DiscoKey.IsZero() {
|
if controlclient.Debug.OnlyDisco && peer.DiscoKey.IsZero() {
|
||||||
continue
|
continue
|
||||||
|
@ -92,16 +98,23 @@ func WGCfg(nm *netmap.NetworkMap, logf logger.Logf, flags netmap.WGConfigFlags,
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
didExitNodeWarn = true
|
didExitNodeWarn = true
|
||||||
logf("[v1] wgcfg: skipping unselected default route from %q (%v)", nodeDebugName(peer), peer.Key.ShortString())
|
if skippedUnselected.Len() > 0 {
|
||||||
|
skippedUnselected.WriteString(", ")
|
||||||
|
}
|
||||||
|
fmt.Fprintf(skippedUnselected, "%q (%v)", nodeDebugName(peer), peer.Key.ShortString())
|
||||||
continue
|
continue
|
||||||
} else if allowedIP.IsSingleIP() && tsaddr.IsTailscaleIP(allowedIP.IP) && (flags&netmap.AllowSingleHosts) == 0 {
|
} else if allowedIP.IsSingleIP() && tsaddr.IsTailscaleIP(allowedIP.IP) && (flags&netmap.AllowSingleHosts) == 0 {
|
||||||
logf("[v1] wgcfg: skipping node IP %v from %q (%v)",
|
if skippedIPs.Len() > 0 {
|
||||||
allowedIP.IP, nodeDebugName(peer), peer.Key.ShortString())
|
skippedIPs.WriteString(", ")
|
||||||
|
}
|
||||||
|
fmt.Fprintf(skippedIPs, "%v from %q (%v)", allowedIP.IP, nodeDebugName(peer), peer.Key.ShortString())
|
||||||
continue
|
continue
|
||||||
} else if cidrIsSubnet(peer, allowedIP) {
|
} else if cidrIsSubnet(peer, allowedIP) {
|
||||||
if (flags & netmap.AllowSubnetRoutes) == 0 {
|
if (flags & netmap.AllowSubnetRoutes) == 0 {
|
||||||
logf("[v1] wgcfg: not accepting subnet route %v from %q (%v)",
|
if skippedSubnets.Len() > 0 {
|
||||||
allowedIP, nodeDebugName(peer), peer.Key.ShortString())
|
skippedSubnets.WriteString(", ")
|
||||||
|
}
|
||||||
|
fmt.Fprintf(skippedSubnets, "%v from %q (%v)", allowedIP, nodeDebugName(peer), peer.Key.ShortString())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,6 +122,16 @@ func WGCfg(nm *netmap.NetworkMap, logf logger.Logf, flags netmap.WGConfigFlags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if skippedUnselected.Len() > 0 {
|
||||||
|
logf("[v1] wgcfg: skipped unselected default routes from: %s", skippedUnselected.Bytes())
|
||||||
|
}
|
||||||
|
if skippedIPs.Len() > 0 {
|
||||||
|
logf("[v1] wgcfg: skipped node IPs: %s", skippedIPs)
|
||||||
|
}
|
||||||
|
if skippedSubnets.Len() > 0 {
|
||||||
|
logf("[v1] wgcfg: did not accept subnet routes: %s", skippedSubnets)
|
||||||
|
}
|
||||||
|
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue