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
pull/323/head
Ryo Kawaguchi 2024-08-09 18:28:20 +09:00 committed by GitHub
parent dbac0dc530
commit 70e36369b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

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

View File

@ -12,6 +12,7 @@ use std::{
pub type Result<T> = result::Result<T, Box<dyn std::error::Error>>;
/// A custom error struct for this crate.
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct Error(String);