Fix tunnel proxy configuration and make it independent from the cloud configuration
This commit is contained in:
parent
1e132a49ac
commit
3eb3b8ad8a
@ -212,33 +212,14 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tunnel Proxy Server
|
// Tunnel Proxy Server
|
||||||
createDefaults = !settings.childGroups().contains("TunnelProxyServer");
|
|
||||||
if (settings.childGroups().contains("TunnelProxyServer")) {
|
if (settings.childGroups().contains("TunnelProxyServer")) {
|
||||||
settings.beginGroup("TunnelProxyServer");
|
settings.beginGroup("TunnelProxyServer");
|
||||||
if (settings.value("disabled").toBool()) {
|
foreach (const QString &key, settings.childGroups()) {
|
||||||
qCDebug(dcConfiguration) << "Tunnel proxy server disabled by configuration.";
|
TunnelProxyServerConfiguration config = readTunnelProxyServerConfig(key);
|
||||||
} else if (!settings.childGroups().isEmpty()) {
|
m_tunnelProxyServerConfigs[config.id] = config;
|
||||||
foreach (const QString &key, settings.childGroups()) {
|
|
||||||
TunnelProxyServerConfiguration config = readTunnelProxyServerConfig(key);
|
|
||||||
m_tunnelProxyServerConfigs[config.id] = config;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
createDefaults = true;
|
|
||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
if (createDefaults) {
|
|
||||||
qCWarning(dcConfiguration) << "No Tunnel Proxy server configuration found. Generating default of remoteproxy.nymea.io:2213";
|
|
||||||
TunnelProxyServerConfiguration config;
|
|
||||||
config.id = "default";
|
|
||||||
config.address = "remoteproxy.nymea.io";
|
|
||||||
config.port = 2213;
|
|
||||||
config.sslEnabled = true;
|
|
||||||
config.authenticationEnabled = true;
|
|
||||||
config.ignoreSslErrors = false;
|
|
||||||
m_tunnelProxyServerConfigs[config.id] = config;
|
|
||||||
storeTunnelProxyServerConfig(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write defaults for log settings
|
// Write defaults for log settings
|
||||||
settings.beginGroup("Logs");
|
settings.beginGroup("Logs");
|
||||||
@ -403,7 +384,7 @@ QHash<QString, TunnelProxyServerConfiguration> NymeaConfiguration::tunnelProxySe
|
|||||||
void NymeaConfiguration::setTunnelProxyServerConfiguration(const TunnelProxyServerConfiguration &config)
|
void NymeaConfiguration::setTunnelProxyServerConfiguration(const TunnelProxyServerConfiguration &config)
|
||||||
{
|
{
|
||||||
m_tunnelProxyServerConfigs[config.id] = config;
|
m_tunnelProxyServerConfigs[config.id] = config;
|
||||||
storeServerConfig("TunnelProxyServer", config);
|
storeTunnelProxyServerConfig(config);
|
||||||
emit tunnelProxyServerConfigurationChanged(config.id);
|
emit tunnelProxyServerConfigurationChanged(config.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -791,7 +772,30 @@ QDebug operator <<(QDebug debug, const ServerConfiguration &configuration)
|
|||||||
debug.nospace() << ", " << configuration.id;
|
debug.nospace() << ", " << configuration.id;
|
||||||
debug.nospace() << ", " << QString("%1:%2").arg(configuration.address).arg(configuration.port);
|
debug.nospace() << ", " << QString("%1:%2").arg(configuration.address).arg(configuration.port);
|
||||||
debug.nospace() << ") ";
|
debug.nospace() << ") ";
|
||||||
return debug;
|
return debug.maybeSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const TunnelProxyServerConfiguration &configuration)
|
||||||
|
{
|
||||||
|
debug.nospace() << "TunnelProxyServerConfiguration(" << configuration.id;
|
||||||
|
debug.nospace() << ", " << QString("%1:%2").arg(configuration.address).arg(configuration.port);
|
||||||
|
if (configuration.sslEnabled) {
|
||||||
|
debug.nospace() << ", SSL enabled";
|
||||||
|
} else {
|
||||||
|
debug.nospace() << ", SSL disabled";
|
||||||
|
}
|
||||||
|
if (configuration.authenticationEnabled) {
|
||||||
|
debug.nospace() << ", Authentication enabled";
|
||||||
|
} else {
|
||||||
|
debug.nospace() << ", Authentication disabled";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.ignoreSslErrors) {
|
||||||
|
debug.nospace() << ", Ignoring SSL errors";
|
||||||
|
}
|
||||||
|
|
||||||
|
debug.nospace() << ") ";
|
||||||
|
return debug.maybeSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,6 +46,7 @@ class ServerConfiguration {
|
|||||||
Q_PROPERTY(uint port MEMBER port)
|
Q_PROPERTY(uint port MEMBER port)
|
||||||
Q_PROPERTY(bool sslEnabled MEMBER sslEnabled)
|
Q_PROPERTY(bool sslEnabled MEMBER sslEnabled)
|
||||||
Q_PROPERTY(bool authenticationEnabled MEMBER authenticationEnabled)
|
Q_PROPERTY(bool authenticationEnabled MEMBER authenticationEnabled)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString id;
|
QString id;
|
||||||
QString address;
|
QString address;
|
||||||
@ -69,19 +70,34 @@ class WebServerConfiguration: public ServerConfiguration
|
|||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
Q_PROPERTY(QString publicFolder MEMBER publicFolder)
|
Q_PROPERTY(QString publicFolder MEMBER publicFolder)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString publicFolder;
|
QString publicFolder;
|
||||||
bool restServerEnabled = false;
|
bool restServerEnabled = false;
|
||||||
|
|
||||||
|
bool operator==(const WebServerConfiguration &other) const {
|
||||||
|
return ServerConfiguration::operator==(other)
|
||||||
|
&& publicFolder == other.publicFolder
|
||||||
|
&& restServerEnabled == other.restServerEnabled;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TunnelProxyServerConfiguration: public ServerConfiguration
|
class TunnelProxyServerConfiguration: public ServerConfiguration
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
Q_PROPERTY(bool ignoreSslErrors MEMBER ignoreSslErrors)
|
Q_PROPERTY(bool ignoreSslErrors MEMBER ignoreSslErrors)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool ignoreSslErrors = false;
|
bool ignoreSslErrors = false;
|
||||||
|
|
||||||
|
bool operator==(const TunnelProxyServerConfiguration &other) const {
|
||||||
|
return ServerConfiguration::operator==(other)
|
||||||
|
&& ignoreSslErrors == other.ignoreSslErrors;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const TunnelProxyServerConfiguration &configuration);
|
||||||
|
|
||||||
class MqttPolicy
|
class MqttPolicy
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
|
|||||||
@ -169,7 +169,7 @@ ServerManager::ServerManager(Platform *platform, NymeaConfiguration *configurati
|
|||||||
|
|
||||||
foreach (const TunnelProxyServerConfiguration &config, configuration->tunnelProxyServerConfigurations()) {
|
foreach (const TunnelProxyServerConfiguration &config, configuration->tunnelProxyServerConfigurations()) {
|
||||||
TunnelProxyServer *tunnelProxyServer = new TunnelProxyServer(configuration->serverName(), configuration->serverUuid(), config, this);
|
TunnelProxyServer *tunnelProxyServer = new TunnelProxyServer(configuration->serverName(), configuration->serverUuid(), config, this);
|
||||||
qCDebug(dcServerManager()) << "Creating tunnel proxy server" << config;
|
qCDebug(dcServerManager()) << "Creating tunnel proxy server using" << config;
|
||||||
m_tunnelProxyServers.insert(config.id, tunnelProxyServer);
|
m_tunnelProxyServers.insert(config.id, tunnelProxyServer);
|
||||||
connect(tunnelProxyServer, &TunnelProxyServer::runningChanged, this, [this, tunnelProxyServer](bool running){
|
connect(tunnelProxyServer, &TunnelProxyServer::runningChanged, this, [this, tunnelProxyServer](bool running){
|
||||||
if (running) {
|
if (running) {
|
||||||
@ -183,10 +183,7 @@ ServerManager::ServerManager(Platform *platform, NymeaConfiguration *configurati
|
|||||||
// FIXME: make use of SSL over tunnel proxy connections
|
// FIXME: make use of SSL over tunnel proxy connections
|
||||||
// FIXME: make sure the authentication is enabled for the tunnel proxy
|
// FIXME: make sure the authentication is enabled for the tunnel proxy
|
||||||
|
|
||||||
// Note: only start the tunnel proxy server if cloud is connected
|
tunnelProxyServer->startServer();
|
||||||
if (configuration->cloudEnabled()) {
|
|
||||||
tunnelProxyServer->startServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const WebServerConfiguration &config, configuration->webServerConfigurations()) {
|
foreach (const WebServerConfiguration &config, configuration->webServerConfigurations()) {
|
||||||
@ -248,12 +245,12 @@ void ServerManager::tcpServerConfigurationChanged(const QString &id)
|
|||||||
ServerConfiguration config = NymeaCore::instance()->configuration()->tcpServerConfigurations().value(id);
|
ServerConfiguration config = NymeaCore::instance()->configuration()->tcpServerConfigurations().value(id);
|
||||||
TcpServer *server = m_tcpServers.value(id);
|
TcpServer *server = m_tcpServers.value(id);
|
||||||
if (server) {
|
if (server) {
|
||||||
qDebug(dcServerManager()) << "Restarting TCP server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
|
qCDebug(dcServerManager()) << "Restarting TCP server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
|
||||||
unregisterZeroConfService(config.id, "tcp");
|
unregisterZeroConfService(config.id, "tcp");
|
||||||
server->stopServer();
|
server->stopServer();
|
||||||
server->setConfiguration(config);
|
server->setConfiguration(config);
|
||||||
} else {
|
} else {
|
||||||
qDebug(dcServerManager()) << "Received a TCP Server config change event but don't have a TCP Server instance for it. Creating new Server instance.";
|
qCDebug(dcServerManager()) << "Received a TCP Server config change event but don't have a TCP Server instance for it. Creating new Server instance.";
|
||||||
server = new TcpServer(config, m_sslConfiguration, this);
|
server = new TcpServer(config, m_sslConfiguration, this);
|
||||||
m_tcpServers.insert(config.id, server);
|
m_tcpServers.insert(config.id, server);
|
||||||
}
|
}
|
||||||
@ -266,7 +263,7 @@ void ServerManager::tcpServerConfigurationChanged(const QString &id)
|
|||||||
void ServerManager::tcpServerConfigurationRemoved(const QString &id)
|
void ServerManager::tcpServerConfigurationRemoved(const QString &id)
|
||||||
{
|
{
|
||||||
if (!m_tcpServers.contains(id)) {
|
if (!m_tcpServers.contains(id)) {
|
||||||
qWarning(dcServerManager()) << "Received a TCP Server config removed event but don't have a TCP Server instance for it.";
|
qCWarning(dcServerManager()) << "Received a TCP Server config removed event but don't have a TCP Server instance for it.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TcpServer *server = m_tcpServers.take(id);
|
TcpServer *server = m_tcpServers.take(id);
|
||||||
@ -281,12 +278,12 @@ void ServerManager::webSocketServerConfigurationChanged(const QString &id)
|
|||||||
WebSocketServer *server = m_webSocketServers.value(id);
|
WebSocketServer *server = m_webSocketServers.value(id);
|
||||||
ServerConfiguration config = NymeaCore::instance()->configuration()->webSocketServerConfigurations().value(id);
|
ServerConfiguration config = NymeaCore::instance()->configuration()->webSocketServerConfigurations().value(id);
|
||||||
if (server) {
|
if (server) {
|
||||||
qDebug(dcServerManager()) << "Restarting WebSocket server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
|
qCDebug(dcServerManager()) << "Restarting WebSocket server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
|
||||||
unregisterZeroConfService(id, "ws");
|
unregisterZeroConfService(id, "ws");
|
||||||
server->stopServer();
|
server->stopServer();
|
||||||
server->setConfiguration(config);
|
server->setConfiguration(config);
|
||||||
} else {
|
} else {
|
||||||
qDebug(dcServerManager()) << "Received a WebSocket Server config change event but don't have a WebSocket Server instance for it. Creating new instance.";
|
qCDebug(dcServerManager()) << "Received a WebSocket Server config change event but don't have a WebSocket Server instance for it. Creating new instance.";
|
||||||
server = new WebSocketServer(config, m_sslConfiguration, this);
|
server = new WebSocketServer(config, m_sslConfiguration, this);
|
||||||
m_webSocketServers.insert(server->configuration().id, server);
|
m_webSocketServers.insert(server->configuration().id, server);
|
||||||
}
|
}
|
||||||
@ -299,7 +296,7 @@ void ServerManager::webSocketServerConfigurationChanged(const QString &id)
|
|||||||
void ServerManager::webSocketServerConfigurationRemoved(const QString &id)
|
void ServerManager::webSocketServerConfigurationRemoved(const QString &id)
|
||||||
{
|
{
|
||||||
if (!m_webSocketServers.contains(id)) {
|
if (!m_webSocketServers.contains(id)) {
|
||||||
qWarning(dcServerManager()) << "Received a WebSocket Server config removed event but don't have a WebSocket Server instance for it.";
|
qCWarning(dcServerManager()) << "Received a WebSocket Server config removed event but don't have a WebSocket Server instance for it.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WebSocketServer *server = m_webSocketServers.take(id);
|
WebSocketServer *server = m_webSocketServers.take(id);
|
||||||
@ -314,12 +311,12 @@ void ServerManager::webServerConfigurationChanged(const QString &id)
|
|||||||
WebServerConfiguration config = NymeaCore::instance()->configuration()->webServerConfigurations().value(id);
|
WebServerConfiguration config = NymeaCore::instance()->configuration()->webServerConfigurations().value(id);
|
||||||
WebServer *server = m_webServers.value(id);
|
WebServer *server = m_webServers.value(id);
|
||||||
if (server) {
|
if (server) {
|
||||||
qDebug(dcServerManager()) << "Restarting Web server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
|
qCDebug(dcServerManager()) << "Restarting Web server for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
|
||||||
unregisterZeroConfService(id, "http");
|
unregisterZeroConfService(id, "http");
|
||||||
server->stopServer();
|
server->stopServer();
|
||||||
server->setConfiguration(config);
|
server->setConfiguration(config);
|
||||||
} else {
|
} else {
|
||||||
qDebug(dcServerManager()) << "Received a Web Server config change event but don't have a Web Server instance for it. Creating new WebServer instance on" << config.address << config.port << "(SSL:" << config.sslEnabled << ")";
|
qCDebug(dcServerManager()) << "Received a Web Server config change event but don't have a Web Server instance for it. Creating new WebServer instance on" << config.address << config.port << "(SSL:" << config.sslEnabled << ")";
|
||||||
server = new WebServer(config, m_sslConfiguration, this);
|
server = new WebServer(config, m_sslConfiguration, this);
|
||||||
m_webServers.insert(config.id, server);
|
m_webServers.insert(config.id, server);
|
||||||
}
|
}
|
||||||
@ -331,7 +328,7 @@ void ServerManager::webServerConfigurationChanged(const QString &id)
|
|||||||
void ServerManager::webServerConfigurationRemoved(const QString &id)
|
void ServerManager::webServerConfigurationRemoved(const QString &id)
|
||||||
{
|
{
|
||||||
if (!m_webServers.contains(id)) {
|
if (!m_webServers.contains(id)) {
|
||||||
qWarning(dcServerManager()) << "Received a Web Server config removed event but don't have a Web Server instance for it.";
|
qCWarning(dcServerManager()) << "Received a Web Server config removed event but don't have a Web Server instance for it.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WebServer *server = m_webServers.take(id);
|
WebServer *server = m_webServers.take(id);
|
||||||
@ -373,23 +370,31 @@ void ServerManager::tunnelProxyServerConfigurationChanged(const QString &id)
|
|||||||
TunnelProxyServer *server = m_tunnelProxyServers.value(id);
|
TunnelProxyServer *server = m_tunnelProxyServers.value(id);
|
||||||
TunnelProxyServerConfiguration config = NymeaCore::instance()->configuration()->tunnelProxyServerConfigurations().value(id);
|
TunnelProxyServerConfiguration config = NymeaCore::instance()->configuration()->tunnelProxyServerConfigurations().value(id);
|
||||||
if (server) {
|
if (server) {
|
||||||
qDebug(dcServerManager()) << "Restarting tunnel proxy connection for" << config.address << config.port << "SSL" << (config.sslEnabled ? "enabled" : "disabled") << "Authentication" << (config.authenticationEnabled ? "enabled" : "disabled");
|
qCDebug(dcServerManager()) << "Restarting tunnel proxy connection using" << config;
|
||||||
unregisterZeroConfService(id, "ws");
|
|
||||||
server->stopServer();
|
server->stopServer();
|
||||||
server->setConfiguration(config);
|
server->setTunnelProxyConfig(config);
|
||||||
} else {
|
} else {
|
||||||
qDebug(dcServerManager()) << "Received a tunnel proxy config change event but don't have a WebSocket Server instance for it. Creating new instance.";
|
qCDebug(dcServerManager()) << "Received a tunnel proxy config change event but don't have a tunnel proxy server instance for it.";
|
||||||
|
qCDebug(dcServerManager()) << "Creating tunnel proxy server using" << config;
|
||||||
server = new TunnelProxyServer(m_nymeaConfiguration->serverName(), m_nymeaConfiguration->serverUuid(), config, this);
|
server = new TunnelProxyServer(m_nymeaConfiguration->serverName(), m_nymeaConfiguration->serverUuid(), config, this);
|
||||||
m_tunnelProxyServers.insert(server->configuration().id, server);
|
m_tunnelProxyServers.insert(server->configuration().id, server);
|
||||||
|
connect(server, &TunnelProxyServer::runningChanged, this, [this, server](bool running){
|
||||||
|
if (running) {
|
||||||
|
// Note: enable authentication in any case, we don't want to expose unprotected access trough the internet
|
||||||
|
m_jsonServer->registerTransportInterface(server, true);
|
||||||
|
} else {
|
||||||
|
m_jsonServer->unregisterTransportInterface(server);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
m_jsonServer->registerTransportInterface(server, config.authenticationEnabled);
|
|
||||||
server->startServer();
|
server->startServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerManager::tunnelProxyServerConfigurationRemoved(const QString &id)
|
void ServerManager::tunnelProxyServerConfigurationRemoved(const QString &id)
|
||||||
{
|
{
|
||||||
if (!m_tunnelProxyServers.contains(id)) {
|
if (!m_tunnelProxyServers.contains(id)) {
|
||||||
qWarning(dcServerManager()) << "Received a tunnel proxy config removed event but don't have a tunnel proxy connection for it.";
|
qCWarning(dcServerManager()) << "Received a tunnel proxy config removed event but don't have a tunnel proxy connection for it.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TunnelProxyServer *server = m_tunnelProxyServers.take(id);
|
TunnelProxyServer *server = m_tunnelProxyServers.take(id);
|
||||||
|
|||||||
@ -37,7 +37,7 @@ namespace nymeaserver {
|
|||||||
|
|
||||||
TunnelProxyServer::TunnelProxyServer(const QString &serverName, const QUuid &serverUuid, const TunnelProxyServerConfiguration &configuration, QObject *parent) :
|
TunnelProxyServer::TunnelProxyServer(const QString &serverName, const QUuid &serverUuid, const TunnelProxyServerConfiguration &configuration, QObject *parent) :
|
||||||
TransportInterface(configuration, parent),
|
TransportInterface(configuration, parent),
|
||||||
m_config(configuration),
|
m_tunnelProxyConfig(configuration),
|
||||||
m_serverName(serverName),
|
m_serverName(serverName),
|
||||||
m_serverUuid(serverUuid)
|
m_serverUuid(serverUuid)
|
||||||
{
|
{
|
||||||
@ -47,9 +47,7 @@ TunnelProxyServer::TunnelProxyServer(const QString &serverName, const QUuid &ser
|
|||||||
qCWarning(dcTunnelProxyServer()) << "=====================================================================================================================";
|
qCWarning(dcTunnelProxyServer()) << "=====================================================================================================================";
|
||||||
}
|
}
|
||||||
|
|
||||||
m_serverUrl.setScheme(configuration.sslEnabled ? "ssl" : "tcp");
|
initConfiguration();
|
||||||
m_serverUrl.setHost(configuration.address);
|
|
||||||
m_serverUrl.setPort(configuration.port);
|
|
||||||
|
|
||||||
m_tunnelProxySocketServer = new TunnelProxySocketServer(m_serverUuid, m_serverName, this);
|
m_tunnelProxySocketServer = new TunnelProxySocketServer(m_serverUuid, m_serverName, this);
|
||||||
connect(m_tunnelProxySocketServer, &TunnelProxySocketServer::stateChanged, this, &TunnelProxyServer::onStateChanged);
|
connect(m_tunnelProxySocketServer, &TunnelProxySocketServer::stateChanged, this, &TunnelProxyServer::onStateChanged);
|
||||||
@ -99,8 +97,15 @@ void TunnelProxyServer::setServerName(const QString &serverName)
|
|||||||
m_serverName = serverName;
|
m_serverName = serverName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TunnelProxyServer::setTunnelProxyConfig(const TunnelProxyServerConfiguration &tunnelProxyConfig)
|
||||||
|
{
|
||||||
|
m_tunnelProxyConfig = tunnelProxyConfig;
|
||||||
|
}
|
||||||
|
|
||||||
bool TunnelProxyServer::startServer()
|
bool TunnelProxyServer::startServer()
|
||||||
{
|
{
|
||||||
|
initConfiguration();
|
||||||
|
|
||||||
qCDebug(dcTunnelProxyServer()) << "Connecting to tunnel proxy server at:" << m_serverUrl;
|
qCDebug(dcTunnelProxyServer()) << "Connecting to tunnel proxy server at:" << m_serverUrl;
|
||||||
m_tunnelProxySocketServer->startServer(m_serverUrl);
|
m_tunnelProxySocketServer->startServer(m_serverUrl);
|
||||||
return true;
|
return true;
|
||||||
@ -142,8 +147,7 @@ void TunnelProxyServer::onServerErrorOccurred(TunnelProxySocketServer::Error err
|
|||||||
void TunnelProxyServer::onSslErrors(const QList<QSslError> &errors)
|
void TunnelProxyServer::onSslErrors(const QList<QSslError> &errors)
|
||||||
{
|
{
|
||||||
qCDebug(dcTunnelProxyServer()) << "Remote proxy connection SSL errors occurred" << errors;
|
qCDebug(dcTunnelProxyServer()) << "Remote proxy connection SSL errors occurred" << errors;
|
||||||
// FIXME: make this configurable
|
if (m_tunnelProxyConfig.ignoreSslErrors) {
|
||||||
if (m_config.ignoreSslErrors) {
|
|
||||||
qCWarning(dcTunnelProxyServer()) << "Ingoring SSL errors on tunnel proxy connection:" << errors;
|
qCWarning(dcTunnelProxyServer()) << "Ingoring SSL errors on tunnel proxy connection:" << errors;
|
||||||
m_tunnelProxySocketServer->ignoreSslErrors();
|
m_tunnelProxySocketServer->ignoreSslErrors();
|
||||||
} else {
|
} else {
|
||||||
@ -172,4 +176,13 @@ void TunnelProxyServer::onClientDisconnected(TunnelProxySocket *tunnelProxySocke
|
|||||||
emit clientDisconnected(clientId);
|
emit clientDisconnected(clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TunnelProxyServer::initConfiguration()
|
||||||
|
{
|
||||||
|
qCDebug(dcTunnelProxyServer()) << "Init configuration" << m_tunnelProxyConfig;
|
||||||
|
m_serverUrl.setScheme(m_tunnelProxyConfig.sslEnabled ? "ssl" : "tcp");
|
||||||
|
m_serverUrl.setHost(m_tunnelProxyConfig.address);
|
||||||
|
m_serverUrl.setPort(m_tunnelProxyConfig.port);
|
||||||
|
qCDebug(dcTunnelProxyServer()) << "Using server URL" << m_serverUrl.toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,6 +57,8 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setServerName(const QString &serverName) override;
|
void setServerName(const QString &serverName) override;
|
||||||
|
void setTunnelProxyConfig(const TunnelProxyServerConfiguration &tunnelProxyConfig);
|
||||||
|
|
||||||
bool startServer() override;
|
bool startServer() override;
|
||||||
bool stopServer() override;
|
bool stopServer() override;
|
||||||
|
|
||||||
@ -74,7 +76,7 @@ private slots:
|
|||||||
void onClientDisconnected(TunnelProxySocket *tunnelProxySocket);
|
void onClientDisconnected(TunnelProxySocket *tunnelProxySocket);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TunnelProxyServerConfiguration m_config;
|
TunnelProxyServerConfiguration m_tunnelProxyConfig;
|
||||||
TunnelProxySocketServer *m_tunnelProxySocketServer = nullptr;
|
TunnelProxySocketServer *m_tunnelProxySocketServer = nullptr;
|
||||||
QString m_serverName;
|
QString m_serverName;
|
||||||
QUuid m_serverUuid;
|
QUuid m_serverUuid;
|
||||||
@ -82,6 +84,8 @@ private:
|
|||||||
|
|
||||||
QHash<QUuid, TunnelProxySocket *> m_clients;
|
QHash<QUuid, TunnelProxySocket *> m_clients;
|
||||||
|
|
||||||
|
void initConfiguration();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user