Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Include node identity in the P2P advertised client version. #8830

Merged
merged 1 commit into from
Jun 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,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 @@ -1787,6 +1795,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