OpenVpnLogic added

This commit is contained in:
pokamest 2021-09-06 13:41:45 +03:00
parent d1ea625435
commit a6e5cfff8a
12 changed files with 899 additions and 578 deletions

View file

@ -1,7 +1,7 @@
#include "GeneralSettingsLogic.h"
#include "ShareConnectionLogic.h"
#include "../uilogic.h"
#include "ShareConnectionLogic.h"
using namespace amnezia;
using namespace PageEnumNS;

View file

@ -0,0 +1,51 @@
#include <QApplication>
#include <QClipboard>
#include <QDebug>
#include <QDesktopServices>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QHostInfo>
#include <QItemSelectionModel>
#include <QJsonDocument>
#include <QJsonObject>
#include <QKeyEvent>
#include <QMenu>
#include <QMessageBox>
#include <QMetaEnum>
#include <QSysInfo>
#include <QThread>
#include <QTimer>
#include <QRegularExpression>
#include <QSaveFile>
//#include "configurators/cloak_configurator.h"
//#include "configurators/vpn_configurator.h"
//#include "configurators/openvpn_configurator.h"
//#include "configurators/shadowsocks_configurator.h"
//#include "configurators/ssh_configurator.h"
//#include "core/servercontroller.h"
//#include "core/server_defs.h"
//#include "core/errorstrings.h"
//#include "protocols/protocols_defs.h"
//#include "protocols/shadowsocksvpnprotocol.h"
#include "debug.h"
#include "defines.h"
#include "CloakLogic.h"
#include "utils.h"
#include "vpnconnection.h"
#include <functional>
using namespace amnezia;
using namespace PageEnumNS;
CloakLogic::CloakLogic(UiLogic *uiLogic, QObject *parent):
QObject(parent),
m_uiLogic(uiLogic)
{
}

View file

@ -0,0 +1,34 @@
#ifndef CLOAK_LOGIC_H
#define CLOAK_LOGIC_H
#include "../../pages.h"
#include "settings.h"
class UiLogic;
class CloakLogic : public QObject
{
Q_OBJECT
public:
explicit CloakLogic(UiLogic *uiLogic, QObject *parent = nullptr);
~CloakLogic() = default;
signals:
private:
private slots:
private:
Settings m_settings;
UiLogic *m_uiLogic;
};
#endif // CLOAK_LOGIC_H

View file

