From 066e5cdaa0d28a0efa7931a1d324013a0a7db8c6 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Wed, 26 Aug 2015 21:16:01 +0200 Subject: exclude loopback addresses --- src/base/QXmppStun.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/base/QXmppStun.cpp') diff --git a/src/base/QXmppStun.cpp b/src/base/QXmppStun.cpp index d41231ac..b8313881 100644 --- a/src/base/QXmppStun.cpp +++ b/src/base/QXmppStun.cpp @@ -118,6 +118,11 @@ static bool isIPv6LinkLocalAddress(const QHostAddress &addr) return (((ipv6addr[0] << 8) + ipv6addr[1]) & 0xffc0) == 0xfe80; } +static bool isLoopbackAddress(const QHostAddress &addr) +{ + return (addr.toIPv4Address() & 0xff000000) == 0x7f000000; +} + static bool decodeAddress(QDataStream &stream, quint16 a_length, QHostAddress &address, quint16 &port, const QByteArray &xorId = QByteArray()) { if (a_length < 4) @@ -2427,6 +2432,11 @@ QList QXmppIceComponent::discoverAddresses() entry.netmask().isNull()) continue; + // FIXME: for some reason we can have loopback addresses + // even if the interface does not have the loopback flag + if (isLoopbackAddress(ip)) + continue; + // FIXME: for now skip IPv6 link-local addresses, seems to upset // clients such as empathy if (isIPv6LinkLocalAddress(ip)) { -- cgit v1.2.3