mirror of
https://github.com/DJSundog/wg-portal.git
synced 2024-11-23 07:03:50 -05:00
fix default mtu handling
This commit is contained in:
parent
6fd4089766
commit
ec60dd136a
@ -390,6 +390,9 @@ func (u *UserManager) validateOrCreateDevice(dev wgtypes.Device, ipAddresses []s
|
|||||||
device.Mtu = 0
|
device.Mtu = 0
|
||||||
device.PersistentKeepalive = 16 // Default
|
device.PersistentKeepalive = 16 // Default
|
||||||
device.IPsStr = strings.Join(ipAddresses, ", ")
|
device.IPsStr = strings.Join(ipAddresses, ", ")
|
||||||
|
if mtu == wireguard.WireGuardDefaultMTU {
|
||||||
|
mtu = 0
|
||||||
|
}
|
||||||
device.Mtu = mtu
|
device.Mtu = mtu
|
||||||
|
|
||||||
res := u.db.Create(&device)
|
res := u.db.Create(&device)
|
||||||
|
@ -7,6 +7,8 @@ import (
|
|||||||
"github.com/milosgajdos/tenus"
|
"github.com/milosgajdos/tenus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const WireGuardDefaultMTU = 1420
|
||||||
|
|
||||||
func (m *Manager) GetIPAddress() ([]string, error) {
|
func (m *Manager) GetIPAddress() ([]string, error) {
|
||||||
wgInterface, err := tenus.NewLinkFrom(m.Cfg.DeviceName)
|
wgInterface, err := tenus.NewLinkFrom(m.Cfg.DeviceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -107,7 +109,7 @@ func (m *Manager) SetMTU(mtu int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if mtu == 0 {
|
if mtu == 0 {
|
||||||
mtu = 1420 // WireGuard default MTU
|
mtu = WireGuardDefaultMTU
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := wgInterface.SetLinkMTU(mtu); err != nil {
|
if err := wgInterface.SetLinkMTU(mtu); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user