diff --git a/gossip/src/main.rs b/gossip/src/main.rs index 01cfe86704..0099b44f3d 100644 --- a/gossip/src/main.rs +++ b/gossip/src/main.rs @@ -45,6 +45,12 @@ fn main() -> Result<(), Box> { .subcommand( SubCommand::with_name("get-rpc-url") .about("Get an RPC URL for the cluster") + .arg( + Arg::with_name("all") + .long("all") + .takes_value(false) + .help("Return all RPC URLs"), + ) .arg( Arg::with_name("timeout") .long("timeout") @@ -194,18 +200,23 @@ fn main() -> Result<(), Box> { gossip_addr.as_ref(), )?; - let rpc_addr = nodes + let rpc_addrs: Vec<_> = nodes .iter() .filter_map(ContactInfo::valid_client_facing_addr) .map(|addrs| addrs.0) - .find(|rpc_addr| rpc_addr.ip() == entrypoint_addr.ip()); + .filter(|rpc_addr| { + matches.is_present("all") || rpc_addr.ip() == entrypoint_addr.ip() + }) + .collect(); - if rpc_addr.is_none() { + if rpc_addrs.is_empty() { eprintln!("No RPC URL found"); exit(1); } - println!("http://{}", rpc_addr.unwrap()); + for rpc_addr in rpc_addrs { + println!("http://{}", rpc_addr); + } } ("stop", Some(matches)) => { let pubkey = matches