Merge pull request #2021 from tewinget/route-metric-preference

select gateway with lowest metric
This commit is contained in:
Jason Rhinelander 2022-10-20 14:43:45 -03:00 committed by GitHub
commit 02108f0504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -147,13 +147,16 @@ namespace llarp
auto& route = platform->RouteManager();
// find current gateways
// get current gateways, assume sorted by lowest metric first
auto gateways = route.GetGatewaysNotOnInterface(*vpn);
std::optional<net::ipv4addr_t> next_gw;
for (auto& gateway : gateways)
{
if (auto* gw_ptr = std::get_if<net::ipv4addr_t>(&gateway))
{
next_gw = *gw_ptr;
break;
}
}
// update current gateway and apply state changes as needed