Changeset View
Changeset View
Standalone View
Standalone View
src/net_permissions.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | else { | ||||
NetPermissions::AddFlag(flags, PF_MEMPOOL); | NetPermissions::AddFlag(flags, PF_MEMPOOL); | ||||
} 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.length() == 0) { | } else if (permission.length() == 0) { | ||||
// Allow empty entries | // Allow empty entries | ||||
} else { | } else { | ||||
error = | error = strprintf(_("Invalid P2P permission: '%s'").translated, | ||||
strprintf(_("Invalid P2P permission: '%s'"), permission); | permission); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
readen++; | readen++; | ||||
} | } | ||||
output = flags; | output = flags; | ||||
error = ""; | error = ""; | ||||
Show All 27 Lines | bool NetWhitebindPermissions::TryParse(const std::string str, | ||||
size_t offset; | size_t offset; | ||||
if (!TryParsePermissionFlags(str, flags, offset, error)) { | if (!TryParsePermissionFlags(str, flags, offset, error)) { | ||||
return false; | return false; | ||||
} | } | ||||
const std::string strBind = str.substr(offset); | const std::string strBind = str.substr(offset); | ||||
CService addrBind; | CService addrBind; | ||||
if (!Lookup(strBind.c_str(), addrBind, 0, false)) { | if (!Lookup(strBind.c_str(), addrBind, 0, false)) { | ||||
error = strprintf(_("Cannot resolve -%s address: '%s'"), "whitebind", | error = strprintf(_("Cannot resolve -%s address: '%s'").translated, | ||||
strBind); | "whitebind", strBind); | ||||
return false; | return false; | ||||
} | } | ||||
if (addrBind.GetPort() == 0) { | if (addrBind.GetPort() == 0) { | ||||
error = strprintf(_("Need to specify a port with -whitebind: '%s'"), | error = strprintf( | ||||
_("Need to specify a port with -whitebind: '%s'").translated, | |||||
strBind); | strBind); | ||||
return false; | return false; | ||||
} | } | ||||
output.m_flags = flags; | output.m_flags = flags; | ||||
output.m_service = addrBind; | output.m_service = addrBind; | ||||
error = ""; | error = ""; | ||||
return true; | return true; | ||||
} | } | ||||
bool NetWhitelistPermissions::TryParse(const std::string str, | bool NetWhitelistPermissions::TryParse(const std::string str, | ||||
NetWhitelistPermissions &output, | NetWhitelistPermissions &output, | ||||
std::string &error) { | std::string &error) { | ||||
NetPermissionFlags flags; | NetPermissionFlags flags; | ||||
size_t offset; | size_t offset; | ||||
if (!TryParsePermissionFlags(str, flags, offset, error)) { | if (!TryParsePermissionFlags(str, flags, offset, error)) { | ||||
return false; | return false; | ||||
} | } | ||||
const std::string net = str.substr(offset); | const std::string net = str.substr(offset); | ||||
CSubNet subnet; | CSubNet subnet; | ||||
LookupSubNet(net.c_str(), subnet); | LookupSubNet(net.c_str(), subnet); | ||||
if (!subnet.IsValid()) { | if (!subnet.IsValid()) { | ||||
error = | error = strprintf( | ||||
strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net); | _("Invalid netmask specified in -whitelist: '%s'").translated, net); | ||||
return false; | return false; | ||||
} | } | ||||
output.m_flags = flags; | output.m_flags = flags; | ||||
output.m_subnet = subnet; | output.m_subnet = subnet; | ||||
error = ""; | error = ""; | ||||
return true; | return true; | ||||
} | } |