diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-18 17:18:40 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-11-18 17:18:40 +0100 |
commit | 8a876e394f7625f1f7d620370f0a8092d3cd73dc (patch) | |
tree | 868387451e13e5fd3af3a534498138d6b151ddaa /conf | |
parent | installer: regard KB2921916 exits when prompted to be USEREXIT so fetcher doesn't mind (diff) | |
download | wireguard-windows-8a876e394f7625f1f7d620370f0a8092d3cd73dc.tar.xz wireguard-windows-8a876e394f7625f1f7d620370f0a8092d3cd73dc.zip |
tunnel: mask self before giving routes to windows
Otherwise Windows complains.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'conf')
-rw-r--r-- | conf/config.go | 8 |
1 files changed, 8 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) |