Update unix socket settings and fix tests
parent
b255e52396
commit
d576a7bdf4
|
|
@ -77,7 +77,7 @@ void Engine::start(ProxyConfiguration *configuration)
|
|||
m_proxyServer = new ProxyServer(this);
|
||||
m_webSocketServerProxy = new WebSocketServer(m_configuration->sslEnabled(), m_configuration->sslConfiguration(), this);
|
||||
m_tcpSocketServerProxy = new TcpSocketServer(m_configuration->sslEnabled(), m_configuration->sslConfiguration(), this);
|
||||
m_unixSocketServerProxy = new UnixSocketServer(m_configuration->localSocketFileName(), this);
|
||||
m_unixSocketServerProxy = new UnixSocketServer(m_configuration->unixSocketFileName(), this);
|
||||
|
||||
// Configure websocket server
|
||||
QUrl websocketServerUrl;
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ bool ProxyConfiguration::loadConfiguration(const QString &fileName)
|
|||
setTcpServerPort(static_cast<quint16>(settings.value("port", 1213).toInt()));
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("LocalSocketServer");
|
||||
setTcpServerHost(QHostAddress(settings.value("localSocketFileName", "/run/nymea-remoteproxy.socket").toString()));
|
||||
settings.beginGroup("UnixSocketServer");
|
||||
setUnixSocketFileName(settings.value("unixSocketFileName", "/run/nymea-remoteproxy.socket").toString());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("WebSocketServerTunnelProxy");
|
||||
|
|
@ -356,9 +356,14 @@ void ProxyConfiguration::setTcpServerPort(quint16 port)
|
|||
m_tcpServerPort = port;
|
||||
}
|
||||
|
||||
QString ProxyConfiguration::localSocketFileName() const
|
||||
QString ProxyConfiguration::unixSocketFileName() const
|
||||
{
|
||||
return m_localSocketFileName;
|
||||
return m_unixSocketFileName;
|
||||
}
|
||||
|
||||
void ProxyConfiguration::setUnixSocketFileName(const QString &unixSocketFileName)
|
||||
{
|
||||
m_unixSocketFileName = unixSocketFileName;
|
||||
}
|
||||
|
||||
QHostAddress ProxyConfiguration::webSocketServerTunnelProxyHost() const
|
||||
|
|
@ -445,8 +450,8 @@ QDebug operator<<(QDebug debug, ProxyConfiguration *configuration)
|
|||
debug.nospace() << "TcpServer Proxy" << endl;
|
||||
debug.nospace() << " - Host:" << configuration->tcpServerHost().toString() << endl;
|
||||
debug.nospace() << " - Port:" << configuration->tcpServerPort() << endl;
|
||||
debug.nospace() << "LocalSocket Proxy" << endl;
|
||||
debug.nospace() << " - Socket file:" << configuration->localSocketFileName() << endl;
|
||||
debug.nospace() << "UnixSocketServer Proxy" << endl;
|
||||
debug.nospace() << " - Filename:" << configuration->unixSocketFileName() << endl;
|
||||
debug.nospace() << "WebSocketServer TunnelProxy" << endl;
|
||||
debug.nospace() << " - Host:" << configuration->webSocketServerTunnelProxyHost().toString() << endl;
|
||||
debug.nospace() << " - Port:" << configuration->webSocketServerTunnelProxyPort() << endl;
|
||||
|
|
|
|||
|
|
@ -113,8 +113,9 @@ public:
|
|||
quint16 tcpServerPort() const;
|
||||
void setTcpServerPort(quint16 port);
|
||||
|
||||
// LocalServer
|
||||
QString localSocketFileName() const;
|
||||
// UnixSocketServer
|
||||
QString unixSocketFileName() const;
|
||||
void setUnixSocketFileName(const QString &unixSocketFileName);
|
||||
|
||||
// WebSocketServer (tunnel)
|
||||
QHostAddress webSocketServerTunnelProxyHost() const;
|
||||
|
|
@ -164,8 +165,8 @@ private:
|
|||
QHostAddress m_tcpServerHost = QHostAddress::LocalHost;
|
||||
quint16 m_tcpServerPort = 1213;
|
||||
|
||||
// LocalSocketServer (proxy)
|
||||
QString m_localSocketFileName = "/run/nymea-remoteproxy.socket";
|
||||
// UnixSocketServer (proxy)
|
||||
QString m_unixSocketFileName = "/run/nymea-remoteproxy.socket";
|
||||
|
||||
// WebSocketServer (tunnel)
|
||||
QHostAddress m_webSocketServerTunnelProxyHost = QHostAddress::LocalHost;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ UnixSocketServer::UnixSocketServer(QString socketFileName, QObject *parent) :
|
|||
TransportInterface(parent),
|
||||
m_socketFileName(socketFileName)
|
||||
{
|
||||
m_serverName = "LOCAL";
|
||||
m_serverName = "unix";
|
||||
}
|
||||
|
||||
UnixSocketServer::~UnixSocketServer()
|
||||
|
|
@ -94,14 +94,14 @@ bool UnixSocketServer::startServer()
|
|||
m_server = new QLocalServer(this);
|
||||
m_server->setSocketOptions(QLocalServer::UserAccessOption | QLocalServer::GroupAccessOption | QLocalServer::OtherAccessOption);
|
||||
if (!m_server->listen(m_socketFileName)) {
|
||||
qCWarning(dcUnixSocketServer()) << "Could not start local server for monitor on" << m_serverName << m_server->errorString();
|
||||
qCWarning(dcUnixSocketServer()) << "Could not start local server for monitor on" << m_socketFileName << m_server->errorString();
|
||||
delete m_server;
|
||||
m_server = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_server, &QLocalServer::newConnection, this, &UnixSocketServer::onClientConnected);
|
||||
qCDebug(dcUnixSocketServer()) << "Started successfully on" << m_serverName;
|
||||
qCDebug(dcUnixSocketServer()) << "Started successfully on" << m_serverName << m_socketFileName;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ bool UnixSocketServer::stopServer()
|
|||
if (!m_server)
|
||||
return true;
|
||||
|
||||
qCDebug(dcUnixSocketServer()) << "Stopping server" << m_serverName;
|
||||
qCDebug(dcUnixSocketServer()) << "Stopping server" << m_socketFileName;
|
||||
foreach (QLocalSocket *clientConnection, m_clientList) {
|
||||
clientConnection->close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ port=443
|
|||
host=127.0.0.1
|
||||
port=80
|
||||
|
||||
[LocalSocketServer]
|
||||
localSocketFileName=/run/nymea-remoteproxy.socket
|
||||
[UnixSocketServer]
|
||||
unixSocketFileName=/run/nymea-remoteproxy.socket
|
||||
|
||||
[WebSocketServerTunnelProxy]
|
||||
host=127.0.0.1
|
||||
|
|
|
|||
|
|
@ -175,6 +175,18 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
// Verify webserver configuration
|
||||
if (configuration->webSocketServerProxyHost().isNull()) {
|
||||
qCCritical(dcApplication()) << "Invalid web socket host address passed.";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// Verify tcp server configuration
|
||||
if (configuration->tcpServerHost().isNull()) {
|
||||
qCCritical(dcApplication()) << "Invalid TCP server host address passed.";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// Verify SSL configuration
|
||||
if (configuration->sslEnabled() && configuration->sslConfiguration().isNull()) {
|
||||
qCCritical(dcApplication()) << "SSL is enabled but no SSL configuration specified.";
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ port=1212
|
|||
host=127.0.0.1
|
||||
port=1213
|
||||
|
||||
[UnixSocketServer]
|
||||
unixSocketFileName=/tmp/nymea-remoteproxy.socket
|
||||
|
||||
[WebSocketServerTunnelProxy]
|
||||
host=127.0.0.1
|
||||
port=2212
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ port=1212
|
|||
host=127.0.0.1
|
||||
port=1213
|
||||
|
||||
[UnixSocketServer]
|
||||
unixSocketFileName=/tmp/nymea-remoteproxy.socket
|
||||
|
||||
[WebSocketServerTunnelProxy]
|
||||
host=127.0.0.1
|
||||
port=2212
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ port=1212
|
|||
host=127.0.0.1
|
||||
port=1213
|
||||
|
||||
[UnixSocketServer]
|
||||
unixSocketFileName=/tmp/nymea-remoteproxy.socket
|
||||
|
||||
[WebSocketServerTunnelProxy]
|
||||
host=127.0.0.1
|
||||
port=2212
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ port=1212
|
|||
host=127.0.0.1
|
||||
port=1213
|
||||
|
||||
[UnixSocketServer]
|
||||
unixSocketFileName=/tmp/nymea-remoteproxy.socket
|
||||
|
||||
[WebSocketServerTunnelProxy]
|
||||
host=127.0.0.1
|
||||
port=2212
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ port=1212
|
|||
host=127.0.0.1
|
||||
port=1213
|
||||
|
||||
[UnixSocketServer]
|
||||
unixSocketFileName=/tmp/nymea-remoteproxy.socket
|
||||
|
||||
[WebSocketServerTunnelProxy]
|
||||
host=127.0.0.1
|
||||
port=2212
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ void RemoteProxyTestsProxy::dummyAuthenticator()
|
|||
// Make sure the server is running
|
||||
QVERIFY(Engine::instance()->running());
|
||||
QVERIFY(Engine::instance()->webSocketServerProxy()->running());
|
||||
QVERIFY(Engine::instance()->unixSocketServerProxy()->running());
|
||||
QVERIFY(Engine::instance()->proxyServer()->running());
|
||||
|
||||
// Create request
|
||||
|
|
|
|||
Loading…
Reference in New Issue