aboutsummaryrefslogtreecommitdiff
path: root/device/boundif_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-10-21 13:29:57 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-21 13:29:57 +0200
commitffffbbcc8a3344a45c45884f11a1aee1407615ab (patch)
tree0c73dacb74ebf195b49841751f775ca33f6314c5 /device/boundif_windows.go
parent47b02c618bcd4f65726bc2c57538296e430a842c (diff)
downloadwireguard-go-ffffbbcc8a3344a45c45884f11a1aee1407615ab.tar.gz
wireguard-go-ffffbbcc8a3344a45c45884f11a1aee1407615ab.zip
device: allow blackholing sockets
Diffstat (limited to '')
-rw-r--r--device/boundif_windows.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/device/boundif_windows.go b/device/boundif_windows.go
index 7879a43..6908415 100644
--- a/device/boundif_windows.go
+++ b/device/boundif_windows.go
@@ -18,7 +18,7 @@ const (
sockoptIPV6_UNICAST_IF = 31
)
-func (device *Device) BindSocketToInterface4(interfaceIndex uint32) error {
+func (device *Device) BindSocketToInterface4(interfaceIndex uint32, blackhole bool) error {
/* MSDN says for IPv4 this needs to be in net byte order, so that it's like an IP address with leading zeros. */
bytes := make([]byte, 4)
binary.BigEndian.PutUint32(bytes, interfaceIndex)
@@ -41,10 +41,11 @@ func (device *Device) BindSocketToInterface4(interfaceIndex uint32) error {
if err != nil {
return err
}
+ device.net.bind.(*nativeBind).blackhole4 = blackhole
return nil
}
-func (device *Device) BindSocketToInterface6(interfaceIndex uint32) error {
+func (device *Device) BindSocketToInterface6(interfaceIndex uint32, blackhole bool) error {
sysconn, err := device.net.bind.(*nativeBind).ipv6.SyscallConn()
if err != nil {
return err
@@ -58,5 +59,6 @@ func (device *Device) BindSocketToInterface6(interfaceIndex uint32) error {
if err != nil {
return err
}
+ device.net.bind.(*nativeBind).blackhole6 = blackhole
return nil
}