Don't bind to temporary Ipv6 addresses (windows)

This commit is contained in:
Grant Limberg 2021-05-26 09:15:24 -07:00
parent 810e2a761f
commit 198e6f765c

View file

@ -135,21 +135,25 @@ public:
while (a) { while (a) {
PIP_ADAPTER_UNICAST_ADDRESS ua = a->FirstUnicastAddress; PIP_ADAPTER_UNICAST_ADDRESS ua = a->FirstUnicastAddress;
while (ua) { while (ua) {
InetAddress ip(ua->Address.lpSockaddr); // Don't bind temporary/random IPv6 addresses
char strBuf[128] = { 0 }; if (ua->SuffixOrigin != IpSuffixOriginRandom) {
wcstombs(strBuf, a->FriendlyName, sizeof(strBuf)); InetAddress ip(ua->Address.lpSockaddr);
if (ifChecker.shouldBindInterface(strBuf,ip)) { char strBuf[128] = { 0 };
switch(ip.ipScope()) { wcstombs(strBuf, a->FriendlyName, sizeof(strBuf));
default: break; if (ifChecker.shouldBindInterface(strBuf, ip)) {
case InetAddress::IP_SCOPE_PSEUDOPRIVATE: switch (ip.ipScope()) {
case InetAddress::IP_SCOPE_GLOBAL: default:
case InetAddress::IP_SCOPE_SHARED: break;
case InetAddress::IP_SCOPE_PRIVATE: case InetAddress::IP_SCOPE_PSEUDOPRIVATE:
for(int x=0;x<(int)portCount;++x) { case InetAddress::IP_SCOPE_GLOBAL:
ip.setPort(ports[x]); case InetAddress::IP_SCOPE_SHARED:
localIfAddrs.insert(std::pair<InetAddress,std::string>(ip,std::string())); case InetAddress::IP_SCOPE_PRIVATE:
} for (int x = 0; x < (int)portCount; ++x) {
break; ip.setPort(ports[x]);
localIfAddrs.insert(std::pair<InetAddress, std::string>(ip, std::string()));
}
break;
}
} }
} }
ua = ua->Next; ua = ua->Next;