diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-09-18 17:22:18 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-09-18 17:22:18 +0200 |
| commit | c072667ffed6b4b698cec5a4a8adff00be88c3e5 (patch) | |
| tree | c1fe4b5354c23e939f97577ef7aadaf6eab5731e /mullvad-cli/src | |
| parent | 923414f3f00b033dde8ed538ad05c18da4da6b27 (diff) | |
| parent | a074cb8e3625d5378c0be7954b1f5423479d071c (diff) | |
| download | mullvadvpn-c072667ffed6b4b698cec5a4a8adff00be88c3e5.tar.xz mullvadvpn-c072667ffed6b4b698cec5a4a8adff00be88c3e5.zip | |
Merge branch 'add-staggered-obfuscator'
Diffstat (limited to 'mullvad-cli/src')
| -rw-r--r-- | mullvad-cli/src/format.rs | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/mullvad-cli/src/format.rs b/mullvad-cli/src/format.rs index 31369e7f3e..0797a1dced 100644 --- a/mullvad-cli/src/format.rs +++ b/mullvad-cli/src/format.rs @@ -224,12 +224,12 @@ fn format_relay_connection( verbose: bool, ) -> String { let first_hop = endpoint.entry_endpoint.as_ref().map(|entry| { - let endpoint = format_endpoint( + let endpoint = format_endpoints( location.and_then(|l| l.entry_hostname.as_deref()), // Check if we *actually* want to print an obfuscator endpoint .. match endpoint.obfuscation { - Some(ref obfuscation) => &obfuscation.endpoint, - _ => entry, + Some(ref info) => info.get_endpoints(), + _ => vec![*entry], }, verbose, ); @@ -246,13 +246,13 @@ fn format_relay_connection( format!(" via {proxy_endpoint}") }); - let exit_endpoint = format_endpoint( + let exit_endpoint = format_endpoints( location.and_then(|l| l.hostname.as_deref()), // Check if we *actually* want to print an obfuscator endpoint .. // The obfuscator information should be printed for the exit relay if multihop is disabled - match (endpoint.obfuscation, &first_hop) { - (Some(ref obfuscation), None) => &obfuscation.endpoint, - _ => &endpoint.endpoint, + match (&endpoint.obfuscation, &first_hop) { + (Some(obfuscation), None) => obfuscation.get_endpoints(), + _ => vec![endpoint.endpoint], }, verbose, ); @@ -264,6 +264,31 @@ fn format_relay_connection( ) } +fn format_endpoints( + hostname: Option<&str>, + endpoints: impl AsRef<[Endpoint]>, + verbose: bool, +) -> String { + let endpoints = endpoints.as_ref(); + if endpoints.len() == 1 { + return format_endpoint(hostname, &endpoints[0], verbose); + } + + let mut endpoints_str = String::new(); + for (i, endpoint) in endpoints.iter().enumerate() { + if i > 0 { + endpoints_str.push_str(" | "); + } + endpoints_str.push_str(&endpoint.to_string()); + } + + match (hostname, verbose) { + (Some(hostname), true) => format!("{hostname} ({endpoints_str})"), + (None, _) => endpoints_str, + (Some(hostname), false) => hostname.to_string(), + } +} + fn format_endpoint(hostname: Option<&str>, endpoint: &Endpoint, verbose: bool) -> String { match (hostname, verbose) { (Some(hostname), true) => format!("{hostname} ({endpoint})"), |
