Skip to content

Commit

Permalink
Include node identity in the P2P advertised client version. (openethe…
Browse files Browse the repository at this point in the history
  • Loading branch information
jimpo authored and 5chdn committed Jun 18, 2018
1 parent 6004c39 commit 6f11621
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,15 @@ impl Configuration {
ret.config_path = Some(net_path.to_str().unwrap().to_owned());
ret.reserved_nodes = self.init_reserved_nodes()?;
ret.allow_non_reserved = !self.args.flag_reserved_only;
ret.client_version = version();
ret.client_version = {
let mut client_version = version();
if !self.args.arg_identity.is_empty() {
// Insert name after the "Parity/" at the beginning of version string.
let idx = client_version.find('/').unwrap_or(client_version.len());
client_version.insert_str(idx, &format!("/{}", self.args.arg_identity));
}
client_version
};
Ok(ret)
}

Expand Down Expand Up @@ -1790,6 +1798,19 @@ mod tests {
}
}

#[test]
fn test_identity_arg() {
let args = vec!["parity", "--identity", "Somebody"];
let conf = Configuration::parse_cli(&args).unwrap();
match conf.into_command().unwrap().cmd {
Cmd::Run(c) => {
assert_eq!(c.name, "Somebody");
assert!(c.net_conf.client_version.starts_with("Parity/Somebody/"));
}
_ => panic!("Should be Cmd::Run"),
}
}

#[test]
fn should_apply_ports_shift() {
// given
Expand Down

0 comments on commit 6f11621

Please sign in to comment.