@ -0,0 +1,474 @@
//#include <QApplication>
//#include <QClipboard>
//#include <QDebug>
//#include <QDesktopServices>
//#include <QFileDialog>
//#include <QHBoxLayout>
//#include <QHostInfo>
//#include <QItemSelectionModel>
//#include <QJsonDocument>
//#include <QJsonObject>
//#include <QKeyEvent>
//#include <QMenu>
//#include <QMessageBox>
//#include <QMetaEnum>
//#include <QSysInfo>
//#include <QThread>
//#include <QTimer>
//#include <QRegularExpression>
//#include <QSaveFile>
//#include "configurators/cloak_configurator.h"
//#include "configurators/vpn_configurator.h"
//#include "configurators/openvpn_configurator.h"
//#include "configurators/shadowsocks_configurator.h"
//#include "configurators/ssh_configurator.h"
#include "core/servercontroller.h"
//#include "core/server_defs.h"
//#include "core/errorstrings.h"
//#include "protocols/protocols_defs.h"
//#include "protocols/shadowsocksvpnprotocol.h"
#include "debug.h"
#include "defines.h"
#include "OpenVpnLogic.h"
#include "utils.h"
#include "vpnconnection.h"
#include <functional>
#include "../../uilogic.h"
using namespace amnezia;
using namespace PageEnumNS;
OpenVpnLogic::OpenVpnLogic(UiLogic *uiLogic, QObject *parent):
QObject(parent),
m_uiLogic(uiLogic),
m_lineEditProtoOpenvpnSubnetText{},
m_radioButtonProtoOpenvpnUdpChecked{false},
m_checkBoxProtoOpenvpnAutoEncryptionChecked{},
m_comboBoxProtoOpenvpnCipherText{"AES-256-GCM"},
m_comboBoxProtoOpenvpnHashText{"SHA512"},
m_checkBoxProtoOpenvpnBlockDnsChecked{false},
m_lineEditProtoOpenvpnPortText{},
m_checkBoxProtoOpenvpnTlsAuthChecked{false},
m_widgetProtoOpenvpnEnabled{false},
m_pushButtonProtoOpenvpnSaveVisible{false},
m_progressBarProtoOpenvpnResetVisible{false},
m_radioButtonProtoOpenvpnUdpEnabled{false},
m_radioButtonProtoOpenvpnTcpEnabled{false},
m_radioButtonProtoOpenvpnTcpChecked{false},
m_lineEditProtoOpenvpnPortEnabled{false},
m_comboBoxProtoOpenvpnCipherEnabled{true},
m_comboBoxProtoOpenvpnHashEnabled{true},
m_pageProtoOpenvpnEnabled{true},
m_labelProtoOpenvpnInfoVisible{true},
m_labelProtoOpenvpnInfoText{},
m_progressBarProtoOpenvpnResetValue{0},
m_progressBarProtoOpenvpnResetMaximium{100}
{
}
void OpenVpnLogic::updateOpenVpnPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData)
{
setWidgetProtoOpenvpnEnabled(haveAuthData);
setPushButtonProtoOpenvpnSaveVisible(haveAuthData);
setProgressBarProtoOpenvpnResetVisible(haveAuthData);
setRadioButtonProtoOpenvpnUdpEnabled(true);
setRadioButtonProtoOpenvpnTcpEnabled(true);
setLineEditProtoOpenvpnSubnetText(openvpnConfig.value(config_key::subnet_address).
toString(protocols::openvpn::defaultSubnetAddress));
QString trasnsport = openvpnConfig.value(config_key::transport_proto).
toString(protocols::openvpn::defaultTransportProto);
setRadioButtonProtoOpenvpnUdpChecked(trasnsport == protocols::openvpn::defaultTransportProto);
setRadioButtonProtoOpenvpnTcpChecked(trasnsport != protocols::openvpn::defaultTransportProto);
setComboBoxProtoOpenvpnCipherText(openvpnConfig.value(config_key::cipher).
toString(protocols::openvpn::defaultCipher));
setComboBoxProtoOpenvpnHashText(openvpnConfig.value(config_key::hash).
toString(protocols::openvpn::defaultHash));
bool blockOutsideDns = openvpnConfig.value(config_key::block_outside_dns).toBool(protocols::openvpn::defaultBlockOutsideDns);
setCheckBoxProtoOpenvpnBlockDnsChecked(blockOutsideDns);
bool isNcpDisabled = openvpnConfig.value(config_key::ncp_disable).toBool(protocols::openvpn::defaultNcpDisable);
setCheckBoxProtoOpenvpnAutoEncryptionChecked(!isNcpDisabled);
bool isTlsAuth = openvpnConfig.value(config_key::tls_auth).toBool(protocols::openvpn::defaultTlsAuth);
setCheckBoxProtoOpenvpnTlsAuthChecked(isTlsAuth);
if (container == DockerContainer::OpenVpnOverShadowSocks) {
setRadioButtonProtoOpenvpnUdpEnabled(false);
setRadioButtonProtoOpenvpnTcpEnabled(false);
setRadioButtonProtoOpenvpnTcpChecked(true);
}
setLineEditProtoOpenvpnPortText(openvpnConfig.value(config_key::port).
toString(protocols::openvpn::defaultPort));
setLineEditProtoOpenvpnPortEnabled(container == DockerContainer::OpenVpn);
}
QString OpenVpnLogic::getLineEditProtoOpenvpnSubnetText() const
{
return m_lineEditProtoOpenvpnSubnetText;
}
void OpenVpnLogic::setLineEditProtoOpenvpnSubnetText(const QString &lineEditProtoOpenvpnSubnetText)
{
if (m_lineEditProtoOpenvpnSubnetText != lineEditProtoOpenvpnSubnetText) {
m_lineEditProtoOpenvpnSubnetText = lineEditProtoOpenvpnSubnetText;
emit lineEditProtoOpenvpnSubnetTextChanged();
}
}
bool OpenVpnLogic::getRadioButtonProtoOpenvpnUdpChecked() const
{
return m_radioButtonProtoOpenvpnUdpChecked;
}
void OpenVpnLogic::setRadioButtonProtoOpenvpnUdpChecked(bool radioButtonProtoOpenvpnUdpChecked)
{
if (m_radioButtonProtoOpenvpnUdpChecked != radioButtonProtoOpenvpnUdpChecked) {
m_radioButtonProtoOpenvpnUdpChecked = radioButtonProtoOpenvpnUdpChecked;
emit radioButtonProtoOpenvpnUdpCheckedChanged();
}
}
bool OpenVpnLogic::getCheckBoxProtoOpenvpnAutoEncryptionChecked() const
{
return m_checkBoxProtoOpenvpnAutoEncryptionChecked;
}
void OpenVpnLogic::setCheckBoxProtoOpenvpnAutoEncryptionChecked(bool checkBoxProtoOpenvpnAutoEncryptionChecked)
{
if (m_checkBoxProtoOpenvpnAutoEncryptionChecked != checkBoxProtoOpenvpnAutoEncryptionChecked) {
m_checkBoxProtoOpenvpnAutoEncryptionChecked = checkBoxProtoOpenvpnAutoEncryptionChecked;
emit checkBoxProtoOpenvpnAutoEncryptionCheckedChanged();
}
}
QString OpenVpnLogic::getComboBoxProtoOpenvpnCipherText() const
{
return m_comboBoxProtoOpenvpnCipherText;
}
void OpenVpnLogic::setComboBoxProtoOpenvpnCipherText(const QString &comboBoxProtoOpenvpnCipherText)
{
if (m_comboBoxProtoOpenvpnCipherText != comboBoxProtoOpenvpnCipherText) {
m_comboBoxProtoOpenvpnCipherText = comboBoxProtoOpenvpnCipherText;
emit comboBoxProtoOpenvpnCipherTextChanged();
}
}
QString OpenVpnLogic::getComboBoxProtoOpenvpnHashText() const
{
return m_comboBoxProtoOpenvpnHashText;
}
void OpenVpnLogic::setComboBoxProtoOpenvpnHashText(const QString &comboBoxProtoOpenvpnHashText)
{
if (m_comboBoxProtoOpenvpnHashText != comboBoxProtoOpenvpnHashText) {
m_comboBoxProtoOpenvpnHashText = comboBoxProtoOpenvpnHashText;
emit comboBoxProtoOpenvpnHashTextChanged();
}
}
bool OpenVpnLogic::getCheckBoxProtoOpenvpnBlockDnsChecked() const
{
return m_checkBoxProtoOpenvpnBlockDnsChecked;
}
void OpenVpnLogic::setCheckBoxProtoOpenvpnBlockDnsChecked(bool checkBoxProtoOpenvpnBlockDnsChecked)
{
if (m_checkBoxProtoOpenvpnBlockDnsChecked != checkBoxProtoOpenvpnBlockDnsChecked) {
m_checkBoxProtoOpenvpnBlockDnsChecked = checkBoxProtoOpenvpnBlockDnsChecked;
emit checkBoxProtoOpenvpnBlockDnsCheckedChanged();
}
}
QString OpenVpnLogic::getLineEditProtoOpenvpnPortText() const
{
return m_lineEditProtoOpenvpnPortText;
}
void OpenVpnLogic::setLineEditProtoOpenvpnPortText(const QString &lineEditProtoOpenvpnPortText)
{
if (m_lineEditProtoOpenvpnPortText != lineEditProtoOpenvpnPortText) {
m_lineEditProtoOpenvpnPortText = lineEditProtoOpenvpnPortText;
emit lineEditProtoOpenvpnPortTextChanged();
}
}
bool OpenVpnLogic::getCheckBoxProtoOpenvpnTlsAuthChecked() const
{
return m_checkBoxProtoOpenvpnTlsAuthChecked;
}
void OpenVpnLogic::setCheckBoxProtoOpenvpnTlsAuthChecked(bool checkBoxProtoOpenvpnTlsAuthChecked)
{
if (m_checkBoxProtoOpenvpnTlsAuthChecked != checkBoxProtoOpenvpnTlsAuthChecked) {
m_checkBoxProtoOpenvpnTlsAuthChecked = checkBoxProtoOpenvpnTlsAuthChecked;
emit checkBoxProtoOpenvpnTlsAuthCheckedChanged();
}
}
bool OpenVpnLogic::getWidgetProtoOpenvpnEnabled() const
{
return m_widgetProtoOpenvpnEnabled;
}
void OpenVpnLogic::setWidgetProtoOpenvpnEnabled(bool widgetProtoOpenvpnEnabled)
{
if (m_widgetProtoOpenvpnEnabled != widgetProtoOpenvpnEnabled) {
m_widgetProtoOpenvpnEnabled = widgetProtoOpenvpnEnabled;
emit widgetProtoOpenvpnEnabledChanged();
}
}
bool OpenVpnLogic::getPushButtonProtoOpenvpnSaveVisible() const
{
return m_pushButtonProtoOpenvpnSaveVisible;
}
void OpenVpnLogic::setPushButtonProtoOpenvpnSaveVisible(bool pushButtonProtoOpenvpnSaveVisible)
{
if (m_pushButtonProtoOpenvpnSaveVisible != pushButtonProtoOpenvpnSaveVisible) {
m_pushButtonProtoOpenvpnSaveVisible = pushButtonProtoOpenvpnSaveVisible;
emit pushButtonProtoOpenvpnSaveVisibleChanged();
}
}
bool OpenVpnLogic::getProgressBarProtoOpenvpnResetVisible() const
{
return m_progressBarProtoOpenvpnResetVisible;
}
void OpenVpnLogic::setProgressBarProtoOpenvpnResetVisible(bool progressBarProtoOpenvpnResetVisible)
{
if (m_progressBarProtoOpenvpnResetVisible != progressBarProtoOpenvpnResetVisible) {
m_progressBarProtoOpenvpnResetVisible = progressBarProtoOpenvpnResetVisible;
emit progressBarProtoOpenvpnResetVisibleChanged();
}
}
bool OpenVpnLogic::getRadioButtonProtoOpenvpnUdpEnabled() const
{
return m_radioButtonProtoOpenvpnUdpEnabled;
}
void OpenVpnLogic::setRadioButtonProtoOpenvpnUdpEnabled(bool radioButtonProtoOpenvpnUdpEnabled)
{
if (m_radioButtonProtoOpenvpnUdpEnabled != radioButtonProtoOpenvpnUdpEnabled) {
m_radioButtonProtoOpenvpnUdpEnabled = radioButtonProtoOpenvpnUdpEnabled;
emit radioButtonProtoOpenvpnUdpEnabledChanged();
}
}
bool OpenVpnLogic::getRadioButtonProtoOpenvpnTcpEnabled() const
{
return m_radioButtonProtoOpenvpnTcpEnabled;
}
void OpenVpnLogic::setRadioButtonProtoOpenvpnTcpEnabled(bool radioButtonProtoOpenvpnTcpEnabled)
{
if (m_radioButtonProtoOpenvpnTcpEnabled != radioButtonProtoOpenvpnTcpEnabled) {
m_radioButtonProtoOpenvpnTcpEnabled = radioButtonProtoOpenvpnTcpEnabled;
emit radioButtonProtoOpenvpnTcpEnabledChanged();
}
}
bool OpenVpnLogic::getRadioButtonProtoOpenvpnTcpChecked() const
{
return m_radioButtonProtoOpenvpnTcpChecked;
}
void OpenVpnLogic::setRadioButtonProtoOpenvpnTcpChecked(bool radioButtonProtoOpenvpnTcpChecked)
{
if (m_radioButtonProtoOpenvpnTcpChecked != radioButtonProtoOpenvpnTcpChecked) {
m_radioButtonProtoOpenvpnTcpChecked = radioButtonProtoOpenvpnTcpChecked;
emit radioButtonProtoOpenvpnTcpCheckedChanged();
}
}
bool OpenVpnLogic::getLineEditProtoOpenvpnPortEnabled() const
{
return m_lineEditProtoOpenvpnPortEnabled;
}
void OpenVpnLogic::setLineEditProtoOpenvpnPortEnabled(bool lineEditProtoOpenvpnPortEnabled)
{
if (m_lineEditProtoOpenvpnPortEnabled != lineEditProtoOpenvpnPortEnabled) {
m_lineEditProtoOpenvpnPortEnabled = lineEditProtoOpenvpnPortEnabled;
emit lineEditProtoOpenvpnPortEnabledChanged();
}
}
bool OpenVpnLogic::getComboBoxProtoOpenvpnCipherEnabled() const
{
return m_comboBoxProtoOpenvpnCipherEnabled;
}
void OpenVpnLogic::setComboBoxProtoOpenvpnCipherEnabled(bool comboBoxProtoOpenvpnCipherEnabled)
{
if (m_comboBoxProtoOpenvpnCipherEnabled != comboBoxProtoOpenvpnCipherEnabled) {
m_comboBoxProtoOpenvpnCipherEnabled = comboBoxProtoOpenvpnCipherEnabled;
emit comboBoxProtoOpenvpnCipherEnabledChanged();
}
}
bool OpenVpnLogic::getComboBoxProtoOpenvpnHashEnabled() const
{
return m_comboBoxProtoOpenvpnHashEnabled;
}
void OpenVpnLogic::setComboBoxProtoOpenvpnHashEnabled(bool comboBoxProtoOpenvpnHashEnabled)
{
if (m_comboBoxProtoOpenvpnHashEnabled != comboBoxProtoOpenvpnHashEnabled) {
m_comboBoxProtoOpenvpnHashEnabled = comboBoxProtoOpenvpnHashEnabled;
emit comboBoxProtoOpenvpnHashEnabledChanged();
}
}
bool OpenVpnLogic::getPageProtoOpenvpnEnabled() const
{
return m_pageProtoOpenvpnEnabled;
}
void OpenVpnLogic::setPageProtoOpenvpnEnabled(bool pageProtoOpenvpnEnabled)
{
if (m_pageProtoOpenvpnEnabled != pageProtoOpenvpnEnabled) {
m_pageProtoOpenvpnEnabled = pageProtoOpenvpnEnabled;
emit pageProtoOpenvpnEnabledChanged();
}
}
bool OpenVpnLogic::getLabelProtoOpenvpnInfoVisible() const
{
return m_labelProtoOpenvpnInfoVisible;
}
void OpenVpnLogic::setLabelProtoOpenvpnInfoVisible(bool labelProtoOpenvpnInfoVisible)
{
if (m_labelProtoOpenvpnInfoVisible != labelProtoOpenvpnInfoVisible) {
m_labelProtoOpenvpnInfoVisible = labelProtoOpenvpnInfoVisible;
emit labelProtoOpenvpnInfoVisibleChanged();
}
}
QString OpenVpnLogic::getLabelProtoOpenvpnInfoText() const
{
return m_labelProtoOpenvpnInfoText;
}
void OpenVpnLogic::setLabelProtoOpenvpnInfoText(const QString &labelProtoOpenvpnInfoText)
{
if (m_labelProtoOpenvpnInfoText != labelProtoOpenvpnInfoText) {
m_labelProtoOpenvpnInfoText = labelProtoOpenvpnInfoText;
emit labelProtoOpenvpnInfoTextChanged();
}
}
int OpenVpnLogic::getProgressBarProtoOpenvpnResetValue() const
{
return m_progressBarProtoOpenvpnResetValue;
}
void OpenVpnLogic::setProgressBarProtoOpenvpnResetValue(int progressBarProtoOpenvpnResetValue)
{
if (m_progressBarProtoOpenvpnResetValue != progressBarProtoOpenvpnResetValue) {
m_progressBarProtoOpenvpnResetValue = progressBarProtoOpenvpnResetValue;
emit progressBarProtoOpenvpnResetValueChanged();
}
}
int OpenVpnLogic::getProgressBarProtoOpenvpnResetMaximium() const
{
return m_progressBarProtoOpenvpnResetMaximium;
}
void OpenVpnLogic::setProgressBarProtoOpenvpnResetMaximium(int progressBarProtoOpenvpnResetMaximium)
{
if (m_progressBarProtoOpenvpnResetMaximium != progressBarProtoOpenvpnResetMaximium) {
m_progressBarProtoOpenvpnResetMaximium = progressBarProtoOpenvpnResetMaximium;
emit progressBarProtoOpenvpnResetMaximiumChanged();
}
}
void OpenVpnLogic::onCheckBoxProtoOpenvpnAutoEncryptionClicked()
{
setComboBoxProtoOpenvpnCipherEnabled(!getCheckBoxProtoOpenvpnAutoEncryptionChecked());
setComboBoxProtoOpenvpnHashEnabled(!getCheckBoxProtoOpenvpnAutoEncryptionChecked());
}
void OpenVpnLogic::onPushButtonProtoOpenvpnSaveClicked()
{
QJsonObject protocolConfig = m_settings.protocolConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, Protocol::OpenVpn);
protocolConfig = getOpenVpnConfigFromPage(protocolConfig);
QJsonObject containerConfig = m_settings.containerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
QJsonObject newContainerConfig = containerConfig;
newContainerConfig.insert(config_key::openvpn, protocolConfig);
UiLogic::PageFunc page_proto_openvpn;
page_proto_openvpn.setEnabledFunc = [this] (bool enabled) -> void {
setPageProtoOpenvpnEnabled(enabled);
};
UiLogic::ButtonFunc pushButton_proto_openvpn_save;
pushButton_proto_openvpn_save.setVisibleFunc = [this] (bool visible) ->void {
setPushButtonProtoOpenvpnSaveVisible(visible);
};
UiLogic::LabelFunc label_proto_openvpn_info;
label_proto_openvpn_info.setVisibleFunc = [this] (bool visible) ->void {
setLabelProtoOpenvpnInfoVisible(visible);
};
label_proto_openvpn_info.setTextFunc = [this] (const QString& text) ->void {
setLabelProtoOpenvpnInfoText(text);
};
UiLogic::ProgressFunc progressBar_proto_openvpn_reset;
progressBar_proto_openvpn_reset.setVisibleFunc = [this] (bool visible) ->void {
setProgressBarProtoOpenvpnResetVisible(visible);
};
progressBar_proto_openvpn_reset.setValueFunc = [this] (int value) ->void {
setProgressBarProtoOpenvpnResetValue(value);
};
progressBar_proto_openvpn_reset.getValueFunc = [this] (void) -> int {
return getProgressBarProtoOpenvpnResetValue();
};
progressBar_proto_openvpn_reset.getMaximiumFunc = [this] (void) -> int {
return getProgressBarProtoOpenvpnResetMaximium();
};
ErrorCode e = m_uiLogic->doInstallAction([this, containerConfig, newContainerConfig](){
return ServerController::updateContainer(m_settings.serverCredentials(m_uiLogic->selectedServerIndex), m_uiLogic->selectedDockerContainer, containerConfig, newContainerConfig);
},
page_proto_openvpn, progressBar_proto_openvpn_reset,
pushButton_proto_openvpn_save, label_proto_openvpn_info);
if (!e) {
m_settings.setContainerConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer, newContainerConfig);
m_settings.clearLastConnectionConfig(m_uiLogic->selectedServerIndex, m_uiLogic->selectedDockerContainer);
}
qDebug() << "Protocol saved with code:" << e << "for" << m_uiLogic->selectedServerIndex << m_uiLogic->selectedDockerContainer;
}
QJsonObject OpenVpnLogic::getOpenVpnConfigFromPage(QJsonObject oldConfig)
{
oldConfig.insert(config_key::subnet_address, getLineEditProtoOpenvpnSubnetText());
oldConfig.insert(config_key::transport_proto, getRadioButtonProtoOpenvpnUdpChecked() ? protocols::UDP : protocols::TCP);
oldConfig.insert(config_key::ncp_disable, ! getCheckBoxProtoOpenvpnAutoEncryptionChecked());
oldConfig.insert(config_key::cipher, getComboBoxProtoOpenvpnCipherText());
oldConfig.insert(config_key::hash, getComboBoxProtoOpenvpnHashText());
oldConfig.insert(config_key::block_outside_dns, getCheckBoxProtoOpenvpnBlockDnsChecked());
oldConfig.insert(config_key::port, getLineEditProtoOpenvpnPortText());
oldConfig.insert(config_key::tls_auth, getCheckBoxProtoOpenvpnTlsAuthChecked());
return oldConfig;
}

