Skip to content

Commit

Permalink
getLocalIp: Have the fallback path keep looking if the IP found is 12…
Browse files Browse the repository at this point in the history
…7.0.0.1

Fixes #19919
  • Loading branch information
hrydgard committed Jan 28, 2025
1 parent 41b93c8 commit ae2d5c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Core/HLE/proAdhoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,7 @@ int getLocalIp(sockaddr_in* SocketAddress) {

// Fallback if not connected to AdhocServer
// getifaddrs first appeared in glibc 2.3, On Android officially supported since __ANDROID_API__ >= 24
#if defined(_IFADDRS_H_) || (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || (__ANDROID_API__ >= 24)
#if (defined(_IFADDRS_H_) || (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || (__ANDROID_API__ >= 24))
struct ifaddrs* ifAddrStruct = NULL;
struct ifaddrs* ifa = NULL;

Expand All @@ -1808,7 +1808,11 @@ int getLocalIp(sockaddr_in* SocketAddress) {
if (ifa->ifa_addr->sa_family == AF_INET) { // check it is IP4
// is a valid IP4 Address
SocketAddress->sin_addr = ((struct sockaddr_in*)ifa->ifa_addr)->sin_addr;
break;
u32 addr = ((struct sockaddr_in*)ifa->ifa_addr)->sin_addr.s_addr;
if (addr != 0x0100007f) { // 127.0.0.1
// Found a plausible one
break;
}
}
}
freeifaddrs(ifAddrStruct);
Expand Down

0 comments on commit ae2d5c1

Please sign in to comment.