diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index ba932c4c1..aaa0d1175 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -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)); } diff --git a/llarp/handlers/tun.cpp b/llarp/handlers/tun.cpp index 1eea6df0e..6cb923842 100644 --- a/llarp/handlers/tun.cpp +++ b/llarp/handlers/tun.cpp @@ -929,6 +929,8 @@ namespace llarp else { const auto addr = *exits.begin(); + if (addr.IsZero()) // drop + return; pkt.ZeroSourceAddress(); MarkAddressOutbound(addr); EnsurePathToService( diff --git a/llarp/rpc/rpc_server.cpp b/llarp/rpc/rpc_server.cpp index 5a5ecf11b..3f56cb759 100644 --- a/llarp/rpc/rpc_server.cpp +++ b/llarp/rpc/rpc_server.cpp @@ -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(&*maybe)) { - mapExit(*ptr); + if (ptr->IsZero()) + reply(CreateJSONError("name does not exist")); + else + mapExit(*ptr); } else { diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index 0551413fe..2b2bb5553 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -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; }); }