Skip to content

Commit

Permalink
feat: add IN_ADDR_ANY for V4 and V6 (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbraun96 authored Nov 9, 2024
1 parent 5620565 commit ac13787
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Submodule forge-std updated 1 files
+1 −1 package.json
2 changes: 1 addition & 1 deletion blueprints/incredible-squaring/contracts/lib/forge-std
Submodule forge-std updated 1 files
+1 −1 package.json
8 changes: 5 additions & 3 deletions sdk/src/network/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,15 @@ pub fn multiplexed_libp2p_network(config: NetworkConfig) -> NetworkResult {
);
}

let ips_to_bind_to = vec![
IpAddr::from_str("0.0.0.0").unwrap(),
IpAddr::from_str("::1").unwrap(),
let ips_to_bind_to = [
IpAddr::from_str("::").unwrap(), // IN_ADDR_ANY_V6
IpAddr::from_str("0.0.0.0").unwrap(), // IN_ADDR_ANY_V4
];

for addr in ips_to_bind_to {
let ip_label = if addr.is_ipv4() { "ip4" } else { "ip6" };
// Bind to both UDP and TCP to increase probability of successful NAT traversal.
// Use QUIC over UDP to have reliable ordered transport like TCP.
swarm.listen_on(format!("/{ip_label}/{addr}/udp/{bind_port}/quic-v1").parse()?)?;
swarm.listen_on(format!("/{ip_label}/{addr}/tcp/{bind_port}").parse()?)?;
}
Expand Down

0 comments on commit ac13787

Please sign in to comment.