Handle blacklist-snode validation in config

pull/1246/head
Stephen Shelton 4 years ago committed by Jeff Becker
parent fde93ac02d
commit 3198a8b139
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -448,16 +448,15 @@ namespace llarp
conf.defineOption<bool>(
section, "bundle-rc", false, BundleRCDefault, AssignmentAcceptor(m_bundleRC));
conf.addUndeclaredHandler(
section, [&](std::string_view, std::string_view name, std::string_view value) {
if (name == "blacklist-snode")
{
m_snodeBlacklist.push_back(str(value));
return true;
}
return false;
});
conf.defineOption<std::string>(section, "blacklist-snode", true, "", [this](std::string arg) {
RouterID id;
if (not id.FromString(arg))
throw std::invalid_argument(stringify("Invalide RouterID: ", arg));
auto itr = m_snodeBlacklist.emplace(std::move(id));
if (itr.second)
throw std::invalid_argument(stringify("Duplicate blacklist-snode: ", arg));
});
}
bool

@ -166,7 +166,7 @@ namespace llarp
int m_hops;
int m_paths;
bool m_bundleRC;
std::vector<std::string> m_snodeBlacklist;
std::set<RouterID> m_snodeBlacklist;
std::string m_exitNode;
std::string m_localDNS;
std::string m_upstreamDNS;

@ -19,16 +19,7 @@ namespace llarp
m_PrefetchAddrs = conf.m_prefetchAddrs;
m_MinPathLatency = conf.m_minLatency;
m_BundleRC = conf.m_bundleRC;
// TODO: update EndpointConfig to treat these as RouterIDs and detect dupes
for (const auto& item : conf.m_snodeBlacklist)
{
RouterID snode;
if (not snode.FromString(item))
throw std::runtime_error(stringify("Invalide RouterID: ", item));
m_SnodeBlacklist.insert(snode);
}
m_SnodeBlacklist = conf.m_snodeBlacklist;
// TODO:
/*

Loading…
Cancel
Save