15 "bloomfilter (allow requesting BIP37 filtered blocks and transactions)",
16 "noban (do not ban for misbehavior; implies download)",
17 "forcerelay (relay transactions that are already in the mempool; implies "
19 "relay (relay even in -blocksonly mode, and unlimited transaction "
21 "mempool (allow requesting BIP35 mempool contents)",
22 "download (allow getheaders during IBD, no disconnect after "
23 "maxuploadtarget limit)",
24 "bypass_proof_request_limits (experimental, bypass the limits on avalanche "
26 "addr (responses to GETADDR avoid hitting the cache and contain random "
27 "records with the most up-to-date info)"};
38 const auto atSeparator = str.find(
'@');
42 if (atSeparator == std::string::npos) {
51 const auto permissions = str.substr(0, atSeparator);
52 while (readen < permissions.length()) {
53 const auto commaSeparator = permissions.find(
',', readen);
54 const auto len = commaSeparator == std::string::npos
55 ? permissions.length() - readen
56 : commaSeparator - readen;
58 const auto permission = permissions.substr(readen, len);
61 if (commaSeparator != std::string::npos) {
66 if (permission ==
"bloomfilter" || permission ==
"bloom") {
68 }
else if (permission ==
"noban") {
70 }
else if (permission ==
"forcerelay") {
72 }
else if (permission ==
"mempool") {
74 }
else if (permission ==
"download") {
76 }
else if (permission ==
"all") {
78 }
else if (permission ==
"relay") {
80 }
else if (permission ==
"addr") {
82 }
else if (permission ==
"in") {
84 }
else if (permission ==
"out") {
85 if (output_connection_direction ==
nullptr) {
87 error =
_(
"whitebind may only be used for incoming "
88 "connections (\"out\" was passed)");
92 }
else if (permission ==
"bypass_proof_request_limits") {
95 }
else if (permission.length() == 0) {
99 strprintf(
_(
"Invalid P2P permission: '%s'"), permission);
111 strprintf(
_(
"Only direction was set, no permissions: '%s'"), str);
116 if (output_connection_direction) {
117 *output_connection_direction = connection_direction;
126 std::vector<std::string> strings;
128 strings.push_back(
"bloomfilter");
131 strings.push_back(
"noban");
134 strings.push_back(
"forcerelay");
137 strings.push_back(
"relay");
140 strings.push_back(
"mempool");
143 strings.push_back(
"download");
146 strings.push_back(
"addr");
150 strings.push_back(
"bypass_proof_request_limits");
160 if (!TryParsePermissionFlags(str,
flags,
166 const std::string strBind = str.substr(offset);
167 const std::optional<CService> addrBind{
Lookup(strBind, 0,
false)};
168 if (!addrBind.has_value()) {
172 if (addrBind.value().GetPort() == 0) {
173 error =
strprintf(
_(
"Need to specify a port with -whitebind: '%s'"),
191 if (!TryParsePermissionFlags(str,
flags, &output_connection_direction,
196 const std::string net = str.substr(offset);
201 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
@ 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.
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.