Merge #10118: Util: Remove redundant calls to argsGlobal.IsArgSet()
ed866ab Indentation after 'Remove redundant calls to gArgs.IsArgSet()' (Jorge Timón) 506b700 Util: Remove redundant calls to gArgs.IsArgSet() (Jorge Timón) Tree-SHA512: 4f97a0bf2a76c0f351a6343db62898cf057d745c848de00fa09465e870a120f28e0d836cafd6a047f4ec0da7ab671aebee43fa7410c9f0e66382edd1bb2009ba
This commit is contained in:
parent
2708a7be06
commit
e19fc0b9b2
@ -92,10 +92,8 @@ static bool multiUserAuthorized(std::string strUserPass)
|
|||||||
std::string strUser = strUserPass.substr(0, strUserPass.find(":"));
|
std::string strUser = strUserPass.substr(0, strUserPass.find(":"));
|
||||||
std::string strPass = strUserPass.substr(strUserPass.find(":") + 1);
|
std::string strPass = strUserPass.substr(strUserPass.find(":") + 1);
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-rpcauth")) {
|
for (const std::string& strRPCAuth : gArgs.GetArgs("-rpcauth")) {
|
||||||
//Search for multi-user login/pass "rpcauth" from config
|
//Search for multi-user login/pass "rpcauth" from config
|
||||||
for (std::string strRPCAuth : gArgs.GetArgs("-rpcauth"))
|
|
||||||
{
|
|
||||||
std::vector<std::string> vFields;
|
std::vector<std::string> vFields;
|
||||||
boost::split(vFields, strRPCAuth, boost::is_any_of(":$"));
|
boost::split(vFields, strRPCAuth, boost::is_any_of(":$"));
|
||||||
if (vFields.size() != 3) {
|
if (vFields.size() != 3) {
|
||||||
@ -122,7 +120,6 @@ static bool multiUserAuthorized(std::string strUserPass)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,6 @@ static bool InitHTTPAllowList()
|
|||||||
LookupHost("::1", localv6, false);
|
LookupHost("::1", localv6, false);
|
||||||
rpc_allow_subnets.push_back(CSubNet(localv4, 8)); // always allow IPv4 local subnet
|
rpc_allow_subnets.push_back(CSubNet(localv4, 8)); // always allow IPv4 local subnet
|
||||||
rpc_allow_subnets.push_back(CSubNet(localv6)); // always allow IPv6 localhost
|
rpc_allow_subnets.push_back(CSubNet(localv6)); // always allow IPv6 localhost
|
||||||
if (gArgs.IsArgSet("-rpcallowip")) {
|
|
||||||
for (const std::string& strAllow : gArgs.GetArgs("-rpcallowip")) {
|
for (const std::string& strAllow : gArgs.GetArgs("-rpcallowip")) {
|
||||||
CSubNet subnet;
|
CSubNet subnet;
|
||||||
LookupSubNet(strAllow.c_str(), subnet);
|
LookupSubNet(strAllow.c_str(), subnet);
|
||||||
@ -209,7 +208,6 @@ static bool InitHTTPAllowList()
|
|||||||
}
|
}
|
||||||
rpc_allow_subnets.push_back(subnet);
|
rpc_allow_subnets.push_back(subnet);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
std::string strAllowed;
|
std::string strAllowed;
|
||||||
for (const CSubNet& subnet : rpc_allow_subnets)
|
for (const CSubNet& subnet : rpc_allow_subnets)
|
||||||
strAllowed += subnet.ToString() + " ";
|
strAllowed += subnet.ToString() + " ";
|
||||||
|
23
src/init.cpp
23
src/init.cpp
@ -1105,9 +1105,7 @@ bool AppInitParameterInteraction()
|
|||||||
fAllowPrivateNet = gArgs.GetBoolArg("-allowprivatenet", DEFAULT_ALLOWPRIVATENET);
|
fAllowPrivateNet = gArgs.GetBoolArg("-allowprivatenet", DEFAULT_ALLOWPRIVATENET);
|
||||||
|
|
||||||
// -bind and -whitebind can't be set when not listening
|
// -bind and -whitebind can't be set when not listening
|
||||||
size_t nUserBind =
|
size_t nUserBind = gArgs.GetArgs("-bind").size() + gArgs.GetArgs("-whitebind").size();
|
||||||
(gArgs.IsArgSet("-bind") ? gArgs.GetArgs("-bind").size() : 0) +
|
|
||||||
(gArgs.IsArgSet("-whitebind") ? gArgs.GetArgs("-whitebind").size() : 0);
|
|
||||||
if (nUserBind != 0 && !gArgs.GetBoolArg("-listen", DEFAULT_LISTEN)) {
|
if (nUserBind != 0 && !gArgs.GetBoolArg("-listen", DEFAULT_LISTEN)) {
|
||||||
return InitError("Cannot set -bind or -whitebind together with -listen=0");
|
return InitError("Cannot set -bind or -whitebind together with -listen=0");
|
||||||
}
|
}
|
||||||
@ -1145,7 +1143,6 @@ bool AppInitParameterInteraction()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now remove the logging categories which were explicitly excluded
|
// Now remove the logging categories which were explicitly excluded
|
||||||
if (gArgs.IsArgSet("-debugexclude")) {
|
|
||||||
for (const std::string& cat : gArgs.GetArgs("-debugexclude")) {
|
for (const std::string& cat : gArgs.GetArgs("-debugexclude")) {
|
||||||
uint64_t flag;
|
uint64_t flag;
|
||||||
if (!GetLogCategory(&flag, &cat)) {
|
if (!GetLogCategory(&flag, &cat)) {
|
||||||
@ -1153,7 +1150,6 @@ bool AppInitParameterInteraction()
|
|||||||
}
|
}
|
||||||
logCategories &= ~flag;
|
logCategories &= ~flag;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Check for -debugnet
|
// Check for -debugnet
|
||||||
if (gArgs.GetBoolArg("-debugnet", false))
|
if (gArgs.GetBoolArg("-debugnet", false))
|
||||||
@ -1569,14 +1565,11 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
uacomments.push_back(strprintf("devnet=%s", GetDevNetName()));
|
uacomments.push_back(strprintf("devnet=%s", GetDevNetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-uacomment")) {
|
for (const std::string& cmt : gArgs.GetArgs("-uacomment")) {
|
||||||
for (std::string cmt : gArgs.GetArgs("-uacomment"))
|
|
||||||
{
|
|
||||||
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT))
|
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT))
|
||||||
return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt));
|
return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt));
|
||||||
uacomments.push_back(cmt);
|
uacomments.push_back(cmt);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments);
|
strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments);
|
||||||
if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
|
if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
|
||||||
return InitError(strprintf(_("Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
|
return InitError(strprintf(_("Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
|
||||||
@ -1648,7 +1641,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
fDiscover = gArgs.GetBoolArg("-discover", true);
|
fDiscover = gArgs.GetBoolArg("-discover", true);
|
||||||
fRelayTxes = !gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY);
|
fRelayTxes = !gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY);
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-externalip")) {
|
|
||||||
for (const std::string& strAddr : gArgs.GetArgs("-externalip")) {
|
for (const std::string& strAddr : gArgs.GetArgs("-externalip")) {
|
||||||
CService addrLocal;
|
CService addrLocal;
|
||||||
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
|
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
|
||||||
@ -1656,7 +1648,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
else
|
else
|
||||||
return InitError(ResolveErrMsg("externalip", strAddr));
|
return InitError(ResolveErrMsg("externalip", strAddr));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#if ENABLE_ZMQ
|
#if ENABLE_ZMQ
|
||||||
pzmqNotificationInterface = CZMQNotificationInterface::Create();
|
pzmqNotificationInterface = CZMQNotificationInterface::Create();
|
||||||
@ -2033,9 +2024,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
|
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
|
||||||
|
|
||||||
std::vector<fs::path> vImportFiles;
|
std::vector<fs::path> vImportFiles;
|
||||||
if (gArgs.IsArgSet("-loadblock"))
|
for (const std::string& strFile : gArgs.GetArgs("-loadblock")) {
|
||||||
{
|
|
||||||
for (const std::string& strFile : gArgs.GetArgs("-loadblock"))
|
|
||||||
vImportFiles.push_back(strFile);
|
vImportFiles.push_back(strFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2078,7 +2067,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
|
connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
|
||||||
connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
|
connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-bind")) {
|
|
||||||
for (const std::string& strBind : gArgs.GetArgs("-bind")) {
|
for (const std::string& strBind : gArgs.GetArgs("-bind")) {
|
||||||
CService addrBind;
|
CService addrBind;
|
||||||
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) {
|
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) {
|
||||||
@ -2086,8 +2074,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
}
|
}
|
||||||
connOptions.vBinds.push_back(addrBind);
|
connOptions.vBinds.push_back(addrBind);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (gArgs.IsArgSet("-whitebind")) {
|
|
||||||
for (const std::string& strBind : gArgs.GetArgs("-whitebind")) {
|
for (const std::string& strBind : gArgs.GetArgs("-whitebind")) {
|
||||||
CService addrBind;
|
CService addrBind;
|
||||||
if (!Lookup(strBind.c_str(), addrBind, 0, false)) {
|
if (!Lookup(strBind.c_str(), addrBind, 0, false)) {
|
||||||
@ -2098,9 +2084,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
}
|
}
|
||||||
connOptions.vWhiteBinds.push_back(addrBind);
|
connOptions.vWhiteBinds.push_back(addrBind);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-whitelist")) {
|
|
||||||
for (const auto& net : gArgs.GetArgs("-whitelist")) {
|
for (const auto& net : gArgs.GetArgs("-whitelist")) {
|
||||||
CSubNet subnet;
|
CSubNet subnet;
|
||||||
LookupSubNet(net.c_str(), subnet);
|
LookupSubNet(net.c_str(), subnet);
|
||||||
@ -2108,7 +2092,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
return InitError(strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net));
|
return InitError(strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net));
|
||||||
connOptions.vWhitelistedRange.push_back(subnet);
|
connOptions.vWhitelistedRange.push_back(subnet);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-seednode")) {
|
if (gArgs.IsArgSet("-seednode")) {
|
||||||
connOptions.vSeedNodes = gArgs.GetArgs("-seednode");
|
connOptions.vSeedNodes = gArgs.GetArgs("-seednode");
|
||||||
|
@ -1786,7 +1786,7 @@ void CConnman::ProcessOneShot()
|
|||||||
void CConnman::ThreadOpenConnections()
|
void CConnman::ThreadOpenConnections()
|
||||||
{
|
{
|
||||||
// Connect to specific addresses
|
// Connect to specific addresses
|
||||||
if (gArgs.IsArgSet("-connect") && gArgs.GetArgs("-connect").size() > 0)
|
if (gArgs.IsArgSet("-connect"))
|
||||||
{
|
{
|
||||||
for (int64_t nLoop = 0;; nLoop++)
|
for (int64_t nLoop = 0;; nLoop++)
|
||||||
{
|
{
|
||||||
@ -2022,7 +2022,6 @@ void CConnman::ThreadOpenAddedConnections()
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
LOCK(cs_vAddedNodes);
|
LOCK(cs_vAddedNodes);
|
||||||
if (gArgs.IsArgSet("-addnode"))
|
|
||||||
vAddedNodes = gArgs.GetArgs("-addnode");
|
vAddedNodes = gArgs.GetArgs("-addnode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,7 +516,9 @@ void ArgsManager::ParseParameters(int argc, const char* const argv[])
|
|||||||
std::vector<std::string> ArgsManager::GetArgs(const std::string& strArg)
|
std::vector<std::string> ArgsManager::GetArgs(const std::string& strArg)
|
||||||
{
|
{
|
||||||
LOCK(cs_args);
|
LOCK(cs_args);
|
||||||
|
if (IsArgSet(strArg))
|
||||||
return mapMultiArgs.at(strArg);
|
return mapMultiArgs.at(strArg);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArgsManager::IsArgSet(const std::string& strArg)
|
bool ArgsManager::IsArgSet(const std::string& strArg)
|
||||||
|
Loading…
Reference in New Issue
Block a user