-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(anvil): add ability to listen on multiple IP addresses #5222
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will review and QA later to ensure this is not a breaking change
|
Is there anything else that needs to be done here ? |
Will review soon! sorry for the wait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how this could be useful,
supportive, since this only adds functionality and doesn't break anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good now!
Nice! Minor point since my issue is already solved (becomes even more minor if Node.js 20+ keeps Happy Eyeballs on by default - but they may revert 🥴), but one way to make localhost "just work" could be to introduce (if it's not too breaking?): - default_value = "127.0.0.1",
+ default_value = "::1,127.0.0.1", - host: vec![IpAddr::V4(Ipv4Addr::LOCALHOST)],
+ host: vec![IpAddr::V4(Ipv4Addr::LOCALHOST), IpAddr::V6(Ipv6Addr::LOCALHOST)], - self.host = if host.is_empty() { vec![IpAddr::V4(Ipv4Addr::LOCALHOST)] } else { host };
+ self.host = if host.is_empty() { vec![IpAddr::V4(Ipv4Addr::LOCALHOST), IpAddr::V6(Ipv6Addr::LOCALHOST)] } else { host }; Or support hostnames and default to ; evcxr
>> use std::net::ToSocketAddrs;
>> let addrs_iter = "localhost:8545".to_socket_addrs().unwrap();
>> addrs_iter
IntoIter([[::1]:8545, 127.0.0.1:8545]) For reference, the tl;dr of the rabbit hole is that:
Given how all over the place the networking standards/conventions are (to the point where even language stdlibs don't have it together), perhaps the sanest thing may be to ignore all of my above ideas and just put something in the docs to the effect of "anvil serves on only 127.0.0.1 by default, don't try to connect to it via |
Motivation
In complex setups, there is sometimes a need to listen on multiple internal network addresses or both IPv4 and IPv6 simultaneously.
Resolves #4941
Solution
I updated the NodeHandle to store Vecs of server handles and addresses.
The following commands work the same way they worked before:
anvil
- makes it listen on 127.0.0.1:8545env ANVIL_IP_ADDR="1.1.1.1" anvil
- makes it listen on 1.1.1.1:8545anvil --host 1.1.1.1
- makes it listen on 1.1.1.1:8545etc.
but now you can also add additional hosts if needed
anvil --host :: --host 127.0.0.1 --host 1.1.1.1
- makes it listen on [::]:8545, 127.0.0.1:8545, 1.1.1.1:8545env ANVIL_IP_ADDR="::1,1.1.1.1" anvil
- makes it listen on [::1]:8545, 1.1.1.1:8545The limitations in the current implementation are:
TBD:
I'm opening a Draft Pull Request to get your feedback on this :)