diff options
Diffstat (limited to 'drivers/unix/ip_unix.cpp')
| -rw-r--r-- | drivers/unix/ip_unix.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index 8d46495e1..feb1809fc 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -127,6 +127,15 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { using namespace Windows::Networking; using namespace Windows::Networking::Connectivity; + auto hostnames = NetworkInformation::GetHostNames(); + + for (int i = 0; i < hostnames->Size; i++) { + + if (hostnames->GetAt(i)->Type == HostNameType::Ipv4 && hostnames->GetAt(i)->IPInformation != nullptr) { + + r_addresses->push_back(IP_Address(String(hostnames->GetAt(i)->CanonicalName->Data()))); + } + } auto hostnames = NetworkInformation::GetHostNames(); @@ -148,10 +157,7 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { while (true) { addrs = (IP_ADAPTER_ADDRESSES *)memalloc(buf_size); - int err = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | - GAA_FLAG_SKIP_MULTICAST | - GAA_FLAG_SKIP_DNS_SERVER | - GAA_FLAG_SKIP_FRIENDLY_NAME, + int err = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME, NULL, addrs, &buf_size); if (err == NO_ERROR) { break; |
