diff --git a/CMakeLists.txt b/CMakeLists.txt index 1655bc2..dea9e62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -project(smsub LANGUAGES CXX VERSION 0.10) +project(smsub LANGUAGES CXX VERSION 0.10.1) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/SMSubServer.cpp b/SMSubServer.cpp index 20a5672..6ea0b0f 100644 --- a/SMSubServer.cpp +++ b/SMSubServer.cpp @@ -113,15 +113,15 @@ void SMSubServer::newConnection() bool SMSubServer::messageReceived(QObject *socket, const QByteArray &message) { // Only allow commands being sent if authenticated - const bool isAuthenticated = socket->property("Authenticated").toBool(); + const bool isAuthenticated = isVariantTrue(socket->property("Authenticated")); if (isAuthenticated) { if (message == "+dbg") { socket->setProperty("ReceiveDbgMsg", true); - sendMessage(socket, "Debug messages enabled!\n"); + debugOutput(socket, "Debug messages enabled!"); } else if (message == "-dbg") { + debugOutput(socket, "Debug messages disabled!"); socket->setProperty("ReceiveDbgMsg", false); - sendMessage(socket, "Debug messages disabled!\n"); } else if (message == "+json") { socket->setProperty("ReceiveJson", true); @@ -152,7 +152,7 @@ bool SMSubServer::messageReceived(QObject *socket, const QByteArray &message) QByteArray authUuid = QUuid::createUuid().toByteArray(QUuid::Id128) + QUuid::createUuid().toByteArray(QUuid::Id128); authUuid = QByteArray::fromHex(authUuid).toBase64(QByteArray::OmitTrailingEquals); - emit tokenRegistered(QString::fromUtf8(authUuid)); + emit tokenRegistered(authUuid); sendMessage(socket, "Token: " + authUuid + '\n'); } else { @@ -215,7 +215,7 @@ bool SMSubServer::messageReceived(QObject *socket, const QByteArray &message) } else { // Authenticate when token is valid, otherwise disconnect - if (tokens.contains(QString::fromUtf8(message))) { + if (tokens.contains(message)) { // Set client as authenticated and add it to vector socket->setProperty("Authenticated", true); sendMessage(socket, "Login successful!\n"); @@ -349,7 +349,7 @@ void SMSubServer::sendMessage(QObject *socket, const QByteArray &message) } } -void SMSubServer::registerToken(const QString &token) +void SMSubServer::registerToken(const QByteArray &token) { // Register temporary token for a secure remote connection tokens << token; diff --git a/SMSubServer.h b/SMSubServer.h index f86786e..d7f452a 100644 --- a/SMSubServer.h +++ b/SMSubServer.h @@ -44,7 +44,7 @@ public: public slots: void writeOutput(const QByteArray &output); - void registerToken(const QString &token); + void registerToken(const QByteArray &token); void statusUpdated(const bool status, const qint64 time); private slots: @@ -60,7 +60,7 @@ private: inline bool isVariantTrue(const QVariant &variant); SMSubServerSettings *serverSettings; QVector sockets; - QVector tokens; + QVector tokens; qint64 startTime; qint64 stopTime; ServerType type; @@ -68,7 +68,7 @@ private: bool status; signals: - void tokenRegistered(const QString &password); + void tokenRegistered(const QByteArray &token); void inputWritten(const QByteArray &input); void startRequested(); void stopRequested(); diff --git a/main.cpp b/main.cpp index 815a281..a3d8eee 100644 --- a/main.cpp +++ b/main.cpp @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); a.setApplicationName("Server Manager Subprocess"); - a.setApplicationVersion("0.10"); + a.setApplicationVersion("0.10.1"); #ifdef Q_OS_UNIX catchUnixSignals({SIGINT, SIGHUP, SIGQUIT, SIGTERM});