mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
Windows fix: iterate over IPv4/IPv6 interfaces separately
If we get back an IPv6 address as the first gateway then we won't have the expected IPv4 gateway that the route poker needs to operate. This iterates through them separately so that we treat the IPv4 and IPv6 sides of an address as separate interfaces which should allow the route poker to find the one it wants (and just skip the IPv6 one).
This commit is contained in:
parent
e398b5bff8
commit
6f31d5108b
|
@ -171,7 +171,9 @@ namespace llarp::net
|
||||||
AllNetworkInterfaces() const override
|
AllNetworkInterfaces() const override
|
||||||
{
|
{
|
||||||
std::vector<InterfaceInfo> all;
|
std::vector<InterfaceInfo> all;
|
||||||
iter_adapters([&all](auto* a) {
|
for (int af : {AF_INET, AF_INET6})
|
||||||
|
iter_adapters(
|
||||||
|
[&all](auto* a) {
|
||||||
auto& cur = all.emplace_back();
|
auto& cur = all.emplace_back();
|
||||||
cur.index = a->IfIndex;
|
cur.index = a->IfIndex;
|
||||||
cur.name = a->AdapterName;
|
cur.name = a->AdapterName;
|
||||||
|
@ -180,14 +182,16 @@ namespace llarp::net
|
||||||
SockAddr saddr{*addr->Address.lpSockaddr};
|
SockAddr saddr{*addr->Address.lpSockaddr};
|
||||||
cur.addrs.emplace_back(
|
cur.addrs.emplace_back(
|
||||||
saddr.asIPv6(),
|
saddr.asIPv6(),
|
||||||
ipaddr_netmask_bits(addr->OnLinkPrefixLength, addr->Address.lpSockaddr->sa_family));
|
ipaddr_netmask_bits(
|
||||||
|
addr->OnLinkPrefixLength, addr->Address.lpSockaddr->sa_family));
|
||||||
}
|
}
|
||||||
if (auto* addr = a->FirstGatewayAddress)
|
if (auto* addr = a->FirstGatewayAddress)
|
||||||
{
|
{
|
||||||
SockAddr gw{*addr->Address.lpSockaddr};
|
SockAddr gw{*addr->Address.lpSockaddr};
|
||||||
cur.gateway = gw.getIP();
|
cur.gateway = gw.getIP();
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
af);
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue