Fix client test applications and implement tunnel client utils
This commit is contained in:
parent
6d4ff26481
commit
3eb247e652
@ -162,22 +162,25 @@ int main(int argc, char *argv[])
|
|||||||
qCCritical(dcProxyClient()) << "Invalid proxy server url passed." << parser.value(urlOption);
|
qCCritical(dcProxyClient()) << "Invalid proxy server url passed." << parser.value(urlOption);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
qCDebug(dcProxyClient()) << "Using URL" << serverUrl;
|
||||||
|
|
||||||
QUuid uuid(parser.value(uuidOption));
|
QUuid uuid(parser.value(uuidOption));
|
||||||
if (uuid.isNull()) {
|
if (uuid.isNull()) {
|
||||||
uuid = QUuid::createUuid();
|
uuid = QUuid::createUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProxyClient *client = nullptr;
|
||||||
if (parser.isSet(tcpOption)) {
|
if (parser.isSet(tcpOption)) {
|
||||||
ProxyClient client(parser.value(nameOption), uuid, RemoteProxyConnection::ConnectionTypeTcpSocket);
|
qCDebug(dcProxyClient()) << "Using TCP as transport layer";
|
||||||
client.setInsecure(parser.isSet(insecureOption));
|
client = new ProxyClient(parser.value(nameOption), uuid, RemoteProxyConnection::ConnectionTypeTcpSocket);
|
||||||
client.setPingpong(parser.isSet(pingPongOption));
|
client->setInsecure(parser.isSet(insecureOption));
|
||||||
client.start(serverUrl, parser.value(tokenOption), parser.value(nonceOption));
|
client->setPingpong(parser.isSet(pingPongOption));
|
||||||
|
client->start(serverUrl, parser.value(tokenOption), parser.value(nonceOption));
|
||||||
} else {
|
} else {
|
||||||
ProxyClient client(parser.value(nameOption), uuid, RemoteProxyConnection::ConnectionTypeWebSocket);
|
client = new ProxyClient(parser.value(nameOption), uuid, RemoteProxyConnection::ConnectionTypeWebSocket);
|
||||||
client.setInsecure(parser.isSet(insecureOption));
|
client->setInsecure(parser.isSet(insecureOption));
|
||||||
client.setPingpong(parser.isSet(pingPongOption));
|
client->setPingpong(parser.isSet(pingPongOption));
|
||||||
client.start(serverUrl, parser.value(tokenOption), parser.value(nonceOption));
|
client->start(serverUrl, parser.value(tokenOption), parser.value(nonceOption));
|
||||||
}
|
}
|
||||||
|
|
||||||
return application.exec();
|
return application.exec();
|
||||||
|
|||||||
@ -158,7 +158,6 @@ void SslServer::incomingConnection(qintptr socketDescriptor)
|
|||||||
emit clientConnected(sslSocket);
|
emit clientConnected(sslSocket);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &);
|
typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &);
|
||||||
connect(sslSocket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, [](const QList<QSslError> &errors) {
|
connect(sslSocket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, [](const QList<QSslError> &errors) {
|
||||||
qCWarning(dcTcpSocketServer()) << "SSL Errors happened in the client connections:";
|
qCWarning(dcTcpSocketServer()) << "SSL Errors happened in the client connections:";
|
||||||
|
|||||||
@ -53,11 +53,6 @@ void ProxyConnection::setConnected(bool connected)
|
|||||||
emit connectedChanged(m_connected);
|
emit connectedChanged(m_connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyConnection::setServerUrl(const QUrl &serverUrl)
|
|
||||||
{
|
|
||||||
m_serverUrl = serverUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProxyConnection::~ProxyConnection()
|
ProxyConnection::~ProxyConnection()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,7 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSslError>
|
#include <QSslError>
|
||||||
|
#include <QSslConfiguration>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
|
||||||
namespace remoteproxyclient {
|
namespace remoteproxyclient {
|
||||||
@ -53,11 +54,11 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_connected = false;
|
bool m_connected = false;
|
||||||
QUrl m_serverUrl;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
QUrl m_serverUrl;
|
||||||
|
|
||||||
void setConnected(bool connected);
|
void setConnected(bool connected);
|
||||||
void setServerUrl(const QUrl &serverUrl);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectedChanged(bool connected);
|
void connectedChanged(bool connected);
|
||||||
|
|||||||
@ -36,18 +36,26 @@ TcpSocketConnection::TcpSocketConnection(QObject *parent) :
|
|||||||
{
|
{
|
||||||
m_tcpSocket = new QSslSocket(this);
|
m_tcpSocket = new QSslSocket(this);
|
||||||
|
|
||||||
connect(m_tcpSocket, &QSslSocket::disconnected, this, &TcpSocketConnection::onDisconnected);
|
QObject::connect(m_tcpSocket, &QSslSocket::connected, this, [=](){ qCDebug(dcRemoteProxyClientTcpSocket()) << "Connected!!!!"; });
|
||||||
connect(m_tcpSocket, &QSslSocket::encrypted, this, &TcpSocketConnection::onEncrypted);
|
QObject::connect(m_tcpSocket, &QSslSocket::disconnected, this, &TcpSocketConnection::onDisconnected);
|
||||||
connect(m_tcpSocket, &QSslSocket::readyRead, this, &TcpSocketConnection::onReadyRead);
|
QObject::connect(m_tcpSocket, &QSslSocket::encrypted, this, &TcpSocketConnection::onEncrypted);
|
||||||
|
QObject::connect(m_tcpSocket, &QSslSocket::readyRead, this, &TcpSocketConnection::onReadyRead);
|
||||||
|
QObject::connect(m_tcpSocket, &QSslSocket::stateChanged, this, &TcpSocketConnection::onStateChanged);
|
||||||
|
|
||||||
typedef void (QSslSocket:: *errorSignal)(QAbstractSocket::SocketError);
|
typedef void (QSslSocket:: *errorSignal)(QAbstractSocket::SocketError);
|
||||||
connect(m_tcpSocket, static_cast<errorSignal>(&QSslSocket::error), this, &TcpSocketConnection::onError);
|
QObject::connect(m_tcpSocket, static_cast<errorSignal>(&QSslSocket::error), this, &TcpSocketConnection::onError);
|
||||||
connect(m_tcpSocket, &QSslSocket::stateChanged, this, &TcpSocketConnection::onStateChanged);
|
|
||||||
typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &);
|
typedef void (QSslSocket:: *sslErrorsSignal)(const QList<QSslError> &);
|
||||||
QObject::connect(m_tcpSocket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TcpSocketConnection::sslErrors);
|
QObject::connect(m_tcpSocket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors), this, &TcpSocketConnection::sslErrors);
|
||||||
|
|
||||||
|
// QObject::connect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onError(QAbstractSocket::SocketError)));
|
||||||
|
// QObject::connect(m_tcpSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SIGNAL(sslErrors(QList<QSslError>)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TcpSocketConnection::~TcpSocketConnection()
|
TcpSocketConnection::~TcpSocketConnection()
|
||||||
{
|
{
|
||||||
|
qCDebug(dcRemoteProxyClientTcpSocket()) << "Delete socket connection";
|
||||||
m_tcpSocket->close();
|
m_tcpSocket->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,21 +118,24 @@ void TcpSocketConnection::onReadyRead()
|
|||||||
|
|
||||||
void TcpSocketConnection::connectServer(const QUrl &serverUrl)
|
void TcpSocketConnection::connectServer(const QUrl &serverUrl)
|
||||||
{
|
{
|
||||||
setServerUrl(serverUrl);
|
m_serverUrl = serverUrl;
|
||||||
if (serverUrl.scheme() == "tcp") {
|
|
||||||
qCDebug(dcRemoteProxyClientTcpSocket()) << "Connecting to" << this->serverUrl().toString();
|
if (m_serverUrl.scheme() == "tcp") {
|
||||||
m_tcpSocket->connectToHost(QHostAddress(this->serverUrl().host()), static_cast<quint16>(this->serverUrl().port()));
|
qCDebug(dcRemoteProxyClientTcpSocket()) << "Connecting to" << m_serverUrl.toString();
|
||||||
|
m_tcpSocket->connectToHost(QHostAddress(m_serverUrl.host()), static_cast<quint16>(m_serverUrl.port()));
|
||||||
} else {
|
} else {
|
||||||
m_ssl = true;
|
m_ssl = true;
|
||||||
qCDebug(dcRemoteProxyClientTcpSocket()) << "Connecting encrypted to" << this->serverUrl().toString();
|
qCDebug(dcRemoteProxyClientTcpSocket()) << "Connecting encrypted to" << m_serverUrl.host() + ":" + QString::number(m_serverUrl.port());
|
||||||
m_tcpSocket->connectToHostEncrypted(this->serverUrl().host(), static_cast<quint16>(this->serverUrl().port()));
|
m_tcpSocket->connectToHostEncrypted(m_serverUrl.host(), static_cast<quint16>(m_serverUrl.port()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TcpSocketConnection::disconnectServer()
|
void TcpSocketConnection::disconnectServer()
|
||||||
{
|
{
|
||||||
qCDebug(dcRemoteProxyClientTcpSocket()) << "Disconnecting from" << serverUrl().toString();
|
qCDebug(dcRemoteProxyClientTcpSocket()) << "Disconnecting from" << serverUrl().toString();
|
||||||
|
m_tcpSocket->disconnectFromHost();
|
||||||
m_tcpSocket->close();
|
m_tcpSocket->close();
|
||||||
|
m_tcpSocket->abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#include "proxyconnection.h"
|
#include "proxyconnection.h"
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(dcRemoteProxyClienTcpSocket)
|
Q_DECLARE_LOGGING_CATEGORY(dcRemoteProxyClientTcpSocket)
|
||||||
|
|
||||||
namespace remoteproxyclient {
|
namespace remoteproxyclient {
|
||||||
|
|
||||||
|
|||||||
@ -32,8 +32,8 @@
|
|||||||
#include "proxyjsonrpcclient.h"
|
#include "proxyjsonrpcclient.h"
|
||||||
#include "../../common/slipdataprocessor.h"
|
#include "../../common/slipdataprocessor.h"
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(dcTunnelProxySocketServer, "dcTunnelProxySocketServer")
|
Q_LOGGING_CATEGORY(dcTunnelProxySocketServer, "TunnelProxySocketServer")
|
||||||
Q_LOGGING_CATEGORY(dcTunnelProxySocketServerTraffic, "dcTunnelProxySocketServerTraffic")
|
Q_LOGGING_CATEGORY(dcTunnelProxySocketServerTraffic, "TunnelProxySocketServerTraffic")
|
||||||
|
|
||||||
namespace remoteproxyclient {
|
namespace remoteproxyclient {
|
||||||
|
|
||||||
@ -109,7 +109,6 @@ QString TunnelProxySocketServer::remoteProxyApiVersion() const
|
|||||||
return m_remoteProxyApiVersion;
|
return m_remoteProxyApiVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TunnelProxySocketServer::startServer(const QUrl &serverUrl)
|
void TunnelProxySocketServer::startServer(const QUrl &serverUrl)
|
||||||
{
|
{
|
||||||
m_serverUrl = serverUrl;
|
m_serverUrl = serverUrl;
|
||||||
|
|||||||
@ -103,15 +103,15 @@ void WebSocketConnection::connectServer(const QUrl &serverUrl)
|
|||||||
if (connected()) {
|
if (connected()) {
|
||||||
m_webSocket->close();
|
m_webSocket->close();
|
||||||
}
|
}
|
||||||
setServerUrl(serverUrl);
|
m_serverUrl = serverUrl;
|
||||||
|
|
||||||
qCDebug(dcRemoteProxyClientWebSocket()) << "Connecting to" << this->serverUrl().toString();
|
qCDebug(dcRemoteProxyClientWebSocket()) << "Connecting to" << m_serverUrl.toString();
|
||||||
m_webSocket->open(this->serverUrl());
|
m_webSocket->open(this->serverUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketConnection::disconnectServer()
|
void WebSocketConnection::disconnectServer()
|
||||||
{
|
{
|
||||||
qCDebug(dcRemoteProxyClientWebSocket()) << "Disconnecting from" << serverUrl().toString();
|
qCDebug(dcRemoteProxyClientWebSocket()) << "Disconnecting from" << m_serverUrl.toString();
|
||||||
m_webSocket->close();
|
m_webSocket->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,51 @@
|
|||||||
#include "clientconnection.h"
|
#include "clientconnection.h"
|
||||||
|
|
||||||
ClientConnection::ClientConnection(QObject *parent) : QObject(parent)
|
ClientConnection::ClientConnection(const QUrl &serverUrl, const QString &name, const QUuid &uuid, const QUuid &serverUuid, bool insecure, QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
m_serverUrl(serverUrl),
|
||||||
|
m_name(name),
|
||||||
|
m_uuid(uuid),
|
||||||
|
m_serverUuid(serverUuid),
|
||||||
|
m_insecure(insecure)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_remoteConnection = new TunnelProxyRemoteConnection(m_uuid, m_name);
|
||||||
|
|
||||||
|
connect(m_remoteConnection, &TunnelProxyRemoteConnection::stateChanged, this, [this](TunnelProxyRemoteConnection::State state){
|
||||||
|
switch (state) {
|
||||||
|
case TunnelProxyRemoteConnection::StateRegister:
|
||||||
|
qDebug() << "Connected with" << m_remoteConnection->remoteProxyServer() << m_remoteConnection->remoteProxyServerName() << m_remoteConnection->remoteProxyServerVersion() << m_remoteConnection->remoteProxyApiVersion();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_remoteConnection, &TunnelProxyRemoteConnection::remoteConnectedChanged, this, [](bool remoteConnected){
|
||||||
|
qDebug() << "Remote connection " << (remoteConnected ? "established" : "disconnected");
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_remoteConnection, &TunnelProxyRemoteConnection::dataReady, this, [](const QByteArray &data){
|
||||||
|
qDebug() << "Data received" << data;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_remoteConnection, &TunnelProxyRemoteConnection::errorOccured, this, [](QAbstractSocket::SocketError error){
|
||||||
|
qWarning() << "Socket error occured" << error;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_remoteConnection, &TunnelProxyRemoteConnection::sslErrors, this, [=](const QList<QSslError> &errors){
|
||||||
|
if (m_insecure) {
|
||||||
|
m_remoteConnection->ignoreSslErrors(errors);
|
||||||
|
} else {
|
||||||
|
qWarning() << "SSL errors occured:";
|
||||||
|
foreach (const QSslError &sslError, errors) {
|
||||||
|
qWarning() << " --> " << sslError.errorString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientConnection::connectToServer()
|
||||||
|
{
|
||||||
|
m_remoteConnection->connectServer(m_serverUrl, m_serverUuid);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,30 @@
|
|||||||
#ifndef CLIENTCONNECTION_H
|
#ifndef CLIENTCONNECTION_H
|
||||||
#define CLIENTCONNECTION_H
|
#define CLIENTCONNECTION_H
|
||||||
|
|
||||||
|
#include <QUrl>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "tunnelproxy/tunnelproxyremoteconnection.h"
|
||||||
|
|
||||||
|
using namespace remoteproxyclient;
|
||||||
|
|
||||||
class ClientConnection : public QObject
|
class ClientConnection : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ClientConnection(QObject *parent = nullptr);
|
explicit ClientConnection(const QUrl &serverUrl, const QString &name, const QUuid &uuid, const QUuid &serverUuid, bool insecure, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
void connectToServer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QUrl m_serverUrl;
|
||||||
|
QString m_name;
|
||||||
|
QUuid m_uuid;
|
||||||
|
QUuid m_serverUuid;
|
||||||
|
bool m_insecure = false;
|
||||||
|
|
||||||
|
TunnelProxyRemoteConnection *m_remoteConnection = nullptr;
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -58,10 +58,18 @@ static void consoleLogHandler(QtMsgType type, const QMessageLogContext& context,
|
|||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QtInfoMsg:
|
case QtInfoMsg:
|
||||||
fprintf(stdout, "%s: %s\n", context.category, message.toUtf8().data());
|
if (context.category == QStringLiteral("default")) {
|
||||||
|
fprintf(stdout, "%s\n", message.toUtf8().data());
|
||||||
|
} else {
|
||||||
|
fprintf(stdout, "%s: %s\n", context.category, message.toUtf8().data());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
fprintf(stdout, "%s: %s\n", context.category, message.toUtf8().data());
|
if (context.category == QStringLiteral("default")) {
|
||||||
|
fprintf(stdout, "%s\n", message.toUtf8().data());
|
||||||
|
} else {
|
||||||
|
fprintf(stdout, "%s: %s\n", context.category, message.toUtf8().data());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case QtWarningMsg:
|
case QtWarningMsg:
|
||||||
fprintf(stdout, "%s%s: %s%s\n", warning, context.category, message.toUtf8().data(), normal);
|
fprintf(stdout, "%s%s: %s%s\n", warning, context.category, message.toUtf8().data(), normal);
|
||||||
@ -86,12 +94,15 @@ int main(int argc, char *argv[])
|
|||||||
application.setApplicationVersion(SERVER_VERSION_STRING);
|
application.setApplicationVersion(SERVER_VERSION_STRING);
|
||||||
|
|
||||||
// Default debug categories
|
// Default debug categories
|
||||||
s_loggingFilters.insert("ProxyClient", true);
|
|
||||||
s_loggingFilters.insert("RemoteProxyClientJsonRpc", false);
|
s_loggingFilters.insert("RemoteProxyClientJsonRpc", false);
|
||||||
s_loggingFilters.insert("RemoteProxyClientWebSocket", false);
|
|
||||||
s_loggingFilters.insert("RemoteProxyClientConnection", false);
|
|
||||||
s_loggingFilters.insert("RemoteProxyClientJsonRpcTraffic", false);
|
s_loggingFilters.insert("RemoteProxyClientJsonRpcTraffic", false);
|
||||||
|
s_loggingFilters.insert("RemoteProxyClientWebSocket", false);
|
||||||
|
s_loggingFilters.insert("RemoteProxyClientTcpSocket", false);
|
||||||
|
s_loggingFilters.insert("RemoteProxyClientConnection", false);
|
||||||
s_loggingFilters.insert("RemoteProxyClientConnectionTraffic", false);
|
s_loggingFilters.insert("RemoteProxyClientConnectionTraffic", false);
|
||||||
|
s_loggingFilters.insert("TunnelProxySocketServer", false);
|
||||||
|
s_loggingFilters.insert("TunnelProxySocketServerTraffic", false);
|
||||||
|
s_loggingFilters.insert("TunnelProxyRemoteConnection", false);
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
@ -118,13 +129,13 @@ int main(int argc, char *argv[])
|
|||||||
QCommandLineOption clientOption(QStringList() << "c" << "client", "Connect as tunnel proxy client connection. The server uuid is required.");
|
QCommandLineOption clientOption(QStringList() << "c" << "client", "Connect as tunnel proxy client connection. The server uuid is required.");
|
||||||
parser.addOption(clientOption);
|
parser.addOption(clientOption);
|
||||||
|
|
||||||
QCommandLineOption nameOption(QStringList() << "n" << "name", "The name of the connecting client.", "name");
|
QCommandLineOption nameOption(QStringList() << "n" << "name", "The name of the connecting client. If not specified a default name will be selected.", "name");
|
||||||
parser.addOption(nameOption);
|
parser.addOption(nameOption);
|
||||||
|
|
||||||
QCommandLineOption uuidOption(QStringList() << "u" << "uuid", "The uuid of the connecting client. If not specified, a new one will be created", "uuid");
|
QCommandLineOption uuidOption(QStringList() << "uuid", "The uuid of the connecting client. If not specified, a new one will be created.", "uuid");
|
||||||
parser.addOption(uuidOption);
|
parser.addOption(uuidOption);
|
||||||
|
|
||||||
QCommandLineOption serverUuidOption(QStringList() << "server-uuid", "The uuid of the server you want to connect to as client connection.");
|
QCommandLineOption serverUuidOption(QStringList() << "server-uuid", "The uuid of the server you want to connect to as client connection.", "uuid");
|
||||||
parser.addOption(serverUuidOption);
|
parser.addOption(serverUuidOption);
|
||||||
|
|
||||||
QCommandLineOption verboseOption(QStringList() << "verbose", "Print more information about the connection.");
|
QCommandLineOption verboseOption(QStringList() << "verbose", "Print more information about the connection.");
|
||||||
@ -166,23 +177,25 @@ int main(int argc, char *argv[])
|
|||||||
if (parser.isSet(verboseOption) || parser.isSet(veryVerboseOption)) {
|
if (parser.isSet(verboseOption) || parser.isSet(veryVerboseOption)) {
|
||||||
s_loggingFilters["default"] = true;
|
s_loggingFilters["default"] = true;
|
||||||
s_loggingFilters["TunnelProxySocketServer"] = true;
|
s_loggingFilters["TunnelProxySocketServer"] = true;
|
||||||
s_loggingFilters["RemoteProxyClientJsonRpc"] = true;
|
s_loggingFilters["TunnelProxyRemoteConnection"] = true;
|
||||||
s_loggingFilters["RemoteProxyClientWebSocket"] = true;
|
|
||||||
s_loggingFilters["RemoteProxyClientConnection"] = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable very verbose
|
// Enable very verbose
|
||||||
if (parser.isSet(veryVerboseOption)) {
|
if (parser.isSet(veryVerboseOption)) {
|
||||||
|
s_loggingFilters["RemoteProxyClientJsonRpc"] = true;
|
||||||
s_loggingFilters["RemoteProxyClientJsonRpcTraffic"] = true;
|
s_loggingFilters["RemoteProxyClientJsonRpcTraffic"] = true;
|
||||||
|
s_loggingFilters["RemoteProxyClientWebSocket"] = true;
|
||||||
|
s_loggingFilters["RemoteProxyClientTcpSocket"] = true;
|
||||||
|
s_loggingFilters["RemoteProxyClientConnection"] = true;
|
||||||
|
s_loggingFilters["RemoteProxyClientConnectionTraffic"] = true;
|
||||||
s_loggingFilters["TunnelProxySocketServerTraffic"] = true;
|
s_loggingFilters["TunnelProxySocketServerTraffic"] = true;
|
||||||
}
|
}
|
||||||
QLoggingCategory::installFilter(loggingCategoryFilter);
|
QLoggingCategory::installFilter(loggingCategoryFilter);
|
||||||
|
|
||||||
|
|
||||||
// Create the server connection
|
// Create the server connection
|
||||||
ServerConnection server(serverUrl, name, uuid, parser.isSet(insecureOption));
|
ServerConnection *server = new ServerConnection(serverUrl, name, uuid, parser.isSet(insecureOption));
|
||||||
|
server->startServer();
|
||||||
server.startServer();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Client
|
// Client
|
||||||
@ -197,21 +210,34 @@ int main(int argc, char *argv[])
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUuid serverUuid(parser.value(serverUuidOption));
|
||||||
|
if (serverUuid.isNull()) {
|
||||||
|
qCritical() << "The given server uuid is not valid." << parser.value(serverUuidOption);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
// Enable verbose
|
// Enable verbose
|
||||||
if (parser.isSet(verboseOption) || parser.isSet(veryVerboseOption)) {
|
if (parser.isSet(verboseOption) || parser.isSet(veryVerboseOption)) {
|
||||||
s_loggingFilters["default"] = true;
|
s_loggingFilters["default"] = true;
|
||||||
|
s_loggingFilters["TunnelProxySocketServer"] = true;
|
||||||
s_loggingFilters["TunnelProxyRemoteConnection"] = true;
|
s_loggingFilters["TunnelProxyRemoteConnection"] = true;
|
||||||
s_loggingFilters["RemoteProxyClientJsonRpc"] = true;
|
|
||||||
s_loggingFilters["RemoteProxyClientWebSocket"] = true;
|
|
||||||
s_loggingFilters["RemoteProxyClientConnection"] = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable very verbose
|
// Enable very verbose
|
||||||
if (parser.isSet(veryVerboseOption)) {
|
if (parser.isSet(veryVerboseOption)) {
|
||||||
|
s_loggingFilters["RemoteProxyClientJsonRpc"] = true;
|
||||||
s_loggingFilters["RemoteProxyClientJsonRpcTraffic"] = true;
|
s_loggingFilters["RemoteProxyClientJsonRpcTraffic"] = true;
|
||||||
|
s_loggingFilters["RemoteProxyClientWebSocket"] = true;
|
||||||
|
s_loggingFilters["RemoteProxyClientTcpSocket"] = true;
|
||||||
|
s_loggingFilters["RemoteProxyClientConnection"] = true;
|
||||||
|
s_loggingFilters["RemoteProxyClientConnectionTraffic"] = true;
|
||||||
s_loggingFilters["TunnelProxySocketServerTraffic"] = true;
|
s_loggingFilters["TunnelProxySocketServerTraffic"] = true;
|
||||||
}
|
}
|
||||||
QLoggingCategory::installFilter(loggingCategoryFilter);
|
QLoggingCategory::installFilter(loggingCategoryFilter);
|
||||||
|
|
||||||
|
// Create the server connection
|
||||||
|
ClientConnection *client = new ClientConnection(serverUrl, name, uuid, serverUuid, parser.isSet(insecureOption));
|
||||||
|
client->connectToServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
return application.exec();
|
return application.exec();
|
||||||
|
|||||||
@ -19,15 +19,14 @@ ServerConnection::ServerConnection(const QUrl &serverUrl, const QString &name, c
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(m_socketServer, &TunnelProxySocketServer::runningChanged, this, [=](bool running){
|
connect(m_socketServer, &TunnelProxySocketServer::runningChanged, this, [=](bool running){
|
||||||
qDebug() << "--> Server is" << (running ? "running" : "not running any more");
|
|
||||||
if (running) {
|
if (running) {
|
||||||
qDebug() << "--> Connected with" << m_socketServer->remoteProxyServer() << m_socketServer->remoteProxyServerName() << m_socketServer->remoteProxyServerVersion() << m_socketServer->remoteProxyApiVersion();
|
qDebug() << "Connected with" << m_socketServer->remoteProxyServer() << m_socketServer->remoteProxyServerName() << m_socketServer->remoteProxyServerVersion() << m_socketServer->remoteProxyApiVersion();
|
||||||
}
|
}
|
||||||
|
qDebug() << "--> The tunnel proxy server is" << (running ? "running and listening for incoming connections" : "not running any more");
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_socketServer, &TunnelProxySocketServer::sslErrors, this, [=](const QList<QSslError> &errors){
|
connect(m_socketServer, &TunnelProxySocketServer::sslErrors, this, [=](const QList<QSslError> &errors){
|
||||||
if (m_insecure) {
|
if (m_insecure) {
|
||||||
qDebug() << "SSL errors occured. Ignoring because explicit specified.";
|
|
||||||
m_socketServer->ignoreSslErrors(errors);
|
m_socketServer->ignoreSslErrors(errors);
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "SSL errors occured:";
|
qWarning() << "SSL errors occured:";
|
||||||
|
|||||||
@ -8,6 +8,10 @@ INCLUDEPATH += ../libnymea-remoteproxy
|
|||||||
|
|
||||||
LIBS += -L$$top_builddir/libnymea-remoteproxyclient/ -lnymea-remoteproxyclient
|
LIBS += -L$$top_builddir/libnymea-remoteproxyclient/ -lnymea-remoteproxyclient
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
clientconnection.h \
|
||||||
|
serverconnection.h
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
clientconnection.cpp \
|
clientconnection.cpp \
|
||||||
serverconnection.cpp
|
serverconnection.cpp
|
||||||
@ -15,6 +19,3 @@ SOURCES += main.cpp \
|
|||||||
target.path = $$[QT_INSTALL_PREFIX]/bin
|
target.path = $$[QT_INSTALL_PREFIX]/bin
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
clientconnection.h \
|
|
||||||
serverconnection.h
|
|
||||||
|
|||||||
Reference in New Issue
Block a user