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