aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-16 01:51:50 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-16 01:51:56 +0530
commitf63c9fd5983f96cfc43891b5301830549b472c6d (patch)
treefe47784dc12ce7e76edb35d3fa89fda296958512 /WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
parentmacOS: Different status bar icon looks for different states (diff)
downloadwireguard-apple-f63c9fd5983f96cfc43891b5301830549b472c6d.tar.xz
wireguard-apple-f63c9fd5983f96cfc43891b5301830549b472c6d.zip
macOS: Use tunnelOverheadBytes for automatic MTU in macOS
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift')
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift12
1 files changed, 8 insertions, 4 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
index f6eb722..a1f90f1 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
@@ -70,7 +70,7 @@ class PacketTunnelSettingsGenerator {
dnsSettings.matchDomains = [""] // All DNS queries must first go through the tunnel's DNS
networkSettings.dnsSettings = dnsSettings
- var mtu = tunnelConfiguration.interface.mtu ?? 0
+ let mtu = tunnelConfiguration.interface.mtu ?? 0
/* 0 means automatic MTU. In theory, we should just do
* `networkSettings.tunnelOverheadBytes = 80` but in
@@ -79,11 +79,15 @@ class PacketTunnelSettingsGenerator {
* add a nob, maybe, or iOS will do probing for us.
*/
if mtu == 0 {
- mtu = 1280
+ #if os(iOS)
+ networkSettings.mtu = NSNumber(value: 1280)
+ #elseif os(OSX)
+ networkSettings.tunnelOverheadBytes = 80
+ #endif
+ } else {
+ networkSettings.mtu = NSNumber(value: mtu)
}
- networkSettings.mtu = NSNumber(value: mtu)
-
let (ipv4Routes, ipv6Routes) = routes()
let (ipv4IncludedRoutes, ipv6IncludedRoutes) = includedRoutes()