diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-02-28 17:41:30 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-01 01:38:30 +0100 |
commit | 616f56bd5d9640212a1f8beccb7b7208068d2b7c (patch) | |
tree | dd411c7c77d655164621b5ed623d945346b2ebf7 /conf/config.go | |
parent | tunnel: log the builtin go log to elog (diff) | |
download | wireguard-windows-616f56bd5d9640212a1f8beccb7b7208068d2b7c.tar.xz wireguard-windows-616f56bd5d9640212a1f8beccb7b7208068d2b7c.zip |
tunnel: make winipcfg sort of work
The duplicate route thing is silly, and we currently don't do DNS or the
fancy socket routing. But this is a step in the right direction,
perhaps.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'conf/config.go')
-rw-r--r-- | conf/config.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/conf/config.go b/conf/config.go index a321bc0c..d802ec61 100644 --- a/conf/config.go +++ b/conf/config.go @@ -64,6 +64,21 @@ func (r *IPCidr) String() string { return fmt.Sprintf("%s/%d", r.IP.String(), r.Cidr) } +func (r *IPCidr) Bits() uint8 { + if r.IP.To4() != nil { + return 32 + } else { + return 128 + } +} + +func (r *IPCidr) IPNet() net.IPNet { + return net.IPNet{ + IP: r.IP, + Mask: net.CIDRMask(int(r.Cidr), int(r.Bits())), + } +} + func (e *Endpoint) String() string { if strings.IndexByte(e.Host, ':') > 0 { return fmt.Sprintf("[%s]:%d", e.Host, e.Port) |