fix default mtu handling

This commit is contained in:
Christoph Haas 2020-12-18 22:07:55 +01:00
parent 6fd4089766
commit ec60dd136a
2 changed files with 6 additions and 1 deletions

View File

@ -390,6 +390,9 @@ func (u *UserManager) validateOrCreateDevice(dev wgtypes.Device, ipAddresses []s
device.Mtu = 0
device.PersistentKeepalive = 16 // Default
device.IPsStr = strings.Join(ipAddresses, ", ")
if mtu == wireguard.WireGuardDefaultMTU {
mtu = 0
}
device.Mtu = mtu
res := u.db.Create(&device)

View File

@ -7,6 +7,8 @@ import (
"github.com/milosgajdos/tenus"
)
const WireGuardDefaultMTU = 1420
func (m *Manager) GetIPAddress() ([]string, error) {
wgInterface, err := tenus.NewLinkFrom(m.Cfg.DeviceName)
if err != nil {
@ -107,7 +109,7 @@ func (m *Manager) SetMTU(mtu int) error {
}
if mtu == 0 {
mtu = 1420 // WireGuard default MTU
mtu = WireGuardDefaultMTU
}
if err := wgInterface.SetLinkMTU(mtu); err != nil {