Skip to content

Commit

Permalink
Fixed|libcore: Querying the local IP addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 13, 2016
1 parent e3b7bc2 commit 8e006bd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions doomsday/sdk/libcore/src/net/address.cpp
Expand Up @@ -21,6 +21,7 @@
#include "de/String"

#include <QHostInfo>
#include <QNetworkInterface>
#include <QRegularExpression>

namespace de {
Expand Down Expand Up @@ -169,10 +170,10 @@ bool Address::isHostLocal(QHostAddress const &host) // static
{
if (host.isLoopback()) return true;

QHostInfo const info = QHostInfo::fromName(QHostInfo::localHostName());
foreach (QHostAddress addr, info.addresses())
QHostAddress const hostv6(host.toIPv6Address());
foreach (QHostAddress addr, QNetworkInterface::allAddresses())
{
if (QHostAddress(addr.toIPv6Address()) == host)
if (QHostAddress(addr.toIPv6Address()) == hostv6)
return true;
}
return false;
Expand Down

0 comments on commit 8e006bd

Please sign in to comment.