mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-09 00:11:28 +02:00
Android 16+ local network protection derives the blocked prefixes from the interface address prefix. A /16 address turns the whole overlay into a local network, so apps without ACCESS_LOCAL_NETWORK cannot reach any peer. Pass the address as /32 and /128 and add the overlay networks to the route list that the Android side turns into VPN routes, on both the initial create and the renew path.
25 lines
842 B
Go
25 lines
842 B
Go
package wgaddr
|
|
|
|
import (
|
|
"net/netip"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestAddress_HostPrefix(t *testing.T) {
|
|
addr := MustParseWGAddress("100.91.96.107/16")
|
|
|
|
assert.Equal(t, netip.MustParsePrefix("100.91.96.107/32"), addr.HostPrefix(), "v4 host prefix must be a single host")
|
|
assert.Equal(t, netip.MustParsePrefix("100.91.0.0/16"), addr.Network, "network must keep the overlay prefix length")
|
|
assert.False(t, addr.IPv6HostPrefix().IsValid(), "no v6 overlay means no v6 host prefix")
|
|
}
|
|
|
|
func TestAddress_IPv6HostPrefix(t *testing.T) {
|
|
addr := MustParseWGAddress("100.91.96.107/16")
|
|
addr.IPv6 = netip.MustParseAddr("fd00:1234::1")
|
|
addr.IPv6Net = netip.MustParsePrefix("fd00:1234::/64")
|
|
|
|
assert.Equal(t, netip.MustParsePrefix("fd00:1234::1/128"), addr.IPv6HostPrefix(), "v6 host prefix must be a single host")
|
|
}
|