Fix crash with KDE network detection
[quassel.git] / src / common / authhandler.cpp
index 9148e21..7c2905d 100644 (file)
@@ -18,6 +18,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include <QHostAddress>
+
 #include "authhandler.h"
 
 AuthHandler::AuthHandler(QObject *parent)
@@ -43,6 +45,16 @@ void AuthHandler::setSocket(QTcpSocket *socket)
 }
 
 
+bool AuthHandler::isLocal() const
+{
+    if (socket()) {
+        if (socket()->peerAddress() == QHostAddress::LocalHost || socket()->peerAddress() == QHostAddress::LocalHostIPv6)
+            return true;
+    }
+    return false;
+}
+
+
 // Some errors (e.g. connection refused) don't trigger a disconnected() from the socket, so send this explicitly
 // (but make sure it's only sent once!)
 void AuthHandler::onSocketError(QAbstractSocket::SocketError error)