Rename solana-netutil to solana-net-utils for consistency (#6895)
* sed -i -e 's/netutil/net_utils/g' $(git grep --files-with-matches netutil :**.rs) * sed -i -e 's/netutil/net-utils/g' $(git grep --files-with-matches netutil) * git mv netutil/ net-utils * Tweak a bit * Fix rustfmt & clippy
This commit is contained in:
parent
bb00904fc8
commit
3faeb7fa79
|
@ -2997,7 +2997,7 @@ dependencies = [
|
|||
"solana-core 0.21.0",
|
||||
"solana-logger 0.21.0",
|
||||
"solana-metrics 0.21.0",
|
||||
"solana-netutil 0.21.0",
|
||||
"solana-net-utils 0.21.0",
|
||||
"solana-sdk 0.21.0",
|
||||
]
|
||||
|
||||
|
@ -3043,7 +3043,7 @@ dependencies = [
|
|||
"solana-genesis 0.21.0",
|
||||
"solana-logger 0.21.0",
|
||||
"solana-metrics 0.21.0",
|
||||
"solana-netutil 0.21.0",
|
||||
"solana-net-utils 0.21.0",
|
||||
"solana-runtime 0.21.0",
|
||||
"solana-sdk 0.21.0",
|
||||
"untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3057,7 +3057,7 @@ dependencies = [
|
|||
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-core 0.21.0",
|
||||
"solana-logger 0.21.0",
|
||||
"solana-netutil 0.21.0",
|
||||
"solana-net-utils 0.21.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3084,7 +3084,7 @@ dependencies = [
|
|||
"solana-metrics 0.21.0",
|
||||
"solana-move-loader-api 0.21.0",
|
||||
"solana-move-loader-program 0.21.0",
|
||||
"solana-netutil 0.21.0",
|
||||
"solana-net-utils 0.21.0",
|
||||
"solana-runtime 0.21.0",
|
||||
"solana-sdk 0.21.0",
|
||||
]
|
||||
|
@ -3214,7 +3214,7 @@ dependencies = [
|
|||
"solana-core 0.21.0",
|
||||
"solana-drone 0.21.0",
|
||||
"solana-logger 0.21.0",
|
||||
"solana-netutil 0.21.0",
|
||||
"solana-net-utils 0.21.0",
|
||||
"solana-runtime 0.21.0",
|
||||
"solana-sdk 0.21.0",
|
||||
"solana-stake-api 0.21.0",
|
||||
|
@ -3241,7 +3241,7 @@ dependencies = [
|
|||
"serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-logger 0.21.0",
|
||||
"solana-netutil 0.21.0",
|
||||
"solana-net-utils 0.21.0",
|
||||
"solana-sdk 0.21.0",
|
||||
]
|
||||
|
||||
|
@ -3330,7 +3330,7 @@ dependencies = [
|
|||
"solana-measure 0.21.0",
|
||||
"solana-merkle-tree 0.21.0",
|
||||
"solana-metrics 0.21.0",
|
||||
"solana-netutil 0.21.0",
|
||||
"solana-net-utils 0.21.0",
|
||||
"solana-perf 0.21.0",
|
||||
"solana-rayon-threadlimit 0.21.0",
|
||||
"solana-reed-solomon-erasure 4.0.1-3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3487,7 +3487,7 @@ dependencies = [
|
|||
"solana-client 0.21.0",
|
||||
"solana-core 0.21.0",
|
||||
"solana-logger 0.21.0",
|
||||
"solana-netutil 0.21.0",
|
||||
"solana-net-utils 0.21.0",
|
||||
"solana-sdk 0.21.0",
|
||||
]
|
||||
|
||||
|
@ -3725,7 +3725,7 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-netutil"
|
||||
name = "solana-net-utils"
|
||||
version = "0.21.0"
|
||||
dependencies = [
|
||||
"bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -3986,7 +3986,7 @@ dependencies = [
|
|||
"solana-ledger 0.21.0",
|
||||
"solana-logger 0.21.0",
|
||||
"solana-metrics 0.21.0",
|
||||
"solana-netutil 0.21.0",
|
||||
"solana-net-utils 0.21.0",
|
||||
"solana-perf 0.21.0",
|
||||
"solana-runtime 0.21.0",
|
||||
"solana-sdk 0.21.0",
|
||||
|
|
|
@ -51,7 +51,7 @@ members = [
|
|||
"sdk",
|
||||
"sdk-c",
|
||||
"upload-perf",
|
||||
"netutil",
|
||||
"net-utils",
|
||||
"fixed-buf",
|
||||
"vote-signer",
|
||||
"cli",
|
||||
|
|
|
@ -14,6 +14,6 @@ solana-clap-utils = { path = "../clap-utils", version = "0.21.0" }
|
|||
solana-core = { path = "../core", version = "0.21.0" }
|
||||
solana-logger = { path = "../logger", version = "0.21.0" }
|
||||
solana-metrics = { path = "../metrics", version = "0.21.0" }
|
||||
solana-netutil = { path = "../netutil", version = "0.21.0" }
|
||||
solana-net-utils = { path = "../net-utils", version = "0.21.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.21.0" }
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ fn main() {
|
|||
.value_name("HOST:PORT")
|
||||
.takes_value(true)
|
||||
.required(true)
|
||||
.validator(solana_netutil::is_host_port)
|
||||
.validator(solana_net_utils::is_host_port)
|
||||
.help("Rendezvous with the cluster at this entry point"),
|
||||
)
|
||||
.arg(
|
||||
|
@ -80,14 +80,15 @@ fn main() {
|
|||
let entrypoint_addr = matches
|
||||
.value_of("entrypoint")
|
||||
.map(|entrypoint| {
|
||||
solana_netutil::parse_host_port(entrypoint).expect("failed to parse entrypoint address")
|
||||
solana_net_utils::parse_host_port(entrypoint)
|
||||
.expect("failed to parse entrypoint address")
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let gossip_addr = {
|
||||
let ip = solana_netutil::get_public_ip_addr(&entrypoint_addr).unwrap();
|
||||
let ip = solana_net_utils::get_public_ip_addr(&entrypoint_addr).unwrap();
|
||||
let mut addr = SocketAddr::new(ip, 0);
|
||||
addr.set_ip(solana_netutil::get_public_ip_addr(&entrypoint_addr).unwrap());
|
||||
addr.set_ip(solana_net_utils::get_public_ip_addr(&entrypoint_addr).unwrap());
|
||||
addr
|
||||
};
|
||||
let node =
|
||||
|
|
|
@ -32,7 +32,7 @@ solana-exchange-api = { path = "../programs/exchange_api", version = "0.21.0" }
|
|||
solana-exchange-program = { path = "../programs/exchange_program", version = "0.21.0" }
|
||||
solana-logger = { path = "../logger", version = "0.21.0" }
|
||||
solana-metrics = { path = "../metrics", version = "0.21.0" }
|
||||
solana-netutil = { path = "../netutil", version = "0.21.0" }
|
||||
solana-net-utils = { path = "../net-utils", version = "0.21.0" }
|
||||
solana-runtime = { path = "../runtime", version = "0.21.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.21.0" }
|
||||
untrusted = "0.7.0"
|
||||
|
|
|
@ -166,13 +166,15 @@ pub fn build_args<'a, 'b>() -> App<'a, 'b> {
|
|||
pub fn extract_args<'a>(matches: &ArgMatches<'a>) -> Config {
|
||||
let mut args = Config::default();
|
||||
|
||||
args.entrypoint_addr = solana_netutil::parse_host_port(matches.value_of("entrypoint").unwrap())
|
||||
.unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse entrypoint address: {}", e);
|
||||
exit(1)
|
||||
});
|
||||
args.entrypoint_addr = solana_net_utils::parse_host_port(
|
||||
matches.value_of("entrypoint").unwrap(),
|
||||
)
|
||||
.unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse entrypoint address: {}", e);
|
||||
exit(1)
|
||||
});
|
||||
|
||||
args.drone_addr = solana_netutil::parse_host_port(matches.value_of("drone").unwrap())
|
||||
args.drone_addr = solana_net_utils::parse_host_port(matches.value_of("drone").unwrap())
|
||||
.unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse drone address: {}", e);
|
||||
exit(1)
|
||||
|
|
|
@ -11,4 +11,4 @@ homepage = "https://solana.com/"
|
|||
clap = "2.33.0"
|
||||
solana-core = { path = "../core", version = "0.21.0" }
|
||||
solana-logger = { path = "../logger", version = "0.21.0" }
|
||||
solana-netutil = { path = "../netutil", version = "0.21.0" }
|
||||
solana-net-utils = { path = "../net-utils", version = "0.21.0" }
|
||||
|
|
|
@ -77,7 +77,7 @@ fn main() -> Result<()> {
|
|||
let mut read_threads = Vec::new();
|
||||
let recycler = PacketsRecycler::default();
|
||||
for _ in 0..num_sockets {
|
||||
let read = solana_netutil::bind_to(port, false).unwrap();
|
||||
let read = solana_net_utils::bind_to(port, false).unwrap();
|
||||
read.set_read_timeout(Some(Duration::new(1, 0))).unwrap();
|
||||
|
||||
addr = read.local_addr().unwrap();
|
||||
|
|
|
@ -24,7 +24,7 @@ solana-librapay-api = { path = "../programs/librapay_api", version = "0.21.0", o
|
|||
solana-logger = { path = "../logger", version = "0.21.0" }
|
||||
solana-metrics = { path = "../metrics", version = "0.21.0" }
|
||||
solana-measure = { path = "../measure", version = "0.21.0" }
|
||||
solana-netutil = { path = "../netutil", version = "0.21.0" }
|
||||
solana-net-utils = { path = "../net-utils", version = "0.21.0" }
|
||||
solana-runtime = { path = "../runtime", version = "0.21.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.21.0" }
|
||||
solana-move-loader-program = { path = "../programs/move_loader_program", version = "0.21.0", optional = true }
|
||||
|
|
|
@ -174,14 +174,14 @@ pub fn extract_args<'a>(matches: &ArgMatches<'a>) -> Config {
|
|||
let mut args = Config::default();
|
||||
|
||||
if let Some(addr) = matches.value_of("entrypoint") {
|
||||
args.entrypoint_addr = solana_netutil::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
args.entrypoint_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse entrypoint address: {}", e);
|
||||
exit(1)
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(addr) = matches.value_of("drone") {
|
||||
args.drone_addr = solana_netutil::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
args.drone_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse drone address: {}", e);
|
||||
exit(1)
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ declare print_free_tree=(
|
|||
'core/src'
|
||||
'drone/src'
|
||||
'metrics/src'
|
||||
'netutil/src'
|
||||
'net-utils/src'
|
||||
'runtime/src'
|
||||
'sdk/bpf/rust/rust-utils'
|
||||
'sdk/src'
|
||||
|
|
|
@ -32,7 +32,7 @@ solana-client = { path = "../client", version = "0.21.0" }
|
|||
solana-config-api = { path = "../programs/config_api", version = "0.21.0" }
|
||||
solana-drone = { path = "../drone", version = "0.21.0" }
|
||||
solana-logger = { path = "../logger", version = "0.21.0" }
|
||||
solana-netutil = { path = "../netutil", version = "0.21.0" }
|
||||
solana-net-utils = { path = "../net-utils", version = "0.21.0" }
|
||||
solana-runtime = { path = "../runtime", version = "0.21.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.21.0" }
|
||||
solana-stake-api = { path = "../programs/stake_api", version = "0.21.0" }
|
||||
|
|
|
@ -331,7 +331,7 @@ pub fn parse_command(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, Box<dyn
|
|||
})?;
|
||||
|
||||
let drone_host = if let Some(drone_host) = matches.value_of("drone_host") {
|
||||
Some(solana_netutil::parse_host(drone_host).or_else(|err| {
|
||||
Some(solana_net_utils::parse_host(drone_host).or_else(|err| {
|
||||
Err(CliError::BadParameter(format!(
|
||||
"Invalid drone host: {:?}",
|
||||
err
|
||||
|
@ -1058,7 +1058,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||
.host()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
solana_netutil::parse_host(&drone_host).unwrap_or_else(|err| {
|
||||
solana_net_utils::parse_host(&drone_host).unwrap_or_else(|err| {
|
||||
panic!("Unable to resolve {}: {}", drone_host, err);
|
||||
})
|
||||
}),
|
||||
|
|
|
@ -19,7 +19,7 @@ reqwest = { version = "0.9.22", default-features = false, features = ["rustls-tl
|
|||
serde = "1.0.102"
|
||||
serde_derive = "1.0.102"
|
||||
serde_json = "1.0.41"
|
||||
solana-netutil = { path = "../netutil", version = "0.21.0" }
|
||||
solana-net-utils = { path = "../net-utils", version = "0.21.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.21.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -594,7 +594,7 @@ impl AsyncClient for ThinClient {
|
|||
}
|
||||
|
||||
pub fn create_client((rpc, tpu): (SocketAddr, SocketAddr), range: (u16, u16)) -> ThinClient {
|
||||
let (_, transactions_socket) = solana_netutil::bind_in_range(range).unwrap();
|
||||
let (_, transactions_socket) = solana_net_utils::bind_in_range(range).unwrap();
|
||||
ThinClient::new(rpc, tpu, transactions_socket)
|
||||
}
|
||||
|
||||
|
@ -603,7 +603,7 @@ pub fn create_client_with_timeout(
|
|||
range: (u16, u16),
|
||||
timeout: Duration,
|
||||
) -> ThinClient {
|
||||
let (_, transactions_socket) = solana_netutil::bind_in_range(range).unwrap();
|
||||
let (_, transactions_socket) = solana_net_utils::bind_in_range(range).unwrap();
|
||||
ThinClient::new_socket_with_timeout(rpc, tpu, transactions_socket, timeout)
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ solana-logger = { path = "../logger", version = "0.21.0" }
|
|||
solana-merkle-tree = { path = "../merkle-tree", version = "0.21.0" }
|
||||
solana-metrics = { path = "../metrics", version = "0.21.0" }
|
||||
solana-measure = { path = "../measure", version = "0.21.0" }
|
||||
solana-netutil = { path = "../netutil", version = "0.21.0" }
|
||||
solana-net-utils = { path = "../net-utils", version = "0.21.0" }
|
||||
solana-perf = { path = "../perf", version = "0.21.0" }
|
||||
solana-runtime = { path = "../runtime", version = "0.21.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.21.0" }
|
||||
|
|
|
@ -23,7 +23,7 @@ use solana_client::{rpc_client::RpcClient, rpc_request::RpcRequest, thin_client:
|
|||
use solana_ledger::{
|
||||
blocktree::Blocktree, leader_schedule_cache::LeaderScheduleCache, shred::Shred,
|
||||
};
|
||||
use solana_netutil::bind_in_range;
|
||||
use solana_net_utils::bind_in_range;
|
||||
use solana_perf::recycler::Recycler;
|
||||
use solana_sdk::{
|
||||
account_utils::State,
|
||||
|
|
|
@ -32,7 +32,7 @@ use itertools::Itertools;
|
|||
use rand::{thread_rng, Rng};
|
||||
use solana_ledger::{bank_forks::BankForks, blocktree::Blocktree, staking_utils};
|
||||
use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_error};
|
||||
use solana_netutil::{
|
||||
use solana_net_utils::{
|
||||
bind_common, bind_common_in_range, bind_in_range, find_available_port_in_range,
|
||||
multi_bind_in_range, PortRange,
|
||||
};
|
||||
|
|
|
@ -76,7 +76,7 @@ pub fn discover(
|
|||
info!("Gossip entry point: {:?}", entry_point);
|
||||
info!("Spy node id: {:?}", id);
|
||||
|
||||
let _ip_echo_server = ip_echo.map(solana_netutil::ip_echo_server);
|
||||
let _ip_echo_server = ip_echo.map(solana_net_utils::ip_echo_server);
|
||||
|
||||
let (met_criteria, secs, tvu_peers, archivers) = spy(
|
||||
spy_ref.clone(),
|
||||
|
@ -143,7 +143,7 @@ pub fn get_multi_client(nodes: &[ContactInfo]) -> (ThinClient, usize) {
|
|||
.collect();
|
||||
let rpc_addrs: Vec<_> = addrs.iter().map(|addr| addr.0).collect();
|
||||
let tpu_addrs: Vec<_> = addrs.iter().map(|addr| addr.1).collect();
|
||||
let (_, transactions_socket) = solana_netutil::bind_in_range(VALIDATOR_PORT_RANGE).unwrap();
|
||||
let (_, transactions_socket) = solana_net_utils::bind_in_range(VALIDATOR_PORT_RANGE).unwrap();
|
||||
let num_nodes = tpu_addrs.len();
|
||||
(
|
||||
ThinClient::new_from_addrs(rpc_addrs, tpu_addrs, transactions_socket),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! The `local_vote_signer_service` can be started locally to sign validator votes
|
||||
|
||||
use crate::service::Service;
|
||||
use solana_netutil::PortRange;
|
||||
use solana_net_utils::PortRange;
|
||||
use solana_vote_signer::rpc::VoteSignerRpcService;
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
@ -25,7 +25,7 @@ impl Service for LocalVoteSignerService {
|
|||
impl LocalVoteSignerService {
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new(port_range: PortRange) -> (Self, SocketAddr) {
|
||||
let addr = match solana_netutil::find_available_port_in_range(port_range) {
|
||||
let addr = match solana_net_utils::find_available_port_in_range(port_range) {
|
||||
Ok(port) => SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), port),
|
||||
Err(_e) => panic!("Failed to find an available port for local vote signer service"),
|
||||
};
|
||||
|
|
|
@ -278,7 +278,7 @@ mod tests {
|
|||
use crate::packet::{self, Meta, Packet, Packets};
|
||||
use solana_ledger::blocktree::create_new_tmp_ledger;
|
||||
use solana_ledger::blocktree_processor::{process_blocktree, ProcessOptions};
|
||||
use solana_netutil::find_available_port_in_range;
|
||||
use solana_net_utils::find_available_port_in_range;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -202,7 +202,7 @@ mod tests {
|
|||
)));
|
||||
let rpc_addr = SocketAddr::new(
|
||||
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
|
||||
solana_netutil::find_available_port_in_range((10000, 65535)).unwrap(),
|
||||
solana_net_utils::find_available_port_in_range((10000, 65535)).unwrap(),
|
||||
);
|
||||
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank.slot(), bank)));
|
||||
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::default()));
|
||||
|
|
|
@ -106,7 +106,7 @@ pub struct Validator {
|
|||
poh_service: PohService,
|
||||
tpu: Tpu,
|
||||
tvu: Tvu,
|
||||
ip_echo_server: solana_netutil::IpEchoServer,
|
||||
ip_echo_server: solana_net_utils::IpEchoServer,
|
||||
}
|
||||
|
||||
impl Validator {
|
||||
|
@ -272,7 +272,7 @@ impl Validator {
|
|||
"New blob signal for the TVU should be the same as the clear bank signal."
|
||||
);
|
||||
|
||||
let ip_echo_server = solana_netutil::ip_echo_server(node.sockets.ip_echo.unwrap());
|
||||
let ip_echo_server = solana_net_utils::ip_echo_server(node.sockets.ip_echo.unwrap());
|
||||
|
||||
let gossip_service = GossipService::new(
|
||||
&cluster_info,
|
||||
|
|
|
@ -14,7 +14,7 @@ solana-clap-utils = { path = "../clap-utils", version = "0.21.0" }
|
|||
solana-core = { path = "../core", version = "0.21.0" }
|
||||
solana-client = { path = "../client", version = "0.21.0" }
|
||||
solana-logger = { path = "../logger", version = "0.21.0" }
|
||||
solana-netutil = { path = "../netutil", version = "0.21.0" }
|
||||
solana-net-utils = { path = "../net-utils", version = "0.21.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.21.0" }
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||
.value_name("HOST:PORT")
|
||||
.takes_value(true)
|
||||
.default_value(&entrypoint_string)
|
||||
.validator(solana_netutil::is_host_port)
|
||||
.validator(solana_net_utils::is_host_port)
|
||||
.global(true)
|
||||
.help("Rendezvous with the cluster at this entry point"),
|
||||
)
|
||||
|
@ -113,7 +113,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||
.get_matches();
|
||||
|
||||
if let Some(addr) = matches.value_of("entrypoint") {
|
||||
entrypoint_addr = solana_netutil::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
entrypoint_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse entrypoint address: {}", e);
|
||||
exit(1);
|
||||
});
|
||||
|
@ -136,7 +136,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||
.map(|pubkey_str| pubkey_str.parse::<Pubkey>().unwrap());
|
||||
|
||||
let gossip_addr = SocketAddr::new(
|
||||
solana_netutil::get_public_ip_addr(&entrypoint_addr).unwrap_or_else(|err| {
|
||||
solana_net_utils::get_public_ip_addr(&entrypoint_addr).unwrap_or_else(|err| {
|
||||
eprintln!("failed to contact {}: {}", entrypoint_addr, err);
|
||||
exit(1);
|
||||
}),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "solana-netutil"
|
||||
name = "solana-net-utils"
|
||||
version = "0.21.0"
|
||||
description = "Solana Network Utilities"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||
|
@ -23,7 +23,7 @@ tokio = "0.1"
|
|||
tokio-codec = "0.1"
|
||||
|
||||
[lib]
|
||||
name = "solana_netutil"
|
||||
name = "solana_net_utils"
|
||||
|
||||
[[bin]]
|
||||
name = "solana-ip-address"
|
|
@ -13,10 +13,10 @@ fn main() {
|
|||
.get_matches();
|
||||
|
||||
let host_port = matches.value_of("host_port").unwrap();
|
||||
let addr = solana_netutil::parse_host_port(host_port)
|
||||
let addr = solana_net_utils::parse_host_port(host_port)
|
||||
.unwrap_or_else(|_| panic!("failed to parse {}", host_port));
|
||||
|
||||
match solana_netutil::get_public_ip_addr(&addr) {
|
||||
match solana_net_utils::get_public_ip_addr(&addr) {
|
||||
Ok(ip) => println!("{}", ip),
|
||||
Err(err) => {
|
||||
eprintln!("{}: {}", addr, err);
|
|
@ -19,7 +19,7 @@ fn main() {
|
|||
.unwrap_or_else(|_| panic!("Unable to parse {}", port));
|
||||
let bind_addr = SocketAddr::from(([0, 0, 0, 0], port));
|
||||
let tcp_listener = TcpListener::bind(bind_addr).expect("unable to start tcp listener");
|
||||
let _runtime = solana_netutil::ip_echo_server(tcp_listener);
|
||||
let _runtime = solana_net_utils::ip_echo_server(tcp_listener);
|
||||
loop {
|
||||
std::thread::park();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
//! The `netutil` module assists with networking
|
||||
//! The `net_utils` module assists with networking
|
||||
use log::*;
|
||||
use rand::{thread_rng, Rng};
|
||||
use socket2::{Domain, SockAddr, Socket, Type};
|
|
@ -25,7 +25,7 @@ solana-ledger = { path = "../ledger", version = "0.21.0" }
|
|||
solana-logger = { path = "../logger", version = "0.21.0" }
|
||||
solana-perf = { path = "../perf", version = "0.21.0" }
|
||||
solana-metrics = { path = "../metrics", version = "0.21.0" }
|
||||
solana-netutil = { path = "../netutil", version = "0.21.0" }
|
||||
solana-net-utils = { path = "../net-utils", version = "0.21.0" }
|
||||
solana-runtime = { path = "../runtime", version = "0.21.0" }
|
||||
solana-sdk = { path = "../sdk", version = "0.21.0" }
|
||||
solana-vote-api = { path = "../programs/vote_api", version = "0.21.0" }
|
||||
|
|
|
@ -36,7 +36,7 @@ fn port_validator(port: String) -> Result<(), String> {
|
|||
}
|
||||
|
||||
fn port_range_validator(port_range: String) -> Result<(), String> {
|
||||
if solana_netutil::parse_port_range(&port_range).is_some() {
|
||||
if solana_net_utils::parse_port_range(&port_range).is_some() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err("Invalid port range".to_string())
|
||||
|
@ -305,7 +305,7 @@ pub fn main() {
|
|||
.long("entrypoint")
|
||||
.value_name("HOST:PORT")
|
||||
.takes_value(true)
|
||||
.validator(solana_netutil::is_host_port)
|
||||
.validator(solana_net_utils::is_host_port)
|
||||
.help("Rendezvous with the cluster at this entry point"),
|
||||
)
|
||||
.arg(
|
||||
|
@ -360,7 +360,7 @@ pub fn main() {
|
|||
.long("rpc-drone-address")
|
||||
.value_name("HOST:PORT")
|
||||
.takes_value(true)
|
||||
.validator(solana_netutil::is_host_port)
|
||||
.validator(solana_net_utils::is_host_port)
|
||||
.help("Enable the JSON RPC 'requestAirdrop' API with this drone address."),
|
||||
)
|
||||
.arg(
|
||||
|
@ -369,7 +369,7 @@ pub fn main() {
|
|||
.value_name("HOST:PORT")
|
||||
.takes_value(true)
|
||||
.hidden(true) // Don't document this argument to discourage its use
|
||||
.validator(solana_netutil::is_host_port)
|
||||
.validator(solana_net_utils::is_host_port)
|
||||
.help("Rendezvous with the vote signer at this RPC end point"),
|
||||
)
|
||||
.arg(
|
||||
|
@ -486,11 +486,11 @@ pub fn main() {
|
|||
validator_config.rpc_config.enable_validator_exit = matches.is_present("enable_rpc_exit");
|
||||
|
||||
validator_config.rpc_config.drone_addr = matches.value_of("rpc_drone_addr").map(|address| {
|
||||
solana_netutil::parse_host_port(address).expect("failed to parse drone address")
|
||||
solana_net_utils::parse_host_port(address).expect("failed to parse drone address")
|
||||
});
|
||||
|
||||
let dynamic_port_range =
|
||||
solana_netutil::parse_port_range(matches.value_of("dynamic_port_range").unwrap())
|
||||
solana_net_utils::parse_port_range(matches.value_of("dynamic_port_range").unwrap())
|
||||
.expect("invalid dynamic_port_range");
|
||||
|
||||
if let Some(account_paths) = matches.value_of("account_paths") {
|
||||
|
@ -586,25 +586,26 @@ pub fn main() {
|
|||
enable_recycler_warming();
|
||||
}
|
||||
|
||||
let mut gossip_addr = solana_netutil::parse_port_or_addr(
|
||||
let mut gossip_addr = solana_net_utils::parse_port_or_addr(
|
||||
matches.value_of("gossip_port"),
|
||||
socketaddr!(
|
||||
[127, 0, 0, 1],
|
||||
solana_netutil::find_available_port_in_range(dynamic_port_range)
|
||||
solana_net_utils::find_available_port_in_range(dynamic_port_range)
|
||||
.expect("unable to find an available gossip port")
|
||||
),
|
||||
);
|
||||
|
||||
let cluster_entrypoint = entrypoint.map(|entrypoint| {
|
||||
let entrypoint_addr = solana_netutil::parse_host_port(entrypoint)
|
||||
let entrypoint_addr = solana_net_utils::parse_host_port(entrypoint)
|
||||
.expect("failed to parse entrypoint address");
|
||||
let ip_addr = solana_netutil::get_public_ip_addr(&entrypoint_addr).unwrap_or_else(|err| {
|
||||
error!(
|
||||
"Failed to contact cluster entrypoint {} ({}): {}",
|
||||
entrypoint, entrypoint_addr, err
|
||||
);
|
||||
exit(1);
|
||||
});
|
||||
let ip_addr =
|
||||
solana_net_utils::get_public_ip_addr(&entrypoint_addr).unwrap_or_else(|err| {
|
||||
error!(
|
||||
"Failed to contact cluster entrypoint {} ({}): {}",
|
||||
entrypoint, entrypoint_addr, err
|
||||
);
|
||||
exit(1);
|
||||
});
|
||||
gossip_addr.set_ip(ip_addr);
|
||||
|
||||
ContactInfo::new_gossip_entry_point(&entrypoint_addr)
|
||||
|
@ -646,7 +647,7 @@ pub fn main() {
|
|||
tcp_listeners.push((node.info.gossip.port(), ip_echo));
|
||||
}
|
||||
|
||||
solana_netutil::verify_reachable_ports(
|
||||
solana_net_utils::verify_reachable_ports(
|
||||
&cluster_entrypoint.gossip,
|
||||
tcp_listeners,
|
||||
&udp_sockets,
|
||||
|
|
Loading…
Reference in New Issue