Implement support for the HAProxy proxy protocol
[quassel.git] / src / common / proxyline.h
diff --git a/src/common/proxyline.h b/src/common/proxyline.h
new file mode 100644 (file)
index 0000000..4fb2e9e
--- /dev/null
@@ -0,0 +1,39 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2020 by the Quassel Project                        *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
+ ***************************************************************************/
+
+#pragma once
+
+#include <QAbstractSocket>
+#include <QByteArray>
+#include <QHostAddress>
+
+#include "common-export.h"
+
+struct COMMON_EXPORT ProxyLine
+{
+    QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::UnknownNetworkLayerProtocol;
+    QHostAddress sourceHost;
+    uint16_t sourcePort;
+    QHostAddress targetHost;
+    uint16_t targetPort;
+
+    static ProxyLine parseProxyLine(const QByteArray& line);
+    friend COMMON_EXPORT QDebug operator<<(QDebug dbg, const ProxyLine& p);
+};