-
Notifications
You must be signed in to change notification settings - Fork 37.7k
init: Allow -proxy="" setting values #24830
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
Concept ACK. |
Should |
Concept ACK |
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
Renamed PR from "init: Allow -noproxy and -proxy="" setting values" to "init: Allow -proxy="" setting values" because I was wrong that |
Bitcoin treats bare arguments ( The problem is #20003 also forbids setting no proxy with More broadly, I think it is a bad thing that ArgsManager does not make a distinction between |
Updated 6a51a91 -> 93e83a4 ( |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
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.
Approach ACK c241778.
@@ -175,6 +175,7 @@ class ArgsManager | |||
// ALLOW_STRING = 0x08, //!< unimplemented, draft implementation in #16545 | |||
// ALLOW_LIST = 0x10, //!< unimplemented, draft implementation in #16545 | |||
DISALLOW_NEGATION = 0x20, //!< disallow -nofoo syntax | |||
DISALLOW_ELISION = 0x40, //!< disallow -foo syntax that doesn't assign any value |
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 like this idea.
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 c241778
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
But I would prefer a two-commit approach, fixing the bug simpler in commit 1, and refactoring in commit 2. (And only backporting the first commit)
This sounds appealing, but what is the simpler fix that could be backported? The problem is that ArgsManager currently stores |
I thought maybe a default/compare with "\0"s, and/or a combination with GetBoolArg might do the trick, but you're right, I don't see a clean solution. |
This hack seems to work, but maybe not worth it? idk diff --git a/src/init.cpp b/src/init.cpp
index a3d53c3fae9..8e8db27f676 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -98,6 +98,8 @@
#include <zmq/zmqrpc.h>
#endif
+using namespace std::literals::string_literals;
+
using node::CacheSizes;
using node::CalculateCacheSizes;
using node::ChainstateLoadVerifyError;
@@ -1025,7 +1027,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
nMaxTipAge = args.GetIntArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
- if (args.IsArgSet("-proxy") && args.GetArg("-proxy", "").empty()) {
+ if (args.IsArgSet("-proxy") && args.GetArg("-proxy", "") == "\0"s) {
return InitError(_("No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>."));
}
diff --git a/src/util/system.cpp b/src/util/system.cpp
index aa9122106bd..4e89b4cbbd3 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -78,6 +78,8 @@
#include <thread>
#include <typeinfo>
+using namespace std::literals::string_literals;
+
// Application startup time (used for uptime calculation)
const int64_t nStartupTime = GetTime();
@@ -360,6 +362,11 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
std::optional<util::SettingsValue> value = InterpretValue(keyinfo, val, *flags, error);
if (!value) return false;
+ if (is_index == std::string::npos && keyinfo.name == "proxy") {
+ assert(value->get_str() == "");
+ value = "\0"s;
+ }
+
m_settings.command_line_options[keyinfo.name].push_back(*value);
}
|
This is pretty twisted and I love it. It solves the issue described minimally, like a key in a lock. But even the current full PR is only 14 lines, and I'm assuming straightforward to backport, and I think doesn't even need to be backported, so I think there's not a need for it to be so minimal. But the diff is good to have in case any issues come up, or to provide an example of how to usefully abuse char(0). |
(It might or might not break the actual proxy code tho) |
I was assuming it wouldn't do that because it keeps the |
…th other settings 3429d67 init: Prevent -noproxy and -proxy=0 settings from interacting with other settings (Ryan Ofsky) Pull request description: Prevent `-noproxy` and `-proxy=0` settings from interacting with `-listen`, `-upnp`, and `-natpmp` settings. These settings started being handled inconsistently in the `AppInitMain` and `InitParameterInteraction` functions starting in commit baf0507 from #6272: https://github.com/bitcoin/bitcoin/blob/baf05075fae2cc2625a2a74b35cc66902f3cbfa3/src/init.cpp#L990-L991 https://github.com/bitcoin/bitcoin/blob/baf05075fae2cc2625a2a74b35cc66902f3cbfa3/src/init.cpp#L687 This commit changes both functions to handle proxy arguments the same way so there are not side effects from specifying a proxy=0 setting. This change was originally part of #24830 but really is independent and makes more sense as a separate PR ACKs for top commit: hebasto: ACK 3429d67, tested on Ubuntu 22.04. Tree-SHA512: c4c6b4aeb3c07321700e974c16fd47a1bd3d469f273a6b308a69638db81c88c4e67208fddc96fcda9c8bd85f3ae22c98ca131c9622895edaa34eb65c194f35db
…ting with other settings 3429d67 init: Prevent -noproxy and -proxy=0 settings from interacting with other settings (Ryan Ofsky) Pull request description: Prevent `-noproxy` and `-proxy=0` settings from interacting with `-listen`, `-upnp`, and `-natpmp` settings. These settings started being handled inconsistently in the `AppInitMain` and `InitParameterInteraction` functions starting in commit baf0507 from bitcoin#6272: https://github.com/bitcoin/bitcoin/blob/baf05075fae2cc2625a2a74b35cc66902f3cbfa3/src/init.cpp#L990-L991 https://github.com/bitcoin/bitcoin/blob/baf05075fae2cc2625a2a74b35cc66902f3cbfa3/src/init.cpp#L687 This commit changes both functions to handle proxy arguments the same way so there are not side effects from specifying a proxy=0 setting. This change was originally part of bitcoin#24830 but really is independent and makes more sense as a separate PR ACKs for top commit: hebasto: ACK 3429d67, tested on Ubuntu 22.04. Tree-SHA512: c4c6b4aeb3c07321700e974c16fd47a1bd3d469f273a6b308a69638db81c88c4e67208fddc96fcda9c8bd85f3ae22c98ca131c9622895edaa34eb65c194f35db
Hacky but simple alternative to bitcoin#24830
Edit: Nevermind, those don't work since all the settings are set |
This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>` error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or `settings.json` value is specified, and just makes bitcoin connect and listen normally in these cases. The error was originally added in bitcoin#20003 to prevent a bare `-proxy` command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty `-proxy=` assignments as well. The motivation for this change is to prevent a GUI bug that happens with bitcoin#15936, reported in bitcoin#15936 (review) by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message.
Rebased c241778 -> c657f00 ( |
Updated c657f00 -> 1d4122d ( |
Ping for maintainers. Can this be merged? It's a small change that's had two acks and a decent amount of discussion. It should be a straightforward (if minor) UX improvement, and it helps with #15936. (I can ask for more reviewers if needed. Just want to make sure this didn't fall of the radar) |
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.
Hacky but simple alternative to bitcoin#24830
This drops the
No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>
error when a empty-proxy=
command line argument,bitcoin.conf
value, orsettings.json
value is specified, and just makes bitcoin connect and listen normally in these cases.The error was originally added in #20003 to prevent a bare
-proxy
command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty-proxy=
assignments as well.The motivation for this change is to prevent a GUI bug that happens with #15936, reported in #15936 (review) by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message.