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 buildpull/323/head
parent
dbac0dc530
commit
70e36369b4
|
@ -1002,14 +1002,14 @@ fn override_endpoint(
|
||||||
sub_opts: OverrideEndpointOpts,
|
sub_opts: OverrideEndpointOpts,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let config = InterfaceConfig::from_interface(&opts.config_dir, interface)?;
|
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 {
|
let endpoint_contents = if sub_opts.unset {
|
||||||
prompts::unset_override_endpoint(&sub_opts)?.then_some(EndpointContents::Unset)
|
prompts::unset_override_endpoint(&sub_opts)?.then_some(EndpointContents::Unset)
|
||||||
} else {
|
} 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)?;
|
let endpoint = prompts::override_endpoint(&sub_opts, port)?;
|
||||||
endpoint.map(EndpointContents::Set)
|
endpoint.map(EndpointContents::Set)
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@ use std::{
|
||||||
pub type Result<T> = result::Result<T, Box<dyn std::error::Error>>;
|
pub type Result<T> = result::Result<T, Box<dyn std::error::Error>>;
|
||||||
|
|
||||||
/// A custom error struct for this crate.
|
/// A custom error struct for this crate.
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Error(String);
|
pub struct Error(String);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue