Add option for disableing proxy server functionality
parent
0c5da0213a
commit
1694a43098
|
|
@ -69,6 +69,8 @@ void Engine::start(ProxyConfiguration *configuration)
|
|||
m_configuration = configuration;
|
||||
qCDebug(dcEngine()) << "Using configuration" << m_configuration;
|
||||
|
||||
// TODO: the old proxy server is deprecated. Will be removed in future releases
|
||||
if (configuration->proxyEnabled()) {
|
||||
// Make sure an authenticator was registered
|
||||
Q_ASSERT_X(m_authenticator != nullptr, "Engine", "There is no authenticator registerd.");
|
||||
|
||||
|
|
@ -101,6 +103,9 @@ void Engine::start(ProxyConfiguration *configuration)
|
|||
// Start the server
|
||||
qCDebug(dcEngine()) << "Starting the proxy servers...";
|
||||
m_proxyServer->startServer();
|
||||
} else {
|
||||
qCDebug(dcEngine()) << "Proxy server disabled. Not starting proxy server.";
|
||||
}
|
||||
|
||||
// Tunnel proxy
|
||||
// -------------------------------------
|
||||
|
|
@ -263,7 +268,9 @@ QVariantMap Engine::createServerStatistic()
|
|||
monitorData.insert("serverName", m_configuration->serverName());
|
||||
monitorData.insert("serverVersion", SERVER_VERSION_STRING);
|
||||
monitorData.insert("apiVersion", API_VERSION_STRING);
|
||||
monitorData.insert("proxyStatistic", proxyServer()->currentStatistics());
|
||||
if (m_proxyServer) {
|
||||
monitorData.insert("proxyStatistic", m_proxyServer->currentStatistics());
|
||||
}
|
||||
monitorData.insert("tunnelProxyStatistic", tunnelProxyServer()->currentStatistics());
|
||||
return monitorData;
|
||||
}
|
||||
|
|
@ -277,6 +284,7 @@ void Engine::onTimerTick()
|
|||
m_currentTimeCounter += deltaTime;
|
||||
if (m_currentTimeCounter >= 1000) {
|
||||
// One second passed, do second tick
|
||||
if (m_proxyServer)
|
||||
m_proxyServer->tick();
|
||||
|
||||
QVariantMap serverStatistics = createServerStatistic();
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ bool ProxyConfiguration::loadConfiguration(const QString &fileName)
|
|||
|
||||
settings.beginGroup("ProxyServer");
|
||||
setServerName(settings.value("name", "nymea-remoteproxy").toString());
|
||||
setProxyEnabled(settings.value("proxyEnabled", true).toBool());
|
||||
setWriteLogFile(settings.value("writeLogs", false).toBool());
|
||||
setLogFileName(settings.value("logFile", "/var/log/nymea-remoteproxy.log").toString());
|
||||
setLogEngineEnabled(settings.value("logEngineEnabled", false).toBool());
|
||||
|
|
@ -241,6 +242,16 @@ void ProxyConfiguration::setAloneTimeout(int timeout)
|
|||
m_aloneTimeout = timeout;
|
||||
}
|
||||
|
||||
bool ProxyConfiguration::proxyEnabled() const
|
||||
{
|
||||
return m_proxyEnabled;
|
||||
}
|
||||
|
||||
void ProxyConfiguration::setProxyEnabled(bool proxyEnabled)
|
||||
{
|
||||
m_proxyEnabled = proxyEnabled;
|
||||
}
|
||||
|
||||
QString ProxyConfiguration::awsRegion() const
|
||||
{
|
||||
return m_awsRegion;
|
||||
|
|
@ -419,10 +430,6 @@ QDebug operator<<(QDebug debug, ProxyConfiguration *configuration)
|
|||
debug.nospace() << " - Authentication timeout:" << configuration->authenticationTimeout() << " [ms]" << endl;
|
||||
debug.nospace() << " - Inactive timeout:" << configuration->inactiveTimeout() << " [ms]" << endl;
|
||||
debug.nospace() << " - Alone timeout:" << configuration->aloneTimeout() << " [ms]" << endl;
|
||||
debug.nospace() << "AWS configuration" << endl;
|
||||
debug.nospace() << " - Region:" << configuration->awsRegion() << endl;
|
||||
debug.nospace() << " - Authorizer lambda function:" << configuration->awsAuthorizerLambdaFunctionName() << endl;
|
||||
debug.nospace() << " - Credentials URL:" << configuration->awsCredentialsUrl().toString() << endl;
|
||||
debug.nospace() << "SSL configuration" << endl;
|
||||
debug.nospace() << " - Enabled:" << configuration->sslEnabled() << endl;
|
||||
debug.nospace() << " - Certificate:" << configuration->sslCertificateFileName() << endl;
|
||||
|
|
@ -444,6 +451,11 @@ QDebug operator<<(QDebug debug, ProxyConfiguration *configuration)
|
|||
debug.nospace() << " Locality name:" << configuration->sslConfiguration().localCertificate().issuerInfo(QSslCertificate::LocalityName) << endl;
|
||||
debug.nospace() << " State/Province:" << configuration->sslConfiguration().localCertificate().issuerInfo(QSslCertificate::StateOrProvinceName) << endl;
|
||||
debug.nospace() << " Email address:" << configuration->sslConfiguration().localCertificate().issuerInfo(QSslCertificate::EmailAddress) << endl;
|
||||
if (configuration->proxyEnabled()) {
|
||||
debug.nospace() << "AWS configuration" << endl;
|
||||
debug.nospace() << " - Region:" << configuration->awsRegion() << endl;
|
||||
debug.nospace() << " - Authorizer lambda function:" << configuration->awsAuthorizerLambdaFunctionName() << endl;
|
||||
debug.nospace() << " - Credentials URL:" << configuration->awsCredentialsUrl().toString() << endl;
|
||||
debug.nospace() << "WebSocketServer Proxy" << endl;
|
||||
debug.nospace() << " - Host:" << configuration->webSocketServerProxyHost().toString() << endl;
|
||||
debug.nospace() << " - Port:" << configuration->webSocketServerProxyPort() << endl;
|
||||
|
|
@ -452,6 +464,9 @@ QDebug operator<<(QDebug debug, ProxyConfiguration *configuration)
|
|||
debug.nospace() << " - Port:" << configuration->tcpServerPort() << endl;
|
||||
debug.nospace() << "UnixSocketServer Proxy" << endl;
|
||||
debug.nospace() << " - Filename:" << configuration->unixSocketFileName() << endl;
|
||||
} else {
|
||||
debug.nospace() << "Proxy Server: disabled" << endl;
|
||||
}
|
||||
debug.nospace() << "WebSocketServer TunnelProxy" << endl;
|
||||
debug.nospace() << " - Host:" << configuration->webSocketServerTunnelProxyHost().toString() << endl;
|
||||
debug.nospace() << " - Port:" << configuration->webSocketServerTunnelProxyPort() << endl;
|
||||
|
|
|
|||
|
|
@ -74,6 +74,9 @@ public:
|
|||
int aloneTimeout() const;
|
||||
void setAloneTimeout(int timeout);
|
||||
|
||||
bool proxyEnabled() const;
|
||||
void setProxyEnabled(bool proxyEnabled);
|
||||
|
||||
// AWS
|
||||
QString awsRegion() const;
|
||||
void setAwsRegion(const QString ®ion);
|
||||
|
|
@ -145,6 +148,8 @@ private:
|
|||
int m_inactiveTimeout = 8000;
|
||||
int m_aloneTimeout = 8000;
|
||||
|
||||
bool m_proxyEnabled = true;
|
||||
|
||||
// AWS
|
||||
QString m_awsRegion;
|
||||
QString m_awsAuthorizerLambdaFunctionName;
|
||||
|
|
|
|||
|
|
@ -64,11 +64,9 @@ void TcpSocketServer::killClientConnection(const QUuid &clientId, const QString
|
|||
if (!client)
|
||||
return;
|
||||
|
||||
if (client->state() == QAbstractSocket::ConnectedState) {
|
||||
qCWarning(dcTcpSocketServer()) << "Killing client connection" << clientId.toString() << "Reason:" << killReason;
|
||||
qCDebug(dcTcpSocketServer()) << "Killing client connection" << clientId.toString() << "Reason:" << killReason;
|
||||
client->close();
|
||||
}
|
||||
}
|
||||
|
||||
bool TcpSocketServer::running() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -207,14 +207,15 @@ int main(int argc, char *argv[])
|
|||
if (s_loggingEnabled)
|
||||
qCDebug(dcApplication()) << "Logging enabled. Writing logs to" << s_logFile.fileName();
|
||||
|
||||
|
||||
Authenticator *authenticator = nullptr;
|
||||
if (parser.isSet(mockAuthenticatorOption)) {
|
||||
authenticator = qobject_cast<Authenticator *>(new DummyAuthenticator(nullptr));
|
||||
} else {
|
||||
if (configuration->proxyEnabled()) {
|
||||
// Create default authenticator
|
||||
authenticator = qobject_cast<Authenticator *>(new AwsAuthenticator(configuration->awsCredentialsUrl(), nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
// Configure and start the engines
|
||||
Engine::instance()->setAuthenticator(authenticator);
|
||||
|
|
|
|||
Loading…
Reference in New Issue