Merge branch 'fix/internet' into play
This commit is contained in:
commit
db66662a8b
|
@ -708,24 +708,28 @@ void Socket::getLocalIPAddressListForPlatform(std::vector<std::string> &ipList)
|
|||
// Now check all linux network devices
|
||||
struct ifaddrs *ifap = NULL;
|
||||
getifaddrs(&ifap);
|
||||
for(struct ifaddrs *ifa = ifap; ifa; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr->sa_family == AF_INET) {
|
||||
for(struct ifaddrs *ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (!ifa->ifa_addr) {
|
||||
continue;
|
||||
}
|
||||
if (ifa->ifa_addr->sa_family == AF_INET) { // check it is IP4
|
||||
// is a valid IP4 Address
|
||||
struct sockaddr_in *sa = (struct sockaddr_in *) ifa->ifa_addr;
|
||||
char *addr = inet_ntoa(sa->sin_addr);
|
||||
//printf("Interface: %s\tAddress: %s\n", ifa->ifa_name, addr);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Interface: [%s] address: [%s]\n",__FILE__,__FUNCTION__,__LINE__,ifa->ifa_name,addr);
|
||||
}
|
||||
if(strlen(addr) > 0 &&
|
||||
strncmp(addr,"127.",4) != 0 &&
|
||||
strncmp(addr,"0.",2) != 0) {
|
||||
if(std::find(ipList.begin(),ipList.end(),addr) == ipList.end()) {
|
||||
ipList.push_back(addr);
|
||||
}
|
||||
}
|
||||
if(strlen(addr) > 0 &&
|
||||
strncmp(addr,"127.",4) != 0 &&
|
||||
strncmp(addr,"0.",2) != 0) {
|
||||
if(std::find(ipList.begin(),ipList.end(),addr) == ipList.end()) {
|
||||
ipList.push_back(addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
freeifaddrs(ifap);
|
||||
if (ifap != NULL) freeifaddrs(ifap);
|
||||
|
||||
if(Socket::intfTypes.empty()) {
|
||||
Socket::intfTypes.push_back("lo");
|
||||
|
|
Loading…
Reference in New Issue