12 "bloomfilter (allow requesting BIP37 filtered blocks and transactions)",
13 "noban (do not ban for misbehavior; implies download)",
14 "forcerelay (relay transactions that are already in the mempool; implies relay)",
15 "relay (relay even in -blocksonly mode, and unlimited transaction announcements)",
16 "mempool (allow requesting BIP35 mempool contents)",
17 "download (allow getheaders during IBD, no disconnect after maxuploadtarget limit)",
18 "addr (responses to GETADDR avoid hitting the cache and contain random records with the most up-to-date info)"
28 const auto atSeparator = str.find(
'@');
31 if (atSeparator == std::string::npos) {
39 const auto permissions = str.substr(0, atSeparator);
40 while (readen < permissions.length()) {
41 const auto commaSeparator = permissions.find(
',', readen);
42 const auto len = commaSeparator == std::string::npos ? permissions.length() - readen : commaSeparator - readen;
44 const auto permission = permissions.substr(readen, len);
46 if (commaSeparator != std::string::npos) readen++;
57 else if (permission ==
"out") {
58 if (output_connection_direction ==
nullptr) {
60 error =
_(
"whitebind may only be used for incoming connections (\"out\" was passed)");
65 else if (permission.length() == 0);
67 error =
strprintf(
_(
"Invalid P2P permission: '%s'"), permission);
78 error =
strprintf(
_(
"Only direction was set, no permissions: '%s'"), str);
83 if (output_connection_direction) *output_connection_direction = connection_direction;
92 std::vector<std::string> strings;
107 if (!TryParsePermissionFlags(str,
flags,
nullptr, offset, error))
return false;
109 const std::string strBind = str.substr(offset);
110 const std::optional<CService> addrBind{
Lookup(strBind, 0,
false)};
111 if (!addrBind.has_value()) {
115 if (addrBind.value().GetPort() == 0) {
116 error =
strprintf(
_(
"Need to specify a port with -whitebind: '%s'"), strBind);
131 if (!TryParsePermissionFlags(str,
flags, &output_connection_direction, offset, error))
return false;
133 const std::string net = str.substr(offset);
135 if (!subnet.IsValid()) {
136 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)
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 _(const char *psz)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.