Use Ipv4Addr::{LOCALHOST, UNSPECIFIED} constants (#29813)
This commit is contained in:
parent
f1b2e49b03
commit
dd92f225bb
|
@ -26,7 +26,7 @@ use {
|
|||
solana_transaction_status::parse_token::spl_token_instruction,
|
||||
std::{
|
||||
cmp::min,
|
||||
net::SocketAddr,
|
||||
net::{Ipv4Addr, SocketAddr},
|
||||
process::exit,
|
||||
sync::{
|
||||
atomic::{AtomicU64, Ordering},
|
||||
|
@ -618,14 +618,14 @@ fn main() {
|
|||
let skip_gossip = !matches.is_present("check_gossip");
|
||||
|
||||
let port = if skip_gossip { DEFAULT_RPC_PORT } else { 8001 };
|
||||
let mut entrypoint_addr = SocketAddr::from(([127, 0, 0, 1], port));
|
||||
let mut entrypoint_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, port));
|
||||
if let Some(addr) = matches.value_of("entrypoint") {
|
||||
entrypoint_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse entrypoint address: {e}");
|
||||
exit(1)
|
||||
});
|
||||
}
|
||||
let mut faucet_addr = SocketAddr::from(([127, 0, 0, 1], FAUCET_PORT));
|
||||
let mut faucet_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, FAUCET_PORT));
|
||||
if let Some(addr) = matches.value_of("faucet_addr") {
|
||||
faucet_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse entrypoint address: {e}");
|
||||
|
@ -730,7 +730,7 @@ pub mod test {
|
|||
..ClusterConfig::default()
|
||||
};
|
||||
|
||||
let faucet_addr = SocketAddr::from(([127, 0, 0, 1], 9900));
|
||||
let faucet_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 9900));
|
||||
let cluster = LocalCluster::new(&mut config, SocketAddrSpace::Unspecified);
|
||||
let iterations = 10;
|
||||
let maybe_space = None;
|
||||
|
|
|
@ -445,7 +445,7 @@ pub async fn start_tcp_server(
|
|||
t.as_ref()
|
||||
.peer_addr()
|
||||
.map(|x| x.ip())
|
||||
.unwrap_or_else(|_| Ipv4Addr::new(0, 0, 0, 0).into())
|
||||
.unwrap_or_else(|_| Ipv4Addr::UNSPECIFIED.into())
|
||||
})
|
||||
// serve is generated by the service attribute. It takes as input any type implementing
|
||||
// the generated Banks trait.
|
||||
|
|
|
@ -86,7 +86,7 @@ fn main() -> Result<()> {
|
|||
let num_producers: u64 = matches.value_of_t("num_producers").unwrap_or(4);
|
||||
|
||||
let port = 0;
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let mut addr = SocketAddr::new(ip_addr, 0);
|
||||
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
|
|
|
@ -11,7 +11,11 @@ use {
|
|||
solana_tpu_client::tpu_connection_cache::{
|
||||
DEFAULT_TPU_CONNECTION_POOL_SIZE, DEFAULT_TPU_USE_QUIC,
|
||||
},
|
||||
std::{net::SocketAddr, process::exit, time::Duration},
|
||||
std::{
|
||||
net::{Ipv4Addr, SocketAddr},
|
||||
process::exit,
|
||||
time::Duration,
|
||||
},
|
||||
};
|
||||
|
||||
const NUM_LAMPORTS_PER_ACCOUNT_DEFAULT: u64 = solana_sdk::native_token::LAMPORTS_PER_SOL;
|
||||
|
@ -71,7 +75,7 @@ pub struct Config {
|
|||
impl Default for Config {
|
||||
fn default() -> Config {
|
||||
Config {
|
||||
entrypoint_addr: SocketAddr::from(([127, 0, 0, 1], 8001)),
|
||||
entrypoint_addr: SocketAddr::from((Ipv4Addr::LOCALHOST, 8001)),
|
||||
json_rpc_url: ConfigInput::default().json_rpc_url,
|
||||
websocket_url: ConfigInput::default().websocket_url,
|
||||
id: Keypair::new(),
|
||||
|
|
|
@ -55,7 +55,7 @@ static NEXT_RPC_PUBSUB_PORT: AtomicU16 = AtomicU16::new(rpc_port::DEFAULT_RPC_PU
|
|||
|
||||
fn pubsub_addr() -> SocketAddr {
|
||||
SocketAddr::new(
|
||||
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
|
||||
IpAddr::V4(Ipv4Addr::UNSPECIFIED),
|
||||
NEXT_RPC_PUBSUB_PORT.fetch_add(1, Ordering::Relaxed),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -372,7 +372,7 @@ impl ConnectionCache {
|
|||
impl Default for ConnectionCache {
|
||||
fn default() -> Self {
|
||||
let (cert, priv_key) =
|
||||
new_self_signed_tls_certificate(&Keypair::new(), IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))
|
||||
new_self_signed_tls_certificate(&Keypair::new(), IpAddr::V4(Ipv4Addr::UNSPECIFIED))
|
||||
.expect("Failed to initialize QUIC client certificates");
|
||||
Self {
|
||||
map: RwLock::new(IndexMap::with_capacity(MAX_CONNECTIONS)),
|
||||
|
@ -380,7 +380,7 @@ impl Default for ConnectionCache {
|
|||
last_stats: AtomicInterval::default(),
|
||||
connection_pool_size: DEFAULT_TPU_CONNECTION_POOL_SIZE,
|
||||
tpu_udp_socket: Arc::new(
|
||||
solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))
|
||||
solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::UNSPECIFIED))
|
||||
.expect("Unable to bind to UDP socket"),
|
||||
),
|
||||
client_certificate: Arc::new(QuicClientCertificate {
|
||||
|
@ -627,7 +627,7 @@ mod tests {
|
|||
fn test_overflow_address() {
|
||||
let port = u16::MAX - QUIC_PORT_OFFSET + 1;
|
||||
assert!(port.checked_add(QUIC_PORT_OFFSET).is_none());
|
||||
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), port);
|
||||
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port);
|
||||
let connection_cache = ConnectionCache::new(1);
|
||||
|
||||
let conn = connection_cache.get_connection(&addr);
|
||||
|
@ -674,13 +674,13 @@ mod tests {
|
|||
|
||||
// server port 1:
|
||||
let port1 = 9001;
|
||||
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), port1);
|
||||
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port1);
|
||||
let conn = connection_cache.get_connection(&addr);
|
||||
assert_eq!(conn.tpu_addr().port(), port1 + QUIC_PORT_OFFSET);
|
||||
|
||||
// server port 2:
|
||||
let port2 = 9002;
|
||||
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), port2);
|
||||
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port2);
|
||||
let conn = connection_cache.get_connection(&addr);
|
||||
assert_eq!(conn.tpu_addr().port(), port2 + QUIC_PORT_OFFSET);
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ mod test {
|
|||
let nonce = 9;
|
||||
let mut packet = repair_response_packet_from_bytes(
|
||||
shred.into_payload(),
|
||||
&SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080),
|
||||
&SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8080),
|
||||
nonce,
|
||||
)
|
||||
.unwrap();
|
||||
|
|
|
@ -1257,7 +1257,7 @@ mod tests {
|
|||
timing::timestamp,
|
||||
},
|
||||
solana_streamer::socket::SocketAddrSpace,
|
||||
std::io::Cursor,
|
||||
std::{io::Cursor, net::Ipv4Addr},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
@ -1740,18 +1740,18 @@ mod tests {
|
|||
);
|
||||
assert_matches!(rv, Err(Error::ClusterInfo(ClusterInfoError::NoPeers)));
|
||||
|
||||
let serve_repair_addr = socketaddr!([127, 0, 0, 1], 1243);
|
||||
let serve_repair_addr = socketaddr!(Ipv4Addr::LOCALHOST, 1243);
|
||||
let nxt = ContactInfo {
|
||||
id: solana_sdk::pubkey::new_rand(),
|
||||
gossip: socketaddr!([127, 0, 0, 1], 1234),
|
||||
tvu: socketaddr!([127, 0, 0, 1], 1235),
|
||||
tvu_forwards: socketaddr!([127, 0, 0, 1], 1236),
|
||||
repair: socketaddr!([127, 0, 0, 1], 1237),
|
||||
tpu: socketaddr!([127, 0, 0, 1], 1238),
|
||||
tpu_forwards: socketaddr!([127, 0, 0, 1], 1239),
|
||||
tpu_vote: socketaddr!([127, 0, 0, 1], 1240),
|
||||
rpc: socketaddr!([127, 0, 0, 1], 1241),
|
||||
rpc_pubsub: socketaddr!([127, 0, 0, 1], 1242),
|
||||
gossip: socketaddr!(Ipv4Addr::LOCALHOST, 1234),
|
||||
tvu: socketaddr!(Ipv4Addr::LOCALHOST, 1235),
|
||||
tvu_forwards: socketaddr!(Ipv4Addr::LOCALHOST, 1236),
|
||||
repair: socketaddr!(Ipv4Addr::LOCALHOST, 1237),
|
||||
tpu: socketaddr!(Ipv4Addr::LOCALHOST, 1238),
|
||||
tpu_forwards: socketaddr!(Ipv4Addr::LOCALHOST, 1239),
|
||||
tpu_vote: socketaddr!(Ipv4Addr::LOCALHOST, 1240),
|
||||
rpc: socketaddr!(Ipv4Addr::LOCALHOST, 1241),
|
||||
rpc_pubsub: socketaddr!(Ipv4Addr::LOCALHOST, 1242),
|
||||
serve_repair: serve_repair_addr,
|
||||
wallclock: 0,
|
||||
shred_version: 0,
|
||||
|
@ -1774,15 +1774,15 @@ mod tests {
|
|||
let serve_repair_addr2 = socketaddr!([127, 0, 0, 2], 1243);
|
||||
let nxt = ContactInfo {
|
||||
id: solana_sdk::pubkey::new_rand(),
|
||||
gossip: socketaddr!([127, 0, 0, 1], 1234),
|
||||
tvu: socketaddr!([127, 0, 0, 1], 1235),
|
||||
tvu_forwards: socketaddr!([127, 0, 0, 1], 1236),
|
||||
repair: socketaddr!([127, 0, 0, 1], 1237),
|
||||
tpu: socketaddr!([127, 0, 0, 1], 1238),
|
||||
tpu_forwards: socketaddr!([127, 0, 0, 1], 1239),
|
||||
tpu_vote: socketaddr!([127, 0, 0, 1], 1240),
|
||||
rpc: socketaddr!([127, 0, 0, 1], 1241),
|
||||
rpc_pubsub: socketaddr!([127, 0, 0, 1], 1242),
|
||||
gossip: socketaddr!(Ipv4Addr::LOCALHOST, 1234),
|
||||
tvu: socketaddr!(Ipv4Addr::LOCALHOST, 1235),
|
||||
tvu_forwards: socketaddr!(Ipv4Addr::LOCALHOST, 1236),
|
||||
repair: socketaddr!(Ipv4Addr::LOCALHOST, 1237),
|
||||
tpu: socketaddr!(Ipv4Addr::LOCALHOST, 1238),
|
||||
tpu_forwards: socketaddr!(Ipv4Addr::LOCALHOST, 1239),
|
||||
tpu_vote: socketaddr!(Ipv4Addr::LOCALHOST, 1240),
|
||||
rpc: socketaddr!(Ipv4Addr::LOCALHOST, 1241),
|
||||
rpc_pubsub: socketaddr!(Ipv4Addr::LOCALHOST, 1242),
|
||||
serve_repair: serve_repair_addr2,
|
||||
wallclock: 0,
|
||||
shred_version: 0,
|
||||
|
|
|
@ -589,7 +589,7 @@ mod test {
|
|||
0, // version
|
||||
);
|
||||
let mut shreds = vec![shred.clone(), shred.clone(), shred];
|
||||
let _from_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
|
||||
let _from_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8080);
|
||||
let repair_meta = RepairMeta {
|
||||
_from_addr,
|
||||
nonce: 0,
|
||||
|
|
|
@ -515,7 +515,7 @@ mod tests {
|
|||
fn test_clear_caches() {
|
||||
let keypair = Keypair::new();
|
||||
let mut faucet = Faucet::new(keypair, None, None, None);
|
||||
let ip = socketaddr!([127, 0, 0, 1], 0).ip();
|
||||
let ip = socketaddr!(Ipv4Addr::LOCALHOST, 0).ip();
|
||||
assert_eq!(faucet.ip_cache.len(), 0);
|
||||
faucet.check_time_request_limit(1, ip).unwrap();
|
||||
assert_eq!(faucet.ip_cache.len(), 1);
|
||||
|
@ -589,7 +589,7 @@ mod tests {
|
|||
// Test multiple requests from loopback with different addresses succeed
|
||||
let mint = Keypair::new();
|
||||
faucet = Faucet::new(mint, None, Some(2), None);
|
||||
let ip = socketaddr!([127, 0, 0, 1], 0).ip();
|
||||
let ip = socketaddr!(Ipv4Addr::LOCALHOST, 0).ip();
|
||||
let other = Pubkey::new_unique();
|
||||
let _tx0 = faucet.build_airdrop_transaction(request, ip).unwrap(); // first request succeeds
|
||||
let request1 = FaucetRequest::GetAirdrop {
|
||||
|
|
|
@ -460,7 +460,7 @@ impl AbiExample for std::path::PathBuf {
|
|||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
impl AbiExample for SocketAddr {
|
||||
fn example() -> Self {
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0)
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2678,7 +2678,7 @@ impl ClusterInfo {
|
|||
gossip_addr: &SocketAddr,
|
||||
shred_version: u16,
|
||||
) -> (ContactInfo, UdpSocket, Option<TcpListener>) {
|
||||
let bind_ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let bind_ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let (port, (gossip_socket, ip_echo)) =
|
||||
Node::get_gossip_port(gossip_addr, VALIDATOR_PORT_RANGE, bind_ip_addr);
|
||||
let contact_info =
|
||||
|
@ -2692,7 +2692,7 @@ impl ClusterInfo {
|
|||
id: Pubkey,
|
||||
shred_version: u16,
|
||||
) -> (ContactInfo, UdpSocket, Option<TcpListener>) {
|
||||
let bind_ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let bind_ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let (_, gossip_socket) = bind_in_range(bind_ip_addr, VALIDATOR_PORT_RANGE).unwrap();
|
||||
let contact_info = Self::gossip_contact_info(id, socketaddr_any!(), shred_version);
|
||||
|
||||
|
@ -2781,13 +2781,13 @@ impl Node {
|
|||
Self::new_localhost_with_pubkey(&pubkey)
|
||||
}
|
||||
pub fn new_localhost_with_pubkey(pubkey: &Pubkey) -> Self {
|
||||
let bind_ip_addr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
|
||||
let bind_ip_addr = IpAddr::V4(Ipv4Addr::LOCALHOST);
|
||||
let port_range = (1024, 65535);
|
||||
let ((_tpu_port, tpu), (_tpu_quic_port, tpu_quic)) =
|
||||
bind_two_in_range_with_offset(bind_ip_addr, port_range, QUIC_PORT_OFFSET).unwrap();
|
||||
let (gossip_port, (gossip, ip_echo)) =
|
||||
bind_common_in_range(bind_ip_addr, port_range).unwrap();
|
||||
let gossip_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), gossip_port);
|
||||
let gossip_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), gossip_port);
|
||||
let tvu = UdpSocket::bind("127.0.0.1:0").unwrap();
|
||||
let tvu_forwards = UdpSocket::bind("127.0.0.1:0").unwrap();
|
||||
let ((_tpu_forwards_port, tpu_forwards), (_tpu_forwards_quic_port, tpu_forwards_quic)) =
|
||||
|
@ -2795,10 +2795,9 @@ impl Node {
|
|||
let tpu_vote = UdpSocket::bind("127.0.0.1:0").unwrap();
|
||||
let repair = UdpSocket::bind("127.0.0.1:0").unwrap();
|
||||
let rpc_port = find_available_port_in_range(bind_ip_addr, port_range).unwrap();
|
||||
let rpc_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), rpc_port);
|
||||
let rpc_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), rpc_port);
|
||||
let rpc_pubsub_port = find_available_port_in_range(bind_ip_addr, port_range).unwrap();
|
||||
let rpc_pubsub_addr =
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), rpc_pubsub_port);
|
||||
let rpc_pubsub_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), rpc_pubsub_port);
|
||||
|
||||
let broadcast = vec![UdpSocket::bind("0.0.0.0:0").unwrap()];
|
||||
let retransmit_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
|
@ -3149,20 +3148,20 @@ mod tests {
|
|||
let keypair = Keypair::from_base58_string("3jATNWfbii1btv6nCpToAXAJz6a4km5HsLSWiwLfNvHNQAmvksLFVAKGUz286bXb9N4ivXx8nuwkn91PFDTyoFEp");
|
||||
|
||||
let node = {
|
||||
let tpu = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8900);
|
||||
let _tpu_quic = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8901);
|
||||
let tpu = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8900);
|
||||
let _tpu_quic = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8901);
|
||||
|
||||
let gossip = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8888);
|
||||
let tvu = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8902);
|
||||
let tvu_forwards = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8903);
|
||||
let tpu_forwards = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8904);
|
||||
let gossip = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8888);
|
||||
let tvu = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8902);
|
||||
let tvu_forwards = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8903);
|
||||
let tpu_forwards = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8904);
|
||||
|
||||
let tpu_vote = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8906);
|
||||
let repair = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8907);
|
||||
let rpc = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8908);
|
||||
let rpc_pubsub = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8909);
|
||||
let tpu_vote = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8906);
|
||||
let repair = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8907);
|
||||
let rpc = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8908);
|
||||
let rpc_pubsub = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8909);
|
||||
|
||||
let serve_repair = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8910);
|
||||
let serve_repair = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8910);
|
||||
|
||||
let info = ContactInfo {
|
||||
id: keypair.pubkey(),
|
||||
|
|
|
@ -171,7 +171,7 @@ fn parse_gossip_host(matches: &ArgMatches, entrypoint_addr: Option<SocketAddr>)
|
|||
exit(1);
|
||||
})
|
||||
} else {
|
||||
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))
|
||||
IpAddr::V4(Ipv4Addr::LOCALHOST)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ fn process_spy(matches: &ArgMatches, socket_addr_space: SocketAddrSpace) -> std:
|
|||
gossip_host,
|
||||
value_t!(matches, "gossip_port", u16).unwrap_or_else(|_| {
|
||||
solana_net_utils::find_available_port_in_range(
|
||||
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
|
||||
IpAddr::V4(Ipv4Addr::UNSPECIFIED),
|
||||
(0, 1),
|
||||
)
|
||||
.expect("unable to find an available gossip port")
|
||||
|
|
|
@ -47,7 +47,7 @@ pub fn get_client_facing_addr(contact_info: &ContactInfo) -> (SocketAddr, Socket
|
|||
let (rpc, mut tpu) = contact_info.client_facing_addr();
|
||||
// QUIC certificate authentication requires the IP Address to match. ContactInfo might have
|
||||
// 0.0.0.0 as the IP instead of 127.0.0.1.
|
||||
tpu.set_ip(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
|
||||
tpu.set_ip(IpAddr::V4(Ipv4Addr::LOCALHOST));
|
||||
(rpc, tpu)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use {
|
||||
clap::{Arg, Command},
|
||||
std::net::{SocketAddr, TcpListener},
|
||||
std::net::{Ipv4Addr, SocketAddr, TcpListener},
|
||||
};
|
||||
|
||||
fn main() {
|
||||
|
@ -19,7 +19,7 @@ fn main() {
|
|||
let port = port
|
||||
.parse()
|
||||
.unwrap_or_else(|_| panic!("Unable to parse {port}"));
|
||||
let bind_addr = SocketAddr::from(([0, 0, 0, 0], port));
|
||||
let bind_addr = SocketAddr::from((Ipv4Addr::UNSPECIFIED, port));
|
||||
let tcp_listener = TcpListener::bind(bind_addr).expect("unable to start tcp listener");
|
||||
let _runtime = solana_net_utils::ip_echo_server(tcp_listener, /*shred_version=*/ None);
|
||||
loop {
|
||||
|
|
|
@ -678,9 +678,9 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_bind() {
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
assert_eq!(bind_in_range(ip_addr, (2000, 2001)).unwrap().0, 2000);
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let x = bind_to(ip_addr, 2002, true).unwrap();
|
||||
let y = bind_to(ip_addr, 2002, true).unwrap();
|
||||
assert_eq!(
|
||||
|
@ -698,7 +698,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_bind_with_any_port() {
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let x = bind_with_any_port(ip_addr).unwrap();
|
||||
let y = bind_with_any_port(ip_addr).unwrap();
|
||||
assert_ne!(
|
||||
|
@ -709,14 +709,14 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_bind_in_range_nil() {
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
bind_in_range(ip_addr, (2000, 2000)).unwrap_err();
|
||||
bind_in_range(ip_addr, (2000, 1999)).unwrap_err();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_find_available_port_in_range() {
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
assert_eq!(
|
||||
find_available_port_in_range(ip_addr, (3000, 3001)).unwrap(),
|
||||
3000
|
||||
|
@ -730,7 +730,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_bind_common_in_range() {
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let (port, _sockets) = bind_common_in_range(ip_addr, (3100, 3150)).unwrap();
|
||||
assert!((3100..3150).contains(&port));
|
||||
|
||||
|
@ -740,7 +740,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_get_public_ip_addr_none() {
|
||||
solana_logger::setup();
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let (_server_port, (server_udp_socket, server_tcp_listener)) =
|
||||
bind_common_in_range(ip_addr, (3200, 3250)).unwrap();
|
||||
|
||||
|
@ -758,7 +758,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_get_public_ip_addr_reachable() {
|
||||
solana_logger::setup();
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let (_server_port, (server_udp_socket, server_tcp_listener)) =
|
||||
bind_common_in_range(ip_addr, (3200, 3250)).unwrap();
|
||||
let (client_port, (client_udp_socket, client_tcp_listener)) =
|
||||
|
@ -782,7 +782,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_get_public_ip_addr_tcp_unreachable() {
|
||||
solana_logger::setup();
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let (_server_port, (server_udp_socket, _server_tcp_listener)) =
|
||||
bind_common_in_range(ip_addr, (3200, 3250)).unwrap();
|
||||
|
||||
|
@ -805,7 +805,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_get_public_ip_addr_udp_unreachable() {
|
||||
solana_logger::setup();
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let (_server_port, (server_udp_socket, _server_tcp_listener)) =
|
||||
bind_common_in_range(ip_addr, (3200, 3250)).unwrap();
|
||||
|
||||
|
@ -828,7 +828,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_bind_two_in_range_with_offset() {
|
||||
solana_logger::setup();
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let offset = 6;
|
||||
if let Ok(((port1, _), (port2, _))) =
|
||||
bind_two_in_range_with_offset(ip_addr, (1024, 65535), offset)
|
||||
|
|
|
@ -98,7 +98,7 @@ impl NewTpuConfig for QuicConfig {
|
|||
|
||||
fn new() -> Result<Self, QuicClientError> {
|
||||
let (cert, priv_key) =
|
||||
new_self_signed_tls_certificate(&Keypair::new(), IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))
|
||||
new_self_signed_tls_certificate(&Keypair::new(), IpAddr::V4(Ipv4Addr::UNSPECIFIED))
|
||||
.map_err(|err| QuicClientError::CertificateError(err.to_string()))?;
|
||||
Ok(Self {
|
||||
client_certificate: Arc::new(QuicClientCertificate {
|
||||
|
|
|
@ -106,7 +106,7 @@ impl QuicLazyInitializedEndpoint {
|
|||
endpoint.clone()
|
||||
} else {
|
||||
let client_socket = solana_net_utils::bind_in_range(
|
||||
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
|
||||
IpAddr::V4(Ipv4Addr::UNSPECIFIED),
|
||||
VALIDATOR_PORT_RANGE,
|
||||
)
|
||||
.expect("QuicLazyInitializedEndpoint::create_endpoint bind_in_range")
|
||||
|
@ -166,7 +166,7 @@ impl QuicLazyInitializedEndpoint {
|
|||
impl Default for QuicLazyInitializedEndpoint {
|
||||
fn default() -> Self {
|
||||
let (cert, priv_key) =
|
||||
new_self_signed_tls_certificate(&Keypair::new(), IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))
|
||||
new_self_signed_tls_certificate(&Keypair::new(), IpAddr::V4(Ipv4Addr::UNSPECIFIED))
|
||||
.expect("Failed to create QUIC client certificate");
|
||||
Self::new(
|
||||
Arc::new(QuicClientCertificate {
|
||||
|
|
|
@ -229,7 +229,7 @@ mod tests {
|
|||
let connection_cache_stats = Arc::new(ConnectionCacheStats::default());
|
||||
|
||||
let (cert, priv_key) =
|
||||
new_self_signed_tls_certificate(&Keypair::new(), IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))
|
||||
new_self_signed_tls_certificate(&Keypair::new(), IpAddr::V4(Ipv4Addr::UNSPECIFIED))
|
||||
.expect("Failed to initialize QUIC client certificates");
|
||||
let client_certificate = Arc::new(QuicClientCertificate {
|
||||
certificate: cert,
|
||||
|
@ -252,11 +252,9 @@ mod tests {
|
|||
info!("Received requests!");
|
||||
|
||||
// Response sender
|
||||
let (cert, priv_key) = new_self_signed_tls_certificate(
|
||||
&Keypair::new(),
|
||||
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
|
||||
)
|
||||
.expect("Failed to initialize QUIC client certificates");
|
||||
let (cert, priv_key) =
|
||||
new_self_signed_tls_certificate(&Keypair::new(), IpAddr::V4(Ipv4Addr::LOCALHOST))
|
||||
.expect("Failed to initialize QUIC client certificates");
|
||||
|
||||
let client_certificate2 = Arc::new(QuicClientCertificate {
|
||||
certificate: cert,
|
||||
|
|
|
@ -452,9 +452,9 @@ impl RpcClient {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use std::net::SocketAddr;
|
||||
/// # use std::net::{Ipv4Addr, SocketAddr};
|
||||
/// # use solana_rpc_client::nonblocking::rpc_client::RpcClient;
|
||||
/// let addr = SocketAddr::from(([127, 0, 0, 1], 8899));
|
||||
/// let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899));
|
||||
/// let client = RpcClient::new_socket(addr);
|
||||
/// ```
|
||||
pub fn new_socket(addr: SocketAddr) -> Self {
|
||||
|
@ -471,10 +471,10 @@ impl RpcClient {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use std::net::SocketAddr;
|
||||
/// # use std::net::{Ipv4Addr, SocketAddr};
|
||||
/// # use solana_rpc_client::nonblocking::rpc_client::RpcClient;
|
||||
/// # use solana_sdk::commitment_config::CommitmentConfig;
|
||||
/// let addr = SocketAddr::from(([127, 0, 0, 1], 8899));
|
||||
/// let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899));
|
||||
/// let commitment_config = CommitmentConfig::processed();
|
||||
/// let client = RpcClient::new_socket_with_commitment(
|
||||
/// addr,
|
||||
|
@ -497,10 +497,10 @@ impl RpcClient {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use std::net::SocketAddr;
|
||||
/// # use std::net::{Ipv4Addr, SocketAddr};
|
||||
/// # use std::time::Duration;
|
||||
/// # use solana_rpc_client::nonblocking::rpc_client::RpcClient;
|
||||
/// let addr = SocketAddr::from(([127, 0, 0, 1], 8899));
|
||||
/// let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899));
|
||||
/// let timeout = Duration::from_secs(1);
|
||||
/// let client = RpcClient::new_socket_with_timeout(addr, timeout);
|
||||
/// ```
|
||||
|
|
|
@ -521,9 +521,9 @@ impl RpcClient {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use std::net::SocketAddr;
|
||||
/// # use std::net::{Ipv4Addr, SocketAddr};
|
||||
/// # use solana_rpc_client::rpc_client::RpcClient;
|
||||
/// let addr = SocketAddr::from(([127, 0, 0, 1], 8899));
|
||||
/// let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899));
|
||||
/// let client = RpcClient::new_socket(addr);
|
||||
/// ```
|
||||
pub fn new_socket(addr: SocketAddr) -> Self {
|
||||
|
@ -542,10 +542,10 @@ impl RpcClient {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use std::net::SocketAddr;
|
||||
/// # use std::net::{Ipv4Addr, SocketAddr};
|
||||
/// # use solana_rpc_client::rpc_client::RpcClient;
|
||||
/// # use solana_sdk::commitment_config::CommitmentConfig;
|
||||
/// let addr = SocketAddr::from(([127, 0, 0, 1], 8899));
|
||||
/// let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899));
|
||||
/// let commitment_config = CommitmentConfig::processed();
|
||||
/// let client = RpcClient::new_socket_with_commitment(
|
||||
/// addr,
|
||||
|
@ -569,10 +569,10 @@ impl RpcClient {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use std::net::SocketAddr;
|
||||
/// # use std::net::{Ipv4Addr, SocketAddr};
|
||||
/// # use std::time::Duration;
|
||||
/// # use solana_rpc_client::rpc_client::RpcClient;
|
||||
/// let addr = SocketAddr::from(([127, 0, 0, 1], 8899));
|
||||
/// let addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 8899));
|
||||
/// let timeout = Duration::from_secs(1);
|
||||
/// let client = RpcClient::new_socket_with_timeout(addr, timeout);
|
||||
/// ```
|
||||
|
|
|
@ -75,7 +75,7 @@ mod test {
|
|||
timing::timestamp,
|
||||
},
|
||||
solana_streamer::socket::SocketAddrSpace,
|
||||
std::sync::atomic::AtomicBool,
|
||||
std::{net::Ipv4Addr, sync::atomic::AtomicBool},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
@ -119,9 +119,9 @@ mod test {
|
|||
SocketAddrSpace::Unspecified,
|
||||
));
|
||||
|
||||
let validator0_socket = SocketAddr::from(([127, 0, 0, 1], 1111));
|
||||
let validator1_socket = SocketAddr::from(([127, 0, 0, 1], 2222));
|
||||
let validator2_socket = SocketAddr::from(([127, 0, 0, 1], 3333));
|
||||
let validator0_socket = SocketAddr::from((Ipv4Addr::LOCALHOST, 1111));
|
||||
let validator1_socket = SocketAddr::from((Ipv4Addr::LOCALHOST, 2222));
|
||||
let validator2_socket = SocketAddr::from((Ipv4Addr::LOCALHOST, 3333));
|
||||
let recent_peers: HashMap<_, _> = vec![
|
||||
(
|
||||
validator_vote_keypairs0.node_keypair.pubkey(),
|
||||
|
|
|
@ -398,7 +398,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_pubsub_new() {
|
||||
let pubsub_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0);
|
||||
let pubsub_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 0);
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let max_complete_transaction_status_slot = Arc::new(AtomicU64::default());
|
||||
let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(10_000);
|
||||
|
|
|
@ -613,7 +613,7 @@ mod tests {
|
|||
Arc::new(Keypair::new()),
|
||||
SocketAddrSpace::Unspecified,
|
||||
));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let rpc_addr = SocketAddr::new(
|
||||
ip_addr,
|
||||
solana_net_utils::find_available_port_in_range(ip_addr, (10000, 65535)).unwrap(),
|
||||
|
|
|
@ -967,7 +967,7 @@ pub mod test {
|
|||
}
|
||||
|
||||
pub fn get_client_config(keypair: &Keypair) -> ClientConfig {
|
||||
let ipaddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
|
||||
let ipaddr = IpAddr::V4(Ipv4Addr::LOCALHOST);
|
||||
let (cert, key) = new_self_signed_tls_certificate(keypair, ipaddr)
|
||||
.expect("Failed to generate client certificate");
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ mod tests {
|
|||
let keypair = Keypair::new();
|
||||
|
||||
if let Ok((cert, _)) =
|
||||
new_self_signed_tls_certificate(&keypair, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)))
|
||||
new_self_signed_tls_certificate(&keypair, IpAddr::V4(Ipv4Addr::LOCALHOST))
|
||||
{
|
||||
if let Some(pubkey) = get_pubkey_from_tls_certificate(&cert) {
|
||||
assert_eq!(pubkey, keypair.pubkey());
|
||||
|
|
|
@ -87,7 +87,7 @@ impl Default for TestValidatorNodeConfig {
|
|||
const MIN_PORT_RANGE: u16 = 1024;
|
||||
const MAX_PORT_RANGE: u16 = 65535;
|
||||
|
||||
let bind_ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
|
||||
let bind_ip_addr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
|
||||
let port_range = (MIN_PORT_RANGE, MAX_PORT_RANGE);
|
||||
|
||||
Self {
|
||||
|
@ -793,9 +793,9 @@ impl TestValidator {
|
|||
let mut validator_config = ValidatorConfig {
|
||||
geyser_plugin_config_files: config.geyser_plugin_config_files.clone(),
|
||||
rpc_addrs: Some((
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), node.info.rpc.port()),
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), node.info.rpc.port()),
|
||||
SocketAddr::new(
|
||||
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
|
||||
IpAddr::V4(Ipv4Addr::UNSPECIFIED),
|
||||
node.info.rpc_pubsub.port(),
|
||||
),
|
||||
)),
|
||||
|
|
|
@ -410,7 +410,7 @@ mod tests {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
tpu_udp_socket: Arc::new(
|
||||
solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))
|
||||
solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::UNSPECIFIED))
|
||||
.expect("Unable to bind to UDP socket"),
|
||||
),
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ mod tests {
|
|||
fn new() -> Result<Self, String> {
|
||||
Ok(Self {
|
||||
tpu_udp_socket: Arc::new(
|
||||
solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))
|
||||
solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::UNSPECIFIED))
|
||||
.map_err(|_| "Unable to bind to UDP socket".to_string())?,
|
||||
),
|
||||
})
|
||||
|
@ -572,7 +572,7 @@ mod tests {
|
|||
fn test_overflow_address() {
|
||||
let port = u16::MAX - MOCK_PORT_OFFSET + 1;
|
||||
assert!(port.checked_add(MOCK_PORT_OFFSET).is_none());
|
||||
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), port);
|
||||
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), port);
|
||||
let connection_cache = TpuConnectionCache::<MockUdpPool>::new(1).unwrap();
|
||||
|
||||
let conn: MockUdpTpuConnection = connection_cache.get_connection(&addr);
|
||||
|
|
|
@ -27,7 +27,7 @@ use {
|
|||
},
|
||||
solana_streamer::socket::SocketAddrSpace,
|
||||
std::{
|
||||
net::SocketAddr,
|
||||
net::{Ipv4Addr, SocketAddr},
|
||||
process::exit,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
|
@ -538,14 +538,14 @@ fn main() {
|
|||
let just_calculate_fees = matches.is_present("just_calculate_fees");
|
||||
|
||||
let port = if skip_gossip { DEFAULT_RPC_PORT } else { 8001 };
|
||||
let mut entrypoint_addr = SocketAddr::from(([127, 0, 0, 1], port));
|
||||
let mut entrypoint_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, port));
|
||||
if let Some(addr) = matches.value_of("entrypoint") {
|
||||
entrypoint_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse entrypoint address: {e}");
|
||||
exit(1)
|
||||
});
|
||||
}
|
||||
let mut faucet_addr = SocketAddr::from(([127, 0, 0, 1], FAUCET_PORT));
|
||||
let mut faucet_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, FAUCET_PORT));
|
||||
if let Some(addr) = matches.value_of("faucet_addr") {
|
||||
faucet_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse entrypoint address: {e}");
|
||||
|
@ -686,7 +686,7 @@ pub mod test {
|
|||
..ClusterConfig::default()
|
||||
};
|
||||
|
||||
let faucet_addr = SocketAddr::from(([127, 0, 0, 1], 9900));
|
||||
let faucet_addr = SocketAddr::from((Ipv4Addr::LOCALHOST, 9900));
|
||||
let cluster = LocalCluster::new(&mut config, SocketAddrSpace::Unspecified);
|
||||
|
||||
let program_keypair = Keypair::new();
|
||||
|
|
|
@ -75,7 +75,7 @@ impl NewTpuConfig for UdpConfig {
|
|||
type ClientError = UdpClientError;
|
||||
|
||||
fn new() -> Result<Self, UdpClientError> {
|
||||
let socket = solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))
|
||||
let socket = solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::UNSPECIFIED))
|
||||
.map_err(Into::<UdpClientError>::into)?;
|
||||
Ok(Self {
|
||||
tpu_udp_socket: Arc::new(socket),
|
||||
|
|
|
@ -84,7 +84,7 @@ mod tests {
|
|||
let addr_str = "0.0.0.0:50100";
|
||||
let addr = addr_str.parse().unwrap();
|
||||
let socket =
|
||||
solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0))).unwrap();
|
||||
solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::UNSPECIFIED)).unwrap();
|
||||
let connection = UdpTpuConnection::new_from_addr(socket, addr);
|
||||
let reader = UdpSocket::bind(addr_str).await.expect("bind");
|
||||
check_send_one(&connection, &reader).await;
|
||||
|
|
|
@ -177,7 +177,7 @@ fn main() {
|
|||
});
|
||||
let compute_unit_limit = value_t!(matches, "compute_unit_limit", u64).ok();
|
||||
|
||||
let faucet_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), faucet_port);
|
||||
let faucet_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), faucet_port);
|
||||
|
||||
let mut programs_to_load = vec![];
|
||||
if let Some(values) = matches.values_of("bpf_program") {
|
||||
|
@ -352,10 +352,7 @@ fn main() {
|
|||
admin_rpc_service::run(
|
||||
&ledger_path,
|
||||
admin_rpc_service::AdminRpcRequestMetadata {
|
||||
rpc_addr: Some(SocketAddr::new(
|
||||
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
|
||||
rpc_port,
|
||||
)),
|
||||
rpc_addr: Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), rpc_port)),
|
||||
start_progress: genesis.start_progress.clone(),
|
||||
start_time: std::time::SystemTime::now(),
|
||||
validator_exit: genesis.validator_exit.clone(),
|
||||
|
|
|
@ -59,7 +59,7 @@ use {
|
|||
collections::{HashSet, VecDeque},
|
||||
env,
|
||||
fs::{self, File},
|
||||
net::{IpAddr, SocketAddr},
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
path::{Path, PathBuf},
|
||||
process::exit,
|
||||
str::FromStr,
|
||||
|
@ -1522,7 +1522,7 @@ pub fn main() {
|
|||
exit(1);
|
||||
})
|
||||
} else {
|
||||
std::net::IpAddr::V4(std::net::Ipv4Addr::new(127, 0, 0, 1))
|
||||
IpAddr::V4(Ipv4Addr::LOCALHOST)
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1559,7 +1559,7 @@ pub fn main() {
|
|||
);
|
||||
|
||||
if restricted_repair_only_mode {
|
||||
let any = SocketAddr::new(std::net::IpAddr::V4(std::net::Ipv4Addr::new(0, 0, 0, 0)), 0);
|
||||
let any = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 0);
|
||||
// When in --restricted_repair_only_mode is enabled only the gossip and repair ports
|
||||
// need to be reachable by the entrypoint to respond to gossip pull requests and repair
|
||||
// requests initiated by the node. All other ports are unused.
|
||||
|
|
Loading…
Reference in New Issue