diff --git a/src/util.cpp b/src/util.cpp index 82d705ea8..ef2ae9b74 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -627,10 +627,37 @@ void ReadConfigFile(const std::string& confPath, set setOptions; setOptions.insert("*"); + const vector allowed_duplicates = { + "addnode", + "bind", + "connect", + "debug", + "externalip", + "fundingstream", + "loadblock", + "onlynet", + "rpcallowip", + "rpcauth", + "rpcbind", + "seednode", + "uacomment", + "whitebind", + "whitelist" + }; + set unique_options; + for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) { string strKey = string("-") + it->string_key; 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("Option '%s' is duplicated, which is not allowed.", strKey)); + } + } + InterpretNegativeSetting(strKey, strValue); // Don't overwrite existing settings so command line settings override zcash.conf if (mapSettingsRet.count(strKey) == 0)