mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-04-22 16:09:12 +00:00
Test each address returned in the getaddrinfo() call and stop blindly preferring IPv4
Fixes NAT64 on iOS 12 and probably other obscure configurations
This commit is contained in:
@@ -52,18 +52,12 @@ int LiFindExternalAddressIP4(const char* stunServer, unsigned short stunPort, un
|
||||
char buf[1024];
|
||||
} resp;
|
||||
|
||||
err = resolveHostName(stunServer, &stunAddr, &stunAddrLen);
|
||||
err = resolveHostName(stunServer, AF_INET, 0, &stunAddr, &stunAddrLen);
|
||||
if (err != 0) {
|
||||
Limelog("Failed to resolve STUN server: %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
// We must use IPv4 to talk to the STUN server to get our IPv4 address back
|
||||
if (stunAddr.ss_family != AF_INET) {
|
||||
Limelog("STUN server was not reachable over IPv4\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sock = bindUdpSocket(AF_INET, 2048);
|
||||
if (sock == INVALID_SOCKET) {
|
||||
err = LastSocketFail();
|
||||
|
||||
Reference in New Issue
Block a user