only allow duplicates for certain options of the config
This commit is contained in:
parent
552482a404
commit
26522d212b
11
src/util.cpp
11
src/util.cpp
|
@ -627,10 +627,21 @@ void ReadConfigFile(const std::string& confPath,
|
||||||
set<string> setOptions;
|
set<string> setOptions;
|
||||||
setOptions.insert("*");
|
setOptions.insert("*");
|
||||||
|
|
||||||
|
const vector<string> allowed_duplicates = {"addnode", "connect", "rpcallowip"};
|
||||||
|
set<string> unique_options;
|
||||||
|
|
||||||
for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it)
|
for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it)
|
||||||
{
|
{
|
||||||
string strKey = string("-") + it->string_key;
|
string strKey = string("-") + it->string_key;
|
||||||
string strValue = it->value[0];
|
string strValue = it->value[0];
|
||||||
|
|
||||||
|
if (find(allowed_duplicates.begin(), allowed_duplicates.end(), it->string_key) == allowed_duplicates.end())
|
||||||
|
{
|
||||||
|
if (!unique_options.insert(strKey).second) {
|
||||||
|
throw std::runtime_error(strprintf("Not allowed duplicated option %s found.", strKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
InterpretNegativeSetting(strKey, strValue);
|
InterpretNegativeSetting(strKey, strValue);
|
||||||
// Don't overwrite existing settings so command line settings override zcash.conf
|
// Don't overwrite existing settings so command line settings override zcash.conf
|
||||||
if (mapSettingsRet.count(strKey) == 0)
|
if (mapSettingsRet.count(strKey) == 0)
|
||||||
|
|
Loading…
Reference in New Issue