2021-06-12 11:59:36 +03:00
|
|
|
#ifndef WIREGUARD_CONFIGURATOR_H
|
|
|
|
|
#define WIREGUARD_CONFIGURATOR_H
|
|
|
|
|
|
|
|
|
|
#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:
|
2023-10-06 17:19:44 +05:00
|
|
|
WireguardConfigurator(std::shared_ptr<Settings> settings, 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
|
|
|
};
|
|
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
QString genWireguardConfig(const ServerCredentials &credentials, DockerContainer container,
|
2023-11-21 20:13:51 +07:00
|
|
|
const QJsonObject &containerConfig, QString &clientId, ErrorCode *errorCode = nullptr);
|
2021-06-12 11:59:36 +03:00
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
QString processConfigWithLocalSettings(QString config);
|
|
|
|
|
QString processConfigWithExportSettings(QString config);
|
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:
|
2023-09-22 00:37:55 +05:00
|
|
|
ConnectionData prepareWireguardConfig(const ServerCredentials &credentials, DockerContainer container,
|
|
|
|
|
const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr);
|
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
|