shared(wg): default to 1400 if network CIDR is IPv6

Second fix for #102
pull/121/head
Jake McGinty 2021-06-14 23:05:59 +09:00
parent 4a458a413c
commit d6ab8e6653
2 changed files with 4 additions and 4 deletions

View File

@ -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<u32>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]

View File

@ -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)?;
}