Slight cleanup of k:v option maps

pull/1186/head
Stephen Shelton 4 years ago
parent e06c2e4502
commit adfcbd1d0b
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C

@ -144,7 +144,10 @@ namespace llarp
conf.defineOption<std::string>("network", "strict-connect", false, m_strictConnect,
AssignmentAcceptor(m_strictConnect));
// TODO: NetConfig was collecting all other k:v pairs here
conf.addUndeclaredHandler("network", [&](string_view, string_view name, string_view value) {
m_options.emplace(name, value);
return true;
});
}
void
@ -161,17 +164,21 @@ namespace llarp
{
(void)params;
// TODO: this was previously a multi-value option
conf.defineOption<std::string>("dns", "upstream", false, "",
[this](std::string arg) {
netConfig.emplace("upstream-dns", std::move(arg));
});
conf.addUndeclaredHandler("network", [&](string_view, string_view name, string_view value) {
// TODO: this was previously a multi-value option
conf.defineOption<std::string>("dns", "bind", false, "",
[this](std::string arg) {
netConfig.emplace("local-dns", std::move(arg));
});
if (name == "upstream-dns")
{
m_options.emplace("upstream-dns", value);
return true;
}
else if (name == "local-dns")
{
m_options.emplace("local-dns", value);
return true;
}
return false;
});
}
LinksConfig::LinkInfo

@ -20,6 +20,9 @@ namespace llarp
using SectionValues_t = llarp::ConfigParser::SectionValues_t;
using Config_impl_t = llarp::ConfigParser::Config_impl_t;
// TODO: don't use these maps. they're sloppy and difficult to follow
using FreehandOptions = std::unordered_multimap< std::string, std::string >;
/// Small struct to gather all parameters needed for config generation to reduce the number of
/// parameters that need to be passed around.
struct ConfigGenParameters
@ -58,12 +61,10 @@ namespace llarp
struct NetworkConfig
{
using NetConfig = std::unordered_multimap< std::string, std::string >;
nonstd::optional< bool > m_enableProfiling;
std::string m_routerProfilesFile = "profiles.dat";
std::string m_strictConnect;
NetConfig m_netConfig;
FreehandOptions m_options;
void
defineConfigOptions(Configuration& conf, const ConfigGenParameters& params);
@ -79,7 +80,7 @@ namespace llarp
struct DnsConfig
{
std::unordered_multimap<std::string, std::string> netConfig;
FreehandOptions m_options;
void
defineConfigOptions(Configuration& conf, const ConfigGenParameters& params);

@ -544,9 +544,6 @@ namespace llarp
_linkManager.AddLink(std::move(server), true);
}
// set network config
netConfig = conf->network.m_netConfig;
// Network config
if(conf->network.m_enableProfiling.has_value())
{
@ -631,7 +628,9 @@ namespace llarp
}
netConfig.insert(conf->dns.netConfig.begin(), conf->dns.netConfig.end());
// TODO: clean this up. it appears that we're dumping the [dns] "options" into the
// [network] "options"
conf->network.m_options.insert(conf->dns.m_options.begin(), conf->dns.m_options.end());
return true;
}

Loading…
Cancel
Save