14 "bloomfilter (allow requesting BIP37 filtered blocks and transactions)",
15 "noban (do not ban for misbehavior; implies download)",
16 "forcerelay (relay transactions that are already in the mempool; implies relay)",
17 "relay (relay even in -blocksonly mode, and unlimited transaction announcements)",
18 "mempool (allow requesting BIP35 mempool contents)",
19 "download (allow getheaders during IBD, no disconnect after maxuploadtarget limit)",
20 "addr (responses to GETADDR avoid hitting the cache and contain random records with the most up-to-date info)"
30 const auto atSeparator = str.find(
'@');
33 if (atSeparator == std::string::npos) {
41 const auto permissions = str.substr(0, atSeparator);
42 while (readen < permissions.length()) {
43 const auto commaSeparator = permissions.find(
',', readen);
44 const auto len = commaSeparator == std::string::npos ? permissions.length() - readen : commaSeparator - readen;
46 const auto permission = permissions.substr(readen, len);
48 if (commaSeparator != std::string::npos) readen++;
59 else if (permission ==
"out") {
60 if (output_connection_direction ==
nullptr) {
62 error =
_(
"whitebind may only be used for incoming connections (\"out\" was passed)");
67 else if (permission.length() == 0);
69 error =
strprintf(
_(
"Invalid P2P permission: '%s'"), permission);
80 error =
strprintf(
_(
"Only direction was set, no permissions: '%s'"), str);
85 if (output_connection_direction) *output_connection_direction = connection_direction;
94 std::vector<std::string> strings;
109 if (!TryParsePermissionFlags(str,
flags,
nullptr, offset, error))
return false;
111 const std::string strBind = str.substr(offset);
112 const std::optional<CService> addrBind{
Lookup(strBind, 0,
false)};
113 if (!addrBind.has_value()) {
117 if (addrBind.value().GetPort() == 0) {
118 error =
strprintf(
_(
"Need to specify a port with -whitebind: '%s'"), strBind);
133 if (!TryParsePermissionFlags(str,
flags, &output_connection_direction, offset, error))
return false;
135 const std::string net = str.substr(offset);
137 if (!subnet.IsValid()) {
138 error =
strprintf(
_(
"Invalid netmask specified in -whitelist: '%s'"), net);
NetPermissionFlags m_flags
static void AddFlag(NetPermissionFlags &flags, NetPermissionFlags f)
static std::vector< std::string > ToStrings(NetPermissionFlags flags)
static bool HasFlag(NetPermissionFlags flags, NetPermissionFlags f)
static bool TryParse(const std::string &str, NetWhitebindPermissions &output, bilingual_str &error)
static bool TryParse(const std::string &str, NetWhitelistPermissions &output, ConnectionDirection &output_connection_direction, bilingual_str &error)
is a home for simple string functions returning descriptive messages that are used in RPC and GUI int...
bilingual_str ResolveErrMsg(const std::string &optname, const std::string &strBind)
const std::vector< std::string > NET_PERMISSIONS_DOC
CSubNet LookupSubNet(const std::string &subnet_str)
Parse and resolve a specified subnet string into the appropriate internal representation.
std::vector< CService > Lookup(const std::string &name, uint16_t portDefault, bool fAllowLookup, unsigned int nMaxSolutions, DNSLookupFn dns_lookup_function)
Resolve a service string to its corresponding service.
bilingual_str _(ConstevalStringLiteral str)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.