diff --git a/src/util.cpp b/src/util.cpp index 82d705ea8..5d88aba88 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -627,10 +627,21 @@ void ReadConfigFile(const std::string& confPath, set setOptions; setOptions.insert("*"); + const vector allowed_duplicates = {"addnode", "connect", "rpcallowip"}; + 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("Not allowed duplicated option %s found.", strKey)); + } + } + InterpretNegativeSetting(strKey, strValue); // Don't overwrite existing settings so command line settings override zcash.conf if (mapSettingsRet.count(strKey) == 0)