57 lines
2.1 KiB
C++
57 lines
2.1 KiB
C++
#include <QUrl>
|
|
#include <QCoreApplication>
|
|
#include <QLoggingCategory>
|
|
#include <QCommandLineParser>
|
|
#include <QCommandLineOption>
|
|
|
|
#include "proxyclient.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
|
|
QCoreApplication application(argc, argv);
|
|
application.setApplicationName(SERVER_NAME_STRING);
|
|
application.setOrganizationName("guh");
|
|
application.setApplicationVersion(SERVER_VERSION_STRING);
|
|
|
|
QCommandLineParser parser;
|
|
parser.addHelpOption();
|
|
parser.addVersionOption();
|
|
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")
|
|
.arg(SERVER_VERSION_STRING)
|
|
.arg(API_VERSION_STRING)
|
|
.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)) {
|
|
qWarning() << "Please specify the token for authentication." << endl;
|
|
exit(-1);
|
|
}
|
|
|
|
ProxyClient client;
|
|
client.setHostAddress(QHostAddress(parser.value(addressOption)));
|
|
client.setPort(parser.value(portOption).toInt());
|
|
client.start(parser.value(tokenOption));
|
|
|
|
return application.exec();
|
|
}
|