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

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

@ -544,9 +544,6 @@ namespace llarp
_linkManager.AddLink(std::move(server), true); _linkManager.AddLink(std::move(server), true);
} }
// set network config
netConfig = conf->network.m_netConfig;
// Network config // Network config
if(conf->network.m_enableProfiling.has_value()) 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; return true;
} }

Loading…
Cancel
Save