aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--conf/config.go8
-rw-r--r--tunnel/addressconfig.go1
2 files changed, 9 insertions, 0 deletions
diff --git a/conf/config.go b/conf/config.go
index e1951d47..f5f25add 100644
--- a/conf/config.go
+++ b/conf/config.go
@@ -81,6 +81,14 @@ func (r *IPCidr) IPNet() net.IPNet {
}
}
+func (r *IPCidr) MaskSelf() {
+ bits := int(r.Bits())
+ mask := net.CIDRMask(int(r.Cidr), bits)
+ for i := 0; i < bits / 8; i++ {
+ r.IP[i] &= mask[i]
+ }
+}
+
func (e *Endpoint) String() string {
if strings.IndexByte(e.Host, ':') > 0 {
return fmt.Sprintf("[%s]:%d", e.Host, e.Port)
diff --git a/tunnel/addressconfig.go b/tunnel/addressconfig.go
index c8b315e1..6aba9ce8 100644
--- a/tunnel/addressconfig.go
+++ b/tunnel/addressconfig.go
@@ -80,6 +80,7 @@ func configureInterface(family winipcfg.AddressFamily, conf *conf.Config, tun *t
foundDefault6 := false
for _, peer := range conf.Peers {
for _, allowedip := range peer.AllowedIPs {
+ allowedip.MaskSelf()
if (allowedip.Bits() == 32 && !haveV4Address) || (allowedip.Bits() == 128 && !haveV6Address) {
continue
}