Merge branch 'dev' into ios_main
This commit is contained in:
commit
c6548afa1b
19 changed files with 168 additions and 89 deletions
|
|
@ -30,6 +30,7 @@ HEADERS += \
|
|||
core/errorstrings.h \
|
||||
core/ipcclient.h \
|
||||
configurators/openvpn_configurator.h \
|
||||
core/privileged_process.h \
|
||||
core/scripts_registry.h \
|
||||
core/server_defs.h \
|
||||
core/servercontroller.h \
|
||||
|
|
@ -84,6 +85,7 @@ SOURCES += \
|
|||
core/errorstrings.cpp \
|
||||
core/ipcclient.cpp \
|
||||
configurators/openvpn_configurator.cpp \
|
||||
core/privileged_process.cpp \
|
||||
core/scripts_registry.cpp \
|
||||
core/server_defs.cpp \
|
||||
core/servercontroller.cpp \
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ bool IpcClient::init(IpcClient *instance)
|
|||
return Instance()->m_ipcClient->isReplicaValid();
|
||||
}
|
||||
|
||||
QSharedPointer<IpcProcessInterfaceReplica> IpcClient::CreatePrivilegedProcess()
|
||||
QSharedPointer<PrivilegedProcess> IpcClient::CreatePrivilegedProcess()
|
||||
{
|
||||
#ifndef Q_OS_IOS
|
||||
if (! Instance()->m_ipcClient || ! Instance()->m_ipcClient->isReplicaValid()) {
|
||||
|
|
@ -84,17 +84,19 @@ QSharedPointer<IpcProcessInterfaceReplica> IpcClient::CreatePrivilegedProcess()
|
|||
connect(pd->localSocket.data(), &QLocalSocket::connected, pd->replicaNode.data(), [pd]() {
|
||||
pd->replicaNode->addClientSideConnection(pd->localSocket.data());
|
||||
|
||||
pd->ipcProcess.reset(pd->replicaNode->acquire<IpcProcessInterfaceReplica>());
|
||||
IpcProcessInterfaceReplica *repl = pd->replicaNode->acquire<IpcProcessInterfaceReplica>();
|
||||
PrivilegedProcess *priv = static_cast<PrivilegedProcess *>(repl);
|
||||
pd->ipcProcess.reset(priv);
|
||||
if (!pd->ipcProcess) {
|
||||
qWarning() << "Acquire IpcProcessInterfaceReplica failed";
|
||||
qWarning() << "Acquire PrivilegedProcess failed";
|
||||
}
|
||||
else {
|
||||
pd->ipcProcess->waitForSource(1000);
|
||||
if (!pd->ipcProcess->isReplicaValid()) {
|
||||
qWarning() << "IpcProcessInterfaceReplica replica is not connected!";
|
||||
qWarning() << "PrivilegedProcess replica is not connected!";
|
||||
}
|
||||
|
||||
QObject::connect(pd->ipcProcess.data(), &IpcProcessInterfaceReplica::destroyed, pd->ipcProcess.data(), [pd](){
|
||||
QObject::connect(pd->ipcProcess.data(), &PrivilegedProcess::destroyed, pd->ipcProcess.data(), [pd](){
|
||||
pd->replicaNode->deleteLater();
|
||||
});
|
||||
}
|
||||
|
|
@ -103,10 +105,10 @@ QSharedPointer<IpcProcessInterfaceReplica> IpcClient::CreatePrivilegedProcess()
|
|||
pd->localSocket->connectToServer(amnezia::getIpcProcessUrl(pid));
|
||||
pd->localSocket->waitForConnected();
|
||||
|
||||
auto proccessReplica = QSharedPointer<IpcProcessInterfaceReplica>(pd->ipcProcess);
|
||||
auto proccessReplica = QSharedPointer<PrivilegedProcess>(pd->ipcProcess);
|
||||
return proccessReplica;
|
||||
#else
|
||||
return QSharedPointer<IpcProcessInterfaceReplica>();
|
||||
return QSharedPointer<PrivilegedProcess>();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,13 +7,7 @@
|
|||
#include "ipc.h"
|
||||
#include "rep_ipc_interface_replica.h"
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
#include "rep_ipc_process_interface_replica.h"
|
||||
#else
|
||||
class IpcProcessInterfaceReplica {
|
||||
|
||||
};
|
||||
#endif
|
||||
#include "privileged_process.h"
|
||||
|
||||
class IpcClient : public QObject
|
||||
{
|
||||
|
|
@ -24,7 +18,7 @@ public:
|
|||
static IpcClient *Instance();
|
||||
static bool init(IpcClient *instance);
|
||||
static QSharedPointer<IpcInterfaceReplica> Interface();
|
||||
static QSharedPointer<IpcProcessInterfaceReplica> CreatePrivilegedProcess();
|
||||
static QSharedPointer<PrivilegedProcess> CreatePrivilegedProcess();
|
||||
|
||||
bool isSocketConnected() const;
|
||||
|
||||
|
|
@ -40,10 +34,10 @@ private:
|
|||
struct ProcessDescriptor {
|
||||
ProcessDescriptor () {
|
||||
replicaNode = QSharedPointer<QRemoteObjectNode>(new QRemoteObjectNode());
|
||||
ipcProcess = QSharedPointer<IpcProcessInterfaceReplica>();
|
||||
ipcProcess = QSharedPointer<PrivilegedProcess>();
|
||||
localSocket = QSharedPointer<QLocalSocket>();
|
||||
}
|
||||
QSharedPointer<IpcProcessInterfaceReplica> ipcProcess;
|
||||
QSharedPointer<PrivilegedProcess> ipcProcess;
|
||||
QSharedPointer<QRemoteObjectNode> replicaNode;
|
||||
QSharedPointer<QLocalSocket> localSocket;
|
||||
};
|
||||
|
|
|
|||
27
client/core/privileged_process.cpp
Normal file
27
client/core/privileged_process.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include "privileged_process.h"
|
||||
|
||||
PrivilegedProcess::PrivilegedProcess() :
|
||||
IpcProcessInterfaceReplica()
|
||||
{
|
||||
}
|
||||
|
||||
PrivilegedProcess::~PrivilegedProcess()
|
||||
{
|
||||
qDebug() << "PrivilegedProcess::~PrivilegedProcess()";
|
||||
}
|
||||
|
||||
void PrivilegedProcess::waitForFinished(int msecs)
|
||||
{
|
||||
QSharedPointer<QEventLoop> loop(new QEventLoop);
|
||||
connect(this, &PrivilegedProcess::finished, this, [this, loop](int exitCode, QProcess::ExitStatus exitStatus) mutable{
|
||||
loop->quit();
|
||||
loop.clear();
|
||||
});
|
||||
|
||||
QTimer::singleShot(msecs, this, [this, loop]() mutable {
|
||||
loop->quit();
|
||||
loop.clear();
|
||||
});
|
||||
|
||||
loop->exec();
|
||||
}
|
||||
30
client/core/privileged_process.h
Normal file
30
client/core/privileged_process.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef PRIVILEGED_PROCESS_H
|
||||
#define PRIVILEGED_PROCESS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
#include "rep_ipc_process_interface_replica.h"
|
||||
// This class is dangerous - instance of this class casted from base class,
|
||||
// so it support only functions
|
||||
// Do not add any members into it
|
||||
//
|
||||
class PrivilegedProcess : public IpcProcessInterfaceReplica
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PrivilegedProcess();
|
||||
~PrivilegedProcess() override;
|
||||
|
||||
void waitForFinished(int msecs);
|
||||
|
||||
};
|
||||
|
||||
#endif // PRIVILEGED_PROCESS_H
|
||||
|
||||
#else // defined Q_OS_IOS
|
||||
class IpcProcessInterfaceReplica {};
|
||||
class PrivilegedProcess {};
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
#define APPLICATION_NAME "AmneziaVPN"
|
||||
#define SERVICE_NAME "AmneziaVPN-service"
|
||||
#define ORGANIZATION_NAME "AmneziaVPN.ORG"
|
||||
#define APP_MAJOR_VERSION "2.0.0"
|
||||
#define APP_VERSION "2.0.0.0"
|
||||
#define APP_MAJOR_VERSION "2.0.1"
|
||||
#define APP_VERSION "2.0.1.0"
|
||||
|
||||
#endif // DEFINES_H
|
||||
|
|
|
|||
|
|
@ -278,18 +278,18 @@ ErrorCode Ikev2Protocol::start()
|
|||
certInstallProcess->setArguments(arguments);
|
||||
|
||||
// qDebug() << arguments.join(" ");
|
||||
// connect(certInstallProcess.data(), &IpcProcessInterfaceReplica::errorOccurred, [certInstallProcess](QProcess::ProcessError error) {
|
||||
// qDebug() << "IpcProcessInterfaceReplica errorOccurred" << error;
|
||||
// connect(certInstallProcess.data(), &PrivilegedProcess::errorOccurred, [certInstallProcess](QProcess::ProcessError error) {
|
||||
// qDebug() << "PrivilegedProcess errorOccurred" << error;
|
||||
// });
|
||||
|
||||
// connect(certInstallProcess.data(), &IpcProcessInterfaceReplica::stateChanged, [certInstallProcess](QProcess::ProcessState newState) {
|
||||
// qDebug() << "IpcProcessInterfaceReplica stateChanged" << newState;
|
||||
// connect(certInstallProcess.data(), &PrivilegedProcess::stateChanged, [certInstallProcess](QProcess::ProcessState newState) {
|
||||
// qDebug() << "PrivilegedProcess stateChanged" << newState;
|
||||
// });
|
||||
|
||||
// connect(certInstallProcess.data(), &IpcProcessInterfaceReplica::readyRead, [certInstallProcess]() {
|
||||
// connect(certInstallProcess.data(), &PrivilegedProcess::readyRead, [certInstallProcess]() {
|
||||
// auto req = certInstallProcess->readAll();
|
||||
// req.waitForFinished();
|
||||
// qDebug() << "IpcProcessInterfaceReplica readyRead" << req.returnValue();
|
||||
// qDebug() << "PrivilegedProcess readyRead" << req.returnValue();
|
||||
// });
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -192,15 +192,15 @@ ErrorCode OpenVpnProtocol::start()
|
|||
m_openVpnProcess->setArguments(arguments);
|
||||
|
||||
qDebug() << arguments.join(" ");
|
||||
connect(m_openVpnProcess.data(), &IpcProcessInterfaceReplica::errorOccurred, [&](QProcess::ProcessError error) {
|
||||
qDebug() << "IpcProcessInterfaceReplica errorOccurred" << error;
|
||||
connect(m_openVpnProcess.data(), &PrivilegedProcess::errorOccurred, [&](QProcess::ProcessError error) {
|
||||
qDebug() << "PrivilegedProcess errorOccurred" << error;
|
||||
});
|
||||
|
||||
connect(m_openVpnProcess.data(), &IpcProcessInterfaceReplica::stateChanged, [&](QProcess::ProcessState newState) {
|
||||
qDebug() << "IpcProcessInterfaceReplica stateChanged" << newState;
|
||||
connect(m_openVpnProcess.data(), &PrivilegedProcess::stateChanged, [&](QProcess::ProcessState newState) {
|
||||
qDebug() << "PrivilegedProcess stateChanged" << newState;
|
||||
});
|
||||
|
||||
connect(m_openVpnProcess.data(), &IpcProcessInterfaceReplica::finished, this, [&]() {
|
||||
connect(m_openVpnProcess.data(), &PrivilegedProcess::finished, this, [&]() {
|
||||
setConnectionState(ConnectionState::Disconnected);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ private:
|
|||
void updateRouteGateway(QString line);
|
||||
void updateVpnGateway(const QString &line);
|
||||
|
||||
QSharedPointer<IpcProcessInterfaceReplica> m_openVpnProcess;
|
||||
QSharedPointer<PrivilegedProcess> m_openVpnProcess;
|
||||
};
|
||||
|
||||
#endif // OPENVPNPROTOCOL_H
|
||||
|
|
|
|||
|
|
@ -19,13 +19,16 @@ WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject*
|
|||
|
||||
WireguardProtocol::~WireguardProtocol()
|
||||
{
|
||||
qDebug() << "WireguardProtocol::~WireguardProtocol()";
|
||||
//qDebug() << "WireguardProtocol::~WireguardProtocol() 1";
|
||||
WireguardProtocol::stop();
|
||||
QThread::msleep(200);
|
||||
//qDebug() << "WireguardProtocol::~WireguardProtocol() 2";
|
||||
}
|
||||
|
||||
void WireguardProtocol::stop()
|
||||
{
|
||||
//qDebug() << "WireguardProtocol::stop() 1";
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
if (!QFileInfo::exists(wireguardExecPath())) {
|
||||
qCritical() << "Wireguard executable missing!";
|
||||
|
|
@ -56,19 +59,22 @@ void WireguardProtocol::stop()
|
|||
|
||||
qDebug() << arguments.join(" ");
|
||||
|
||||
connect(m_wireguardStopProcess.data(), &IpcProcessInterfaceReplica::errorOccurred, this, [this](QProcess::ProcessError error) {
|
||||
qDebug() << "WireguardProtocol::WireguardProtocol errorOccurred" << error;
|
||||
connect(m_wireguardStopProcess.data(), &PrivilegedProcess::errorOccurred, this, [this](QProcess::ProcessError error) {
|
||||
qDebug() << "WireguardProtocol::WireguardProtocol Stop errorOccurred" << error;
|
||||
setConnectionState(ConnectionState::Disconnected);
|
||||
});
|
||||
|
||||
connect(m_wireguardStopProcess.data(), &IpcProcessInterfaceReplica::stateChanged, this, [this](QProcess::ProcessState newState) {
|
||||
connect(m_wireguardStopProcess.data(), &PrivilegedProcess::stateChanged, this, [this](QProcess::ProcessState newState) {
|
||||
qDebug() << "WireguardProtocol::WireguardProtocol Stop stateChanged" << newState;
|
||||
});
|
||||
|
||||
m_wireguardStopProcess->start();
|
||||
m_wireguardStopProcess->waitForFinished(10000);
|
||||
|
||||
setConnectionState(VpnProtocol::Disconnected);
|
||||
#endif
|
||||
|
||||
//qDebug() << "WireguardProtocol::stop() 2";
|
||||
}
|
||||
|
||||
void WireguardProtocol::readWireguardConfiguration(const QJsonObject &configuration)
|
||||
|
|
@ -124,13 +130,15 @@ QString WireguardProtocol::wireguardExecPath() const
|
|||
|
||||
ErrorCode WireguardProtocol::start()
|
||||
{
|
||||
//qDebug() << "WireguardProtocol::start() 1";
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
if (!m_isConfigLoaded) {
|
||||
setLastError(ErrorCode::ConfigMissing);
|
||||
return lastError();
|
||||
}
|
||||
|
||||
//qDebug() << "Start OpenVPN connection";
|
||||
//qDebug() << "Start Wireguard connection";
|
||||
WireguardProtocol::stop();
|
||||
|
||||
if (!QFileInfo::exists(wireguardExecPath())) {
|
||||
|
|
@ -168,38 +176,41 @@ ErrorCode WireguardProtocol::start()
|
|||
|
||||
qDebug() << arguments.join(" ");
|
||||
|
||||
connect(m_wireguardStartProcess.data(), &IpcProcessInterfaceReplica::errorOccurred, this, [this](QProcess::ProcessError error) {
|
||||
connect(m_wireguardStartProcess.data(), &PrivilegedProcess::errorOccurred, this, [this](QProcess::ProcessError error) {
|
||||
qDebug() << "WireguardProtocol::WireguardProtocol errorOccurred" << error;
|
||||
setConnectionState(ConnectionState::Disconnected);
|
||||
});
|
||||
|
||||
connect(m_wireguardStartProcess.data(), &IpcProcessInterfaceReplica::stateChanged, this, [this](QProcess::ProcessState newState) {
|
||||
connect(m_wireguardStartProcess.data(), &PrivilegedProcess::stateChanged, this, [this](QProcess::ProcessState newState) {
|
||||
qDebug() << "WireguardProtocol::WireguardProtocol stateChanged" << newState;
|
||||
});
|
||||
|
||||
connect(m_wireguardStartProcess.data(), &IpcProcessInterfaceReplica::finished, this, [this]() {
|
||||
connect(m_wireguardStartProcess.data(), &PrivilegedProcess::finished, this, [this]() {
|
||||
setConnectionState(ConnectionState::Connected);
|
||||
});
|
||||
|
||||
connect(m_wireguardStartProcess.data(), &IpcProcessInterfaceReplica::readyRead, this, [this]() {
|
||||
connect(m_wireguardStartProcess.data(), &PrivilegedProcess::readyRead, this, [this]() {
|
||||
QRemoteObjectPendingReply<QByteArray> reply = m_wireguardStartProcess->readAll();
|
||||
reply.waitForFinished(1000);
|
||||
qDebug() << "WireguardProtocol::WireguardProtocol readyRead" << reply.returnValue();
|
||||
});
|
||||
|
||||
connect(m_wireguardStartProcess.data(), &IpcProcessInterfaceReplica::readyReadStandardOutput, this, [this]() {
|
||||
connect(m_wireguardStartProcess.data(), &PrivilegedProcess::readyReadStandardOutput, this, [this]() {
|
||||
QRemoteObjectPendingReply<QByteArray> reply = m_wireguardStartProcess->readAllStandardOutput();
|
||||
reply.waitForFinished(1000);
|
||||
qDebug() << "WireguardProtocol::WireguardProtocol readAllStandardOutput" << reply.returnValue();
|
||||
});
|
||||
|
||||
connect(m_wireguardStartProcess.data(), &IpcProcessInterfaceReplica::readyReadStandardError, this, [this]() {
|
||||
connect(m_wireguardStartProcess.data(), &PrivilegedProcess::readyReadStandardError, this, [this]() {
|
||||
QRemoteObjectPendingReply<QByteArray> reply = m_wireguardStartProcess->readAllStandardError();
|
||||
reply.waitForFinished(1000);
|
||||
qDebug() << "WireguardProtocol::WireguardProtocol readAllStandardError" << reply.returnValue();
|
||||
});
|
||||
|
||||
m_wireguardStartProcess->start();
|
||||
m_wireguardStartProcess->waitForFinished(10000);
|
||||
|
||||
//qDebug() << "WireguardProtocol::start() 2";
|
||||
|
||||
return ErrorCode::NoError;
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ private:
|
|||
QString m_configFileName;
|
||||
QFile m_configFile;
|
||||
|
||||
QSharedPointer<IpcProcessInterfaceReplica> m_wireguardStartProcess;
|
||||
QSharedPointer<IpcProcessInterfaceReplica> m_wireguardStopProcess;
|
||||
QSharedPointer<PrivilegedProcess> m_wireguardStartProcess;
|
||||
QSharedPointer<PrivilegedProcess> m_wireguardStopProcess;
|
||||
|
||||
bool m_isConfigLoaded = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@ void ServerSettingsLogic::onUpdatePage()
|
|||
.arg(port.isEmpty() ? "" : ":")
|
||||
.arg(port));
|
||||
set_lineEditDescriptionText(server.value(config_key::description).toString());
|
||||
QString selectedContainerName = m_settings.defaultContainerName(uiLogic()->selectedServerIndex);
|
||||
|
||||
DockerContainer selectedContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||
QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer);
|
||||
set_labelCurrentVpnProtocolText(tr("Service: ") + selectedContainerName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,14 +114,23 @@ void StartPageLogic::onPushButtonConnect()
|
|||
set_pushButtonConnectText(tr("Connect"));
|
||||
|
||||
uiLogic()->installCredentials = serverCredentials;
|
||||
if (ok) uiLogic()->goToPage(Page::NewServer);
|
||||
if (ok) emit uiLogic()->goToPage(Page::NewServer);
|
||||
}
|
||||
|
||||
void StartPageLogic::onPushButtonImport()
|
||||
{
|
||||
QString s = lineEditStartExistingCodeText();
|
||||
s.replace("vpn://", "");
|
||||
QJsonObject o = QJsonDocument::fromJson(QByteArray::fromBase64(s.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals)).object();
|
||||
QByteArray ba = QByteArray::fromBase64(s.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||
QByteArray ba_uncompressed = qUncompress(ba);
|
||||
|
||||
QJsonObject o;
|
||||
if (!ba_uncompressed.isEmpty()) {
|
||||
o = QJsonDocument::fromBinaryData(ba_uncompressed).object();
|
||||
}
|
||||
else {
|
||||
o = QJsonDocument::fromJson(ba).object();
|
||||
}
|
||||
|
||||
ServerCredentials credentials;
|
||||
credentials.hostName = o.value("h").toString();
|
||||
|
|
@ -169,6 +178,8 @@ void StartPageLogic::onPushButtonImport()
|
|||
if (!o.contains(config_key::containers)) {
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||
uiLogic()->goToPage(Page::ServerContainers);
|
||||
uiLogic()->onUpdateAllPages();
|
||||
|
||||
emit uiLogic()->goToPage(Page::ServerContainers);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,30 +50,25 @@ void VpnLogic::onUpdatePage()
|
|||
.arg(server.value(config_key::hostName).toString());
|
||||
set_labelCurrentServer(serverString);
|
||||
|
||||
QString selectedContainerName = m_settings.defaultContainerName(m_settings.defaultServerIndex());
|
||||
DockerContainer selectedContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
||||
QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer);
|
||||
set_labelCurrentService(selectedContainerName);
|
||||
}
|
||||
|
||||
|
||||
void VpnLogic::onRadioButtonVpnModeAllSitesToggled(bool checked)
|
||||
void VpnLogic::onRadioButtonVpnModeAllSitesClicked()
|
||||
{
|
||||
if (checked) {
|
||||
m_settings.setRouteMode(Settings::VpnAllSites);
|
||||
}
|
||||
m_settings.setRouteMode(Settings::VpnAllSites);
|
||||
}
|
||||
|
||||
void VpnLogic::onRadioButtonVpnModeForwardSitesToggled(bool checked)
|
||||
void VpnLogic::onRadioButtonVpnModeForwardSitesClicked()
|
||||
{
|
||||
if (checked) {
|
||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
}
|
||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
}
|
||||
|
||||
void VpnLogic::onRadioButtonVpnModeExceptSitesToggled(bool checked)
|
||||
void VpnLogic::onRadioButtonVpnModeExceptSitesClicked()
|
||||
{
|
||||
if (checked) {
|
||||
m_settings.setRouteMode(Settings::VpnAllExceptSites);
|
||||
}
|
||||
m_settings.setRouteMode(Settings::VpnAllExceptSites);
|
||||
}
|
||||
|
||||
void VpnLogic::onBytesChanged(quint64 receivedData, quint64 sentData)
|
||||
|
|
@ -87,6 +82,8 @@ void VpnLogic::onConnectionStateChanged(VpnProtocol::ConnectionState state)
|
|||
qDebug() << "VpnLogic::onConnectionStateChanged" << VpnProtocol::textConnectionState(state);
|
||||
|
||||
bool pbConnectEnabled = false;
|
||||
bool pbConnectChecked = false;
|
||||
|
||||
bool rbModeEnabled = false;
|
||||
bool pbConnectVisible = false;
|
||||
set_labelStateText(VpnProtocol::textConnectionState(state));
|
||||
|
|
@ -96,49 +93,57 @@ void VpnLogic::onConnectionStateChanged(VpnProtocol::ConnectionState state)
|
|||
switch (state) {
|
||||
case VpnProtocol::Disconnected:
|
||||
onBytesChanged(0,0);
|
||||
set_pushButtonConnectChecked(false);
|
||||
pbConnectChecked = false;
|
||||
pbConnectEnabled = true;
|
||||
pbConnectVisible = true;
|
||||
rbModeEnabled = true;
|
||||
break;
|
||||
case VpnProtocol::Preparing:
|
||||
pbConnectChecked = true;
|
||||
pbConnectEnabled = false;
|
||||
pbConnectVisible = false;
|
||||
rbModeEnabled = false;
|
||||
break;
|
||||
case VpnProtocol::Connecting:
|
||||
pbConnectChecked = true;
|
||||
pbConnectEnabled = false;
|
||||
pbConnectVisible = false;
|
||||
rbModeEnabled = false;
|
||||
break;
|
||||
case VpnProtocol::Connected:
|
||||
pbConnectChecked = true;
|
||||
pbConnectEnabled = true;
|
||||
pbConnectVisible = true;
|
||||
rbModeEnabled = false;
|
||||
break;
|
||||
case VpnProtocol::Disconnecting:
|
||||
pbConnectChecked = false;
|
||||
pbConnectEnabled = false;
|
||||
pbConnectVisible = false;
|
||||
rbModeEnabled = false;
|
||||
break;
|
||||
case VpnProtocol::Reconnecting:
|
||||
pbConnectChecked = true;
|
||||
pbConnectEnabled = true;
|
||||
pbConnectVisible = false;
|
||||
rbModeEnabled = false;
|
||||
break;
|
||||
case VpnProtocol::Error:
|
||||
set_pushButtonConnectEnabled(false);
|
||||
pbConnectChecked = false;
|
||||
pbConnectEnabled = true;
|
||||
pbConnectVisible = true;
|
||||
rbModeEnabled = true;
|
||||
break;
|
||||
case VpnProtocol::Unknown:
|
||||
pbConnectChecked = false;
|
||||
pbConnectEnabled = true;
|
||||
pbConnectVisible = true;
|
||||
rbModeEnabled = true;
|
||||
}
|
||||
|
||||
set_pushButtonConnectEnabled(pbConnectEnabled);
|
||||
set_pushButtonConnectChecked(pbConnectChecked);
|
||||
|
||||
set_pushButtonConnectVisible(pbConnectVisible);
|
||||
set_widgetVpnModeEnabled(rbModeEnabled);
|
||||
}
|
||||
|
|
@ -148,9 +153,9 @@ void VpnLogic::onVpnProtocolError(ErrorCode errorCode)
|
|||
set_labelErrorText(errorString(errorCode));
|
||||
}
|
||||
|
||||
void VpnLogic::onPushButtonConnectClicked(bool checked)
|
||||
void VpnLogic::onPushButtonConnectClicked()
|
||||
{
|
||||
if (checked) {
|
||||
if (! pushButtonConnectChecked()) {
|
||||
onConnect();
|
||||
} else {
|
||||
onDisconnect();
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ class VpnLogic : public PageLogicBase
|
|||
public:
|
||||
Q_INVOKABLE void onUpdatePage() override;
|
||||
|
||||
Q_INVOKABLE void onRadioButtonVpnModeAllSitesToggled(bool checked);
|
||||
Q_INVOKABLE void onRadioButtonVpnModeForwardSitesToggled(bool checked);
|
||||
Q_INVOKABLE void onRadioButtonVpnModeExceptSitesToggled(bool checked);
|
||||
Q_INVOKABLE void onRadioButtonVpnModeAllSitesClicked();
|
||||
Q_INVOKABLE void onRadioButtonVpnModeForwardSitesClicked();
|
||||
Q_INVOKABLE void onRadioButtonVpnModeExceptSitesClicked();
|
||||
|
||||
Q_INVOKABLE void onPushButtonConnectClicked(bool checked);
|
||||
Q_INVOKABLE void onPushButtonConnectClicked();
|
||||
|
||||
public:
|
||||
explicit VpnLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ void OtherProtocolsLogic::onPushButtonSftpMountDriveClicked()
|
|||
// .arg(labelTftpPortText())
|
||||
// .arg(labelTftpPasswordText());
|
||||
|
||||
p->setProgram("C:\\Program Files1\\SSHFS-Win\\bin\\sshfs.exe");
|
||||
p->setProgram("C:\\Program Files\\SSHFS-Win\\bin\\sshfs.exe");
|
||||
|
||||
QString host = m_settings.serverCredentials(uiLogic()->selectedServerIndex).hostName;
|
||||
QString args = QString(
|
||||
|
|
@ -122,6 +122,8 @@ void OtherProtocolsLogic::onPushButtonSftpMountDriveClicked()
|
|||
|
||||
//qDebug().noquote() << "onPushButtonSftpMountDriveClicked" << args;
|
||||
|
||||
set_pushButtonSftpMountEnabled(true);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,10 +53,7 @@ PageBase {
|
|||
height: width
|
||||
checkable: true
|
||||
checked: VpnLogic.pushButtonConnectChecked
|
||||
onCheckedChanged: {
|
||||
VpnLogic.pushButtonConnectChecked = checked
|
||||
VpnLogic.onPushButtonConnectClicked(checked)
|
||||
}
|
||||
onClicked: VpnLogic.onPushButtonConnectClicked()
|
||||
background: Image {
|
||||
anchors.fill: parent
|
||||
source: button_connect.checked ? "qrc:/images/connected.png"
|
||||
|
|
@ -246,11 +243,7 @@ PageBase {
|
|||
height: 19
|
||||
checked: VpnLogic.radioButtonVpnModeAllSitesChecked
|
||||
text: qsTr("For all connections")
|
||||
onCheckedChanged: {
|
||||
VpnLogic.radioButtonVpnModeAllSitesChecked = checked
|
||||
button_add_site.enabled = !checked
|
||||
VpnLogic.onRadioButtonVpnModeAllSitesToggled(checked)
|
||||
}
|
||||
onClicked: VpnLogic.onRadioButtonVpnModeAllSitesClicked(true)
|
||||
}
|
||||
RadioButtonType {
|
||||
x: 0
|
||||
|
|
@ -259,10 +252,7 @@ PageBase {
|
|||
height: 19
|
||||
text: qsTr("Except selected sites")
|
||||
checked: VpnLogic.radioButtonVpnModeExceptSitesChecked
|
||||
onCheckedChanged: {
|
||||
VpnLogic.radioButtonVpnModeExceptSitesChecked = checked
|
||||
VpnLogic.onRadioButtonVpnModeExceptSitesToggled(checked)
|
||||
}
|
||||
onClicked: VpnLogic.onRadioButtonVpnModeExceptSitesClicked(true)
|
||||
}
|
||||
RadioButtonType {
|
||||
x: 0
|
||||
|
|
@ -271,10 +261,7 @@ PageBase {
|
|||
height: 19
|
||||
text: qsTr("For selected sites")
|
||||
checked: VpnLogic.radioButtonVpnModeForwardSitesChecked
|
||||
onCheckedChanged: {
|
||||
VpnLogic.radioButtonVpnModeForwardSitesChecked = checked
|
||||
VpnLogic.onRadioButtonVpnModeForwardSitesToggled(checked)
|
||||
}
|
||||
onClicked: VpnLogic.onRadioButtonVpnModeForwardSitesClicked(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ New encryption keys pair will be generated.")
|
|||
}
|
||||
|
||||
LabelType {
|
||||
height: 20
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Config too long to be displayed as QR code")
|
||||
visible: ShareConnectionLogic.shareAmneziaQrCodeText.length == 0 && tfShareCode.textArea.length > 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ VpnConnection::VpnConnection(QObject* parent) : QObject(parent)
|
|||
|
||||
VpnConnection::~VpnConnection()
|
||||
{
|
||||
//qDebug() << "VpnConnection::~VpnConnection() 1";
|
||||
m_vpnProtocol.clear();
|
||||
//qDebug() << "VpnConnection::~VpnConnection() 2";
|
||||
}
|
||||
|
||||
void VpnConnection::onBytesChanged(quint64 receivedBytes, quint64 sentBytes)
|
||||
|
|
@ -231,8 +233,11 @@ void VpnConnection::connectToVpn(int serverIndex,
|
|||
|
||||
if (m_vpnProtocol) {
|
||||
disconnect(m_vpnProtocol.data(), &VpnProtocol::protocolError, this, &VpnConnection::vpnProtocolError);
|
||||
//qDebug() << "VpnConnection::connectToVpn 1";
|
||||
m_vpnProtocol->stop();
|
||||
//qDebug() << "VpnConnection::connectToVpn 2";
|
||||
m_vpnProtocol.reset();
|
||||
//qDebug() << "VpnConnection::connectToVpn 3";
|
||||
}
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
|
|
@ -281,7 +286,7 @@ QString VpnConnection::bytesPerSecToText(quint64 bytes)
|
|||
|
||||
void VpnConnection::disconnectFromVpn()
|
||||
{
|
||||
qDebug() << "Disconnect from VPN";
|
||||
// qDebug() << "Disconnect from VPN 1";
|
||||
|
||||
if (IpcClient::Interface()) {
|
||||
IpcClient::Interface()->flushDns();
|
||||
|
|
@ -295,6 +300,7 @@ void VpnConnection::disconnectFromVpn()
|
|||
return;
|
||||
}
|
||||
m_vpnProtocol.data()->stop();
|
||||
// qDebug() << "Disconnect from VPN 2";
|
||||
}
|
||||
|
||||
VpnProtocol::ConnectionState VpnConnection::connectionState()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue