@ -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,8 +213,8 @@ 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,8 +238,8 @@ 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 ;
}
}