Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add IN_ADDR_ANY for V4 and V6 #461

Merged
merged 4 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading