Skip to content

Commit

Permalink
Do not error on the listen port not set, for override-endpoint --unset (
Browse files Browse the repository at this point in the history
#317)

* Do not error on the listen port not set, for override-endpoint --unset

* Fix build
  • Loading branch information
skywhale authored Aug 9, 2024
1 parent dbac0dc commit 70e3636
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand Down
1 change: 1 addition & 0 deletions hostsfile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 70e3636

Please sign in to comment.