From 70e36369b41539a9da85ffd3d07462f24faf4e5f Mon Sep 17 00:00:00 2001 From: Ryo Kawaguchi Date: Fri, 9 Aug 2024 18:28:20 +0900 Subject: [PATCH] Do not error on the listen port not set, for override-endpoint --unset (#317) * Do not error on the listen port not set, for override-endpoint --unset * Fix build --- client/src/main.rs | 8 ++++---- hostsfile/src/lib.rs | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/main.rs b/client/src/main.rs index 67cbf1a..3a26ffa 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -1002,14 +1002,14 @@ fn override_endpoint( sub_opts: OverrideEndpointOpts, ) -> Result<(), Error> { let config = InterfaceConfig::from_interface(&opts.config_dir, interface)?; - let port = match config.interface.listen_port { - Some(port) => port, - None => bail!("you need to set a listen port with set-listen-port before overriding the endpoint (otherwise port randomization on the interface would make it useless).") - }; let endpoint_contents = if sub_opts.unset { prompts::unset_override_endpoint(&sub_opts)?.then_some(EndpointContents::Unset) } else { + let port = match config.interface.listen_port { + Some(port) => port, + None => bail!("you need to set a listen port with set-listen-port before overriding the endpoint (otherwise port randomization on the interface would make it useless).") + }; let endpoint = prompts::override_endpoint(&sub_opts, port)?; endpoint.map(EndpointContents::Set) }; diff --git a/hostsfile/src/lib.rs b/hostsfile/src/lib.rs index b8844a2..44de3c3 100644 --- a/hostsfile/src/lib.rs +++ b/hostsfile/src/lib.rs @@ -12,6 +12,7 @@ use std::{ pub type Result = result::Result>; /// A custom error struct for this crate. +#[allow(dead_code)] #[derive(Debug, Clone)] pub struct Error(String);