add option to run lokinet traffic only with no exit and drop all non lokinet traffic

triggered by: exit-node=null
pull/1576/head
Jeff Becker 3 years ago
parent 2ed0ab1ca1
commit 94ecf02a62
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -457,7 +457,7 @@ namespace llarp
return;
}
if (not exit.FromString(arg))
if (arg != "null" and not exit.FromString(arg))
{
throw std::invalid_argument(stringify("[network]:exit-node bad address: ", arg));
}

@ -929,6 +929,8 @@ namespace llarp
else
{
const auto addr = *exits.begin();
if (addr.IsZero()) // drop
return;
pkt.ZeroSourceAddress();
MarkAddressOutbound(addr);
EnsurePathToService(

@ -488,7 +488,14 @@ namespace llarp::rpc
}
else if (lnsExit.has_value())
{
ep->LookupNameAsync(*lnsExit, [reply, mapExit](auto maybe) mutable {
const std::string name = *lnsExit;
if (name == "null")
{
service::Address nullAddr{};
mapExit(nullAddr);
return;
}
ep->LookupNameAsync(name, [reply, mapExit](auto maybe) mutable {
if (not maybe.has_value())
{
reply(CreateJSONError("we could not find an exit with that name"));
@ -496,7 +503,10 @@ namespace llarp::rpc
}
if (auto ptr = std::get_if<service::Address>(&*maybe))
{
mapExit(*ptr);
if (ptr->IsZero())
reply(CreateJSONError("name does not exist"));
else
mapExit(*ptr);
}
else
{

@ -1847,7 +1847,8 @@ namespace llarp
void
Endpoint::MapExitRange(IPRange range, Address exit)
{
LogInfo(Name(), " map ", range, " to exit at ", exit);
if (not exit.IsZero())
LogInfo(Name(), " map ", range, " to exit at ", exit);
m_ExitMap.Insert(range, exit);
}
@ -1858,7 +1859,7 @@ namespace llarp
m_ExitMap.RemoveIf([&](const auto& item) -> bool {
if (not range.Contains(item.first))
return false;
LogInfo(Name(), " unmap ", item.first, " from exit at ", item.second);
LogInfo(Name(), " unmap ", item.first, " exit range mapping");
return true;
});
}

Loading…
Cancel
Save