1
1
Fork 0
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:
Jason Rhinelander 2022-09-14 18:20:35 -03:00
parent 517911b499
commit 45b3365002
No known key found for this signature in database
GPG key ID: C4992CE7A88D4262

View file

@ -7,10 +7,7 @@
namespace llarp
{
namespace
{
auto logcat = log::Cat("route-poker");
}
static auto logcat = log::Cat("route-poker");
void
RoutePoker::AddRoute(net::ipv4addr_t ip)
@ -157,16 +154,8 @@ namespace llarp
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
if (not is_equal(m_CurrentGateway, next_gw))
if (not(m_CurrentGateway == next_gw))
{
if (next_gw and m_CurrentGateway)
{
@ -224,7 +213,7 @@ namespace llarp
route.AddDefaultRouteViaInterface(*vpn);
log::info(logcat, "route poker up");
}
if(not m_up)
if (not m_up)
SetDNSMode(true);
m_up = true;
}
@ -249,7 +238,7 @@ namespace llarp
route.DelBlackhole();
log::info(logcat, "route poker down");
}
if(m_up)
if (m_up)
SetDNSMode(false);
m_up = false;
}