2022-08-29 12:21:09 +04:30
|
|
|
#ifndef UTILITIES_H
|
|
|
|
|
#define UTILITIES_H
|
2020-12-26 15:03:51 +03:00
|
|
|
|
2021-02-25 18:03:24 +03:00
|
|
|
#include <QRegExp>
|
2022-08-29 12:21:09 +04:30
|
|
|
#include <QRegularExpression>
|
2023-06-16 13:43:55 +09:00
|
|
|
#include <QString>
|
2024-05-27 16:15:55 +01:00
|
|
|
#include <QJsonDocument>
|
2020-12-26 15:03:51 +03:00
|
|
|
|
2021-03-18 18:45:08 +03:00
|
|
|
#ifdef Q_OS_WIN
|
2024-09-22 22:52:59 +01:00
|
|
|
#include <windows.h>
|
|
|
|
|
#include <tlhelp32.h>
|
2021-03-18 18:45:08 +03:00
|
|
|
#endif
|
|
|
|
|
|
2023-08-23 00:20:59 +05:00
|
|
|
class Utils : public QObject
|
|
|
|
|
{
|
2022-08-29 12:21:09 +04:30
|
|
|
Q_OBJECT
|
2020-12-26 15:03:51 +03:00
|
|
|
|
|
|
|
|
public:
|
2021-04-04 23:12:36 +03:00
|
|
|
static QString getRandomString(int len);
|
2024-05-27 16:15:55 +01:00
|
|
|
static QString SafeBase64Decode(QString string);
|
|
|
|
|
static QString VerifyJsonString(const QString &source);
|
|
|
|
|
static QString JsonToString(const QJsonObject &json, QJsonDocument::JsonFormat format);
|
|
|
|
|
static QString JsonToString(const QJsonArray &array, QJsonDocument::JsonFormat format);
|
|
|
|
|
static QJsonObject JsonFromString(const QString &string);
|
2023-08-23 00:20:59 +05:00
|
|
|
static QString executable(const QString &baseName, bool absPath);
|
|
|
|
|
static QString usrExecutable(const QString &baseName);
|
|
|
|
|
static bool createEmptyFile(const QString &path);
|
|
|
|
|
static bool initializePath(const QString &path);
|
|
|
|
|
|
2024-05-10 13:06:04 +03:00
|
|
|
static bool processIsRunning(const QString &fileName, const bool fullFlag = false);
|
2024-09-22 22:52:59 +01:00
|
|
|
static bool killProcessByName(const QString &name);
|
2021-03-18 18:45:08 +03:00
|
|
|
|
2022-08-10 22:15:00 +03:00
|
|
|
static QString openVpnExecPath();
|
|
|
|
|
static QString wireguardExecPath();
|
|
|
|
|
static QString certUtilPath();
|
2024-03-27 11:02:34 +00:00
|
|
|
static QString tun2socksPath();
|
2022-08-10 22:15:00 +03:00
|
|
|
|
2024-10-18 13:57:38 +04:00
|
|
|
static void logException(const std::exception &e);
|
|
|
|
|
static void logException(const std::exception_ptr &eptr = std::current_exception());
|
|
|
|
|
|
2021-03-18 18:45:08 +03:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
static bool signalCtrl(DWORD dwProcessId, DWORD dwCtrlEvent);
|
2024-09-22 22:52:59 +01:00
|
|
|
static QString getNextDriverLetter();
|
2021-03-18 18:45:08 +03:00
|
|
|
#endif
|
2020-12-26 15:03:51 +03:00
|
|
|
};
|
|
|
|
|
|
2022-08-29 12:21:09 +04:30
|
|
|
#endif // UTILITIES_H
|