Linux route poker fixes

- don't add routes when not in exit mode
- don't call Up() from rpc code (the RouterPoker itself decides when to
  call Up())
pull/1969/head
Jason Rhinelander 2 years ago
parent e9554c7c5e
commit 613459401d
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262

@ -12,6 +12,8 @@ namespace llarp
void
RoutePoker::AddRoute(net::ipv4addr_t ip)
{
if (not m_up)
return;
bool has_existing = m_PokedRoutes.count(ip);
// set up route and apply as needed
auto& gw = m_PokedRoutes[ip];
@ -162,10 +164,7 @@ namespace llarp
log::info(logcat, "default gateway changed from {} to {}", *m_CurrentGateway, *next_gw);
m_CurrentGateway = next_gw;
m_Router->Thaw();
if (m_Router->HasClientExit())
Up();
else
RefreshAllRoutes();
RefreshAllRoutes();
}
else if (m_CurrentGateway)
{
@ -196,8 +195,12 @@ namespace llarp
void
RoutePoker::Up()
{
if (IsEnabled() and m_CurrentGateway and not m_up)
bool was_up = m_up;
m_up = true;
if (IsEnabled() and m_CurrentGateway and not was_up)
{
log::info(logcat, "RoutePoker coming up; poking routes");
vpn::IRouteManager& route = m_Router->GetVPNPlatform()->RouteManager();
// black hole all routes if enabled
@ -213,9 +216,8 @@ namespace llarp
route.AddDefaultRouteViaInterface(*vpn);
log::info(logcat, "route poker up");
}
if (not m_up)
if (not was_up)
SetDNSMode(true);
m_up = true;
}
void

@ -517,7 +517,6 @@ namespace llarp::rpc
auto mapExit = [=](service::Address addr) mutable {
ep->MapExitRange(range, addr);
r->routePoker()->Up();
bool shouldSendAuth = false;
if (token.has_value())
{

Loading…
Cancel
Save