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"
|
|
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
class WireguardConfigurator : 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:
|
2022-08-25 17:35:28 +03:00
|
|
|
WireguardConfigurator(std::shared_ptr<Settings> settings,
|
|
|
|
|
std::shared_ptr<ServerController> serverController, QObject *parent = nullptr);
|
2021-06-12 11:59:36 +03:00
|
|
|
|
|
|
|
|
struct ConnectionData {
|
|
|
|
|
QString clientPrivKey; // client private key
|
|
|
|
|
QString clientPubKey; // client public key
|
2021-12-25 21:14:55 +03:00
|
|
|
QString clientIP; // internal client IP address
|
2021-06-12 11:59:36 +03:00
|
|
|
QString serverPubKey; // tls-auth key
|
|
|
|
|
QString pskKey; // preshared key
|
|
|
|
|
QString host; // host ip
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
QString genWireguardConfig(const ServerCredentials &credentials, DockerContainer container,
|
2021-06-12 11:59:36 +03:00
|
|
|
const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr);
|
|
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
QString processConfigWithLocalSettings(QString config);
|
|
|
|
|
QString processConfigWithExportSettings(QString config);
|
2021-06-12 11:59:36 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2022-08-25 17:35:28 +03:00
|
|
|
ConnectionData prepareWireguardConfig(const ServerCredentials &credentials,
|
2021-12-25 21:14:55 +03:00
|
|
|
DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr);
|
2021-06-12 11:59:36 +03:00
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
ConnectionData genClientKeys();
|
2021-06-12 11:59:36 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // WIREGUARD_CONFIGURATOR_H
|