Support SSH usernames which contain @ symbols (#25314)
Closes #25246 Release Notes: - SSH: Improved handling of multiple `@` in connection strings: e.g. `ssh jim.lv@es2@10.220.67.57@11.239.1.231` improving support of jump hosts running JumpServer. --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
8f560daec2
commit
a0f995d2ae
6 changed files with 10 additions and 4 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -11253,6 +11253,7 @@ dependencies = [
|
||||||
"smol",
|
"smol",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
|
"urlencoding",
|
||||||
"util",
|
"util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -565,6 +565,7 @@ unindent = "0.2.0"
|
||||||
unicode-segmentation = "1.10"
|
unicode-segmentation = "1.10"
|
||||||
unicode-script = "0.5.7"
|
unicode-script = "0.5.7"
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
|
urlencoding = "2.1.2"
|
||||||
uuid = { version = "1.1.2", features = ["v4", "v5", "v7", "serde"] }
|
uuid = { version = "1.1.2", features = ["v4", "v5", "v7", "serde"] }
|
||||||
wasmparser = "0.221"
|
wasmparser = "0.221"
|
||||||
wasm-encoder = "0.221"
|
wasm-encoder = "0.221"
|
||||||
|
|
|
@ -36,7 +36,7 @@ serde_json.workspace = true
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
sysinfo.workspace = true
|
sysinfo.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
urlencoding = "2.1.2"
|
urlencoding.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
zed_actions.workspace = true
|
zed_actions.workspace = true
|
||||||
|
|
|
@ -39,6 +39,7 @@ shlex.workspace = true
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
tempfile.workspace = true
|
tempfile.workspace = true
|
||||||
thiserror.workspace = true
|
thiserror.workspace = true
|
||||||
|
urlencoding.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -203,7 +203,8 @@ impl SshConnectionOptions {
|
||||||
anyhow::bail!("unsupported argument: {:?}", arg);
|
anyhow::bail!("unsupported argument: {:?}", arg);
|
||||||
}
|
}
|
||||||
let mut input = &arg as &str;
|
let mut input = &arg as &str;
|
||||||
if let Some((u, rest)) = input.split_once('@') {
|
// Destination might be: username1@username2@ip2@ip1
|
||||||
|
if let Some((u, rest)) = input.rsplit_once('@') {
|
||||||
input = rest;
|
input = rest;
|
||||||
username = Some(u.to_string());
|
username = Some(u.to_string());
|
||||||
}
|
}
|
||||||
|
@ -238,7 +239,9 @@ impl SshConnectionOptions {
|
||||||
pub fn ssh_url(&self) -> String {
|
pub fn ssh_url(&self) -> String {
|
||||||
let mut result = String::from("ssh://");
|
let mut result = String::from("ssh://");
|
||||||
if let Some(username) = &self.username {
|
if let Some(username) = &self.username {
|
||||||
result.push_str(username);
|
// Username might be: username1@username2@ip2
|
||||||
|
let username = urlencoding::encode(username);
|
||||||
|
result.push_str(&username);
|
||||||
result.push('@');
|
result.push('@');
|
||||||
}
|
}
|
||||||
result.push_str(&self.host);
|
result.push_str(&self.host);
|
||||||
|
|
|
@ -124,7 +124,7 @@ time.workspace = true
|
||||||
toolchain_selector.workspace = true
|
toolchain_selector.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
url.workspace = true
|
url.workspace = true
|
||||||
urlencoding = "2.1.2"
|
urlencoding.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
uuid.workspace = true
|
uuid.workspace = true
|
||||||
vim.workspace = true
|
vim.workspace = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue