Changeset View
Changeset View
Standalone View
Standalone View
src/net_permissions.cpp
Show All 15 Lines | const std::vector<std::string> NET_PERMISSIONS_DOC{ | ||||
"relay)", | "relay)", | ||||
"relay (relay even in -blocksonly mode, and unlimited transaction " | "relay (relay even in -blocksonly mode, and unlimited transaction " | ||||
"announcements)", | "announcements)", | ||||
"mempool (allow requesting BIP35 mempool contents)", | "mempool (allow requesting BIP35 mempool contents)", | ||||
"download (allow getheaders during IBD, no disconnect after " | "download (allow getheaders during IBD, no disconnect after " | ||||
"maxuploadtarget limit)", | "maxuploadtarget limit)", | ||||
"bypass_proof_request_limits (experimental, bypass the limits on avalanche " | "bypass_proof_request_limits (experimental, bypass the limits on avalanche " | ||||
"proof downloads)", | "proof downloads)", | ||||
}; | "addr (responses to GETADDR avoid hitting the cache and contain random " | ||||
"records with the most up-to-date info)"}; | |||||
namespace { | namespace { | ||||
// The parse the following format "perm1,perm2@xxxxxx" | // The parse the following format "perm1,perm2@xxxxxx" | ||||
bool TryParsePermissionFlags(const std::string str, NetPermissionFlags &output, | bool TryParsePermissionFlags(const std::string str, NetPermissionFlags &output, | ||||
size_t &readen, bilingual_str &error) { | size_t &readen, bilingual_str &error) { | ||||
NetPermissionFlags flags = PF_NONE; | NetPermissionFlags flags = PF_NONE; | ||||
const auto atSeparator = str.find('@'); | const auto atSeparator = str.find('@'); | ||||
Show All 33 Lines | else { | ||||
} else if (permission == "mempool") { | } else if (permission == "mempool") { | ||||
NetPermissions::AddFlag(flags, PF_MEMPOOL); | NetPermissions::AddFlag(flags, PF_MEMPOOL); | ||||
} else if (permission == "download") { | } else if (permission == "download") { | ||||
NetPermissions::AddFlag(flags, PF_DOWNLOAD); | NetPermissions::AddFlag(flags, PF_DOWNLOAD); | ||||
} else if (permission == "all") { | } else if (permission == "all") { | ||||
NetPermissions::AddFlag(flags, PF_ALL); | NetPermissions::AddFlag(flags, PF_ALL); | ||||
} else if (permission == "relay") { | } else if (permission == "relay") { | ||||
NetPermissions::AddFlag(flags, PF_RELAY); | NetPermissions::AddFlag(flags, PF_RELAY); | ||||
} else if (permission == "addr") { | |||||
NetPermissions::AddFlag(flags, PF_ADDR); | |||||
} else if (permission == "bypass_proof_request_limits") { | } else if (permission == "bypass_proof_request_limits") { | ||||
NetPermissions::AddFlag(flags, PF_BYPASS_PROOF_REQUEST_LIMITS); | NetPermissions::AddFlag(flags, PF_BYPASS_PROOF_REQUEST_LIMITS); | ||||
} else if (permission.length() == 0) { | } else if (permission.length() == 0) { | ||||
// Allow empty entries | // Allow empty entries | ||||
} else { | } else { | ||||
error = | error = | ||||
strprintf(_("Invalid P2P permission: '%s'"), permission); | strprintf(_("Invalid P2P permission: '%s'"), permission); | ||||
return false; | return false; | ||||
Show All 24 Lines | if (NetPermissions::HasFlag(flags, PF_RELAY)) { | ||||
strings.push_back("relay"); | strings.push_back("relay"); | ||||
} | } | ||||
if (NetPermissions::HasFlag(flags, PF_MEMPOOL)) { | if (NetPermissions::HasFlag(flags, PF_MEMPOOL)) { | ||||
strings.push_back("mempool"); | strings.push_back("mempool"); | ||||
} | } | ||||
if (NetPermissions::HasFlag(flags, PF_DOWNLOAD)) { | if (NetPermissions::HasFlag(flags, PF_DOWNLOAD)) { | ||||
strings.push_back("download"); | strings.push_back("download"); | ||||
} | } | ||||
if (NetPermissions::HasFlag(flags, PF_ADDR)) { | |||||
strings.push_back("addr"); | |||||
} | |||||
if (NetPermissions::HasFlag(flags, PF_BYPASS_PROOF_REQUEST_LIMITS)) { | if (NetPermissions::HasFlag(flags, PF_BYPASS_PROOF_REQUEST_LIMITS)) { | ||||
strings.push_back("bypass_proof_request_limits"); | strings.push_back("bypass_proof_request_limits"); | ||||
} | } | ||||
return strings; | return strings; | ||||
} | } | ||||
bool NetWhitebindPermissions::TryParse(const std::string str, | bool NetWhitebindPermissions::TryParse(const std::string str, | ||||
NetWhitebindPermissions &output, | NetWhitebindPermissions &output, | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |