mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
Simplifications
- a `static` is less verbose and otherwise identical to an empty namespace for a single declaration like this. - operator== on two optionals already does exactly what the `is_equal` lambda here is doing. - formatting
This commit is contained in:
parent
517911b499
commit
45b3365002
1 changed files with 6 additions and 17 deletions
|
@ -7,10 +7,7 @@
|
||||||
|
|
||||||
namespace llarp
|
namespace llarp
|
||||||
{
|
{
|
||||||
namespace
|
static auto logcat = log::Cat("route-poker");
|
||||||
{
|
|
||||||
auto logcat = log::Cat("route-poker");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RoutePoker::AddRoute(net::ipv4addr_t ip)
|
RoutePoker::AddRoute(net::ipv4addr_t ip)
|
||||||
|
@ -157,16 +154,8 @@ namespace llarp
|
||||||
next_gw = *gw_ptr;
|
next_gw = *gw_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto is_equal = [](auto lhs, auto rhs) {
|
|
||||||
if (lhs == std::nullopt and rhs == std::nullopt)
|
|
||||||
return true;
|
|
||||||
if (lhs and rhs)
|
|
||||||
return *lhs == *rhs;
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// update current gateway and apply state chnages as needed
|
// update current gateway and apply state chnages as needed
|
||||||
if (not is_equal(m_CurrentGateway, next_gw))
|
if (not(m_CurrentGateway == next_gw))
|
||||||
{
|
{
|
||||||
if (next_gw and m_CurrentGateway)
|
if (next_gw and m_CurrentGateway)
|
||||||
{
|
{
|
||||||
|
@ -224,7 +213,7 @@ namespace llarp
|
||||||
route.AddDefaultRouteViaInterface(*vpn);
|
route.AddDefaultRouteViaInterface(*vpn);
|
||||||
log::info(logcat, "route poker up");
|
log::info(logcat, "route poker up");
|
||||||
}
|
}
|
||||||
if(not m_up)
|
if (not m_up)
|
||||||
SetDNSMode(true);
|
SetDNSMode(true);
|
||||||
m_up = true;
|
m_up = true;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +238,7 @@ namespace llarp
|
||||||
route.DelBlackhole();
|
route.DelBlackhole();
|
||||||
log::info(logcat, "route poker down");
|
log::info(logcat, "route poker down");
|
||||||
}
|
}
|
||||||
if(m_up)
|
if (m_up)
|
||||||
SetDNSMode(false);
|
SetDNSMode(false);
|
||||||
m_up = false;
|
m_up = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue