Merge bitcoin-core/gui#813: Don't permit port in proxy IP option

10c5275ba4 gui: don't permit port in proxy IP option (willcl-ark)

Pull request description:

  Fixes: https://github.com/bitcoin-core/gui/issues/809

  Previously it was possible through the GUI to enter an IP address:port into the "Proxy IP" configuration box. After the node was restarted the errant setting would prevent the node starting back up until manually removed from settings.json.

  Prevent this with a simple check for ":" in the string. This is acceptable here in the GUI setting because we already fail on a hostname such as "http://x.x.x.x", so it won't cause false positives.

ACKs for top commit:
  furszy:
    utACK 10c5275ba4
  hebasto:
    ACK 10c5275ba4, tested on Ubuntu 24.04.

Tree-SHA512: ed83590630cf693680a3221f701ecd18dd08710a17b726dc4978a3a6e330a34fb77d73a4f710c01bcb3faf88b6604ff37bcdbb191ce1623348ca5b92fd6fe9a7
This commit is contained in:
merge-script 2024-05-11 19:34:12 +01:00
commit 3207286680
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -18,6 +18,7 @@
#include <node/chainstatemanager_args.h>
#include <netbase.h>
#include <txdb.h>
#include <util/strencodings.h>
#include <chrono>
@ -480,7 +481,10 @@ QValidator(parent)
QValidator::State ProxyAddressValidator::validate(QString &input, int &pos) const
{
Q_UNUSED(pos);
// Validate the proxy
uint16_t port{0};
std::string hostname;
if (!SplitHostPort(input.toStdString(), port, hostname) || port != 0) return QValidator::Invalid;
CService serv(LookupNumeric(input.toStdString(), DEFAULT_GUI_PROXY_PORT));
Proxy addrProxy = Proxy(serv, true);
if (addrProxy.IsValid())