feat(wireguard): MTU defaults to 1400 instead of 1420

This commit is contained in:
Quentin McGaw
2023-06-08 09:50:21 +00:00
parent 9b39a301a8
commit 2ec9293324
2 changed files with 6 additions and 4 deletions

View File

@@ -97,7 +97,7 @@ ENV VPN_SERVICE_PROVIDER=pia \
WIREGUARD_PRESHARED_KEY= \ WIREGUARD_PRESHARED_KEY= \
WIREGUARD_PUBLIC_KEY= \ WIREGUARD_PUBLIC_KEY= \
WIREGUARD_ADDRESSES= \ WIREGUARD_ADDRESSES= \
WIREGUARD_MTU= \ WIREGUARD_MTU=1400 \
WIREGUARD_IMPLEMENTATION=auto \ WIREGUARD_IMPLEMENTATION=auto \
# VPN server filtering # VPN server filtering
SERVER_REGIONS= \ SERVER_REGIONS= \

View File

@@ -10,7 +10,6 @@ import (
"github.com/qdm12/gosettings" "github.com/qdm12/gosettings"
"github.com/qdm12/gosettings/validate" "github.com/qdm12/gosettings/validate"
"github.com/qdm12/gotree" "github.com/qdm12/gotree"
wireguarddevice "golang.zx2c4.com/wireguard/device"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes" "golang.zx2c4.com/wireguard/wgctrl/wgtypes"
) )
@@ -32,7 +31,9 @@ type Wireguard struct {
Interface string `json:"interface"` Interface string `json:"interface"`
// Maximum Transmission Unit (MTU) of the Wireguard interface. // Maximum Transmission Unit (MTU) of the Wireguard interface.
// It cannot be zero in the internal state, and defaults to // It cannot be zero in the internal state, and defaults to
// the wireguard-go MTU default of 1420. // 1400. Note it is not the wireguard-go MTU default of 1420
// because this impacts bandwidth a lot on some VPN providers,
// see https://github.com/qdm12/gluetun/issues/1650.
MTU uint16 `json:"mtu"` MTU uint16 `json:"mtu"`
// Implementation is the Wireguard implementation to use. // Implementation is the Wireguard implementation to use.
// It can be "auto", "userspace" or "kernelspace". // It can be "auto", "userspace" or "kernelspace".
@@ -150,7 +151,8 @@ func (w *Wireguard) setDefaults(vpnProvider string) {
w.Addresses = gosettings.DefaultSlice(w.Addresses, []netip.Prefix{defaultNordVPNPrefix}) w.Addresses = gosettings.DefaultSlice(w.Addresses, []netip.Prefix{defaultNordVPNPrefix})
} }
w.Interface = gosettings.DefaultString(w.Interface, "wg0") w.Interface = gosettings.DefaultString(w.Interface, "wg0")
w.MTU = gosettings.DefaultNumber(w.MTU, wireguarddevice.DefaultMTU) const defaultMTU = 1400
w.MTU = gosettings.DefaultNumber(w.MTU, defaultMTU)
w.Implementation = gosettings.DefaultString(w.Implementation, "auto") w.Implementation = gosettings.DefaultString(w.Implementation, "auto")
} }