Add systemd service file
parent
0a18897de7
commit
26fe64fdfb
|
|
@ -75,3 +75,5 @@ coverage-html
|
|||
client/nymea-remoteproxy-client
|
||||
tests/test-offline/nymea-remoteproxy-tests-offline
|
||||
tests/test-online/nymea-remoteproxy-tests-online
|
||||
.crossbuilder/
|
||||
source_repository/
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ int main(int argc, char *argv[])
|
|||
QCommandLineParser parser;
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
parser.setApplicationDescription(QString("\nThe nymea remote proxy server. This server allowes nymea-cloud users and "
|
||||
"registered nymea deamons to establish a tunnel connection.\n\n"
|
||||
parser.setApplicationDescription(QString("\nThe nymea remote proxy server client application. This client allowes to test "
|
||||
"a server application as client perspective.\n\n"
|
||||
"Server version: %1\n"
|
||||
"API version: %2\n\n"
|
||||
"Copyright %3 2018 Simon Stürz <simon.stuerz@guh.io>\n")
|
||||
|
|
@ -27,9 +27,19 @@ int main(int argc, char *argv[])
|
|||
.arg(QChar(0xA9)));
|
||||
|
||||
|
||||
|
||||
|
||||
QCommandLineOption tokenOption(QStringList() << "t" << "token", "The AWS token for authentication.", "token");
|
||||
parser.addOption(tokenOption);
|
||||
|
||||
QCommandLineOption addressOption(QStringList() << "a" << "address", "The proxy server host address. Default 127.0.0.1", "address");
|
||||
addressOption.setDefaultValue("127.0.0.1");
|
||||
parser.addOption(addressOption);
|
||||
|
||||
QCommandLineOption portOption(QStringList() << "p" << "port", "The proxy server port. Default 1212", "port");
|
||||
portOption.setDefaultValue("1212");
|
||||
parser.addOption(portOption);
|
||||
|
||||
parser.process(application);
|
||||
|
||||
if (!parser.isSet(tokenOption)) {
|
||||
|
|
@ -38,6 +48,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
ProxyClient client;
|
||||
client.setHostAddress(QHostAddress(parser.value(addressOption)));
|
||||
client.setPort(parser.value(portOption).toInt());
|
||||
client.start(parser.value(tokenOption));
|
||||
|
||||
return application.exec();
|
||||
|
|
|
|||
|
|
@ -9,9 +9,20 @@ ProxyClient::ProxyClient(QObject *parent) :
|
|||
connect(m_connection, &RemoteProxyConnection::ready, this, &ProxyClient::onClientReady);
|
||||
connect(m_connection, &RemoteProxyConnection::authenticated, this, &ProxyClient::onAuthenticationFinished);
|
||||
connect(m_connection, &RemoteProxyConnection::errorOccured, this, &ProxyClient::onErrorOccured);
|
||||
connect(m_connection, &RemoteProxyConnection::disconnected, this, &ProxyClient::onClientDisconnected);
|
||||
|
||||
}
|
||||
|
||||
void ProxyClient::setHostAddress(const QHostAddress &hostAddress)
|
||||
{
|
||||
m_hostAddress = hostAddress;
|
||||
}
|
||||
|
||||
void ProxyClient::setPort(int port)
|
||||
{
|
||||
m_port = port;
|
||||
}
|
||||
|
||||
void ProxyClient::onErrorOccured(RemoteProxyConnection::Error error)
|
||||
{
|
||||
qDebug() << "Error occured" << error << m_connection->errorString();
|
||||
|
|
@ -27,6 +38,12 @@ void ProxyClient::onAuthenticationFinished()
|
|||
qDebug() << "Authentication finished.";
|
||||
}
|
||||
|
||||
void ProxyClient::onClientDisconnected()
|
||||
{
|
||||
qDebug() << "Disconnected from" << m_connection;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void ProxyClient::start(const QString &token)
|
||||
{
|
||||
m_token = token;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public:
|
|||
explicit ProxyClient(QObject *parent = nullptr);
|
||||
|
||||
void setHostAddress(const QHostAddress &hostAddress);
|
||||
void setPort(const int &port);
|
||||
void setPort(int port);
|
||||
|
||||
private:
|
||||
QString m_token;
|
||||
|
|
@ -30,6 +30,7 @@ private slots:
|
|||
void onErrorOccured(RemoteProxyConnection::Error error);
|
||||
void onClientReady();
|
||||
void onAuthenticationFinished();
|
||||
void onClientDisconnected();
|
||||
|
||||
public slots:
|
||||
void start(const QString &token);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ Section: utils
|
|||
Priority: options
|
||||
Maintainer: Simon Stürz <simon.stürz@guh.io>
|
||||
Build-depends: debhelper (>= 0.0.0),
|
||||
dh-systemd,
|
||||
libqt5websockets5-dev,
|
||||
Standards-Version: 3.9.3
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=nymea-remoteproxy - Proxy server for the nymea remote connection
|
||||
Documentation=https://gitlab.nymea.io/cloud/nymea-remoteproxy
|
||||
After=network.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/nymea-remoteproxy -c /etc/nymea/nymea-remoteproxy.conf
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
|
|
@ -21,4 +21,4 @@ override_dh_auto_clean:
|
|||
rm -rf $(PREPROCESS_FILES:.in=)
|
||||
|
||||
%:
|
||||
dh $@
|
||||
dh $@ --with systemd
|
||||
|
|
|
|||
Loading…
Reference in New Issue