-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error handling for location argument in CLI DES-435 #5462
Conversation
DES-435 Better error handling when adding non-existent relay/bridge by hostname
ContextSince DES-43 and DES-287, the user should be able to just supply the hostname of a relay/bridge and have the daemon figure out if that relay exist or not. The way that resolution works in the 3 relevant
ProblemThe error handling between the different CLI subcommands differ.
This shows that these 3 different subcommands which should behave the same do not. SolutionThe code/daemon/frontends can assume hostnames are unique. Two relays can never have the same hostname. So only the hostname is a unique identifier for a relay.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! 🎉
See my (minor) comments. After you are done squashing, I will sign the Cargo.lock
-file and merge this PR for you 😊
Reviewed 10 of 11 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @Serock3)
mullvad-cli/src/cmds/relay.rs
line 345 at r2 (raw file):
async fn list() -> Result<()> { let mut countries = get_active_non_bridge_relays().await?;
If I would be a little nit-picky here, I suggest changing this function's name to get_active_relays
.
Bridge relays are most often talked about as just bridges, and "non-bridge" relays are refereed to as just relays.
Code quote:
get_active_non_bridge_relays()
mullvad-cli/src/cmds/relay.rs
line 935 at r2 (raw file):
/// Parses the [`LocationArgs`] into a [`Constraint<GeographicLocationConstraint>`]. /// /// See the documentation of [SetCommands] (`mullvad relay set location`) for a description
These should be the swapped:
[`mullvad relay set location`](SetCommands)
Love the detailed doc-comments with links! 🙌
Code quote:
[SetCommands] (`mullvad relay set location`)
mullvad-cli/src/cmds/relay.rs
line 967 at r2 (raw file):
Constraint::from(location_constraint_args); // If the location constraint was not "any", the validate the country/city
then*
Code quote:
the
mullvad-cli/src/cmds/relay.rs
line 981 at r2 (raw file):
/// Return a list of all relays that are active and not bridges pub async fn get_active_non_bridge_relays() -> Result<Vec<RelayListCountry>> {
See previous comment regarding the naming of relays / bridges 😊
Code quote:
get_active_non_bridge_relays()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 10 of 11 files reviewed, 5 unresolved discussions (waiting on @MarkusPettersson98 and @MrChocolatine)
CHANGELOG.md
line 62 at r1 (raw file):
Previously, MrChocolatine wrote…
- Validate that hostname matches correct server type for CLI commands `mullvad relay set location`, `mullvad bridge set location` and `mullvad relay set tunnel wireguard entry location`
Done.
mullvad-cli/src/cmds/relay.rs
line 345 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
If I would be a little nit-picky here, I suggest changing this function's name to
get_active_relays
.
Bridge relays are most often talked about as just bridges, and "non-bridge" relays are refereed to as just relays.
Done.
mullvad-cli/src/cmds/relay.rs
line 935 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
These should be the swapped:
[`mullvad relay set location`](SetCommands)
Love the detailed doc-comments with links! 🙌
Done.
mullvad-cli/src/cmds/relay.rs
line 967 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
then*
Done.
mullvad-cli/src/cmds/relay.rs
line 981 at r2 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
See previous comment regarding the naming of relays / bridges 😊
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MrChocolatine)
676b5ef
to
a5fb517
Compare
Refactor: Unwrap result return type Refactor: for loop to iter map
The fn exists and returns error on hostname having wrong server type. Allow any host in custom-lists, only the currently configured tunnel protocol for `relay set location`, only bridges for the `bridge` subcommand and only wireguard servers in for the `wireguard` entry command. Reduce repeated init of rpc client Refactor inconsistent filtering on hostname
The command `relay set tunnel wireguard entry-location` is replaced with `relay set tunnel wireguard entry location` and `relay set tunnel wireguard custom-list` is replaced with `relay set tunnel wireguard entry custom-list`. This is intended to communicate that the `custom-list` also affects the entry relay and are mutually exclusive.
Update changelog with the command `mullvad relay set tunnel wireguard entry custom-list` Update changelog with CLI changes
Typo Co-authored-by: MrChocolatine <[email protected]>
a5fb517
to
e1a4f68
Compare
e1a4f68
to
efdef80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MrChocolatine)
Make the CLI arguments that parse
LocationArgs
validate the input. Specifically, make sure that the country or host exists and, if hostname is given, then validate the server type (e.g. only bridge host for the bridge command).Some braking changes to the CLI were done, see the changelog.
You can no longer enter the blocked state through
mullvad relay set location xx
. Instead a hidden commandmullvad debug block-connection
was added. See issue https://linear.app/mullvad/issue/DES-453/update-test-instructions-to-use-new-block-command about updating test instruction.This change is