aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tunnel/defaultroutemonitor.go
diff options
context:
space:
mode:
Diffstat (limited to 'tunnel/defaultroutemonitor.go')
-rw-r--r--tunnel/defaultroutemonitor.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/tunnel/defaultroutemonitor.go b/tunnel/defaultroutemonitor.go
index aa0db675..ac4241c9 100644
--- a/tunnel/defaultroutemonitor.go
+++ b/tunnel/defaultroutemonitor.go
@@ -11,9 +11,7 @@ import (
"time"
"golang.org/x/sys/windows"
-
"golang.zx2c4.com/wireguard/conn"
- "golang.zx2c4.com/wireguard/tun"
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
)
@@ -61,14 +59,17 @@ func bindSocketRoute(family winipcfg.AddressFamily, binder conn.BindSocketToInte
return nil
}
-func monitorDefaultRoutes(family winipcfg.AddressFamily, binder conn.BindSocketToInterface, autoMTU bool, blackholeWhenLoop bool, tun *tun.NativeTun) ([]winipcfg.ChangeCallback, error) {
+type mtuClamper interface {
+ ForceMTU(mtu int)
+}
+
+func monitorDefaultRoutes(family winipcfg.AddressFamily, binder conn.BindSocketToInterface, autoMTU bool, blackholeWhenLoop bool, clamper mtuClamper, ourLUID winipcfg.LUID) ([]winipcfg.ChangeCallback, error) {
var minMTU uint32
if family == windows.AF_INET {
minMTU = 576
} else if family == windows.AF_INET6 {
minMTU = 1280
}
- ourLUID := winipcfg.LUID(tun.LUID())
lastLUID := winipcfg.LUID(0)
lastIndex := ^uint32(0)
lastMTU := uint32(0)
@@ -103,7 +104,11 @@ func monitorDefaultRoutes(family winipcfg.AddressFamily, binder conn.BindSocketT
if err != nil {
return err
}
- tun.ForceMTU(int(iface.NLMTU)) // TODO: having one MTU for both v4 and v6 kind of breaks the windows model, so right now this just gets the second one which is... bad.
+
+ // Having one MTU for both v4 and v6 kind of breaks the Windows model, so right now this just gets the
+ // second one which looks bad. However, internally, it doesn't seem like the Windows stack differentiates
+ // anyway, so it's probably fine.
+ clamper.ForceMTU(int(iface.NLMTU))
lastMTU = mtu
}
return nil