-
Notifications
You must be signed in to change notification settings - Fork 38.7k
net: fixes #20657 - Advertised address where nobody is listening #20769
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
Conversation
|
hi @jadijadi, welcome to the project! if a PR gets merged, the commits get preserved in the history on master. here, it looks like the first commit introduces an extraneous change that gets removed in the second commit. please squash them so there are just relevant changes. |
2c3c4d2 to
beb7f1d
Compare
Thanks @amitiuttarwar for the welcome, help and being this patient with newcomers :) squashed them into one. |
|
Concept ACK. This would fix #20657 |
src/init.cpp
Outdated
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.
The rest of InitParameterInteraction() uses SoftSetBoolArg() which I guess is to avoid overriding a value that has been explicitly set by the user. InitParameterInteraction() only flips defaults. I think this behavior is sensible as it minimizes the user's surprise.
There is some other code which refuses to start the application if incompatible options are given - for example -prune=1 -txindex=1 or -bind=addr:port -listen=0.
Given the above, what about refusing to start if -listen=0 -listenonion=1 is explicitly given?
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 think refusing to start (with an error message?) over changing what the user has set is better
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.
Agree with you guys. Will update the PR to refuse the start instead of changing the explicitly set parameter.
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 think refusing to start (with an error message?) over changing what the user has set is better
I've sent a new PR with this behavior. Refusing to start looks more UNIXish.
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.
The rest of
InitParameterInteraction()usesSoftSetBoolArg()which I guess is to avoid overriding a value that has been explicitly set by the user.InitParameterInteraction()only flips defaults. I think this behavior is sensible as it minimizes the user's surprise.There is some other code which refuses to start the application if incompatible options are given - for example
-prune=1 -txindex=1or-bind=addr:port -listen=0.Given the above, what about refusing to start if
-listen=0 -listenonion=1is explicitly given?
Thanks for the idea. I've updated the PR with this behavior.
beb7f1d to
b743fec
Compare
luke-jr
left a comment
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.
Concept ACK, but this needs changes to InitParameterInteraction to handle -connect and -proxy cleanly (perhaps if -listenonion is explicitly set true, soft-set -listen true also, as with -bind at the top?).
Thanks @luke-jr for the ACK and suggestion. In the initial PR, I was doing this in InitParameterInteraction as you said. But after above discussions, others suggested to do it here and preventing the system from start if the user explicitly set listenionion=1 and listen=0. In all other cases, the system handles the situation properly since the DEFAULT_LISTEN is 1 and DEFAULT_LISTEN_ONION is also 1. |
felipsoarez
left a comment
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.
Concept ACK
I have not tested the code, but I have reviewed it and it looks OK, I agree it can be merged
|
b743feca5bcbdf95ac4993c7b371d05ef1324d99 looks good. The commit message and PR description need to be updated because they refer to the previous incarnation of this PR where it enforced It works as expected:
I am not sure I understand. |
jarolrod
left a comment
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 b743feca5bcbdf95ac4993c7b371d05ef1324d99, Tested on macOS 11.2
Confirming the bug referenced here on master. This PR creates an InitParameterInteraction to set listenonion=0 when listen=0. This functionality works as intended in my testing.
Setting listen=0
2021-03-04T04:46:56Z InitParameterInteraction: parameter interaction: -listen=0 -> setting -listenonion=0
Attempting to set both listen and listenonion
Error: Cannot set -listen=0 together with -listenonion=1
@jadijadi as others have stated you may want to fix the commit message, how about this as a suggestion for the title:
net: do not advertise address where nobody is listening
If the bitcoind starts when listen=0 but listenonion=1, the daemon will advertise its onion address but nothing is listening for it. This update will enforce listenonion=0 when the listen is 0. fixes bitcoin#20657
b743fec to
a381374
Compare
Thanks for the hints. I've updated the PR with the suggested commit message |
vasild
left a comment
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 a381374
jarolrod
left a comment
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 a381374
|
Compiled successfully for Windows using the instructions mentioned here: https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md 1 test failed and this is what I see in logs: |
amitiuttarwar
left a comment
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 a381374
with several thoughts & questions for further improvements:
- the init params are hard to keep track of & dependent on ordering, so it would be good to add a regression test. @jadijadi - I have a draft here (amitiuttarwar@ec622d1) if you'd like to include in this PR or add as a follow-up.
-listenhas a lot of parameter interactions, I'm wondering if any other conflicts should similarly cause a failure-to-start instead of quietly failing, eg-discover,i2pacceptincoming... (cc @vasild if you have more insight into some of these params)- also would be cool to add test coverage to make explicit the other parameter interactions. for example, this change also disallows setting
-connect=1.1.1.1with-listenonion=1. that seems reasonable but would be nice to capture these sorts of complexities.
If Is
Right. That can be worked around with |
…ere nobody is listening a381374 net: do not advertise address where nobody is listening (Jadi) Pull request description: If the bitcoind starts when listen=0 but listenonion=1, the daemon will advertise its onion address but nothing is listening for it. This update will enforce listenonion=0 when the listen is 0. ACKs for top commit: vasild: ACK a381374 jarolrod: ACK a381374 amitiuttarwar: ACK a381374 Tree-SHA512: e84a0a9a51f2217edf35d06c6cd9085d1e664452655ba92027195a1e88ba081d157310c84e9709a99ce5d46c94f231477ca2d36f010648b0c8b4f2a737d54e5d
|
It seems this PR introduced a bug in the GUI: bitcoin-core/gui#567. |

If the bitcoind starts when listen=0 but listenonion=1, the daemon will
advertise its onion address but nothing is listening for it.
This update will enforce listenonion=0 when the listen is 0.