Allow nodes to advertise a different rpc address over gossip (#13053)
* Allow nodes to advertise a different rpc address over gossip * Feedback
This commit is contained in:
@ -154,7 +154,7 @@ fn get_rpc_node(
|
||||
let mut retry_reason = None;
|
||||
loop {
|
||||
sleep(Duration::from_secs(1));
|
||||
info!("\n{}", cluster_info.contact_info_trace());
|
||||
info!("\n{}", cluster_info.rpc_info_trace());
|
||||
|
||||
let shred_version = validator_config
|
||||
.expected_shred_version
|
||||
@ -1058,6 +1058,17 @@ pub fn main() {
|
||||
.help("IP address for the node to advertise in gossip when \
|
||||
--entrypoint is not provided [default: 127.0.0.1]"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("public_rpc_addr")
|
||||
.long("public-rpc-address")
|
||||
.value_name("HOST:PORT")
|
||||
.takes_value(true)
|
||||
.conflicts_with("private_rpc")
|
||||
.validator(solana_net_utils::is_host_port)
|
||||
.help("RPC address for the node to advertise publicly in gossip. \
|
||||
Useful for nodes running behind a load balancer or proxy \
|
||||
[default: use --rpc-bind-address / --rpc-port]"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("dynamic_port_range")
|
||||
.long("dynamic-port-range")
|
||||
@ -1596,6 +1607,13 @@ pub fn main() {
|
||||
})
|
||||
});
|
||||
|
||||
let public_rpc_addr = matches.value_of("public_rpc_addr").map(|addr| {
|
||||
solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse public rpc address: {}", e);
|
||||
exit(1);
|
||||
})
|
||||
});
|
||||
|
||||
let logfile = {
|
||||
let logfile = matches
|
||||
.value_of("logfile")
|
||||
@ -1671,7 +1689,12 @@ pub fn main() {
|
||||
}
|
||||
|
||||
if !private_rpc {
|
||||
if let Some((rpc_addr, rpc_pubsub_addr, rpc_banks_addr)) = validator_config.rpc_addrs {
|
||||
if let Some(public_rpc_addr) = public_rpc_addr {
|
||||
node.info.rpc = public_rpc_addr;
|
||||
node.info.rpc_pubsub = public_rpc_addr;
|
||||
node.info.rpc_banks = public_rpc_addr;
|
||||
} else if let Some((rpc_addr, rpc_pubsub_addr, rpc_banks_addr)) = validator_config.rpc_addrs
|
||||
{
|
||||
node.info.rpc = SocketAddr::new(node.info.gossip.ip(), rpc_addr.port());
|
||||
node.info.rpc_pubsub = SocketAddr::new(node.info.gossip.ip(), rpc_pubsub_addr.port());
|
||||
node.info.rpc_banks = SocketAddr::new(node.info.gossip.ip(), rpc_banks_addr.port());
|
||||
|
Reference in New Issue
Block a user