Skip to content

Commit

Permalink
Added warning log for testing purpose on GetIPList function
Browse files Browse the repository at this point in the history
  • Loading branch information
anr2me committed Apr 12, 2021
1 parent a7d7631 commit 84d7d74
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Common/Net/Resolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void DNSResolveFree(addrinfo *res)
bool GetIPList(std::vector<std::string> &IP4s) {
char ipstr[INET6_ADDRSTRLEN]; // We use IPv6 length since it's longer than IPv4
#if defined(getifaddrs) // On Android: Requires __ANDROID_API__ >= 24
WARN_LOG(SCENET, "GetIPList from defined(getifaddrs)");
struct ifaddrs* ifAddrStruct = NULL;
struct ifaddrs* ifa = NULL;

Expand Down Expand Up @@ -134,6 +135,7 @@ bool GetIPList(std::vector<std::string> &IP4s) {
return true;
}
#elif defined(SIOCGIFCONF) // Better detection on Linux/UNIX/MacOS/some Android
WARN_LOG(SCENET, "GetIPList from defined(SIOCGIFCONF)");
#include <linux/if.h>
static struct ifreq ifreqs[32];
struct ifconf ifconf;
Expand Down Expand Up @@ -166,6 +168,7 @@ bool GetIPList(std::vector<std::string> &IP4s) {
close(sd);
return true;
#else // Fallback to POSIX/Cross-platform way but may not works well on Linux (ie. only shows 127.0.0.1)
WARN_LOG(SCENET, "GetIPList from Fallback");
struct addrinfo hints, * res, * p;
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; // AF_INET or AF_INET6 to force version
Expand Down

0 comments on commit 84d7d74

Please sign in to comment.