add exit auth token awareness to config

pull/1319/head
jeff 4 years ago
parent 1b4f5ee5ea
commit e3bfe76f98

@ -212,6 +212,26 @@ namespace llarp
m_Paths = arg;
});
conf.defineOption<std::string>("network", "exit-auth", false, "", [this](std::string arg) {
if (arg.empty())
return;
service::Address exit;
service::AuthInfo auth;
const auto pos = arg.find(":");
if (pos == std::string::npos)
{
throw std::invalid_argument(
"[network]:exit-auth invalid format, expects exit-address.loki:auth-code-goes-here");
}
const auto exit_str = arg.substr(0, pos);
auth.token = arg.substr(pos + 1);
if (not exit.FromString(exit_str))
{
throw std::invalid_argument("[network]:exit-auth invalid exit address");
}
m_ExitAuths.emplace(exit, auth);
});
conf.defineOption<std::string>("network", "exit-node", false, "", [this](std::string arg) {
if (arg.empty())
return;

@ -85,6 +85,7 @@ namespace llarp
bool m_AllowExit = false;
std::set<RouterID> m_snodeBlacklist;
net::IPRangeMap<service::Address> m_ExitMap;
std::unordered_map<service::Address, service::AuthInfo, service::Address::Hash> m_ExitAuths;
std::unordered_map<huint128_t, service::Address> m_mapAddrs;
service::AuthType m_AuthType = service::AuthType::eAuthTypeNone;

@ -54,6 +54,11 @@ namespace llarp
conf.m_ExitMap.ForEachEntry(
[&](const IPRange& range, const service::Address& addr) { MapExitRange(range, addr); });
for (auto [exit, auth] : conf.m_ExitAuths)
{
SetAuthInfoForEndpoint(exit, auth);
}
return m_state->Configure(conf);
}

Loading…
Cancel
Save