Merge pull request #1818 from majestrate/toggle-route-poker-2021-12-04

configurable route poker
This commit is contained in:
majestrate 2021-12-26 10:58:50 -05:00 committed by GitHub
commit 94611eda19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 4 deletions

View File

@ -533,6 +533,19 @@ namespace llarp
m_ExitAuths.emplace(exit, auth);
});
conf.defineOption<bool>(
"network",
"auto-routing",
ClientOnly,
Default{true},
Comment{
"Enable / disable automatic route configuration.",
"When this is enabled and an exit is used Lokinet will automatically configure "
"operating system routes to route traffic through the exit node.",
"This is enabled by default, but can be disabled to perform advanced exit routing "
"configuration manually."},
AssignmentAcceptor(m_EnableRoutePoker));
conf.defineOption<std::string>(
"network",
"ifname",

View File

@ -129,6 +129,8 @@ namespace llarp
std::optional<fs::path> m_AddrMapPersistFile;
bool m_EnableRoutePoker;
void
defineConfigOptions(ConfigDefinition& conf, const ConfigGenParameters& params);
};

View File

@ -162,10 +162,13 @@ namespace llarp
if (m_Enabled)
return;
m_Enabling = true;
Update();
m_Enabling = false;
m_Enabled = true;
if (m_Router->GetConfig()->network.m_EnableRoutePoker)
{
m_Enabling = true;
Update();
m_Enabling = false;
m_Enabled = true;
}
systemd_resolved_set_dns(
m_Router->hiddenServiceContext().GetDefault()->GetIfName(),
@ -191,6 +194,9 @@ namespace llarp
void
RoutePoker::Up()
{
if (not m_Router->GetConfig()->network.m_EnableRoutePoker)
return;
vpn::IRouteManager& route = m_Router->GetVPNPlatform()->RouteManager();
// black hole all routes by default
@ -207,6 +213,9 @@ namespace llarp
void
RoutePoker::Down()
{
if (not m_Router->GetConfig()->network.m_EnableRoutePoker)
return;
// unpoke routes for first hops
m_Router->ForEachPeer(
[&](auto session, auto) mutable { DelRoute(session->GetRemoteEndpoint().asIPv4()); },