modernize: Use raw string literals instead of escaped strings
[quassel.git] / src / common / authhandler.cpp
index 9148e21..6794730 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2014 by the Quassel Project                        *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include <QHostAddress>
+
 #include "authhandler.h"
 
 AuthHandler::AuthHandler(QObject *parent)
-    : QObject(parent),
-    _socket(0),
-    _disconnectedSent(false)
+    : QObject(parent)
 {
 
 }
@@ -43,6 +43,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)