mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-16 03:29:57 +00:00
* [client] Filter link-local and multicast from network addresses Skip IPv6 link-local and multicast addresses when building the peer network_addresses list on non-iOS platforms, matching the existing iOS behavior. A flapping NIC's link-local address otherwise churns the peer meta on every interface up/down. * [client] Skip engine restart when default route is unchanged After the network monitor's debounce window, re-check the default next hop before triggering a client restart. A flapping NIC that returns to the same default route no longer forces a restart, avoiding redundant sync stream reconnects and peer meta churn. * [client] Exclude own overlay address from reported network addresses The peer's own WireGuard overlay address (v4 and v6) was reported in network_addresses. As the interface comes and goes during reconnects it churned the peer meta on the management server. Drop it in GetInfoWithChecks, matching the IP regardless of prefix length since the engine knows the overlay address with the network mask while the interface reports it as a host address. * [client] Treat missing default route per protocol in next-hop check A failed GetNextHop lookup is now treated as an absent route (zero Nexthop) and compared per protocol, instead of forcing a restart. In a single-stack network the missing IPv6 default route no longer counts as a change on every debounce, which previously defeated the unchanged-route check. * [client] Make next-hop check injectable for network monitor tests Move the next-hop comparison behind a NetworkMonitor field set by New(), so tests can supply a stub instead of hitting the host's real default route. Fixes the Event/MultiEvent tests hanging after the unchanged-route check was added. * Revert "[client] Make next-hop check injectable for network monitor tests" This reverts commit88a9d96e8f. * Revert "[client] Treat missing default route per protocol in next-hop check" This reverts commit0fb531e4bc. * Revert "[client] Skip engine restart when default route is unchanged" This reverts commita071b55f35.
46 lines
998 B
Go
46 lines
998 B
Go
//go:build !ios
|
|
|
|
package system
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
)
|
|
|
|
func mustIPNet(t *testing.T, cidr string) *net.IPNet {
|
|
t.Helper()
|
|
ip, ipNet, err := net.ParseCIDR(cidr)
|
|
if err != nil {
|
|
t.Fatalf("parse %q: %v", cidr, err)
|
|
}
|
|
ipNet.IP = ip
|
|
return ipNet
|
|
}
|
|
|
|
func TestToNetworkAddress_Filtering(t *testing.T) {
|
|
const mac = "c8:4b:d6:b6:04:ac"
|
|
|
|
tests := []struct {
|
|
name string
|
|
cidr string
|
|
want bool
|
|
}{
|
|
{"ipv4 global", "10.65.16.181/23", true},
|
|
{"ipv6 global", "2620:52:0:4110:102d:6a98:ee75:8b92/64", true},
|
|
{"ipv4 loopback", "127.0.0.1/8", false},
|
|
{"ipv6 loopback", "::1/128", false},
|
|
{"ipv6 link-local", "fe80::871:4c25:23d7:2529/64", false},
|
|
{"ipv4 link-local", "169.254.1.2/16", false},
|
|
{"ipv6 multicast", "ff02::1/128", false},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
_, got := toNetworkAddress(mustIPNet(t, tt.cidr), mac)
|
|
if got != tt.want {
|
|
t.Errorf("toNetworkAddress(%s) ok = %v, want %v", tt.cidr, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|