View file

@ -0,0 +1,155 @@
#ifndef OPENVPN_LOGIC_H
#define OPENVPN_LOGIC_H
#include "../../pages.h"
#include "settings.h"
class UiLogic;
class OpenVpnLogic : public QObject
{
Q_OBJECT
public:
Q_PROPERTY(QString lineEditProtoOpenvpnSubnetText READ getLineEditProtoOpenvpnSubnetText WRITE setLineEditProtoOpenvpnSubnetText NOTIFY lineEditProtoOpenvpnSubnetTextChanged)
Q_PROPERTY(bool radioButtonProtoOpenvpnUdpChecked READ getRadioButtonProtoOpenvpnUdpChecked WRITE setRadioButtonProtoOpenvpnUdpChecked NOTIFY radioButtonProtoOpenvpnUdpCheckedChanged)
Q_PROPERTY(bool checkBoxProtoOpenvpnAutoEncryptionChecked READ getCheckBoxProtoOpenvpnAutoEncryptionChecked WRITE setCheckBoxProtoOpenvpnAutoEncryptionChecked NOTIFY checkBoxProtoOpenvpnAutoEncryptionCheckedChanged)
Q_PROPERTY(QString comboBoxProtoOpenvpnCipherText READ getComboBoxProtoOpenvpnCipherText WRITE setComboBoxProtoOpenvpnCipherText NOTIFY comboBoxProtoOpenvpnCipherTextChanged)
Q_PROPERTY(QString comboBoxProtoOpenvpnHashText READ getComboBoxProtoOpenvpnHashText WRITE setComboBoxProtoOpenvpnHashText NOTIFY comboBoxProtoOpenvpnHashTextChanged)
Q_PROPERTY(bool checkBoxProtoOpenvpnBlockDnsChecked READ getCheckBoxProtoOpenvpnBlockDnsChecked WRITE setCheckBoxProtoOpenvpnBlockDnsChecked NOTIFY checkBoxProtoOpenvpnBlockDnsCheckedChanged)
Q_PROPERTY(QString lineEditProtoOpenvpnPortText READ getLineEditProtoOpenvpnPortText WRITE setLineEditProtoOpenvpnPortText NOTIFY lineEditProtoOpenvpnPortTextChanged)
Q_PROPERTY(bool checkBoxProtoOpenvpnTlsAuthChecked READ getCheckBoxProtoOpenvpnTlsAuthChecked WRITE setCheckBoxProtoOpenvpnTlsAuthChecked NOTIFY checkBoxProtoOpenvpnTlsAuthCheckedChanged)
Q_PROPERTY(bool widgetProtoOpenvpnEnabled READ getWidgetProtoOpenvpnEnabled WRITE setWidgetProtoOpenvpnEnabled NOTIFY widgetProtoOpenvpnEnabledChanged)
Q_PROPERTY(bool pushButtonProtoOpenvpnSaveVisible READ getPushButtonProtoOpenvpnSaveVisible WRITE setPushButtonProtoOpenvpnSaveVisible NOTIFY pushButtonProtoOpenvpnSaveVisibleChanged)
Q_PROPERTY(bool progressBarProtoOpenvpnResetVisible READ getProgressBarProtoOpenvpnResetVisible WRITE setProgressBarProtoOpenvpnResetVisible NOTIFY progressBarProtoOpenvpnResetVisibleChanged)
Q_PROPERTY(bool radioButtonProtoOpenvpnUdpEnabled READ getRadioButtonProtoOpenvpnUdpEnabled WRITE setRadioButtonProtoOpenvpnUdpEnabled NOTIFY radioButtonProtoOpenvpnUdpEnabledChanged)
Q_PROPERTY(bool radioButtonProtoOpenvpnTcpEnabled READ getRadioButtonProtoOpenvpnTcpEnabled WRITE setRadioButtonProtoOpenvpnTcpEnabled NOTIFY radioButtonProtoOpenvpnTcpEnabledChanged)
Q_PROPERTY(bool radioButtonProtoOpenvpnTcpChecked READ getRadioButtonProtoOpenvpnTcpChecked WRITE setRadioButtonProtoOpenvpnTcpChecked NOTIFY radioButtonProtoOpenvpnTcpCheckedChanged)
Q_PROPERTY(bool lineEditProtoOpenvpnPortEnabled READ getLineEditProtoOpenvpnPortEnabled WRITE setLineEditProtoOpenvpnPortEnabled NOTIFY lineEditProtoOpenvpnPortEnabledChanged)
Q_PROPERTY(bool comboBoxProtoOpenvpnCipherEnabled READ getComboBoxProtoOpenvpnCipherEnabled WRITE setComboBoxProtoOpenvpnCipherEnabled NOTIFY comboBoxProtoOpenvpnCipherEnabledChanged)
Q_PROPERTY(bool comboBoxProtoOpenvpnHashEnabled READ getComboBoxProtoOpenvpnHashEnabled WRITE setComboBoxProtoOpenvpnHashEnabled NOTIFY comboBoxProtoOpenvpnHashEnabledChanged)
Q_PROPERTY(bool pageProtoOpenvpnEnabled READ getPageProtoOpenvpnEnabled WRITE setPageProtoOpenvpnEnabled NOTIFY pageProtoOpenvpnEnabledChanged)
Q_PROPERTY(bool labelProtoOpenvpnInfoVisible READ getLabelProtoOpenvpnInfoVisible WRITE setLabelProtoOpenvpnInfoVisible NOTIFY labelProtoOpenvpnInfoVisibleChanged)
Q_PROPERTY(QString labelProtoOpenvpnInfoText READ getLabelProtoOpenvpnInfoText WRITE setLabelProtoOpenvpnInfoText NOTIFY labelProtoOpenvpnInfoTextChanged)
Q_PROPERTY(int progressBarProtoOpenvpnResetValue READ getProgressBarProtoOpenvpnResetValue WRITE setProgressBarProtoOpenvpnResetValue NOTIFY progressBarProtoOpenvpnResetValueChanged)
Q_PROPERTY(int progressBarProtoOpenvpnResetMaximium READ getProgressBarProtoOpenvpnResetMaximium WRITE setProgressBarProtoOpenvpnResetMaximium NOTIFY progressBarProtoOpenvpnResetMaximiumChanged)
public:
explicit OpenVpnLogic(UiLogic *uiLogic, QObject *parent = nullptr);
~OpenVpnLogic() = default;
void updateOpenVpnPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData);
QJsonObject getOpenVpnConfigFromPage(QJsonObject oldConfig);
QString getLineEditProtoOpenvpnSubnetText() const;
void setLineEditProtoOpenvpnSubnetText(const QString &lineEditProtoOpenvpnSubnetText);
bool getRadioButtonProtoOpenvpnUdpChecked() const;
void setRadioButtonProtoOpenvpnUdpChecked(bool radioButtonProtoOpenvpnUdpChecked);
bool getCheckBoxProtoOpenvpnAutoEncryptionChecked() const;
void setCheckBoxProtoOpenvpnAutoEncryptionChecked(bool checkBoxProtoOpenvpnAutoEncryptionChecked);
QString getComboBoxProtoOpenvpnCipherText() const;
void setComboBoxProtoOpenvpnCipherText(const QString &comboBoxProtoOpenvpnCipherText);
QString getComboBoxProtoOpenvpnHashText() const;
void setComboBoxProtoOpenvpnHashText(const QString &comboBoxProtoOpenvpnHashText);
bool getCheckBoxProtoOpenvpnBlockDnsChecked() const;
void setCheckBoxProtoOpenvpnBlockDnsChecked(bool checkBoxProtoOpenvpnBlockDnsChecked);
QString getLineEditProtoOpenvpnPortText() const;
void setLineEditProtoOpenvpnPortText(const QString &lineEditProtoOpenvpnPortText);
bool getCheckBoxProtoOpenvpnTlsAuthChecked() const;
void setCheckBoxProtoOpenvpnTlsAuthChecked(bool checkBoxProtoOpenvpnTlsAuthChecked);
bool getWidgetProtoOpenvpnEnabled() const;
void setWidgetProtoOpenvpnEnabled(bool widgetProtoOpenvpnEnabled);
bool getPushButtonProtoOpenvpnSaveVisible() const;
void setPushButtonProtoOpenvpnSaveVisible(bool pushButtonProtoOpenvpnSaveVisible);
bool getProgressBarProtoOpenvpnResetVisible() const;
void setProgressBarProtoOpenvpnResetVisible(bool progressBarProtoOpenvpnResetVisible);
bool getRadioButtonProtoOpenvpnUdpEnabled() const;
void setRadioButtonProtoOpenvpnUdpEnabled(bool radioButtonProtoOpenvpnUdpEnabled);
bool getRadioButtonProtoOpenvpnTcpEnabled() const;
void setRadioButtonProtoOpenvpnTcpEnabled(bool radioButtonProtoOpenvpnTcpEnabled);
bool getRadioButtonProtoOpenvpnTcpChecked() const;
void setRadioButtonProtoOpenvpnTcpChecked(bool radioButtonProtoOpenvpnTcpChecked);
bool getLineEditProtoOpenvpnPortEnabled() const;
void setLineEditProtoOpenvpnPortEnabled(bool lineEditProtoOpenvpnPortEnabled);
bool getComboBoxProtoOpenvpnCipherEnabled() const;
void setComboBoxProtoOpenvpnCipherEnabled(bool comboBoxProtoOpenvpnCipherEnabled);
bool getComboBoxProtoOpenvpnHashEnabled() const;
void setComboBoxProtoOpenvpnHashEnabled(bool comboBoxProtoOpenvpnHashEnabled);
bool getPageProtoOpenvpnEnabled() const;
void setPageProtoOpenvpnEnabled(bool pageProtoOpenvpnEnabled);
bool getLabelProtoOpenvpnInfoVisible() const;
void setLabelProtoOpenvpnInfoVisible(bool labelProtoOpenvpnInfoVisible);
QString getLabelProtoOpenvpnInfoText() const;
void setLabelProtoOpenvpnInfoText(const QString &labelProtoOpenvpnInfoText);
int getProgressBarProtoOpenvpnResetValue() const;
void setProgressBarProtoOpenvpnResetValue(int progressBarProtoOpenvpnResetValue);
int getProgressBarProtoOpenvpnResetMaximium() const;
void setProgressBarProtoOpenvpnResetMaximium(int progressBarProtoOpenvpnResetMaximium);
Q_INVOKABLE void onCheckBoxProtoOpenvpnAutoEncryptionClicked();
Q_INVOKABLE void onPushButtonProtoOpenvpnSaveClicked();
signals:
void lineEditProtoOpenvpnSubnetTextChanged();
void radioButtonProtoOpenvpnUdpCheckedChanged();
void checkBoxProtoOpenvpnAutoEncryptionCheckedChanged();
void comboBoxProtoOpenvpnCipherTextChanged();
void comboBoxProtoOpenvpnHashTextChanged();
void checkBoxProtoOpenvpnBlockDnsCheckedChanged();
void lineEditProtoOpenvpnPortTextChanged();
void checkBoxProtoOpenvpnTlsAuthCheckedChanged();
void widgetProtoOpenvpnEnabledChanged();
void pushButtonProtoOpenvpnSaveVisibleChanged();
void progressBarProtoOpenvpnResetVisibleChanged();
void radioButtonProtoOpenvpnUdpEnabledChanged();
void radioButtonProtoOpenvpnTcpEnabledChanged();
void radioButtonProtoOpenvpnTcpCheckedChanged();
void lineEditProtoOpenvpnPortEnabledChanged();
void comboBoxProtoOpenvpnCipherEnabledChanged();
void comboBoxProtoOpenvpnHashEnabledChanged();
void pageProtoOpenvpnEnabledChanged();
void labelProtoOpenvpnInfoVisibleChanged();
void labelProtoOpenvpnInfoTextChanged();
void progressBarProtoOpenvpnResetValueChanged();
void progressBarProtoOpenvpnResetMaximiumChanged();
private:
private slots:
private:
Settings m_settings;
UiLogic *m_uiLogic;
QString m_lineEditProtoOpenvpnSubnetText;
bool m_radioButtonProtoOpenvpnUdpChecked;
bool m_checkBoxProtoOpenvpnAutoEncryptionChecked;
QString m_comboBoxProtoOpenvpnCipherText;
QString m_comboBoxProtoOpenvpnHashText;
bool m_checkBoxProtoOpenvpnBlockDnsChecked;
QString m_lineEditProtoOpenvpnPortText;
bool m_checkBoxProtoOpenvpnTlsAuthChecked;
bool m_widgetProtoOpenvpnEnabled;
bool m_pushButtonProtoOpenvpnSaveVisible;
bool m_progressBarProtoOpenvpnResetVisible;
bool m_radioButtonProtoOpenvpnUdpEnabled;
bool m_radioButtonProtoOpenvpnTcpEnabled;
bool m_radioButtonProtoOpenvpnTcpChecked;
bool m_lineEditProtoOpenvpnPortEnabled;
bool m_comboBoxProtoOpenvpnCipherEnabled;
bool m_comboBoxProtoOpenvpnHashEnabled;
bool m_pageProtoOpenvpnEnabled;
bool m_labelProtoOpenvpnInfoVisible;
QString m_labelProtoOpenvpnInfoText;
int m_progressBarProtoOpenvpnResetValue;
int m_progressBarProtoOpenvpnResetMaximium;
};
#endif // OPENVPN_LOGIC_H

