1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

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

triggered by: exit-node=null
This commit is contained in:
Jeff Becker 2021-04-05 15:53:47 -04:00
parent 2ed0ab1ca1
commit 94ecf02a62
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05
4 changed files with 18 additions and 5 deletions

View file

@ -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));
}

View file

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

View file

@ -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
{

View file

@ -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;
});
}