diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-08-03 16:04:15 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-08-03 16:04:15 +0200 |
commit | 3f07aa3f0fcd1153687bfb442c0c5b674216d595 (patch) | |
tree | 8754f12c8740080fd60fb57c7532a4e039dbdfe1 /tunnel | |
parent | version: bump (diff) | |
download | wireguard-windows-3f07aa3f0fcd1153687bfb442c0c5b674216d595.tar.xz wireguard-windows-3f07aa3f0fcd1153687bfb442c0c5b674216d595.zip |
winipcfg: set MTU in registry after setting it in iphlpapi
Otherwise wireguard-nt is unable to be notified of it. This is a pretty
nasty hack that we should revert ASAP.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tunnel')
-rw-r--r-- | tunnel/winipcfg/types.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tunnel/winipcfg/types.go b/tunnel/winipcfg/types.go index b06f05dd..7309067b 100644 --- a/tunnel/winipcfg/types.go +++ b/tunnel/winipcfg/types.go @@ -11,6 +11,7 @@ import ( "unsafe" "golang.org/x/sys/windows" + "golang.org/x/sys/windows/registry" ) const ( @@ -675,7 +676,23 @@ func (row *MibIPInterfaceRow) get() error { // Set method sets the properties of an IP interface on the local computer. // https://docs.microsoft.com/en-us/windows/desktop/api/netioapi/nf-netioapi-setipinterfaceentry func (row *MibIPInterfaceRow) Set() error { - return setIPInterfaceEntry(row) + err := setIPInterfaceEntry(row) + if err != nil { + return err + } + if row.NLMTU == 0 || row.InterfaceLUID == 0 { + return nil + } + guid, err := row.InterfaceLUID.GUID() + if err != nil { + return err + } + key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\`+guid.String(), registry.SET_VALUE) + if err != nil { + return err + } + defer key.Close() + return key.SetDWordValue("MTU", row.NLMTU) } // get method returns all table rows as a Go slice. |