13 "bloomfilter (allow requesting BIP37 filtered blocks and transactions)",
14 "noban (do not ban for misbehavior; implies download)",
15 "forcerelay (relay transactions that are already in the mempool; implies "
17 "relay (relay even in -blocksonly mode, and unlimited transaction "
19 "mempool (allow requesting BIP35 mempool contents)",
20 "download (allow getheaders during IBD, no disconnect after "
21 "maxuploadtarget limit)",
22 "bypass_proof_request_limits (experimental, bypass the limits on avalanche "
24 "addr (responses to GETADDR avoid hitting the cache and contain random "
25 "records with the most up-to-date info)"};
36 const auto atSeparator = str.find(
'@');
40 if (atSeparator == std::string::npos) {
49 const auto permissions = str.substr(0, atSeparator);
50 while (readen < permissions.length()) {
51 const auto commaSeparator = permissions.find(
',', readen);
52 const auto len = commaSeparator == std::string::npos
53 ? permissions.length() - readen
54 : commaSeparator - readen;
56 const auto permission = permissions.substr(readen, len);
59 if (commaSeparator != std::string::npos) {
64 if (permission ==
"bloomfilter" || permission ==
"bloom") {
66 }
else if (permission ==
"noban") {
68 }
else if (permission ==
"forcerelay") {
70 }
else if (permission ==
"mempool") {
72 }
else if (permission ==
"download") {
74 }
else if (permission ==
"all") {
76 }
else if (permission ==
"relay") {
78 }
else if (permission ==
"addr") {
80 }
else if (permission ==
"in") {
82 }
else if (permission ==
"out") {
83 if (output_connection_direction ==
nullptr) {
85 error =
_(
"whitebind may only be used for incoming "
86 "connections (\"out\" was passed)");
90 }
else if (permission ==
"bypass_proof_request_limits") {
93 }
else if (permission.length() == 0) {
97 strprintf(
_(
"Invalid P2P permission: '%s'"), permission);
109 strprintf(
_(
"Only direction was set, no permissions: '%s'"), str);
114 if (output_connection_direction) {
115 *output_connection_direction = connection_direction;
124 std::vector<std::string> strings;
126 strings.push_back(
"bloomfilter");
129 strings.push_back(
"noban");
132 strings.push_back(
"forcerelay");
135 strings.push_back(
"relay");
138 strings.push_back(
"mempool");
141 strings.push_back(
"download");
144 strings.push_back(
"addr");
148 strings.push_back(
"bypass_proof_request_limits");
158 if (!TryParsePermissionFlags(str,
flags,
164 const std::string strBind = str.substr(offset);
166 if (!
Lookup(strBind, addrBind, 0,
false)) {
189 if (!TryParsePermissionFlags(str,
flags, &output_connection_direction,
194 const std::string net = str.substr(offset);
199 strprintf(
_(
"Invalid netmask specified in -whitelist: '%s'"), net);
A combination of a network address (CNetAddr) and a (TCP) port.
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)
bool error(const char *fmt, const Args &...args)
const std::vector< std::string > NET_PERMISSIONS_DOC
@ BypassProofRequestLimits
bool LookupSubNet(const std::string &strSubnet, CSubNet &ret, DNSLookupFn dns_lookup_function)
Parse and resolve a specified subnet string into the appropriate internal representation.
bool Lookup(const std::string &name, std::vector< CService > &vAddr, 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.