Skip to content

Commit

Permalink
Replace ifconfig.me with solana_net_utils::get_public_ip_addr for…
Browse files Browse the repository at this point in the history
… Public IP (solana-labs#106)

Co-authored-by: Eric Semeniuc <3838856+esemeniuc@users.noreply.github.com>
  • Loading branch information
jedleggett and esemeniuc authored Feb 5, 2024
1 parent e2d186f commit 0e2a067
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ protobuf-src = "1.1.0"
quinn = "0.9"
rand = "0.8.5"
rayon = "1.7.0"
reqwest = "0.11.16"
rustls = { version = "0.20", features = ["dangerous_configuration"] }
serde = { version = "1.0.160", features = ["derive"] }
serde_json = "1.0.96"
Expand Down
1 change: 0 additions & 1 deletion transaction-relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jwt = { workspace = true }
log = { workspace = true }
openssl = { workspace = true }
prost-types = { workspace = true }
reqwest = { workspace = true }
solana-address-lookup-table-program = { workspace = true }
solana-client = { workspace = true }
solana-core = { workspace = true }
Expand Down
17 changes: 11 additions & 6 deletions transaction-relayer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ struct Args {
)]
websocket_servers: Vec<String>,

#[arg(long, env, default_value = "entrypoint.mainnet-beta.solana.com:8001")]
entrypoint_address: String,

/// This is the IP address that will be shared with the validator. The validator will
/// tell the rest of the network to send packets here.
#[arg(long, env)]
Expand Down Expand Up @@ -253,13 +256,15 @@ fn main() {
let public_ip = if args.public_ip.is_some() {
args.public_ip.unwrap()
} else {
info!("reading public ip from ifconfig.me...");
let response = reqwest::blocking::get("https://ifconfig.me")
.expect("response from ifconfig.me")
.text()
.expect("public ip response");
response.parse().unwrap()
let entrypoint = solana_net_utils::parse_host_port(args.entrypoint_address.as_str())
.expect("parse entrypoint");
info!(
"Contacting {} to determine the validator's public IP address",
entrypoint
);
solana_net_utils::get_public_ip_addr(&entrypoint).expect("get public ip address")
};

info!("public ip: {:?}", public_ip);
assert!(
public_ip.is_ipv4(),
Expand Down

0 comments on commit 0e2a067

Please sign in to comment.