Closed diegomrsantos closed 3 weeks ago
Is it possible to add a withWilcardAddressResolverService()
function in the switch builder? To have a simple way of creating it. This can work well in addition to withServices(@[ .... ])
Is it possible to add a
withWilcardAddressResolverService()
function in the switch builder? To have a simple way of creating it. This can work well in addition towithServices(@[ .... ])
Not a big fan tbh. Maybe we should always add it to the switch.
Is it possible to add a withWilcardAddressResolverService() function in the switch builder? To have a simple way of creating it. This can work well in addition to withServices(@[ .... ])
Not a big fan tbh. Maybe we should always add it to the switch.
Is there a reason to model the resolver as a service? Is there a situation in which this service would no be desired? Imo, the switch should offer this per default.
Is it possible to add a withWilcardAddressResolverService() function in the switch builder? To have a simple way of creating it. This can work well in addition to withServices(@[ .... ])
Not a big fan tbh. Maybe we should always add it to the switch.
Is there a reason to model the resolver as a service? Is there a situation in which this service would no be desired? Imo, the switch should offer this per default.
The motivation was to make it optional. It might be a breaking change if we make it the default behavior tho.
The motivation was to make it optional. It might be a breaking change if we make it the default behavior tho.
With our plan to keep only the public
marked API as stable in versions 1.x, we could break that.
The motivation was to make it optional. It might be a breaking change if we make it the default behavior tho.
With our plan to keep only the
public
marked API as stable in versions 1.x, we could break that.
But I think keeping it as a Service
is still nice cause the setup/stop
is handled automatically by the Switch
.
The last commits that enabled the service by default were reverted as they caused strange errors when running the tests. Initially, it was nil access errors in the tor transport test. After those were fixed, random tests failed as the transports were not closed properly. This happened when running on my macOS m1. On CI the test would hang as it's possible to see in the commits.
I added back the wildcard service enabled by default. There were some issues in the tests that I had to fix, but it seems that the weird errors happened cause of what was explained here https://github.com/vacp2p/nim-libp2p/pull/1105.
Attention: Patch coverage is 83.47826%
with 19 lines
in your changes are missing coverage. Please review.
Project coverage is 84.48%. Comparing base (
02c96fc
) to head (1bb1c1a
). Report is 8 commits behind head on master.
Summary
This PR adds a service that expands wildcard addresses to their respective interface addresses equivalent. closes #1087
Context
Users of nim-libp2p often listen to wildcard addresses like 0.0.0.0 (IPv4) and [::] (IPv6) to allow the OS to bind the transports to all available network interfaces. This is useful for applications that need to be accessible on multiple networks without specifying each interface.
When listening on wildcard addresses, the OS binds to all available IP addresses, simplifying network configuration but requiring a mechanism to resolve these addresses to their specific network interfaces for communication with other peers.
The
listenAddrs
field contains addresses the node listens on, which may include wildcard and private addresses (not directly reachable). Theaddrs
field contains resolved addresses that other peers can use to connect, including public-facing NAT and port-forwarded addresses.Before this PR, nim-libp2p didn't offer a way to resolve wildcard addresses in the
addrs
field.This was reported on https://github.com/status-im/nimbus-eth2/issues/6060 and https://github.com/vacp2p/nim-libp2p/issues/1087.
Changes