Only add the MTU option to the client config, when it is set.
This commit is contained in:
		
							parent
							
								
									7fd2338278
								
							
						
					
					
						commit
						3ee52c50d7
					
				|  | @ -91,9 +91,9 @@ Global Settings | ||||||
|                             <dt>2. DNS Servers</dt> |                             <dt>2. DNS Servers</dt> | ||||||
|                             <dd>The DNS servers will be set to client config.</dd> |                             <dd>The DNS servers will be set to client config.</dd> | ||||||
|                             <dt>3. MTU</dt> |                             <dt>3. MTU</dt> | ||||||
|                             <dd>The MTU will be set to server config. By default it is <code>1420</code>. You might want |                             <dd>The MTU will be set to server and client config. By default it is <code>1420</code>. You might want | ||||||
|                                 to adjust the MTU size if your connection (e.g PPPoE, 3G, satellite network, etc) has a low MTU.</dd> |                                 to adjust the MTU size if your connection (e.g PPPoE, 3G, satellite network, etc) has a low MTU.</dd> | ||||||
|                             <dd>Leave blank to omit this setting in the Server config.</dd> |                             <dd>Leave blank to omit this setting in the configs.</dd> | ||||||
|                             <dt>4. Persistent Keepalive</dt> |                             <dt>4. Persistent Keepalive</dt> | ||||||
|                             <dd>By default, WireGuard peers remain silent while they do not need to communicate, |                             <dd>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 |                                 so peers located behind a NAT and/or firewall may be unreachable from other peers | ||||||
|  |  | ||||||
|  | @ -28,7 +28,10 @@ func BuildClientConfig(client model.Client, server model.Server, setting model.G | ||||||
| 	if client.UseServerDNS { | 	if client.UseServerDNS { | ||||||
| 		clientDNS = fmt.Sprintf("DNS = %s\n", strings.Join(setting.DNSServers, ",")) | 		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
 | 	// Peer section
 | ||||||
| 	peerPublicKey := fmt.Sprintf("PublicKey = %s\n", server.KeyPair.PublicKey) | 	peerPublicKey := fmt.Sprintf("PublicKey = %s\n", server.KeyPair.PublicKey) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue