mirror of https://github.com/oxen-io/lokinet
Merge pull request #1818 from majestrate/toggle-route-poker-2021-12-04
configurable route poker
This commit is contained in:
commit
94611eda19
|
@ -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",
|
||||
|
|
|
@ -129,6 +129,8 @@ namespace llarp
|
|||
|
||||
std::optional<fs::path> m_AddrMapPersistFile;
|
||||
|
||||
bool m_EnableRoutePoker;
|
||||
|
||||
void
|
||||
defineConfigOptions(ConfigDefinition& conf, const ConfigGenParameters& params);
|
||||
};
|
||||
|
|
|
@ -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()); },
|
||||
|
|
Loading…
Reference in New Issue