From d6ab8e6653ebd763bdb34d12e4cd349e9008def0 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Mon, 14 Jun 2021 23:05:59 +0900 Subject: [PATCH] shared(wg): default to 1400 if network CIDR is IPv6 Second fix for #102 --- shared/src/types.rs | 6 +++--- shared/src/wg.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/src/types.rs b/shared/src/types.rs index fb028a6..4950647 100644 --- a/shared/src/types.rs +++ b/shared/src/types.rs @@ -385,9 +385,9 @@ pub struct NetworkOpt { /// If not set, innernet will auto-select based on availability. pub backend: Backend, - #[structopt(long, default_value = "1420")] - /// Specify the desired MTU for your interface. - pub mtu: u32, + #[structopt(long)] + /// Specify the desired MTU for your interface (default: 1420 for IPv4 and 1400 for IPv6). + pub mtu: Option, } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] diff --git a/shared/src/wg.rs b/shared/src/wg.rs index 7a54952..40386a4 100644 --- a/shared/src/wg.rs +++ b/shared/src/wg.rs @@ -85,7 +85,7 @@ pub fn up( .set_private_key(wgctrl::Key::from_base64(&private_key).unwrap()) .apply(interface, network.backend)?; set_addr(interface, address)?; - set_up(interface, network.mtu)?; + set_up(interface, network.mtu.unwrap_or_else(|| if address.is_ipv4() { 1420 } else { 1400 }))?; if !network.no_routing { add_route(interface, address)?; }