-
Notifications
You must be signed in to change notification settings - Fork 36.2k
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
net: Add NAT-PMP port forwarding support #18077
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Thanks for picking this up again. I hope we manage to do this this time. |
2a65212
to
60e2524
Compare
Concept ACK |
60e2524
to
4ff5349
Compare
It is ready for reviewing now. |
4ff5349
to
cf94431
Compare
Updated 4ff5349 -> cf94431 (pr18077.03 -> pr18077.04, compare): added |
Updated cf94431 -> 88248a4 (pr18077.04 -> pr18077.05, compare): added:
|
88248a4
to
c7e90ca
Compare
Concept ACK, will test on my home router. |
Concept ACK. Lightly tested configure / build on macOS. Unfortunately I'm behind a IPv6 DS-Lite router, I can't test the IPv4 port forward. Perhaps
I looked up the error code, and it's what I would expect given my setup:
Two suggesitons for followups, or this PR:
|
Thank you for your review and testing.
Agree. In followups every library call (
Agree. From the OP:
|
src/qt/optionsdialog.cpp
Outdated
@@ -50,6 +51,10 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : | |||
#ifndef USE_UPNP | |||
ui->mapPortUpnp->setEnabled(false); | |||
#endif | |||
connect(this, &QDialog::accepted, [this](){ | |||
QSettings settings; | |||
model->node().mapPort(settings.value("fUseUPnP").toBool()); |
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.
In commit "gui: Apply port mapping changes on dialog exit" (58e8364)
@hebasto It seems like this commit has a bug and will incorrectly overwrite command line and config file -upnp
and -natpmp
options. I think this might have happened before, but previously only if these settings were changed, now if the dialog is just opened and closed.
Would you have an opinion on reverting this change? Aside from the bug, it seems simpler to go back to fully applying settings in OptionsModel, instead of using half-using OptionsModel to apply the setting, and then reading the setting later in a different code path and QSettings instance in dialog code outside of OptionsModel.
(Encountered this while rebasing #15936)
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.
You are right.
It seems like this commit has a bug and will incorrectly overwrite command line and config file
-upnp
and-natpmp
options.
The concerns about user-friendly and correct behavior were raised in #18184. Now users are able to switch -upnp
and -natpmp
on/off on-the-fly via the GUI. Should we drop this feature?
I think this might have happened before, but previously only if these settings were changed, now if the dialog is just opened and closed.
Exiting the dialog via the "Cancel" push button or pressing the "Esc" key should not trigger that code path.
Anyway, I'll happy to revert (or enhance) that change in a proper way.
c198797 build: compile libnatpmp with -DNATPMP_STATICLIB on Windows (Fuzzbawls) f2b62a3 build: use newer source for libnatpmp (fanquake) 8143139 GUI: Re-work port mapping saving (Fuzzbawls) c4300c0 Clang-Tidy up mapport.cpp (Fuzzbawls) f1951b5 Add libnatpmp to nightly snapcraft builds (Fuzzbawls) d48ef00 doc: Add release notes (Fuzzbawls) 7886374 doc: Add libnatpmp stuff (Fuzzbawls) cf992d0 ci: Add libnatpmp-dev package to some builds (Fuzzbawls) 5a5e3cf gui: Add NAT-PMP network option (Fuzzbawls) 9a4ba48 net: Add -natpmp command line option (Fuzzbawls) 9927296 net: Add NAT-PMP to port mapping loop (Hennadii Stepanov) 84cd118 net: Add initial libnatpmp support (Fuzzbawls) faed148 gui: Apply port mapping changes on save (Fuzzbawls) 266d322 scripted-diff: Rename UPnP stuff (Fuzzbawls) 06dc0dd net: Add flags for port mapping protocols (Fuzzbawls) 2abea67 net: Keep trying to use UPnP when -upnp=1 (Hennadii Stepanov) d2fa5c4 Make ThreadMapPort static (Fuzzbawls) 7532090 refactor: Replace magic number with named constant (Hennadii Stepanov) c481f62 refactor: Move port mapping code to its own module (Fuzzbawls) Pull request description: Built on top of #2330, this backports bitcoin#18077 and bitcoin#21209 to add NAT-PMP port forwarding support, which can function along side of or instead of UPnP. Similar to how UPnP is treated, NAT-PMP support will be compiled in if the library is found, but the functionality is disabled by default unless passing `--enable-natpmp-default` to `configure`, or by using the `-natpmp` command line option at startup. A checkbox has also been added to the settings area of the GUI that allows for on-the-fly enabling/disabling of the port mapping features when saving the settings. - [x] #2330 to be merged first. ACKs for top commit: furszy: upnp and code check ACK c198797. random-zebra: utACK c198797 after rebase, and merging... Tree-SHA512: e4b47dcd9589a1fd7a1bf3254c319d80af92c878e1657a17a169e49aa888aea33921a9428da3e8d6ee023d971143cf4a495e5a32957370174cff57e6cc6f2cc0
Details: Homebrew/discussions#691 bitcoin/bitcoin#21663 (1/1) Conflicts: .cirrus.yml; had to remove libnatpnp which was added upstream in bitcoin/bitcoin#18077 which is a much larger PR that we are NOT backporting.
Details: Homebrew/discussions#691 bitcoin/bitcoin#21663 (1/1) Conflicts: .cirrus.yml; had to remove libnatpnp which was added upstream in bitcoin/bitcoin#18077 which is a much larger PR that we are NOT backporting.
Details: Homebrew/discussions#691 bitcoin/bitcoin#21663 (1/1) Conflicts: .cirrus.yml; had to remove libnatpnp which was added upstream in bitcoin/bitcoin#18077 which is a much larger PR that we are NOT backporting.
merge bitcoin#18077...22397: Add NAT-PMP port forwarding support
This also effectively reverts 58e8364 from bitcoin#18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin#18077 (comment))
This also effectively reverts 58e8364 from bitcoin#18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin#18077 (comment))
This also effectively reverts 58e8364 from bitcoin#18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin#18077 (comment))
This also effectively reverts 58e8364 from bitcoin#18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin#18077 (comment))
This also effectively reverts 58e8364 from bitcoin#18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin#18077 (comment))
This also effectively reverts 58e8364 from bitcoin#18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin#18077 (comment))
This also effectively reverts 58e8364 from bitcoin#18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364 from #18077, applying upnp and natpmp settings from the optionsmodel class instead of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
This also effectively reverts 58e8364dcdc4e57b0caac09f8402e6535301de9b from of the optionsdialog class. This makes sense because model code, not view code is responsible for applying all other settings, and because leaving these settings half-applied in optionsmodel seems error prone and could lead to bugs. (These things were discussed a little in bitcoin/bitcoin#18077 (comment))
Close #11902
This PR is an alternative to:
To compile with NAT-PMP support on Ubuntu
libnatpmp-dev
should be available.Log excerpt:
See:
libnatpmp
Some follow-ups are out of this PR's scope:
integrate NAT-PMP into the GUI(already added)