View file

@ -0,0 +1,50 @@
#include <QApplication>
#include <QClipboard>
#include <QDebug>
#include <QDesktopServices>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QHostInfo>
#include <QItemSelectionModel>
#include <QJsonDocument>
#include <QJsonObject>
#include <QKeyEvent>
#include <QMenu>
#include <QMessageBox>
#include <QMetaEnum>
#include <QSysInfo>
#include <QThread>
#include <QTimer>
#include <QRegularExpression>
#include <QSaveFile>
//#include "configurators/cloak_configurator.h"
//#include "configurators/vpn_configurator.h"
//#include "configurators/openvpn_configurator.h"
//#include "configurators/shadowsocks_configurator.h"
//#include "configurators/ssh_configurator.h"
//#include "core/servercontroller.h"
//#include "core/server_defs.h"
//#include "core/errorstrings.h"
//#include "protocols/protocols_defs.h"
//#include "protocols/shadowsocksvpnprotocol.h"
#include "debug.h"
#include "defines.h"
#include "ShadowSocksLogic.h"
#include "utils.h"
#include "vpnconnection.h"
#include <functional>
using namespace amnezia;
using namespace PageEnumNS;
ShadowSocksLogic::ShadowSocksLogic(UiLogic *uiLogic, QObject *parent):
QObject(parent),
m_uiLogic(uiLogic)
{
}

View file

@ -0,0 +1,34 @@
#ifndef SHADOWSOCKS_LOGIC_H
#define SHADOWSOCKS_LOGIC_H
#include "../../pages.h"
#include "settings.h"
class UiLogic;
class ShadowSocksLogic : public QObject
{
Q_OBJECT
public:
explicit ShadowSocksLogic(UiLogic *uiLogic, QObject *parent = nullptr);
~ShadowSocksLogic() = default;
signals:
private:
private slots:
private:
Settings m_settings;
UiLogic *m_uiLogic;
};
#endif // SHADOWSOCKS_LOGIC_H