2021-06-12 11:59:36 +03:00
|
|
|
#ifndef WIREGUARD_CONFIGURATOR_H
|
|
|
|
|
#define WIREGUARD_CONFIGURATOR_H
|
|
|
|
|
|
2025-03-06 15:43:47 +01:00
|
|
|
#include <QHostAddress>
|
2021-06-12 11:59:36 +03:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QProcessEnvironment>
|
|
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
#include "configurator_base.h"
|
2021-06-12 11:59:36 +03:00
|
|
|
#include "core/defs.h"
|
2023-09-27 00:40:01 +05:00
|
|
|
#include "core/scripts_registry.h"
|
2021-06-12 11:59:36 +03:00
|
|
|
|
2023-09-22 00:37:55 +05:00
|
|
|
class WireguardConfigurator : public ConfiguratorBase
|
2021-06-12 11:59:36 +03:00
|
|
|
{
|
2022-08-25 17:35:28 +03:00
|
|
|
Q_OBJECT
|
2021-06-12 11:59:36 +03:00
|
|
|
public:
|
2025-03-06 15:43:47 +01:00
|
|
|
WireguardConfigurator(std::shared_ptr<Settings> settings, const QSharedPointer<ServerController> &serverController,
|
|
|
|
|
bool isAwg, QObject *parent = nullptr);
|
2021-06-12 11:59:36 +03:00
|
|
|
|
2023-09-22 00:37:55 +05:00
|
|
|
struct ConnectionData
|
|
|
|
|
{
|
2021-06-12 11:59:36 +03:00
|
|
|
QString clientPrivKey; // client private key
|
2023-09-22 00:37:55 +05:00
|
|
|
QString clientPubKey; // client public key
|
|
|
|
|
QString clientIP; // internal client IP address
|
|
|
|
|
QString serverPubKey; // tls-auth key
|
|
|
|
|
QString pskKey; // preshared key
|
|
|
|
|
QString host; // host ip
|
2023-07-15 14:19:48 -07:00
|
|
|
QString port;
|
2021-06-12 11:59:36 +03:00
|
|
|
};
|
|
|
|
|
|
2025-03-06 15:43:47 +01:00
|
|
|
QString createConfig(const ServerCredentials &credentials, DockerContainer container,
|
|
|
|
|
const QJsonObject &containerConfig, ErrorCode &errorCode);
|
2021-06-12 11:59:36 +03:00
|
|
|
|
2025-03-06 15:43:47 +01:00
|
|
|
QString processConfigWithLocalSettings(const QPair<QString, QString> &dns, const bool isApiConfig,
|
|
|
|
|
QString &protocolConfigString);
|
|
|
|
|
QString processConfigWithExportSettings(const QPair<QString, QString> &dns, const bool isApiConfig,
|
|
|
|
|
QString &protocolConfigString);
|
2021-06-12 11:59:36 +03:00
|
|
|
|
2024-01-22 16:51:11 +03:00
|
|
|
static ConnectionData genClientKeys();
|
|
|
|
|
|
2021-06-12 11:59:36 +03:00
|
|
|
private:
|
2025-03-06 15:43:47 +01:00
|
|
|
QList<QHostAddress> getIpsFromConf(const QString &input);
|
2023-09-22 00:37:55 +05:00
|
|
|
ConnectionData prepareWireguardConfig(const ServerCredentials &credentials, DockerContainer container,
|
2024-05-09 20:56:52 +03:00
|
|
|
const QJsonObject &containerConfig, ErrorCode &errorCode);
|
2024-04-01 20:20:02 +07:00
|
|
|
|
2023-10-06 17:19:44 +05:00
|
|
|
bool m_isAwg;
|
2023-09-27 00:40:01 +05:00
|
|
|
QString m_serverConfigPath;
|
|
|
|
|
QString m_serverPublicKeyPath;
|
|
|
|
|
QString m_serverPskKeyPath;
|
|
|
|
|
amnezia::ProtocolScriptType m_configTemplate;
|
2023-10-06 16:43:52 +05:00
|
|
|
QString m_protocolName;
|
|
|
|
|
QString m_defaultPort;
|
2021-06-12 11:59:36 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // WIREGUARD_CONFIGURATOR_H
|