mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-11-30 01:34:05 +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:
1 parent
d9210a6a9a
commit
396b02a94d
4 files changed
+41
-35
No files matched your search
+1
-7
@@ -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