aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authoramadeuszpawlik <apawlik@protonmail.com>2021-05-27 14:07:35 +0200
committerAmadeusz Pawlik <amadeusz.pawlik@getinge.com>2022-10-05 19:30:15 +0200
commit04526787b5f6613d1f1ad78434e1dd24ab88dd76 (patch)
tree042d06ec0cafb8cd9d346ea55bb2ef9bc9b81a61 /src/util
parentf8387c42343867779170a0f96ef64e6acff5c481 (diff)
downloadbitcoin-04526787b5f6613d1f1ad78434e1dd24ab88dd76.tar.xz
Validate `port` options
Check `port` options for invalid values (ports are parsed as uint16, so in practice values >65535 are invalid; port 0 is undefined and therefore considered invalid too). This allows for an early rejection of faulty values and an supplying an informative message to the user. Splits tests in `feature_proxy.py` to cover both invalid `hostname` and `port` values. Adds a release-note as previously valid `-port` and `-rpcport` values can now result in errors.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/error.cpp5
-rw-r--r--src/util/error.h2
2 files changed, 7 insertions, 0 deletions
diff --git a/src/util/error.cpp b/src/util/error.cpp
index 33a35a6d59..390cb6c11b 100644
--- a/src/util/error.cpp
+++ b/src/util/error.cpp
@@ -49,6 +49,11 @@ bilingual_str ResolveErrMsg(const std::string& optname, const std::string& strBi
return strprintf(_("Cannot resolve -%s address: '%s'"), optname, strBind);
}
+bilingual_str InvalidPortErrMsg(const std::string& optname, const std::string& invalid_value)
+{
+ return strprintf(_("Invalid port specified in %s: '%s'"), optname, invalid_value);
+}
+
bilingual_str AmountHighWarn(const std::string& optname)
{
return strprintf(_("%s is set very high!"), optname);
diff --git a/src/util/error.h b/src/util/error.h
index 0429de651a..27916501f0 100644
--- a/src/util/error.h
+++ b/src/util/error.h
@@ -39,6 +39,8 @@ bilingual_str TransactionErrorString(const TransactionError error);
bilingual_str ResolveErrMsg(const std::string& optname, const std::string& strBind);
+bilingual_str InvalidPortErrMsg(const std::string& optname, const std::string& strPort);
+
bilingual_str AmountHighWarn(const std::string& optname);
bilingual_str AmountErrMsg(const std::string& optname, const std::string& strValue);