diff --git a/README.md b/README.md index e3f3ec3..21e0c0f 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,10 @@ The package will deliver a default configuration file with following content (`/ writeLogs=false logFile=/var/log/nymea-remoteproxy.log monitorSocket=/tmp/nymea-remoteproxy-monitor.sock + jsonRpcTimeout=10000 + authenticationTimeout=8000 + inactiveTimeout=8000 + aloneTimeout=8000 [SSL] certificate=/etc/ssl/certs/ssl-cert-snakeoil.pem @@ -84,7 +88,6 @@ In order to run the test, you can call `make check` in the build directory or ru If you want to create a line coverage report from the tests simply run following command in the source directory: - $ apt install lcov gcovr $ ./create-coverage-html.sh @@ -100,8 +103,8 @@ In order to get information about the server you can start the command with the The nymea remote proxy server. This server allowes nymea-cloud users and registered nymea deamons to establish a tunnel connection. - Version: 0.1.0 - API version: 0.1 + Version: 0.1.2 + API version: 0.2 Copyright © 2018 Simon Stürz @@ -126,6 +129,29 @@ In order to get information about the server you can start the command with the Once a client connects to the proxy server, he must authenticate him self by passing the token received from the nymea-cloud mqtt connection request. +## Basic flow + +#### First client + +1. Connect to the proxy server +2. Say hello, in order to know the version, name and API version of the server +3. Authenticate with a token +4. Wait for the tunnel established notification + +#### Second client + +1. Connect to the proxy server +2. Say hello, in order to know the version, name and API version of the server +3. Authenticate with a token (this has to be the same token as the first client showed) +4. Wait for the tunnel established notification + + +Once both clients are authenticated, the proxy server will send the `RemoteProxy.TunnelEstablished` notification containing the information of the other tunnel participent. Any traffic coming from he socket is from the remote partner, and any messge sent to the socket will go to the remote partner. + +If anything goes wrong, or the tunnel partner disconnects from the proxy, the server will close the other client connection. If any data will be sent between `Authenticate` method and `TunnelEstablished` notification, the server will close the socket. + + + ## Message format #### Request @@ -168,10 +194,10 @@ Once a client connects to the proxy server, he must authenticate him self by pas { "id": 0, "params": { - "apiVersion": "0.1", + "apiVersion": "0.2", "name": "community-server", "server": "nymea-remoteproxy", - "version": "0.1.0" + "version": "0.1.2" }, "status": "success" } @@ -186,7 +212,7 @@ The first data a client **must** send to the proxy server is the authentication "id": 1, "method": "Authentication.Authenticate", "params": { - "id": "string", + "uuid": "string", "name": "string", "token": "tokenstring" } @@ -313,6 +339,30 @@ The server provides a live monitor interface on a local socket server. You can f $ sudo socat - UNIX-CONNECT:/tmp/nymea-remoteproxy-monitor.sock +There is also the package `nymea-remoteproxy-monitor` package and application which gives you a nice overview about whats going on on the proxy server. + + + $ nymea-remoteproxy-monitor --help + + Usage: nymea-remoteproxy-monitor [options] + + The nymea remote proxy monitor allowes to monitor the live server activity on the a local instance. + + Server version: 0.1.2 + API version: 0.2 + + Copyright © 2018 Simon Stürz + + + Options: + -h, --help Displays this help. + -v, --version Displays version information. + -s, --socket The socket descriptor for the nymea-remoteproxy + monitor socket. Default is + /tmp/nymea-remoteproxy-monitor.sock + + + # Client usage The client allowes you to test the proxy server and create a dummy client for testing the connection. @@ -324,8 +374,8 @@ The client allowes you to test the proxy server and create a dummy client for te The nymea remote proxy client application. This client allowes to test a server application as client perspective. - Version: 0.1.0 - API version: 0.1 + Version: 0.1.2 + API version: 0.2 Copyright © 2018 Simon Stürz @@ -391,13 +441,13 @@ Once the server is up and running with the dummy authenticator, you can try to c > *Note:* assuming you are starting the client on the same system as the server: - $ nymea-remoteproxy-client -i -u wss://127.0.0.1:443 -t "dummytoken" + $ nymea-remoteproxy-client -i -u wss://localhost -t "blubtoken" Open a second terminal and start the same command again. > *Note:* assuming you are starting the client on the same system as the server: - $ nymea-remoteproxy-client -i -u wss://127.0.0.1:443 -t "dummytoken" + $ nymea-remoteproxy-client -i -u wss://localhost -t "blubtoken" You can follow the connection flow on both sides using the `--very-verbose` option. diff --git a/debian/changelog b/debian/changelog index aa8e139..fe65d1f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,12 @@ -nymea-remoteproxy (0.1.0) UNRELEASED; urgency=medium +nymea-remoteproxy (0.1.2) UNRELEASED; urgency=medium + + * Many bug fixes + * Add more scurity mechanisms + * Add monitor + + -- Simon Stürz Wed, 22 Aug 2018 16:55:07 +0200 + +nymea-remoteproxy (0.1.0) xenial; urgency=medium * First working online version diff --git a/libnymea-remoteproxy/proxyserver.cpp b/libnymea-remoteproxy/proxyserver.cpp index 0d454a0..7c2f375 100644 --- a/libnymea-remoteproxy/proxyserver.cpp +++ b/libnymea-remoteproxy/proxyserver.cpp @@ -155,14 +155,14 @@ void ProxyServer::establishTunnel(ProxyClient *firstClient, ProxyClient *secondC // Notify the clients in the next event loop QMetaObject::invokeMethod(m_jsonRpcServer, QString("sendNotification").toLatin1().data(), Qt::QueuedConnection, - Q_ARG(QString, "ProxyServer"), + Q_ARG(QString, m_jsonRpcServer->name()), Q_ARG(QString, "TunnelEstablished"), Q_ARG(QVariantMap, notificationParamsFirst), Q_ARG(ProxyClient *, tunnel.clientOne())); QMetaObject::invokeMethod(m_jsonRpcServer, QString("sendNotification").toLatin1().data(), Qt::QueuedConnection, - Q_ARG(QString, "ProxyServer"), + Q_ARG(QString, m_jsonRpcServer->name()), Q_ARG(QString, "TunnelEstablished"), Q_ARG(QVariantMap, notificationParamsSecond), Q_ARG(ProxyClient *, tunnel.clientTwo())); diff --git a/libnymea-remoteproxyclient/proxyjsonrpcclient.cpp b/libnymea-remoteproxyclient/proxyjsonrpcclient.cpp index 742269f..3f3e0fc 100644 --- a/libnymea-remoteproxyclient/proxyjsonrpcclient.cpp +++ b/libnymea-remoteproxyclient/proxyjsonrpcclient.cpp @@ -104,7 +104,7 @@ void JsonRpcClient::processData(const QByteArray &data) qCDebug(dcRemoteProxyClientJsonRpc()) << "Notification received" << nameSpace << notificationName; - if (nameSpace == "ProxyServer" && notificationName == "TunnelEstablished") { + if (nameSpace == "RemoteProxy" && notificationName == "TunnelEstablished") { QString clientName = notificationParams.value("name").toString(); QString clientUuid = notificationParams.value("uuid").toString(); emit tunnelEstablished(clientName, clientUuid); diff --git a/nymea-remoteproxy.conf b/nymea-remoteproxy.conf index 8a29ce7..463fcaa 100644 --- a/nymea-remoteproxy.conf +++ b/nymea-remoteproxy.conf @@ -3,6 +3,10 @@ name=nymea-remoteproxy writeLogs=false logFile=/var/log/nymea-remoteproxy.log monitorSocket=/tmp/nymea-remoteproxy-monitor.sock +jsonRpcTimeout=10000 +authenticationTimeout=8000 +inactiveTimeout=8000 +aloneTimeout=8000 [SSL] certificate=/etc/ssl/certs/ssl-cert-snakeoil.pem diff --git a/nymea-remoteproxy.pri b/nymea-remoteproxy.pri index 0d27513..9059f94 100644 --- a/nymea-remoteproxy.pri +++ b/nymea-remoteproxy.pri @@ -4,7 +4,7 @@ QT -= gui # Define versions SERVER_NAME=nymea-remoteproxy API_VERSION_MAJOR=0 -API_VERSION_MINOR=1 +API_VERSION_MINOR=2 SERVER_VERSION=0.1.2 DEFINES += SERVER_NAME_STRING=\\\"$${SERVER_NAME}\\\" \ diff --git a/tests/testbase/mockauthenticator.cpp b/tests/testbase/mockauthenticator.cpp index c307b56..95dd8bf 100644 --- a/tests/testbase/mockauthenticator.cpp +++ b/tests/testbase/mockauthenticator.cpp @@ -48,12 +48,12 @@ void MockAuthenticator::setExpectedAuthenticationError(Authenticator::Authentica void MockAuthenticator::replyFinished() { MockAuthenticationReply *reply = static_cast(sender()); - reply->deleteLater(); qCDebug(dcAuthentication()) << name() << "Authentication finished."; setReplyError(reply->authenticationReply(), reply->error()); setReplyFinished(reply->authenticationReply()); + delete reply; } AuthenticationReply *MockAuthenticator::authenticate(ProxyClient *proxyClient)