-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow IPv6 connections to Bitcoin nodes #4045
Conversation
While initially working ok in clearnet, I found that if 'Use Tor for Bitcoin network' is enabled, IPv6 clearnet addresses are ignored. |
Can you fix the commit messages so they are capitalized and well documented like
|
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.
NACK
Test case 1 failed:
- Set btcnode configuration to
node100.wiz.network,node130.wiz.network,node140.wiz.network,node150.wiz.network
Expected) Seeing IPv6 addresses in settings -> network status
Actual) Seeing IPv4 addresses in settings -> network status
Test case 2 failed:
- Set btcnode configuration to
2401:b140::42:100,2401:b140::42:130,2401:b140::42:140,2401:b140::42:150
Expected) Connects to IPv6 btcnodes
Actual) Bisq fails to start due to "invalid configuration"
The IP address is obtained from the user parameters by calling DNS lookup in |
DnsLookupTor.java is doing the same SOCKS5 network query as
What we would need is the tor DNS equivalent of
But we get this
From reading tor-resolve code, there's no parameter that can be written to the DNS socket telling it that we want IPv6 result rather than IPv4. I'm open to suggestions. |
Why you close this PR ? Don't give up so easily lol
Why are you using Tor for DNS if |
Bisq is not using Tor when that option is unchecked. However Java is defaulting to IPv4 for the name lookup. Setting the following option with the JavaVM is necessary to make Java default to IPv6 in the case where both address types are available. Success! |
Good work. Perhaps the "prefer IPv6 addresses" should be a setting in the Bisq preferences GUI, and then you can set the JVM options appropriately at startup if the preference is set. |
That was a lucky timing with your last commit 😉 Could you please adapt the wording of your last commit messages, so it speaks without needing the context of @wiz comment in this PR? Thanks. |
|
||
// #3990 allow IPv6 custom Bitcoin node in settings by hostname | ||
System.setProperty("java.net.preferIPv6Addresses", "true"); |
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.
Is there a drawback when we set this as default for all nodes?
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.
Compared to doing it based on a user preference.
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 have not seen any drawback from setting this, even if IPv6 is not available. Here's a document on the subject, which mentions setting the property. And another one which mentions that the setting has to be made very early in app startup.
If you think its too risky we can revert to choosing between IPv4 and IPv6 addresses in BtcNodeConverter where it creates a PeerAddress from hostname.
@jmacxx Please sign your commit. Thanks! |
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.
Tested the following in GUI preferences:
node100.wiz.network,node130.wiz.network,node140.wiz.network,node150.wiz.network
node100.wiz.network:8333,node130.wiz.network:8333,node140.wiz.network:8333,node150.wiz.network:8333
2401:b140::42:100,2401:b140::44:130,2401:b140::44:140,2401:b140::44:150
[2401:b140::42:100]:8333,[2401:b140::44:130]:8333,[2401:b140::44:140]:8333,[2401:b140::44:150]:8333
All passed except 2, can you fix it?
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.
A safer way to implement this would be:
- if "Use Tor" is unchecked, enable a new radio button for "Prefer IPv4" or "Prefer IPv6"
- if "Prefer IPv6" is selected, then set the JVM option
java.net.preferIPv6Addresses=true
Currently bisq desktop does not accept IPv6 addresses in the settings for custom nodes or via the --btcNodes command line option. The separation of address and port is handled incorrectly in core / BtcNodes::fromFullAddress. This results in IPv6 addresses being ignored. Where Tor is enabled for Bitcoin connections, we need to handle the IPv6 address response from Tor DNS lookup. Fixes #3990
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.
ACK
After discussion, we concluded that "fixing ipv6" and "preferring ipv6" are very separate scopes, and since "preferring ipv6" has potential side effects, we agreed it would be safer to limit the scope of this PR to only "fixing ipv6", which means the expected case for testcases 3 and 4 below is not to connect to IPv6, but to use the JVM default setting, so now all testcases pass. Tested on macOS and Linux using single stack and dual stack configurations.
2401:b140::42:100,2401:b140::44:130,2401:b140::44:140,2401:b140::44:150
[2401:b140::42:100]:8333,[2401:b140::44:130]:8333,[2401:b140::44:140]:8333,[2401:b140::44:150]:8333
node100.wiz.network,node130.wiz.network,node140.wiz.network,node150.wiz.network
node100.wiz.network:8333,node130.wiz.network:8333,node140.wiz.network:8333,node150.wiz.network:8333
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.
utACK based on #4045 (review)
@devinbileck can you please make a note to test both IPv4 single-stack and IPv4/IPv6 dual-stack configurations in your next release testing? |
Fixes #3990
Currently bisq desktop does not accept IPv6 addresses in the settings for custom nodes or via the
--btcNodes
command line option.While the address format is already validated in
desktop / GUIUtil
, the separation of address and port is handled incorrectly incore / BtcNodes::fromFullAddress
.This results in IPv6 addresses being ignored, regardless of whether they are entered via the GUI or command line.
This change fixes the code in
BtcNodes::fromFullAddress
to identify an IPv6 address as being surrounded by square brackets..onion
and an optional colon and port numberTesting:
the following use case tests were identified and checked: