2020-12-26 15:03:51 +03:00
|
|
|
#ifndef UTILS_H
|
|
|
|
|
#define UTILS_H
|
|
|
|
|
|
2021-02-25 18:03:24 +03:00
|
|
|
#include <QRegExp>
|
2020-12-26 15:03:51 +03:00
|
|
|
#include <QString>
|
|
|
|
|
|
2021-03-18 18:45:08 +03:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
#include "Windows.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-12-26 15:03:51 +03:00
|
|
|
class Utils {
|
|
|
|
|
|
|
|
|
|
public:
|
2021-04-04 23:12:36 +03:00
|
|
|
static QString getRandomString(int len);
|
|
|
|
|
|
2020-12-26 23:17:20 +03:00
|
|
|
static QString configPath();
|
|
|
|
|
static QString defaultVpnConfigFileName();
|
2020-12-26 15:03:51 +03:00
|
|
|
static QString executable(const QString& baseName, bool absPath);
|
|
|
|
|
static QString systemLogPath();
|
|
|
|
|
static bool createEmptyFile(const QString& path);
|
2020-12-26 23:17:20 +03:00
|
|
|
static bool initializePath(const QString& path);
|
2021-01-26 15:01:15 +03:00
|
|
|
|
|
|
|
|
static QString getIPAddress(const QString& host);
|
|
|
|
|
static QString getStringBetween(const QString& s, const QString& a, const QString& b);
|
|
|
|
|
static bool checkIPFormat(const QString& ip);
|
2021-02-25 18:03:24 +03:00
|
|
|
static QRegExp ipAddressRegExp() { return QRegExp("^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\\.(?!$)|$)){4}$"); }
|
2021-03-17 03:45:38 +03:00
|
|
|
static QRegExp ipAddressPortRegExp() { return QRegExp("^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}"
|
|
|
|
|
"(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(\\:[0-9]{1,5}){0,1}$"); }
|
2021-03-18 18:45:08 +03:00
|
|
|
|
2021-05-07 23:28:37 +03:00
|
|
|
static QRegExp ipNetwork24RegExp() { return QRegExp("^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}"
|
|
|
|
|
"0$"); }
|
|
|
|
|
|
2021-05-10 02:33:31 +03:00
|
|
|
static QRegExp ipPortRegExp() { return QRegExp("^()([1-9]|[1-5]?[0-9]{2,4}|6[1-4][0-9]{3}|65[1-4][0-9]{2}|655[1-2][0-9]|6553[1-5])$"); }
|
|
|
|
|
|
2021-03-18 18:45:08 +03:00
|
|
|
static bool processIsRunning(const QString& fileName);
|
|
|
|
|
static void killProcessByName(const QString &name);
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
static bool signalCtrl(DWORD dwProcessId, DWORD dwCtrlEvent);
|
|
|
|
|
#endif
|
2020-12-26 15:03:51 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // UTILS_H
|