Skip to content

Commit

Permalink
fix(rust): allow ockam relay create at argument to be node name
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Oakley authored and mrinalwadhwa committed Apr 19, 2023
1 parent 4e97e74 commit e51c73e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion implementations/rust/ockam/ockam_command/src/relay/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct CreateCommand {
to: String,

/// Route to the node at which to create the relay (optional)
#[arg(long, id = "ROUTE", display_order = 900, default_value_t = default_forwarder_at())]
#[arg(long, id = "ROUTE", display_order = 900, value_parser = parse_at, default_value_t = default_forwarder_at())]
at: MultiAddr,

/// Authorized identity for secure channel connection (optional)
Expand All @@ -51,6 +51,17 @@ impl CreateCommand {
}
}

fn parse_at(input: &str) -> Result<MultiAddr> {
let mut at = input.to_string();
if !input.contains('/') {
at = format!("/node/{}", input);
}

let ma = MultiAddr::from_str(&at)?;

Ok(ma)
}

pub fn default_forwarder_at() -> MultiAddr {
MultiAddr::from_str("/project/default").expect("Default relay address is invalid")
}
Expand Down

0 comments on commit e51c73e

Please sign in to comment.