From 3ee52c50d79af7722b6cec15d913ca62ad9131ab Mon Sep 17 00:00:00 2001 From: Marcus Wichelmann Date: Fri, 5 Aug 2022 16:46:47 +0200 Subject: [PATCH] Only add the MTU option to the client config, when it is set. --- templates/global_settings.html | 4 ++-- util/util.go | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/global_settings.html b/templates/global_settings.html index 0288306..1c01438 100644 --- a/templates/global_settings.html +++ b/templates/global_settings.html @@ -91,9 +91,9 @@ Global Settings
2. DNS Servers
The DNS servers will be set to client config.
3. MTU
-
The MTU will be set to server config. By default it is 1420. You might want +
The MTU will be set to server and client config. By default it is 1420. You might want to adjust the MTU size if your connection (e.g PPPoE, 3G, satellite network, etc) has a low MTU.
-
Leave blank to omit this setting in the Server config.
+
Leave blank to omit this setting in the configs.
4. Persistent Keepalive
By default, WireGuard peers remain silent while they do not need to communicate, so peers located behind a NAT and/or firewall may be unreachable from other peers diff --git a/util/util.go b/util/util.go index eb0c9a8..6e9e144 100644 --- a/util/util.go +++ b/util/util.go @@ -28,7 +28,10 @@ func BuildClientConfig(client model.Client, server model.Server, setting model.G if client.UseServerDNS { clientDNS = fmt.Sprintf("DNS = %s\n", strings.Join(setting.DNSServers, ",")) } - clientMTU := fmt.Sprintf("MTU = %d\n", setting.MTU) + clientMTU := "" + if setting.MTU > 0 { + clientMTU = fmt.Sprintf("MTU = %d\n", setting.MTU) + } // Peer section peerPublicKey := fmt.Sprintf("PublicKey = %s\n", server.KeyPair.PublicKey)