2021-04-04 23:12:36 +03:00
|
|
|
#ifndef OPENVPN_CONFIGURATOR_H
|
|
|
|
|
#define OPENVPN_CONFIGURATOR_H
|
2020-12-18 14:57:22 +03:00
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QProcessEnvironment>
|
2021-01-06 17:12:24 +03:00
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
#include "configurator_base.h"
|
2021-04-04 23:12:36 +03:00
|
|
|
#include "core/defs.h"
|
2020-12-18 14:57:22 +03:00
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
class OpenVpnConfigurator : ConfiguratorBase
|
2020-12-18 14:57:22 +03:00
|
|
|
{
|
2022-08-25 17:35:28 +03:00
|
|
|
Q_OBJECT
|
2020-12-18 14:57:22 +03:00
|
|
|
public:
|
2023-04-04 10:22:25 +03:00
|
|
|
OpenVpnConfigurator(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
2020-12-18 14:57:22 +03:00
|
|
|
|
|
|
|
|
struct ConnectionData {
|
|
|
|
|
QString clientId;
|
|
|
|
|
QString request; // certificate request
|
|
|
|
|
QString privKey; // client private key
|
|
|
|
|
QString clientCert; // client signed certificate
|
|
|
|
|
QString caCert; // server certificate
|
|
|
|
|
QString taKey; // tls-auth key
|
|
|
|
|
QString host; // host ip
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
QString genOpenVpnConfig(const ServerCredentials &credentials, DockerContainer container,
|
2023-11-21 20:13:51 +07:00
|
|
|
const QJsonObject &containerConfig, QString &clientId, ErrorCode *errorCode = nullptr);
|
2020-12-18 14:57:22 +03:00
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
QString processConfigWithLocalSettings(QString jsonConfig);
|
|
|
|
|
QString processConfigWithExportSettings(QString jsonConfig);
|
2021-05-10 02:33:31 +03:00
|
|
|
|
2022-08-25 17:35:28 +03:00
|
|
|
ErrorCode signCert(DockerContainer container,
|
2021-04-04 23:12:36 +03:00
|
|
|
const ServerCredentials &credentials, QString clientId);
|
|
|
|
|
|
2023-10-12 20:48:03 +05:00
|
|
|
static ConnectionData createCertRequest();
|
2020-12-18 14:57:22 +03:00
|
|
|
|
2023-10-12 20:48:03 +05:00
|
|
|
private:
|
2022-08-25 17:35:28 +03:00
|
|
|
ConnectionData prepareOpenVpnConfig(const ServerCredentials &credentials,
|
2021-04-26 23:19:19 +03:00
|
|
|
DockerContainer container, ErrorCode *errorCode = nullptr);
|
2021-02-18 15:00:41 +03:00
|
|
|
|
2020-12-18 14:57:22 +03:00
|
|
|
};
|
|
|
|
|
|
2021-04-04 23:12:36 +03:00
|
|
|
#endif // OPENVPN_CONFIGURATOR_H
|