Use tunnelOverheadBytes to properly set tunnel interface MTU (#1924)

Apple provides a mechanism to calculate a smarter MTU for the tunnel
interface that is created.

This will be automatically adjusted depending on the MTU of the
underlying physical device.
This commit is contained in:
Jamil
2023-08-17 22:14:04 -07:00
committed by GitHub
parent 0bd4d9e7b5
commit b8cb59beb2

View File

@@ -31,9 +31,8 @@ class NetworkSettings {
let tunnelAddressIPv6: String
let dnsAddress: String
// In theory we could update the MTU dynamically based on the network environment,
// but 1280 is guaranteed to work everywhere.
let tunnelMTU = NSNumber(1280)
// WireGuard has an 80-byte overhead.
let tunnelOverheadBytes = NSNumber(80)
// Modifiable values
private(set) var dnsFallbackStrategy: DNSFallbackStrategy
@@ -153,7 +152,7 @@ class NetworkSettings {
dnsSettings.matchDomains = [""]
}
tunnelNetworkSettings.dnsSettings = dnsSettings
tunnelNetworkSettings.mtu = tunnelMTU
tunnelNetworkSettings.tunnelOverheadBytes = tunnelOverheadBytes
self.hasUnappliedChanges = false
logger.debug("Attempting to set network settings")