mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 12:03:33 +00:00
network: add auto-detection of optimal MTU for WireGuard interface, --wg-mtu flag, set max_mtu for Corrosion to 1232
This commit is contained in:
@@ -12,6 +12,16 @@ import (
|
||||
const (
|
||||
WireGuardInterfaceName = "uncloud"
|
||||
DefaultWireGuardPort = 51820
|
||||
// MinWireGuardMTU is the minimum MTU for the WireGuard interface. The management traffic inside the tunnel uses
|
||||
// IPv6 whose minimum link MTU is 1280, so this is a safe floor that also keeps Corrosion's max_mtu (>= 1200) valid.
|
||||
MinWireGuardMTU = 1280
|
||||
// MaxWireGuardMTU is the conservative maximum MTU set by auto-detection and the fallback when detection fails.
|
||||
// It's the standard WireGuard MTU for a 1500-byte underlay (1500 - 80) that matches the kernel's default
|
||||
// for WireGuard links.
|
||||
MaxWireGuardMTU = 1500 - wireGuardEncapOverhead
|
||||
// wireGuardEncapOverhead is WireGuard's worst-case (IPv6 endpoint) encapsulation overhead: outer IPv6 (40) +
|
||||
// UDP (8) + WireGuard message header and auth tag (32).
|
||||
wireGuardEncapOverhead = 80
|
||||
// WireGuardKeepaliveInterval is sensible interval that works with a wide variety of firewalls.
|
||||
WireGuardKeepaliveInterval = 25 * time.Second
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user