Various types containers support
This commit is contained in:
parent
0d9f1ba95b
commit
157d7c4f23
39 changed files with 609 additions and 479 deletions
|
@ -43,9 +43,9 @@ HEADERS += \
|
|||
ui/pages_logic/AppSettingsLogic.h \
|
||||
ui/pages_logic/GeneralSettingsLogic.h \
|
||||
ui/pages_logic/NetworkSettingsLogic.h \
|
||||
ui/pages_logic/NewServerConfiguringLogic.h \
|
||||
ui/pages_logic/NewServerProtocolsLogic.h \
|
||||
ui/pages_logic/PageLogicBase.h \
|
||||
ui/pages_logic/ServerConfiguringProgressLogic.h \
|
||||
ui/pages_logic/ServerContainersLogic.h \
|
||||
ui/pages_logic/ServerListLogic.h \
|
||||
ui/pages_logic/ServerSettingsLogic.h \
|
||||
|
@ -94,9 +94,9 @@ SOURCES += \
|
|||
ui/pages_logic/AppSettingsLogic.cpp \
|
||||
ui/pages_logic/GeneralSettingsLogic.cpp \
|
||||
ui/pages_logic/NetworkSettingsLogic.cpp \
|
||||
ui/pages_logic/NewServerConfiguringLogic.cpp \
|
||||
ui/pages_logic/NewServerProtocolsLogic.cpp \
|
||||
ui/pages_logic/PageLogicBase.cpp \
|
||||
ui/pages_logic/ServerConfiguringProgressLogic.cpp \
|
||||
ui/pages_logic/ServerContainersLogic.cpp \
|
||||
ui/pages_logic/ServerListLogic.cpp \
|
||||
ui/pages_logic/ServerSettingsLogic.cpp \
|
||||
|
|
|
@ -296,13 +296,13 @@ ErrorCode OpenVpnConfigurator::signCert(DockerContainer container,
|
|||
{
|
||||
QString script_import = QString("sudo docker exec -i %1 bash -c \"cd /opt/amnezia/openvpn && "
|
||||
"easyrsa import-req %2/%3.req %3\"")
|
||||
.arg(amnezia::containerToString(container))
|
||||
.arg(ContainerProps::containerToString(container))
|
||||
.arg(amnezia::protocols::openvpn::clientsDirPath)
|
||||
.arg(clientId);
|
||||
|
||||
QString script_sign = QString("sudo docker exec -i %1 bash -c \"export EASYRSA_BATCH=1; cd /opt/amnezia/openvpn && "
|
||||
"easyrsa sign-req client %2\"")
|
||||
.arg(amnezia::containerToString(container))
|
||||
.arg(ContainerProps::containerToString(container))
|
||||
.arg(clientId);
|
||||
|
||||
QStringList scriptList {script_import, script_sign};
|
||||
|
|
|
@ -3,39 +3,38 @@
|
|||
QDebug operator<<(QDebug debug, const amnezia::DockerContainer &c)
|
||||
{
|
||||
QDebugStateSaver saver(debug);
|
||||
debug.nospace() << containerToString(c);
|
||||
debug.nospace() << ContainerProps::containerToString(c);
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
amnezia::DockerContainer amnezia::containerFromString(const QString &container){
|
||||
if (container == config_key::amnezia_openvpn) return DockerContainer::OpenVpn;
|
||||
if (container == config_key::amnezia_openvpn_cloak) return DockerContainer::OpenVpnOverCloak;
|
||||
if (container == config_key::amnezia_shadowsocks) return DockerContainer::OpenVpnOverShadowSocks;
|
||||
if (container == config_key::amnezia_wireguard) return DockerContainer::WireGuard;
|
||||
amnezia::DockerContainer ContainerProps::containerFromString(const QString &container){
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<DockerContainer>();
|
||||
for (int i = 0; i < metaEnum.keyCount(); ++i) {
|
||||
DockerContainer c = static_cast<DockerContainer>(i);
|
||||
if (container == containerToString(c)) return c;
|
||||
}
|
||||
return DockerContainer::None;
|
||||
}
|
||||
|
||||
QString amnezia::containerToString(amnezia::DockerContainer container){
|
||||
switch (container) {
|
||||
case(DockerContainer::OpenVpn): return config_key::amnezia_openvpn;
|
||||
case(DockerContainer::OpenVpnOverCloak): return config_key::amnezia_openvpn_cloak;
|
||||
case(DockerContainer::OpenVpnOverShadowSocks): return config_key::amnezia_shadowsocks;
|
||||
case(DockerContainer::WireGuard): return config_key::amnezia_wireguard;
|
||||
default: return "none";
|
||||
}
|
||||
QString ContainerProps::containerToString(amnezia::DockerContainer c){
|
||||
if (c == DockerContainer::None) return "none";
|
||||
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<DockerContainer>();
|
||||
QString containerKey = metaEnum.valueToKey(static_cast<int>(c));
|
||||
return "amnezia-" + containerKey.toLower();
|
||||
}
|
||||
|
||||
QVector<amnezia::Protocol> amnezia::protocolsForContainer(amnezia::DockerContainer container)
|
||||
QVector<amnezia::Protocol> ContainerProps::protocolsForContainer(amnezia::DockerContainer container)
|
||||
{
|
||||
switch (container) {
|
||||
case DockerContainer::OpenVpn:
|
||||
return { Protocol::OpenVpn };
|
||||
|
||||
case DockerContainer::OpenVpnOverShadowSocks:
|
||||
case DockerContainer::ShadowSocks:
|
||||
return { Protocol::OpenVpn, Protocol::ShadowSocks };
|
||||
|
||||
case DockerContainer::OpenVpnOverCloak:
|
||||
case DockerContainer::Cloak:
|
||||
return { Protocol::OpenVpn, Protocol::ShadowSocks, Protocol::Cloak };
|
||||
|
||||
default:
|
||||
|
@ -43,46 +42,62 @@ QVector<amnezia::Protocol> amnezia::protocolsForContainer(amnezia::DockerContain
|
|||
}
|
||||
}
|
||||
|
||||
QVector<amnezia::DockerContainer> amnezia::allContainers()
|
||||
QList<DockerContainer> ContainerProps::allContainers()
|
||||
{
|
||||
return QVector<amnezia::DockerContainer> {
|
||||
DockerContainer::None,
|
||||
DockerContainer::OpenVpn,
|
||||
DockerContainer::OpenVpnOverShadowSocks,
|
||||
DockerContainer::OpenVpnOverCloak,
|
||||
DockerContainer::WireGuard
|
||||
};
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<DockerContainer>();
|
||||
QList<DockerContainer> all;
|
||||
for (int i = 0; i < metaEnum.keyCount(); ++i) {
|
||||
all.append(static_cast<DockerContainer>(i));
|
||||
}
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
QMap<DockerContainer, QString> amnezia::containerHumanNames()
|
||||
QMap<DockerContainer, QString> ContainerProps::containerHumanNames()
|
||||
{
|
||||
return {
|
||||
{DockerContainer::OpenVpn, "OpenVPN"},
|
||||
{DockerContainer::OpenVpnOverShadowSocks, "OpenVpn over ShadowSocks"},
|
||||
{DockerContainer::OpenVpnOverCloak, "OpenVpn over Cloak"},
|
||||
{DockerContainer::WireGuard, "WireGuard"}
|
||||
{DockerContainer::ShadowSocks, "OpenVpn over ShadowSocks"},
|
||||
{DockerContainer::Cloak, "OpenVpn over Cloak"},
|
||||
{DockerContainer::WireGuard, "WireGuard"},
|
||||
{DockerContainer::TorSite, QObject::tr("Web site under TOR")},
|
||||
{DockerContainer::Dns, QObject::tr("DNS Service")},
|
||||
{DockerContainer::FileShare, QObject::tr("File Sharing Service")}
|
||||
};
|
||||
}
|
||||
|
||||
QMap<DockerContainer, QString> amnezia::containerDescriptions()
|
||||
QMap<DockerContainer, QString> ContainerProps::containerDescriptions()
|
||||
{
|
||||
return {
|
||||
{DockerContainer::OpenVpn, QObject::tr("OpenVPN container")},
|
||||
{DockerContainer::OpenVpnOverShadowSocks, QObject::tr("Container with OpenVpn and ShadowSocks")},
|
||||
{DockerContainer::OpenVpnOverCloak, QObject::tr("Container with OpenVpn and ShadowSocks protocols "
|
||||
{DockerContainer::ShadowSocks, QObject::tr("Container with OpenVpn and ShadowSocks")},
|
||||
{DockerContainer::Cloak, QObject::tr("Container with OpenVpn and ShadowSocks protocols "
|
||||
"configured with traffic masking by Cloak plugin")},
|
||||
{DockerContainer::WireGuard, QObject::tr("WireGuard container")}
|
||||
{DockerContainer::WireGuard, QObject::tr("WireGuard container")},
|
||||
{DockerContainer::TorSite, QObject::tr("Web site under TOR")},
|
||||
{DockerContainer::Dns, QObject::tr("DNS Service")},
|
||||
{DockerContainer::FileShare, QObject::tr("File Sharing Service")}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
bool amnezia::isContainerVpnType(DockerContainer c)
|
||||
amnezia::ServiceType ContainerProps::containerService(DockerContainer c)
|
||||
{
|
||||
switch (c) {
|
||||
case DockerContainer::None : return false;
|
||||
case DockerContainer::OpenVpn : return true;
|
||||
case DockerContainer::OpenVpnOverCloak : return true;
|
||||
case DockerContainer::OpenVpnOverShadowSocks : return true;
|
||||
case DockerContainer::WireGuard : return true;
|
||||
default: return false;
|
||||
case DockerContainer::None : return ServiceType::None;
|
||||
case DockerContainer::OpenVpn : return ServiceType::Vpn;
|
||||
case DockerContainer::Cloak : return ServiceType::Vpn;
|
||||
case DockerContainer::ShadowSocks : return ServiceType::Vpn;
|
||||
case DockerContainer::WireGuard : return ServiceType::Vpn;
|
||||
case DockerContainer::TorSite : return ServiceType::Other;
|
||||
case DockerContainer::Dns : return ServiceType::Other;
|
||||
case DockerContainer::FileShare : return ServiceType::Other;
|
||||
default: return ServiceType::Other;
|
||||
}
|
||||
}
|
||||
|
||||
Protocol ContainerProps::defaultProtocol(DockerContainer c)
|
||||
{
|
||||
return static_cast<Protocol>(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,17 @@ namespace amnezia {
|
|||
|
||||
namespace ContainerEnumNS {
|
||||
Q_NAMESPACE
|
||||
enum class DockerContainer {
|
||||
None,
|
||||
enum DockerContainer {
|
||||
None = 0,
|
||||
OpenVpn,
|
||||
OpenVpnOverShadowSocks,
|
||||
OpenVpnOverCloak,
|
||||
WireGuard
|
||||
ShadowSocks,
|
||||
Cloak,
|
||||
WireGuard,
|
||||
|
||||
//non-vpn
|
||||
TorSite,
|
||||
Dns,
|
||||
FileShare
|
||||
};
|
||||
Q_ENUM_NS(DockerContainer)
|
||||
} // namespace ContainerEnumNS
|
||||
|
@ -25,18 +30,31 @@ Q_ENUM_NS(DockerContainer)
|
|||
using namespace ContainerEnumNS;
|
||||
using namespace ProtocolEnumNS;
|
||||
|
||||
DockerContainer containerFromString(const QString &container);
|
||||
QString containerToString(DockerContainer container);
|
||||
class ContainerProps : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QVector<DockerContainer> allContainers();
|
||||
public:
|
||||
Q_INVOKABLE static DockerContainer containerFromString(const QString &container);
|
||||
Q_INVOKABLE static QString containerToString(DockerContainer container);
|
||||
|
||||
QMap<DockerContainer, QString> containerHumanNames();
|
||||
QMap<DockerContainer, QString> containerDescriptions();
|
||||
bool isContainerVpnType(DockerContainer c);
|
||||
Q_INVOKABLE static QList<DockerContainer> allContainers();
|
||||
|
||||
QVector<Protocol> protocolsForContainer(DockerContainer container);
|
||||
Q_INVOKABLE static QMap<DockerContainer, QString> containerHumanNames();
|
||||
Q_INVOKABLE static QMap<DockerContainer, QString> containerDescriptions();
|
||||
|
||||
static void declareQmlContainerEnum() {
|
||||
Q_INVOKABLE static QVector<Protocol> protocolsForContainer(DockerContainer container);
|
||||
|
||||
Q_INVOKABLE static ServiceType containerService(DockerContainer c);
|
||||
|
||||
// binding between Docker container and main protocol of given container
|
||||
// it may be changed fot future containers :)
|
||||
Q_INVOKABLE static Protocol defaultProtocol(DockerContainer c);
|
||||
};
|
||||
|
||||
|
||||
|
||||
static void declareQmlContainerEnum() {
|
||||
qmlRegisterUncreatableMetaObject(
|
||||
ContainerEnumNS::staticMetaObject,
|
||||
"ContainerEnum",
|
||||
|
|
|
@ -8,8 +8,8 @@ QString amnezia::scriptFolder(amnezia::DockerContainer container)
|
|||
{
|
||||
switch (container) {
|
||||
case DockerContainer::OpenVpn: return QLatin1String("openvpn");
|
||||
case DockerContainer::OpenVpnOverCloak: return QLatin1String("openvpn_cloak");
|
||||
case DockerContainer::OpenVpnOverShadowSocks: return QLatin1String("openvpn_shadowsocks");
|
||||
case DockerContainer::Cloak: return QLatin1String("openvpn_cloak");
|
||||
case DockerContainer::ShadowSocks: return QLatin1String("openvpn_shadowsocks");
|
||||
case DockerContainer::WireGuard: return QLatin1String("wireguard");
|
||||
default: return "";
|
||||
}
|
||||
|
|
|
@ -12,5 +12,5 @@
|
|||
|
||||
QString amnezia::server::getDockerfileFolder(amnezia::DockerContainer container)
|
||||
{
|
||||
return "/opt/amnezia/" + containerToString(container);
|
||||
return "/opt/amnezia/" + ContainerProps::containerToString(container);
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ QString ServerController::getTextFileFromContainer(DockerContainer container,
|
|||
if (errorCode) *errorCode = ErrorCode::NoError;
|
||||
|
||||
QString script = QString("sudo docker exec -i %1 sh -c \"cat \'%2\'\"").
|
||||
arg(amnezia::containerToString(container)).arg(path);
|
||||
arg(ContainerProps::containerToString(container)).arg(path);
|
||||
|
||||
qDebug().noquote() << "Copy file from container\n" << script;
|
||||
|
||||
|
@ -363,7 +363,7 @@ ErrorCode ServerController::removeContainer(const ServerCredentials &credentials
|
|||
|
||||
ErrorCode ServerController::setupContainer(const ServerCredentials &credentials, DockerContainer container, const QJsonObject &config)
|
||||
{
|
||||
qDebug().noquote() << "ServerController::setupContainer" << containerToString(container);
|
||||
qDebug().noquote() << "ServerController::setupContainer" << ContainerProps::containerToString(container);
|
||||
//qDebug().noquote() << QJsonDocument(config).toJson();
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
|
||||
|
@ -415,10 +415,10 @@ ErrorCode ServerController::updateContainer(const ServerCredentials &credentials
|
|||
|
||||
bool ServerController::isReinstallContainerRequred(DockerContainer container, const QJsonObject &oldConfig, const QJsonObject &newConfig)
|
||||
{
|
||||
if (container == DockerContainer::OpenVpn) {
|
||||
const QJsonObject &oldProtoConfig = oldConfig[config_key::openvpn].toObject();
|
||||
const QJsonObject &newProtoConfig = newConfig[config_key::openvpn].toObject();
|
||||
const QJsonObject &oldProtoConfig = oldConfig[ContainerProps::containerToString(container)].toObject();
|
||||
const QJsonObject &newProtoConfig = newConfig[ContainerProps::containerToString(container)].toObject();
|
||||
|
||||
if (container == DockerContainer::OpenVpn) {
|
||||
if (oldProtoConfig.value(config_key::transport_proto).toString(protocols::openvpn::defaultTransportProto) !=
|
||||
newProtoConfig.value(config_key::transport_proto).toString(protocols::openvpn::defaultTransportProto))
|
||||
return true;
|
||||
|
@ -428,20 +428,14 @@ bool ServerController::isReinstallContainerRequred(DockerContainer container, co
|
|||
return true;
|
||||
}
|
||||
|
||||
if (container == DockerContainer::OpenVpnOverCloak) {
|
||||
const QJsonObject &oldProtoConfig = oldConfig[config_key::cloak].toObject();
|
||||
const QJsonObject &newProtoConfig = newConfig[config_key::cloak].toObject();
|
||||
|
||||
if (container == DockerContainer::Cloak) {
|
||||
if (oldProtoConfig.value(config_key::port).toString(protocols::cloak::defaultPort) !=
|
||||
newProtoConfig.value(config_key::port).toString(protocols::cloak::defaultPort))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (container == DockerContainer::OpenVpnOverShadowSocks) {
|
||||
const QJsonObject &oldProtoConfig = oldConfig[config_key::shadowsocks].toObject();
|
||||
const QJsonObject &newProtoConfig = newConfig[config_key::shadowsocks].toObject();
|
||||
|
||||
if (oldProtoConfig.value(config_key::port).toString(protocols::shadowsocks::defaultPort) !=
|
||||
if (container == DockerContainer::ShadowSocks) {
|
||||
if (oldProtoConfig.value(config_key::port).toString(protocols::shadowsocks::defaultPort) !=
|
||||
newProtoConfig.value(config_key::port).toString(protocols::shadowsocks::defaultPort))
|
||||
return true;
|
||||
}
|
||||
|
@ -544,10 +538,10 @@ ErrorCode ServerController::startupContainerWorker(const ServerCredentials &cred
|
|||
|
||||
ServerController::Vars ServerController::genVarsForScript(const ServerCredentials &credentials, DockerContainer container, const QJsonObject &config)
|
||||
{
|
||||
const QJsonObject &openvpnConfig = config.value(config_key::openvpn).toObject();
|
||||
const QJsonObject &cloakConfig = config.value(config_key::cloak).toObject();
|
||||
const QJsonObject &ssConfig = config.value(config_key::shadowsocks).toObject();
|
||||
const QJsonObject &wireguarConfig = config.value(config_key::wireguard).toObject();
|
||||
const QJsonObject &openvpnConfig = config.value(ProtocolProps::protoToString(Protocol::OpenVpn)).toObject();
|
||||
const QJsonObject &cloakConfig = config.value(ProtocolProps::protoToString(Protocol::Cloak)).toObject();
|
||||
const QJsonObject &ssConfig = config.value(ProtocolProps::protoToString(Protocol::ShadowSocks)).toObject();
|
||||
const QJsonObject &wireguarConfig = config.value(ProtocolProps::protoToString(Protocol::WireGuard)).toObject();
|
||||
//
|
||||
|
||||
Vars vars;
|
||||
|
@ -580,8 +574,8 @@ ServerController::Vars ServerController::genVarsForScript(const ServerCredential
|
|||
vars.append({{"$SHADOWSOCKS_LOCAL_PORT", ssConfig.value(config_key::local_port).toString(protocols::shadowsocks::defaultLocalProxyPort) }});
|
||||
vars.append({{"$SHADOWSOCKS_CIPHER", ssConfig.value(config_key::cipher).toString(protocols::shadowsocks::defaultCipher) }});
|
||||
|
||||
vars.append({{"$CONTAINER_NAME", amnezia::containerToString(container)}});
|
||||
vars.append({{"$DOCKERFILE_FOLDER", "/opt/amnezia/" + amnezia::containerToString(container)}});
|
||||
vars.append({{"$CONTAINER_NAME", ContainerProps::containerToString(container)}});
|
||||
vars.append({{"$DOCKERFILE_FOLDER", "/opt/amnezia/" + ContainerProps::containerToString(container)}});
|
||||
|
||||
// Cloak vars
|
||||
vars.append({{"$CLOAK_SERVER_PORT", cloakConfig.value(config_key::port).toString(protocols::cloak::defaultPort) }});
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "ui/pages_logic/AppSettingsLogic.h"
|
||||
#include "ui/pages_logic/GeneralSettingsLogic.h"
|
||||
#include "ui/pages_logic/NetworkSettingsLogic.h"
|
||||
#include "ui/pages_logic/NewServerConfiguringLogic.h"
|
||||
#include "ui/pages_logic/ServerConfiguringProgressLogic.h"
|
||||
#include "ui/pages_logic/NewServerProtocolsLogic.h"
|
||||
#include "ui/pages_logic/ServerContainersLogic.h"
|
||||
#include "ui/pages_logic/ServerListLogic.h"
|
||||
|
@ -117,7 +117,9 @@ int main(int argc, char *argv[])
|
|||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
qRegisterMetaType<DockerContainer>("DockerContainer");
|
||||
qRegisterMetaType<TransportProto>("TransportProto");
|
||||
qRegisterMetaType<Protocol>("Protocol");
|
||||
qRegisterMetaType<ServiceType>("ServiceType");
|
||||
qRegisterMetaType<Page>("Page");
|
||||
|
||||
qRegisterMetaType<PageProtocolLogicBase *>("PageProtocolLogicBase *");
|
||||
|
@ -130,6 +132,12 @@ int main(int argc, char *argv[])
|
|||
declareQmlProtocolEnum();
|
||||
declareQmlContainerEnum();
|
||||
|
||||
QScopedPointer<ContainerProps> containerProps(new ContainerProps);
|
||||
qmlRegisterSingletonInstance("ContainerProps", 1, 0, "ContainerProps", containerProps.get());
|
||||
|
||||
QScopedPointer<ProtocolProps> protocolProps(new ProtocolProps);
|
||||
qmlRegisterSingletonInstance("ProtocolProps", 1, 0, "ProtocolProps", protocolProps.get());
|
||||
|
||||
const QUrl url(QStringLiteral("qrc:/ui/qml/main.qml"));
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||
|
@ -142,7 +150,7 @@ int main(int argc, char *argv[])
|
|||
engine.rootContext()->setContextProperty("AppSettingsLogic", uiLogic->appSettingsLogic());
|
||||
engine.rootContext()->setContextProperty("GeneralSettingsLogic", uiLogic->generalSettingsLogic());
|
||||
engine.rootContext()->setContextProperty("NetworkSettingsLogic", uiLogic->networkSettingsLogic());
|
||||
engine.rootContext()->setContextProperty("NewServerConfiguringLogic", uiLogic->newServerConfiguringLogic());
|
||||
engine.rootContext()->setContextProperty("ServerConfiguringProgressLogic", uiLogic->serverConfiguringProgressLogic());
|
||||
engine.rootContext()->setContextProperty("NewServerProtocolsLogic", uiLogic->newServerProtocolsLogic());
|
||||
engine.rootContext()->setContextProperty("ServerListLogic", uiLogic->serverListLogic());
|
||||
engine.rootContext()->setContextProperty("ServerSettingsLogic", uiLogic->serverSettingsLogic());
|
||||
|
@ -153,10 +161,6 @@ int main(int argc, char *argv[])
|
|||
engine.rootContext()->setContextProperty("VpnLogic", uiLogic->vpnLogic());
|
||||
engine.rootContext()->setContextProperty("WizardLogic", uiLogic->wizardLogic());
|
||||
|
||||
// engine.rootContext()->setContextProperty("OpenVpnLogic", uiLogic->openVpnLogic());
|
||||
// engine.rootContext()->setContextProperty("ShadowSocksLogic", uiLogic->shadowSocksLogic());
|
||||
// engine.rootContext()->setContextProperty("CloakLogic", uiLogic->cloakLogic());
|
||||
|
||||
engine.load(url);
|
||||
|
||||
// TODO - fix
|
||||
|
|
|
@ -1,59 +1,115 @@
|
|||
#include "protocols_defs.h"
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
QDebug operator<<(QDebug debug, const amnezia::ProtocolEnumNS::Protocol &p)
|
||||
{
|
||||
QDebugStateSaver saver(debug);
|
||||
debug.nospace() << amnezia::protoToString(p);
|
||||
debug.nospace() << ProtocolProps::protoToString(p);
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
amnezia::Protocol amnezia::protoFromString(QString proto){
|
||||
if (proto == config_key::openvpn) return Protocol::OpenVpn;
|
||||
if (proto == config_key::cloak) return Protocol::Cloak;
|
||||
if (proto == config_key::shadowsocks) return Protocol::ShadowSocks;
|
||||
if (proto == config_key::wireguard) return Protocol::WireGuard;
|
||||
amnezia::Protocol ProtocolProps::protoFromString(QString proto){
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<Protocol>();
|
||||
for (int i = 0; i < metaEnum.keyCount(); ++i) {
|
||||
Protocol p = static_cast<Protocol>(i);
|
||||
if (proto == protoToString(p)) return p;
|
||||
}
|
||||
return Protocol::Any;
|
||||
}
|
||||
|
||||
QString amnezia::protoToString(amnezia::Protocol proto){
|
||||
switch (proto) {
|
||||
case(Protocol::OpenVpn): return config_key::openvpn;
|
||||
case(Protocol::Cloak): return config_key::cloak;
|
||||
case(Protocol::ShadowSocks): return config_key::shadowsocks;
|
||||
case(Protocol::WireGuard): return config_key::wireguard;
|
||||
default: return "";
|
||||
QString ProtocolProps::protoToString(amnezia::Protocol p){
|
||||
if (p == Protocol::Any) return "";
|
||||
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<Protocol>();
|
||||
QString protoKey = metaEnum.valueToKey(static_cast<int>(p));
|
||||
return protoKey.toLower();
|
||||
}
|
||||
|
||||
QList<amnezia::Protocol> ProtocolProps::allProtocols()
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<Protocol>();
|
||||
QList<Protocol> all;
|
||||
for (int i = 0; i < metaEnum.keyCount(); ++i) {
|
||||
all.append(static_cast<Protocol>(i));
|
||||
}
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
TransportProto ProtocolProps::transportProtoFromString(QString p)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<TransportProto>();
|
||||
for (int i = 0; i < metaEnum.keyCount(); ++i) {
|
||||
TransportProto tp = static_cast<TransportProto>(i);
|
||||
if (p.toLower() == transportProtoToString(tp)) return tp;
|
||||
}
|
||||
return TransportProto::Udp;
|
||||
}
|
||||
|
||||
QString ProtocolProps::transportProtoToString(TransportProto proto, Protocol p)
|
||||
{
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<TransportProto>();
|
||||
QString protoKey = metaEnum.valueToKey(static_cast<int>(proto));
|
||||
if (p == Protocol::OpenVpn){
|
||||
return protoKey.toUpper();
|
||||
}
|
||||
else {
|
||||
return protoKey.toLower();
|
||||
}
|
||||
}
|
||||
|
||||
QVector<amnezia::Protocol> amnezia::allProtocols()
|
||||
{
|
||||
return QVector<amnezia::Protocol> {
|
||||
Protocol::Any,
|
||||
Protocol::OpenVpn,
|
||||
Protocol::ShadowSocks,
|
||||
Protocol::Cloak,
|
||||
Protocol::WireGuard
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
QMap<amnezia::Protocol, QString> amnezia::protocolHumanNames()
|
||||
QMap<amnezia::Protocol, QString> ProtocolProps::protocolHumanNames()
|
||||
{
|
||||
return {
|
||||
{Protocol::OpenVpn, "OpenVPN"},
|
||||
{Protocol::ShadowSocks, "ShadowSocks"},
|
||||
{Protocol::Cloak, "Cloak"},
|
||||
{Protocol::WireGuard, "WireGuard"}
|
||||
{Protocol::WireGuard, "WireGuard"},
|
||||
{Protocol::TorSite, "Web site under TOR"},
|
||||
{Protocol::Dns, "DNS Service"},
|
||||
{Protocol::FileShare, "File Sharing Service"}
|
||||
};
|
||||
}
|
||||
|
||||
QMap<amnezia::Protocol, QString> amnezia::protocolDescriptions()
|
||||
QMap<amnezia::Protocol, QString> ProtocolProps::protocolDescriptions()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
bool amnezia::isProtocolVpnType(ProtocolEnumNS::Protocol p)
|
||||
amnezia::ServiceType ProtocolProps::protocolService(Protocol p)
|
||||
{
|
||||
switch (p) {
|
||||
case Protocol::Any : return ServiceType::None;
|
||||
case Protocol::OpenVpn : return ServiceType::Vpn;
|
||||
case Protocol::Cloak : return ServiceType::Vpn;
|
||||
case Protocol::ShadowSocks : return ServiceType::Vpn;
|
||||
case Protocol::WireGuard : return ServiceType::Vpn;
|
||||
case Protocol::TorSite : return ServiceType::Other;
|
||||
case Protocol::Dns : return ServiceType::Other;
|
||||
case Protocol::FileShare : return ServiceType::Other;
|
||||
default: return ServiceType::Other;
|
||||
}
|
||||
}
|
||||
|
||||
int ProtocolProps::defaultPort(Protocol p)
|
||||
{
|
||||
switch (p) {
|
||||
case Protocol::Any : return -1;
|
||||
case Protocol::OpenVpn : return 1194;
|
||||
case Protocol::Cloak : return 443;
|
||||
case Protocol::ShadowSocks : return 6789;
|
||||
case Protocol::WireGuard : return 51820;
|
||||
case Protocol::TorSite : return 443;
|
||||
case Protocol::Dns : return 53;
|
||||
case Protocol::FileShare : return 139;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool ProtocolProps::defaultPortChangeable(Protocol p)
|
||||
{
|
||||
switch (p) {
|
||||
case Protocol::Any : return false;
|
||||
|
@ -61,6 +117,39 @@ bool amnezia::isProtocolVpnType(ProtocolEnumNS::Protocol p)
|
|||
case Protocol::Cloak : return true;
|
||||
case Protocol::ShadowSocks : return true;
|
||||
case Protocol::WireGuard : return true;
|
||||
default: return false;
|
||||
case Protocol::TorSite : return true;
|
||||
case Protocol::Dns : return false;
|
||||
case Protocol::FileShare : return false;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
TransportProto ProtocolProps::defaultTransportProto(Protocol p)
|
||||
{
|
||||
switch (p) {
|
||||
case Protocol::Any : return TransportProto::Udp;
|
||||
case Protocol::OpenVpn : return TransportProto::Udp;
|
||||
case Protocol::Cloak : return TransportProto::Tcp;
|
||||
case Protocol::ShadowSocks : return TransportProto::Tcp;
|
||||
case Protocol::WireGuard : return TransportProto::Udp;
|
||||
case Protocol::TorSite : return TransportProto::Tcp;
|
||||
case Protocol::Dns : return TransportProto::Udp;
|
||||
case Protocol::FileShare : return TransportProto::Tcp;
|
||||
default: return TransportProto::Udp;
|
||||
}
|
||||
}
|
||||
|
||||
bool ProtocolProps::defaultTransportProtoChangeable(Protocol p)
|
||||
{
|
||||
switch (p) {
|
||||
case Protocol::Any : return false;
|
||||
case Protocol::OpenVpn : return true;
|
||||
case Protocol::Cloak : return false;
|
||||
case Protocol::ShadowSocks : return false;
|
||||
case Protocol::WireGuard : return false;
|
||||
case Protocol::TorSite : return false;
|
||||
case Protocol::Dns : return false;
|
||||
case Protocol::FileShare : return false;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,17 +41,6 @@ constexpr char subnet_cidr[] = "subnet_cidr";
|
|||
|
||||
// proto config keys
|
||||
constexpr char last_config[] = "last_config";
|
||||
|
||||
constexpr char openvpn[] = "openvpn";
|
||||
constexpr char shadowsocks[] = "shadowsocks";
|
||||
constexpr char cloak[] = "cloak";
|
||||
constexpr char wireguard[] = "wireguard";
|
||||
|
||||
// containers config keys
|
||||
constexpr char amnezia_openvpn[] = "amnezia-openvpn";
|
||||
constexpr char amnezia_shadowsocks[] = "amnezia-shadowsocks";
|
||||
constexpr char amnezia_openvpn_cloak[] = "amnezia-openvpn-cloak";
|
||||
constexpr char amnezia_wireguard[] = "amnezia-wireguard";
|
||||
}
|
||||
|
||||
namespace protocols {
|
||||
|
@ -116,26 +105,61 @@ constexpr char serverPskKeyPath[] = "/opt/amnezia/wireguard/wireguard_psk.key";
|
|||
|
||||
namespace ProtocolEnumNS {
|
||||
Q_NAMESPACE
|
||||
enum class Protocol {
|
||||
Any,
|
||||
|
||||
enum TransportProto {
|
||||
Udp,
|
||||
Tcp
|
||||
};
|
||||
Q_ENUM_NS(TransportProto)
|
||||
|
||||
enum Protocol {
|
||||
Any = 0,
|
||||
OpenVpn,
|
||||
ShadowSocks,
|
||||
Cloak,
|
||||
WireGuard
|
||||
WireGuard,
|
||||
TorSite,
|
||||
Dns,
|
||||
FileShare
|
||||
};
|
||||
Q_ENUM_NS(Protocol)
|
||||
|
||||
enum ServiceType {
|
||||
None = 0,
|
||||
Vpn,
|
||||
Other
|
||||
};
|
||||
Q_ENUM_NS(ServiceType)
|
||||
} // namespace ProtocolEnumNS
|
||||
|
||||
using namespace ProtocolEnumNS;
|
||||
|
||||
QVector<Protocol> allProtocols();
|
||||
class ProtocolProps : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Protocol protoFromString(QString proto);
|
||||
QString protoToString(Protocol proto);
|
||||
public:
|
||||
Q_INVOKABLE static QList<Protocol> allProtocols();
|
||||
|
||||
QMap<Protocol, QString> protocolHumanNames();
|
||||
QMap<Protocol, QString> protocolDescriptions();
|
||||
bool isProtocolVpnType(Protocol p);
|
||||
// spelling may differ for various protocols - TCP for OpenVPN, tcp for others
|
||||
Q_INVOKABLE static TransportProto transportProtoFromString(QString p);
|
||||
Q_INVOKABLE static QString transportProtoToString(TransportProto proto, Protocol p = Protocol::Any);
|
||||
|
||||
Q_INVOKABLE static Protocol protoFromString(QString p);
|
||||
Q_INVOKABLE static QString protoToString(Protocol p);
|
||||
|
||||
Q_INVOKABLE static QMap<Protocol, QString> protocolHumanNames();
|
||||
Q_INVOKABLE static QMap<Protocol, QString> protocolDescriptions();
|
||||
|
||||
Q_INVOKABLE static ServiceType protocolService(Protocol p);
|
||||
|
||||
Q_INVOKABLE static int defaultPort(Protocol p);
|
||||
Q_INVOKABLE static bool defaultPortChangeable(Protocol p);
|
||||
|
||||
Q_INVOKABLE static TransportProto defaultTransportProto(Protocol p);
|
||||
Q_INVOKABLE static bool defaultTransportProtoChangeable(Protocol p);
|
||||
|
||||
};
|
||||
|
||||
static void declareQmlProtocolEnum() {
|
||||
qmlRegisterUncreatableMetaObject(
|
||||
|
@ -145,6 +169,14 @@ static void declareQmlProtocolEnum() {
|
|||
"ProtocolEnum",
|
||||
"Error: only enums"
|
||||
);
|
||||
|
||||
qmlRegisterUncreatableMetaObject(
|
||||
ProtocolEnumNS::staticMetaObject,
|
||||
"ProtocolEnum",
|
||||
1, 0,
|
||||
"TransportProto",
|
||||
"Error: only enums"
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace amnezia
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
<file>ui/qml/Pages/PageGeneralSettings.qml</file>
|
||||
<file>ui/qml/Pages/PageNetworkSetting.qml</file>
|
||||
<file>ui/qml/Pages/PageNewServer.qml</file>
|
||||
<file>ui/qml/Pages/PageNewServerConfiguring.qml</file>
|
||||
<file>ui/qml/Pages/PageServerConfiguringProgress.qml</file>
|
||||
<file>ui/qml/Pages/PageNewServerProtocols.qml</file>
|
||||
<file>ui/qml/Pages/PageServerList.qml</file>
|
||||
<file>ui/qml/Pages/PageServerContainers.qml</file>
|
||||
|
|
|
@ -79,20 +79,20 @@ bool Settings::editServer(int index, const QJsonObject &server)
|
|||
void Settings::setDefaultContainer(int serverIndex, DockerContainer container)
|
||||
{
|
||||
QJsonObject s = server(serverIndex);
|
||||
s.insert(config_key::defaultContainer, containerToString(container));
|
||||
s.insert(config_key::defaultContainer, ContainerProps::containerToString(container));
|
||||
editServer(serverIndex, s);
|
||||
}
|
||||
|
||||
DockerContainer Settings::defaultContainer(int serverIndex) const
|
||||
{
|
||||
return containerFromString(defaultContainerName(serverIndex));
|
||||
return ContainerProps::containerFromString(defaultContainerName(serverIndex));
|
||||
}
|
||||
|
||||
QString Settings::defaultContainerName(int serverIndex) const
|
||||
{
|
||||
QString name = server(serverIndex).value(config_key::defaultContainer).toString();
|
||||
if (name.isEmpty()) {
|
||||
return containerToString(DockerContainer::None);
|
||||
return ContainerProps::containerToString(DockerContainer::None);
|
||||
}
|
||||
else return name;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ QMap<DockerContainer, QJsonObject> Settings::containers(int serverIndex) const
|
|||
|
||||
QMap<DockerContainer, QJsonObject> containersMap;
|
||||
for (const QJsonValue &val : containers) {
|
||||
containersMap.insert(containerFromString(val.toObject().value(config_key::container).toString()), val.toObject());
|
||||
containersMap.insert(ContainerProps::containerFromString(val.toObject().value(config_key::container).toString()), val.toObject());
|
||||
}
|
||||
|
||||
return containersMap;
|
||||
|
@ -135,7 +135,7 @@ void Settings::setContainerConfig(int serverIndex, DockerContainer container, co
|
|||
}
|
||||
auto c = containers(serverIndex);
|
||||
c[container] = config;
|
||||
c[container][config_key::container] = containerToString(container);
|
||||
c[container][config_key::container] = ContainerProps::containerToString(container);
|
||||
setContainers(serverIndex, c);
|
||||
}
|
||||
|
||||
|
@ -154,13 +154,13 @@ void Settings::removeContainerConfig(int serverIndex, DockerContainer container)
|
|||
QJsonObject Settings::protocolConfig(int serverIndex, DockerContainer container, Protocol proto)
|
||||
{
|
||||
const QJsonObject &c = containerConfig(serverIndex, container);
|
||||
return c.value(protoToString(proto)).toObject();
|
||||
return c.value(ProtocolProps::protoToString(proto)).toObject();
|
||||
}
|
||||
|
||||
void Settings::setProtocolConfig(int serverIndex, DockerContainer container, Protocol proto, const QJsonObject &config)
|
||||
{
|
||||
QJsonObject c = containerConfig(serverIndex, container);
|
||||
c.insert(protoToString(proto), config);
|
||||
c.insert(ProtocolProps::protoToString(proto), config);
|
||||
|
||||
setContainerConfig(serverIndex, container, c);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ ContainersModel::ContainersModel(QObject *parent) :
|
|||
int ContainersModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return amnezia::allContainers().size();
|
||||
return ContainerProps::allContainers().size();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ContainersModel::roleNames() const {
|
||||
|
@ -17,36 +17,32 @@ QHash<int, QByteArray> ContainersModel::roleNames() const {
|
|||
roles[NameRole] = "name_role";
|
||||
roles[DescRole] = "desc_role";
|
||||
roles[DefaultRole] = "default_role";
|
||||
roles[isVpnTypeRole] = "is_vpn_role";
|
||||
roles[isOtherTypeRole] = "is_other_role";
|
||||
roles[isInstalledRole] = "is_installed_role";
|
||||
roles[ServiceTypeRole] = "service_type_role";
|
||||
roles[IsInstalledRole] = "is_installed_role";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= amnezia::allContainers().size()) {
|
||||
|| index.row() >= ContainerProps::allContainers().size()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
DockerContainer c = amnezia::allContainers().at(index.row());
|
||||
DockerContainer c = ContainerProps::allContainers().at(index.row());
|
||||
if (role == NameRole) {
|
||||
return containerHumanNames().value(c);
|
||||
return ContainerProps::containerHumanNames().value(c);
|
||||
}
|
||||
if (role == DescRole) {
|
||||
return containerDescriptions().value(c);
|
||||
return ContainerProps::containerDescriptions().value(c);
|
||||
}
|
||||
if (role == DefaultRole) {
|
||||
return c == m_settings.defaultContainer(m_selectedServerIndex);
|
||||
}
|
||||
if (role == isVpnTypeRole) {
|
||||
return isContainerVpnType(c);
|
||||
if (role == ServiceTypeRole) {
|
||||
return ContainerProps::containerService(c);
|
||||
}
|
||||
// if (role == isOtherTypeRole) {
|
||||
// return isContainerVpnType(c)
|
||||
// }
|
||||
if (role == isInstalledRole) {
|
||||
if (role == IsInstalledRole) {
|
||||
return m_settings.containers(m_selectedServerIndex).contains(c);
|
||||
}
|
||||
return QVariant();
|
||||
|
|
|
@ -19,15 +19,14 @@ public:
|
|||
NameRole = Qt::UserRole + 1,
|
||||
DescRole,
|
||||
DefaultRole,
|
||||
isVpnTypeRole,
|
||||
isOtherTypeRole,
|
||||
isInstalledRole
|
||||
ServiceTypeRole,
|
||||
IsInstalledRole
|
||||
};
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
void setSelectedServerIndex(int index);
|
||||
Q_INVOKABLE void setSelectedServerIndex(int index);
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
|
|
@ -9,41 +9,37 @@ ProtocolsModel::ProtocolsModel(QObject *parent) :
|
|||
int ProtocolsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return amnezia::allProtocols().size();
|
||||
return ProtocolProps::allProtocols().size();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ProtocolsModel::roleNames() const {
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[NameRole] = "name_role";
|
||||
roles[DescRole] = "desc_role";
|
||||
roles[isVpnTypeRole] = "is_vpn_role";
|
||||
roles[isOtherTypeRole] = "is_other_role";
|
||||
roles[isInstalledRole] = "is_installed_role";
|
||||
roles[ServiceTypeRole] = "service_type_role";
|
||||
roles[IsInstalledRole] = "is_installed_role";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QVariant ProtocolsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= amnezia::allContainers().size()) {
|
||||
|| index.row() >= ContainerProps::allContainers().size()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Protocol p = amnezia::allProtocols().at(index.row());
|
||||
Protocol p = ProtocolProps::allProtocols().at(index.row());
|
||||
if (role == NameRole) {
|
||||
return protocolHumanNames().value(p);
|
||||
return ProtocolProps::protocolHumanNames().value(p);
|
||||
}
|
||||
if (role == DescRole) {
|
||||
return protocolDescriptions().value(p);
|
||||
return ProtocolProps::protocolDescriptions().value(p);
|
||||
}
|
||||
if (role == isVpnTypeRole) {
|
||||
return isProtocolVpnType(p);
|
||||
if (role == ServiceTypeRole) {
|
||||
return ProtocolProps::protocolService(p);
|
||||
}
|
||||
// if (role == isOtherTypeRole) {
|
||||
// return isContainerVpnType(c)
|
||||
// }
|
||||
if (role == isInstalledRole) {
|
||||
return protocolsForContainer(m_selectedDockerContainer).contains(p);
|
||||
if (role == IsInstalledRole) {
|
||||
return ContainerProps::protocolsForContainer(m_selectedDockerContainer).contains(p);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
@ -18,9 +18,8 @@ public:
|
|||
enum SiteRoles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
DescRole,
|
||||
isVpnTypeRole,
|
||||
isOtherTypeRole,
|
||||
isInstalledRole
|
||||
ServiceTypeRole,
|
||||
IsInstalledRole
|
||||
};
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace PageEnumNS
|
|||
{
|
||||
Q_NAMESPACE
|
||||
enum class Page {Start = 0, NewServer, NewServerProtocols, Vpn,
|
||||
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguring,
|
||||
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguringProgress,
|
||||
GeneralSettings, AppSettings, NetworkSettings, ServerSettings,
|
||||
ServerContainers, ServersList, ShareConnection, Sites,
|
||||
ProtocolSettings};
|
||||
|
|
|
@ -3,27 +3,9 @@
|
|||
|
||||
NewServerProtocolsLogic::NewServerProtocolsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_pushButtonSettingsCloakChecked{false},
|
||||
m_pushButtonSettingsSsChecked{false},
|
||||
m_pushButtonSettingsOpenvpnChecked{false},
|
||||
m_lineEditCloakPortText{},
|
||||
m_lineEditCloakSiteText{},
|
||||
m_lineEditSsPortText{},
|
||||
m_comboBoxSsCipherText{"chacha20-ietf-poly1305"},
|
||||
m_lineEditOpenvpnPortText{},
|
||||
m_comboBoxOpenvpnProtoText{"udp"},
|
||||
m_frameSettingsParentWireguardVisible{false},
|
||||
m_checkBoxCloakChecked{true},
|
||||
m_checkBoxSsChecked{false},
|
||||
m_checkBoxOpenVpnChecked{false},
|
||||
m_progressBarConnectionMinimum{0},
|
||||
m_progressBarConnectionMaximum{100}
|
||||
{
|
||||
set_frameSettingsParentWireguardVisible(false);
|
||||
|
||||
connect(this, &NewServerProtocolsLogic::pushButtonConfigureClicked, this, [this](){
|
||||
uiLogic()->installServer(getInstallConfigsFromProtocolsPage());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,57 +13,23 @@ void NewServerProtocolsLogic::updatePage()
|
|||
{
|
||||
set_progressBarConnectionMinimum(0);
|
||||
set_progressBarConnectionMaximum(300);
|
||||
|
||||
set_pushButtonSettingsCloakChecked(true);
|
||||
set_pushButtonSettingsCloakChecked(false);
|
||||
set_pushButtonSettingsSsChecked(true);
|
||||
set_pushButtonSettingsSsChecked(false);
|
||||
set_lineEditCloakPortText(amnezia::protocols::cloak::defaultPort);
|
||||
set_lineEditCloakSiteText(amnezia::protocols::cloak::defaultRedirSite);
|
||||
set_lineEditSsPortText(amnezia::protocols::shadowsocks::defaultPort);
|
||||
set_comboBoxSsCipherText(amnezia::protocols::shadowsocks::defaultCipher);
|
||||
set_lineEditOpenvpnPortText(amnezia::protocols::openvpn::defaultPort);
|
||||
set_comboBoxOpenvpnProtoText(amnezia::protocols::openvpn::defaultTransportProto);
|
||||
}
|
||||
|
||||
QMap<DockerContainer, QJsonObject> NewServerProtocolsLogic::getInstallConfigsFromProtocolsPage() const
|
||||
void NewServerProtocolsLogic::onPushButtonConfigureClicked(DockerContainer c, int port, TransportProto tp)
|
||||
{
|
||||
QJsonObject cloakConfig {
|
||||
{ config_key::container, amnezia::containerToString(DockerContainer::OpenVpnOverCloak) },
|
||||
{ config_key::cloak, QJsonObject {
|
||||
{ config_key::port, lineEditCloakPortText() },
|
||||
{ config_key::site, lineEditCloakSiteText() }}
|
||||
}
|
||||
};
|
||||
QJsonObject ssConfig {
|
||||
{ config_key::container, amnezia::containerToString(DockerContainer::OpenVpnOverShadowSocks) },
|
||||
{ config_key::shadowsocks, QJsonObject {
|
||||
{ config_key::port, lineEditSsPortText() },
|
||||
{ config_key::cipher, comboBoxSsCipherText() }}
|
||||
}
|
||||
};
|
||||
QJsonObject openVpnConfig {
|
||||
{ config_key::container, amnezia::containerToString(DockerContainer::OpenVpn) },
|
||||
{ config_key::openvpn, QJsonObject {
|
||||
{ config_key::port, lineEditOpenvpnPortText() },
|
||||
{ config_key::transport_proto, comboBoxOpenvpnProtoText() }}
|
||||
}
|
||||
};
|
||||
|
||||
QMap<DockerContainer, QJsonObject> containers;
|
||||
Protocol mainProto = ContainerProps::defaultProtocol(c);
|
||||
|
||||
if (checkBoxCloakChecked()) {
|
||||
containers.insert(DockerContainer::OpenVpnOverCloak, cloakConfig);
|
||||
}
|
||||
QJsonObject config {
|
||||
{ config_key::container, ContainerProps::containerToString(c) },
|
||||
{ ProtocolProps::protoToString(mainProto), QJsonObject {
|
||||
{ config_key::port, QString::number(port) },
|
||||
{ config_key::transport_proto, ProtocolProps::transportProtoToString(tp, mainProto) }}
|
||||
}
|
||||
};
|
||||
|
||||
if (checkBoxSsChecked()) {
|
||||
containers.insert(DockerContainer::OpenVpnOverShadowSocks, ssConfig);
|
||||
}
|
||||
containers.insert(c, config);
|
||||
|
||||
if (checkBoxOpenVpnChecked()) {
|
||||
containers.insert(DockerContainer::OpenVpn, openVpnConfig);
|
||||
}
|
||||
|
||||
return containers;
|
||||
uiLogic()->installServer(containers);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,33 +9,16 @@ class NewServerProtocolsLogic : public PageLogicBase
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
AUTO_PROPERTY(bool, frameSettingsParentWireguardVisible)
|
||||
AUTO_PROPERTY(bool, pushButtonSettingsCloakChecked)
|
||||
AUTO_PROPERTY(bool, pushButtonSettingsSsChecked)
|
||||
AUTO_PROPERTY(bool, pushButtonSettingsOpenvpnChecked)
|
||||
AUTO_PROPERTY(QString, lineEditCloakPortText)
|
||||
AUTO_PROPERTY(QString, lineEditCloakSiteText)
|
||||
AUTO_PROPERTY(QString, lineEditSsPortText)
|
||||
AUTO_PROPERTY(QString, comboBoxSsCipherText)
|
||||
AUTO_PROPERTY(QString, lineEditOpenvpnPortText)
|
||||
AUTO_PROPERTY(QString, comboBoxOpenvpnProtoText)
|
||||
AUTO_PROPERTY(bool, checkBoxCloakChecked)
|
||||
AUTO_PROPERTY(bool, checkBoxSsChecked)
|
||||
AUTO_PROPERTY(bool, checkBoxOpenVpnChecked)
|
||||
AUTO_PROPERTY(double, progressBarConnectionMinimum)
|
||||
AUTO_PROPERTY(double, progressBarConnectionMaximum)
|
||||
|
||||
public:
|
||||
Q_INVOKABLE void updatePage() override;
|
||||
Q_INVOKABLE void onPushButtonConfigureClicked(DockerContainer c, int port, TransportProto tp);
|
||||
|
||||
public:
|
||||
explicit NewServerProtocolsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~NewServerProtocolsLogic() = default;
|
||||
|
||||
QMap<DockerContainer, QJsonObject> getInstallConfigsFromProtocolsPage() const;
|
||||
|
||||
signals:
|
||||
void pushButtonConfigureClicked();
|
||||
|
||||
};
|
||||
#endif // NEW_SERVER_PROTOCOLS_LOGIC_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "NewServerConfiguringLogic.h"
|
||||
#include "ServerConfiguringProgressLogic.h"
|
||||
|
||||
NewServerConfiguringLogic::NewServerConfiguringLogic(UiLogic *logic, QObject *parent):
|
||||
ServerConfiguringProgressLogic::ServerConfiguringProgressLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_progressBarValue{0},
|
||||
m_labelWaitInfoVisible{true},
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef NEW_SERVER_CONFIGURING_LOGIC_H
|
||||
#define NEW_SERVER_CONFIGURING_LOGIC_H
|
||||
#ifndef SERVER_CONFIGURING_PROGRESS_LOGIC_H
|
||||
#define SERVER_CONFIGURING_PROGRESS_LOGIC_H
|
||||
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class NewServerConfiguringLogic : public PageLogicBase
|
||||
class ServerConfiguringProgressLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -18,8 +18,8 @@ class NewServerConfiguringLogic : public PageLogicBase
|
|||
AUTO_PROPERTY(QString, progressBarText)
|
||||
|
||||
public:
|
||||
explicit NewServerConfiguringLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~NewServerConfiguringLogic() = default;
|
||||
explicit ServerConfiguringProgressLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~ServerConfiguringProgressLogic() = default;
|
||||
|
||||
};
|
||||
#endif // NEW_SERVER_CONFIGURING_LOGIC_H
|
||||
#endif // SERVER_CONFIGURING_PROGRESS_LOGIC_H
|
|
@ -59,8 +59,8 @@ void ServerContainersLogic::updateServerContainersPage()
|
|||
// all containers
|
||||
QList<DockerContainer> allContainers {
|
||||
DockerContainer::OpenVpn,
|
||||
DockerContainer::OpenVpnOverShadowSocks,
|
||||
DockerContainer::OpenVpnOverCloak,
|
||||
DockerContainer::ShadowSocks,
|
||||
DockerContainer::Cloak,
|
||||
DockerContainer::WireGuard
|
||||
};
|
||||
|
||||
|
@ -141,8 +141,8 @@ void ServerContainersLogic::setupProtocolsPageConnections()
|
|||
// all containers
|
||||
QList<DockerContainer> containers {
|
||||
DockerContainer::OpenVpn,
|
||||
DockerContainer::OpenVpnOverShadowSocks,
|
||||
DockerContainer::OpenVpnOverCloak,
|
||||
DockerContainer::ShadowSocks,
|
||||
DockerContainer::Cloak,
|
||||
DockerContainer::WireGuard
|
||||
};
|
||||
using ButtonClickedFunc = void (ServerContainersLogic::*)(bool);
|
||||
|
|
|
@ -142,10 +142,10 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
|||
|
||||
ServerCredentials credentials = m_settings.serverCredentials(uiLogic()->selectedServerIndex);
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
containerConfig.insert(config_key::container, containerToString(uiLogic()->selectedDockerContainer));
|
||||
containerConfig.insert(config_key::container, ContainerProps::containerToString(uiLogic()->selectedDockerContainer));
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
for (Protocol p: amnezia::protocolsForContainer(uiLogic()->selectedDockerContainer)) {
|
||||
for (Protocol p: ContainerProps::protocolsForContainer(uiLogic()->selectedDockerContainer)) {
|
||||
QJsonObject protoConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, p);
|
||||
|
||||
QString cfg = VpnConfigurator::genVpnProtocolConfig(credentials, uiLogic()->selectedDockerContainer, containerConfig, p, &e);
|
||||
|
@ -155,7 +155,7 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
|||
}
|
||||
protoConfig.insert(config_key::last_config, cfg);
|
||||
|
||||
containerConfig.insert(protoToString(p), protoConfig);
|
||||
containerConfig.insert(ProtocolProps::protoToString(p), protoConfig);
|
||||
}
|
||||
|
||||
QByteArray ba;
|
||||
|
@ -165,7 +165,7 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
|||
serverConfig.remove(config_key::password);
|
||||
serverConfig.remove(config_key::port);
|
||||
serverConfig.insert(config_key::containers, QJsonArray {containerConfig});
|
||||
serverConfig.insert(config_key::defaultContainer, containerToString(uiLogic()->selectedDockerContainer));
|
||||
serverConfig.insert(config_key::defaultContainer, ContainerProps::containerToString(uiLogic()->selectedDockerContainer));
|
||||
|
||||
|
||||
ba = QJsonDocument(serverConfig).toJson().toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||
|
@ -248,8 +248,8 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
|
|||
set_toolBoxShareConnectionCurrentIndex(share_openvpn);
|
||||
}
|
||||
|
||||
if (container == DockerContainer::OpenVpnOverShadowSocks ||
|
||||
container == DockerContainer::OpenVpnOverCloak) {
|
||||
if (container == DockerContainer::ShadowSocks ||
|
||||
container == DockerContainer::Cloak) {
|
||||
set_pageShareAmneziaVisible(true);
|
||||
set_pageShareShadowSocksVisible(true);
|
||||
|
||||
|
@ -287,7 +287,7 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
|
|||
set_toolBoxShareConnectionCurrentIndex(share_shadowshock);
|
||||
}
|
||||
|
||||
if (container == DockerContainer::OpenVpnOverCloak) {
|
||||
if (container == DockerContainer::Cloak) {
|
||||
//ui->toolBox_share_connection->addItem(ui->page_share_amnezia, tr(" Share for Amnezia client"));
|
||||
set_pageShareCloakVisible(true);
|
||||
set_plainTextEditShareCloakText(QString(""));
|
||||
|
@ -328,9 +328,9 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, const ServerCreden
|
|||
// Amnezia sharing
|
||||
// QJsonObject exportContainer;
|
||||
// for (Protocol p: protocolsForContainer(container)) {
|
||||
// QJsonObject protocolConfig = containerConfig.value(protoToString(p)).toObject();
|
||||
// QJsonObject protocolConfig = containerConfig.value(ProtocolProps::protoToString(p)).toObject();
|
||||
// protocolConfig.remove(config_key::last_config);
|
||||
// exportContainer.insert(protoToString(p), protocolConfig);
|
||||
// exportContainer.insert(ProtocolProps::protoToString(p), protocolConfig);
|
||||
// }
|
||||
// exportContainer.insert(config_key::container, containerToString(container));
|
||||
|
||||
|
|
|
@ -20,26 +20,26 @@ void WizardLogic::updatePage()
|
|||
QMap<DockerContainer, QJsonObject> WizardLogic::getInstallConfigsFromWizardPage() const
|
||||
{
|
||||
QJsonObject cloakConfig {
|
||||
{ config_key::container, amnezia::containerToString(DockerContainer::OpenVpnOverCloak) },
|
||||
{ config_key::cloak, QJsonObject {
|
||||
{ config_key::container, ContainerProps::containerToString(DockerContainer::Cloak) },
|
||||
{ ProtocolProps::protoToString(Protocol::Cloak), QJsonObject {
|
||||
{ config_key::site, lineEditHighWebsiteMaskingText() }}
|
||||
}
|
||||
};
|
||||
QJsonObject ssConfig {
|
||||
{ config_key::container, amnezia::containerToString(DockerContainer::OpenVpnOverShadowSocks) }
|
||||
{ config_key::container, ContainerProps::containerToString(DockerContainer::ShadowSocks) }
|
||||
};
|
||||
QJsonObject openVpnConfig {
|
||||
{ config_key::container, amnezia::containerToString(DockerContainer::OpenVpn) }
|
||||
{ config_key::container, ContainerProps::containerToString(DockerContainer::OpenVpn) }
|
||||
};
|
||||
|
||||
QMap<DockerContainer, QJsonObject> containers;
|
||||
|
||||
if (radioButtonHighChecked()) {
|
||||
containers.insert(DockerContainer::OpenVpnOverCloak, cloakConfig);
|
||||
containers.insert(DockerContainer::Cloak, cloakConfig);
|
||||
}
|
||||
|
||||
if (radioButtonMediumChecked()) {
|
||||
containers.insert(DockerContainer::OpenVpnOverShadowSocks, ssConfig);
|
||||
containers.insert(DockerContainer::ShadowSocks, ssConfig);
|
||||
}
|
||||
|
||||
if (radioButtonLowChecked()) {
|
||||
|
|
|
@ -38,7 +38,7 @@ void CloakLogic::updateProtocolPage(const QJsonObject &ckConfig, DockerContainer
|
|||
set_lineEditProtoCloakPortText(ckConfig.value(config_key::port).
|
||||
toString(protocols::cloak::defaultPort));
|
||||
|
||||
set_lineEditProtoCloakPortEnabled(container == DockerContainer::OpenVpnOverCloak);
|
||||
set_lineEditProtoCloakPortEnabled(container == DockerContainer::Cloak);
|
||||
}
|
||||
|
||||
QJsonObject CloakLogic::getProtocolConfigFromPage(QJsonObject oldConfig)
|
||||
|
@ -57,7 +57,7 @@ void CloakLogic::onPushButtonProtoCloakSaveClicked()
|
|||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(config_key::cloak, protocolConfig);
|
||||
newContainerConfig.insert(ProtocolProps::protoToString(Protocol::Cloak), protocolConfig);
|
||||
|
||||
UiLogic::PageFunc page_proto_cloak;
|
||||
page_proto_cloak.setEnabledFunc = [this] (bool enabled) -> void {
|
||||
|
|
|
@ -69,7 +69,7 @@ void OpenVpnLogic::updateProtocolPage(const QJsonObject &openvpnConfig, DockerCo
|
|||
bool isTlsAuth = openvpnConfig.value(config_key::tls_auth).toBool(protocols::openvpn::defaultTlsAuth);
|
||||
set_checkBoxProtoOpenVpnTlsAuthChecked(isTlsAuth);
|
||||
|
||||
if (container == DockerContainer::OpenVpnOverShadowSocks) {
|
||||
if (container == DockerContainer::ShadowSocks) {
|
||||
set_radioButtonProtoOpenVpnUdpEnabled(false);
|
||||
set_radioButtonProtoOpenVpnTcpEnabled(false);
|
||||
set_radioButtonProtoOpenVpnTcpChecked(true);
|
||||
|
@ -94,7 +94,7 @@ void OpenVpnLogic::onPushButtonProtoOpenVpnSaveClicked()
|
|||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(config_key::openvpn, protocolConfig);
|
||||
newContainerConfig.insert(ProtocolProps::protoToString(Protocol::OpenVpn), protocolConfig);
|
||||
|
||||
UiLogic::PageFunc page_proto_openvpn;
|
||||
page_proto_openvpn.setEnabledFunc = [this] (bool enabled) -> void {
|
||||
|
|
|
@ -34,7 +34,7 @@ void ShadowSocksLogic::updateProtocolPage(const QJsonObject &ssConfig, DockerCon
|
|||
set_lineEditProtoShadowSocksPortText(ssConfig.value(config_key::port).
|
||||
toString(protocols::shadowsocks::defaultPort));
|
||||
|
||||
set_lineEditProtoShadowSocksPortEnabled(container == DockerContainer::OpenVpnOverShadowSocks);
|
||||
set_lineEditProtoShadowSocksPortEnabled(container == DockerContainer::ShadowSocks);
|
||||
}
|
||||
|
||||
QJsonObject ShadowSocksLogic::getProtocolConfigFromPage(QJsonObject oldConfig)
|
||||
|
@ -52,7 +52,7 @@ void ShadowSocksLogic::onPushButtonProtoShadowSocksSaveClicked()
|
|||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(config_key::shadowsocks, protocolConfig);
|
||||
newContainerConfig.insert(ProtocolProps::protoToString(Protocol::ShadowSocks), protocolConfig);
|
||||
UiLogic::PageFunc page_proto_shadowsocks;
|
||||
page_proto_shadowsocks.setEnabledFunc = [this] (bool enabled) -> void {
|
||||
set_pageProtoShadowSocksEnabled(enabled);
|
||||
|
|
|
@ -3,7 +3,6 @@ import QtQuick.Controls 2.12
|
|||
|
||||
Image {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 30
|
||||
// width: GC.trW(150)
|
||||
// height: GC.trH(22)
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import SortFilterProxyModel 0.2
|
||||
import ProtocolEnum 1.0
|
||||
import "./"
|
||||
import "../../Controls"
|
||||
import "../../Config"
|
||||
|
||||
Drawer {
|
||||
id: root
|
||||
signal containerSelected(int id)
|
||||
property alias selectedIndex: tb.currentIndex
|
||||
signal containerSelected(int c_index)
|
||||
property int selectedIndex: -1
|
||||
property alias modelFilters: proxyModel.filters
|
||||
|
||||
z: -3
|
||||
|
@ -30,8 +31,22 @@ Drawer {
|
|||
roleName: "is_installed_role"
|
||||
value: false },
|
||||
ValueFilter {
|
||||
roleName: "is_vpn_role"
|
||||
value: true }
|
||||
roleName: "service_type_role"
|
||||
value: ProtocolEnum.Vpn }
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
SortFilterProxyModel {
|
||||
id: proxyModel_other
|
||||
sourceModel: UiLogic.containersModel
|
||||
filters: [
|
||||
ValueFilter {
|
||||
roleName: "is_installed_role"
|
||||
value: false },
|
||||
ValueFilter {
|
||||
roleName: "service_type_role"
|
||||
value: ProtocolEnum.Other }
|
||||
]
|
||||
|
||||
}
|
||||
|
@ -60,7 +75,8 @@ Drawer {
|
|||
ListView {
|
||||
id: tb
|
||||
x: 10
|
||||
width: parent.width - 40
|
||||
currentIndex: -1
|
||||
width: parent.width - 20
|
||||
height: contentItem.height
|
||||
|
||||
spacing: 0
|
||||
|
@ -104,7 +120,9 @@ Drawer {
|
|||
anchors.fill: parent
|
||||
onClicked: {
|
||||
tb.currentIndex = index
|
||||
containerSelected(index)
|
||||
tb_other.currentIndex = -1
|
||||
containerSelected(proxyModel.mapToSource(index))
|
||||
selectedIndex = proxyModel.mapToSource(index)
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
|
@ -112,64 +130,68 @@ Drawer {
|
|||
}
|
||||
|
||||
|
||||
// Caption {
|
||||
// id: cap2
|
||||
// text: qsTr("Other containers")
|
||||
// }
|
||||
Caption {
|
||||
id: cap2
|
||||
font.pixelSize: 20
|
||||
text: qsTr("Other containers")
|
||||
}
|
||||
|
||||
// ListView {
|
||||
// id: tb_other
|
||||
// x: 10
|
||||
// //y: 20
|
||||
// width: parent.width - 40
|
||||
// height: contentItem.height
|
||||
ListView {
|
||||
id: tb_other
|
||||
x: 10
|
||||
currentIndex: -1
|
||||
width: parent.width - 20
|
||||
height: contentItem.height
|
||||
|
||||
// spacing: 1
|
||||
// clip: true
|
||||
// interactive: false
|
||||
// property int currentRow: -1
|
||||
// model: UiLogic.containersModel
|
||||
spacing: 0
|
||||
clip: true
|
||||
interactive: false
|
||||
model: proxyModel_other
|
||||
|
||||
// delegate: Item {
|
||||
// implicitWidth: 170 * 2
|
||||
// implicitHeight: 30
|
||||
// Item {
|
||||
// width: parent.width
|
||||
// height: 30
|
||||
// anchors.left: parent.left
|
||||
// id: c1_other
|
||||
// Rectangle {
|
||||
// anchors.top: parent.top
|
||||
// width: parent.width
|
||||
// height: 1
|
||||
// color: "lightgray"
|
||||
// visible: index !== tb_other.currentRow
|
||||
// }
|
||||
// Rectangle {
|
||||
// anchors.fill: parent
|
||||
// color: "#63B4FB"
|
||||
// visible: index === tb_other.currentRow
|
||||
delegate: Item {
|
||||
implicitWidth: 170 * 2
|
||||
implicitHeight: 30
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 30
|
||||
anchors.left: parent.left
|
||||
id: c1_other
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: "lightgray"
|
||||
visible: index !== tb_other.currentIndex
|
||||
}
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#63B4FB"
|
||||
visible: index === tb_other.currentIndex
|
||||
|
||||
// }
|
||||
// Text {
|
||||
// id: text_name_other
|
||||
// text: name
|
||||
// font.pixelSize: 16
|
||||
// anchors.fill: parent
|
||||
// leftPadding: 10
|
||||
// verticalAlignment: Text.AlignVCenter
|
||||
// wrapMode: Text.WordWrap
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Text {
|
||||
id: text_name_other
|
||||
text: name_role
|
||||
font.pixelSize: 16
|
||||
anchors.fill: parent
|
||||
leftPadding: 10
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
}
|
||||
|
||||
// MouseArea {
|
||||
// anchors.fill: parent
|
||||
// onClicked: {
|
||||
// tb_other.currentRow = index
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
tb_other.currentIndex = index
|
||||
tb.currentIndex = -1
|
||||
containerSelected(proxyModel_other.mapToSource(index))
|
||||
selectedIndex = proxyModel_other.mapToSource(index)
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ Item {
|
|||
property var page: PageEnum.Start
|
||||
property var logic: UiLogic
|
||||
|
||||
signal activated(bool reset)
|
||||
|
||||
// width: GC.screenWidth
|
||||
// height: GC.screenHeight
|
||||
|
||||
|
|
|
@ -57,5 +57,6 @@ PageBase {
|
|||
}
|
||||
|
||||
Logo {
|
||||
anchors.bottom: parent.bottom
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import PageEnum 1.0
|
||||
import "./"
|
||||
import "../Controls"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
id: root
|
||||
page: PageEnum.ServerConfiguring
|
||||
logic: NewServerConfiguringLogic
|
||||
|
||||
enabled: NewServerConfiguringLogic.pageEnabled
|
||||
Caption {
|
||||
text: qsTr("Configuring...")
|
||||
}
|
||||
LabelType {
|
||||
x: 30
|
||||
y: 90
|
||||
width: 321
|
||||
height: 31
|
||||
text: qsTr("Please wait.")
|
||||
}
|
||||
LabelType {
|
||||
x: 40
|
||||
y: 560
|
||||
width: 301
|
||||
height: 41
|
||||
text: NewServerConfiguringLogic.labelWaitInfoText
|
||||
visible: NewServerConfiguringLogic.labelWaitInfoVisible
|
||||
}
|
||||
ProgressBar {
|
||||
id: pr
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: 510
|
||||
width: 301
|
||||
height: 40
|
||||
from: 0
|
||||
to: NewServerConfiguringLogic.progressBarMaximium
|
||||
value: NewServerConfiguringLogic.progressBarValue
|
||||
visible: NewServerConfiguringLogic.progressBarVisible
|
||||
background: Rectangle {
|
||||
implicitWidth: parent.width
|
||||
implicitHeight: parent.height
|
||||
color: "#100A44"
|
||||
radius: 4
|
||||
}
|
||||
|
||||
contentItem: Item {
|
||||
implicitWidth: parent.width
|
||||
implicitHeight: parent.height
|
||||
Rectangle {
|
||||
width: pr.visualPosition * parent.width
|
||||
height: parent.height
|
||||
radius: 4
|
||||
color: Qt.rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
}
|
||||
|
||||
LabelType {
|
||||
anchors.fill: parent
|
||||
text: NewServerConfiguringLogic.progressBarText
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font.family: "Lato"
|
||||
font.styleName: "normal"
|
||||
font.pixelSize: 16
|
||||
color: "#D4D4D4"
|
||||
visible: NewServerConfiguringLogic.progressBarTextVisible
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.3
|
||||
import ContainerProps 1.0
|
||||
import ProtocolProps 1.0
|
||||
import PageEnum 1.0
|
||||
import "./"
|
||||
import "../Controls"
|
||||
|
@ -12,6 +14,11 @@ PageBase {
|
|||
page: PageEnum.NewServerProtocols
|
||||
logic: NewServerProtocolsLogic
|
||||
|
||||
onActivated: {
|
||||
container_selector.selectedIndex = -1
|
||||
UiLogic.containersModel.setSelectedServerIndex(-1)
|
||||
}
|
||||
|
||||
BackButton {
|
||||
id: back
|
||||
}
|
||||
|
@ -29,7 +36,10 @@ PageBase {
|
|||
height: 40
|
||||
text: qsTr("Setup server")
|
||||
onClicked: {
|
||||
NewServerProtocolsLogic.pushButtonConfigureClicked()
|
||||
let cont = container_selector.selectedIndex
|
||||
let tp = ProtocolProps.transportProtoFromString(cb_port_proto.currentText)
|
||||
let port = tf_port_num.text
|
||||
NewServerProtocolsLogic.onPushButtonConfigureClicked(cont, port, tp)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,6 +59,15 @@ PageBase {
|
|||
|
||||
SelectContainer {
|
||||
id: container_selector
|
||||
onContainerSelected: {
|
||||
var containerProto = ContainerProps.defaultProtocol(c_index)
|
||||
|
||||
tf_port_num.text = ProtocolProps.defaultPort(containerProto)
|
||||
cb_port_proto.currentIndex = ProtocolProps.defaultTransportProto(containerProto)
|
||||
|
||||
tf_port_num.enabled = ProtocolProps.defaultPortChangeable(containerProto)
|
||||
cb_port_proto.enabled = ProtocolProps.defaultTransportProtoChangeable(containerProto)
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
|
@ -108,36 +127,23 @@ PageBase {
|
|||
|
||||
LabelType {
|
||||
width: 130
|
||||
text: qsTr("Port (TCP/UDP)")
|
||||
text: qsTr("Port")
|
||||
}
|
||||
TextFieldType {
|
||||
id: tf_port_num
|
||||
width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
text: NewServerProtocolsLogic.lineEditOpenvpnPortText
|
||||
onEditingFinished: {
|
||||
NewServerProtocolsLogic.lineEditOpenvpnPortText = text
|
||||
}
|
||||
}
|
||||
LabelType {
|
||||
width: 130
|
||||
text: qsTr("Protocol")
|
||||
text: qsTr("Network Protocol")
|
||||
}
|
||||
ComboBoxType {
|
||||
id: cb_port_proto
|
||||
width: parent.width - 130 - parent.spacing - parent.leftPadding * 2
|
||||
model: [
|
||||
qsTr("udp"),
|
||||
qsTr("tcp"),
|
||||
]
|
||||
currentIndex: {
|
||||
for (let i = 0; i < model.length; ++i) {
|
||||
if (NewServerProtocolsLogic.comboBoxOpenvpnProtoText === model[i]) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
onCurrentTextChanged: {
|
||||
NewServerProtocolsLogic.comboBoxOpenvpnProtoText = currentText
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
93
client/ui/qml/Pages/PageServerConfiguringProgress.qml
Normal file
93
client/ui/qml/Pages/PageServerConfiguringProgress.qml
Normal file
|
@ -0,0 +1,93 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import PageEnum 1.0
|
||||
import "./"
|
||||
import "../Controls"
|
||||
import "../Config"
|
||||
|
||||
PageBase {
|
||||
id: root
|
||||
page: PageEnum.ServerConfiguringProgress
|
||||
logic: ServerConfiguringProgressLogic
|
||||
|
||||
enabled: ServerConfiguringProgressLogic.pageEnabled
|
||||
Caption {
|
||||
id: caption
|
||||
text: qsTr("Configuring...")
|
||||
}
|
||||
LabelType {
|
||||
id: label
|
||||
x: 0
|
||||
anchors.top: caption.bottom
|
||||
anchors.topMargin: 10
|
||||
|
||||
width: parent.width
|
||||
height: 31
|
||||
text: qsTr("Please wait.")
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
LabelType {
|
||||
anchors.bottom: pr.top
|
||||
anchors.bottomMargin: 20
|
||||
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
|
||||
width: parent.width - 40
|
||||
height: 41
|
||||
text: ServerConfiguringProgressLogic.labelWaitInfoText
|
||||
visible: ServerConfiguringProgressLogic.labelWaitInfoVisible
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
id: pr
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.bottom: logo.bottom
|
||||
anchors.bottomMargin: 40
|
||||
width: parent.width - 40
|
||||
height: 40
|
||||
|
||||
from: 0
|
||||
to: ServerConfiguringProgressLogic.progressBarMaximium
|
||||
value: ServerConfiguringProgressLogic.progressBarValue
|
||||
visible: ServerConfiguringProgressLogic.progressBarVisible
|
||||
background: Rectangle {
|
||||
implicitWidth: parent.width
|
||||
implicitHeight: parent.height
|
||||
color: "#100A44"
|
||||
radius: 4
|
||||
}
|
||||
|
||||
contentItem: Item {
|
||||
implicitWidth: parent.width
|
||||
implicitHeight: parent.height
|
||||
Rectangle {
|
||||
width: pr.visualPosition * parent.width
|
||||
height: parent.height
|
||||
radius: 4
|
||||
color: Qt.rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
}
|
||||
|
||||
LabelType {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: ServerConfiguringProgressLogic.progressBarText
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
font.family: "Lato"
|
||||
font.styleName: "normal"
|
||||
font.pixelSize: 16
|
||||
color: "#D4D4D4"
|
||||
visible: ServerConfiguringProgressLogic.progressBarTextVisible
|
||||
}
|
||||
}
|
||||
|
||||
Logo {
|
||||
id : logo
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.bottom: parent.bottom
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ PageBase {
|
|||
|
||||
Logo {
|
||||
id: logo
|
||||
anchors.bottom: parent.bottom
|
||||
}
|
||||
|
||||
BasicButtonType {
|
||||
|
|
|
@ -41,8 +41,8 @@ Window {
|
|||
if (page === PageEnum.WizardHigh) {
|
||||
WizardLogic.updatePage();
|
||||
}
|
||||
if (page === PageEnum.ServerConfiguring) {
|
||||
ServerConfiguringLogic.progressBarValue = 0;
|
||||
if (page === PageEnum.ServerConfiguringProgress) {
|
||||
ServerConfiguringProgressLogic.progressBarValue = 0;
|
||||
}
|
||||
if (page === PageEnum.GeneralSettings) {
|
||||
GeneralSettingsLogic.updatePage();
|
||||
|
@ -79,6 +79,8 @@ Window {
|
|||
} else {
|
||||
pageLoader.push(pages[page], {}, StackView.Immediate)
|
||||
}
|
||||
|
||||
pages[page].activated(reset)
|
||||
}
|
||||
|
||||
function gotoProtocolPage(protocol, reset, slide) {
|
||||
|
@ -91,6 +93,8 @@ Window {
|
|||
} else {
|
||||
pageLoader.push(protocolPages[protocol], {}, StackView.Immediate)
|
||||
}
|
||||
|
||||
protocolPages[protocol].activated(reset)
|
||||
}
|
||||
|
||||
function close_page() {
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include "pages_logic/AppSettingsLogic.h"
|
||||
#include "pages_logic/GeneralSettingsLogic.h"
|
||||
#include "pages_logic/NetworkSettingsLogic.h"
|
||||
#include "pages_logic/NewServerConfiguringLogic.h"
|
||||
#include "pages_logic/ServerConfiguringProgressLogic.h"
|
||||
#include "pages_logic/NewServerProtocolsLogic.h"
|
||||
#include "pages_logic/ServerListLogic.h"
|
||||
#include "pages_logic/ServerSettingsLogic.h"
|
||||
|
@ -81,7 +81,7 @@ UiLogic::UiLogic(QObject *parent) :
|
|||
m_appSettingsLogic = new AppSettingsLogic(this);
|
||||
m_generalSettingsLogic = new GeneralSettingsLogic(this);
|
||||
m_networkSettingsLogic = new NetworkSettingsLogic(this);
|
||||
m_newServerConfiguringLogic = new NewServerConfiguringLogic(this);
|
||||
m_serverConfiguringProgressLogic = new ServerConfiguringProgressLogic(this);
|
||||
m_newServerProtocolsLogic = new NewServerProtocolsLogic(this);
|
||||
m_serverListLogic = new ServerListLogic(this);
|
||||
m_serverSettingsLogic = new ServerSettingsLogic(this);
|
||||
|
@ -132,7 +132,7 @@ void UiLogic::initalizeUiLogic()
|
|||
|
||||
selectedServerIndex = m_settings.defaultServerIndex();
|
||||
goToPage(Page::ServerContainers, true, false);
|
||||
//goToPage(Page::NewServerProtocols, true, false);
|
||||
goToPage(Page::NewServerProtocols, true, false);
|
||||
|
||||
|
||||
//ui->pushButton_general_settings_exit->hide();
|
||||
|
@ -355,12 +355,12 @@ void UiLogic::onCloseWindow()
|
|||
|
||||
QString UiLogic::containerName(int container)
|
||||
{
|
||||
return amnezia::containerHumanNames().value(static_cast<DockerContainer>(container));
|
||||
return ContainerProps::containerHumanNames().value(static_cast<DockerContainer>(container));
|
||||
}
|
||||
|
||||
QString UiLogic::containerDesc(int container)
|
||||
{
|
||||
return amnezia::containerDescriptions().value(static_cast<DockerContainer>(container));
|
||||
return ContainerProps::containerDescriptions().value(static_cast<DockerContainer>(container));
|
||||
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ void UiLogic::installServer(const QMap<DockerContainer, QJsonObject> &containers
|
|||
{
|
||||
if (containers.isEmpty()) return;
|
||||
|
||||
goToPage(Page::ServerConfiguring);
|
||||
emit goToPage(Page::ServerConfiguringProgress);
|
||||
QEventLoop loop;
|
||||
QTimer::singleShot(500, &loop, SLOT(quit()));
|
||||
loop.exec();
|
||||
|
@ -404,34 +404,34 @@ void UiLogic::installServer(const QMap<DockerContainer, QJsonObject> &containers
|
|||
|
||||
PageFunc page_new_server_configuring;
|
||||
page_new_server_configuring.setEnabledFunc = [this] (bool enabled) -> void {
|
||||
newServerConfiguringLogic()->set_pageEnabled(enabled);
|
||||
serverConfiguringProgressLogic()->set_pageEnabled(enabled);
|
||||
};
|
||||
ButtonFunc no_button;
|
||||
LabelFunc label_new_server_configuring_wait_info;
|
||||
label_new_server_configuring_wait_info.setTextFunc = [this] (const QString& text) -> void {
|
||||
newServerConfiguringLogic()->set_labelWaitInfoText(text);
|
||||
serverConfiguringProgressLogic()->set_labelWaitInfoText(text);
|
||||
};
|
||||
label_new_server_configuring_wait_info.setVisibleFunc = [this] (bool visible) ->void {
|
||||
newServerConfiguringLogic()->set_labelWaitInfoVisible(visible);
|
||||
serverConfiguringProgressLogic()->set_labelWaitInfoVisible(visible);
|
||||
};
|
||||
ProgressFunc progressBar_new_server_configuring;
|
||||
progressBar_new_server_configuring.setVisibleFunc = [this] (bool visible) ->void {
|
||||
newServerConfiguringLogic()->set_progressBarVisible(visible);
|
||||
serverConfiguringProgressLogic()->set_progressBarVisible(visible);
|
||||
};
|
||||
progressBar_new_server_configuring.setValueFunc = [this] (int value) ->void {
|
||||
newServerConfiguringLogic()->set_progressBarValue(value);
|
||||
serverConfiguringProgressLogic()->set_progressBarValue(value);
|
||||
};
|
||||
progressBar_new_server_configuring.getValueFunc = [this] (void) -> int {
|
||||
return newServerConfiguringLogic()->progressBarValue();
|
||||
return serverConfiguringProgressLogic()->progressBarValue();
|
||||
};
|
||||
progressBar_new_server_configuring.getMaximiumFunc = [this] (void) -> int {
|
||||
return newServerConfiguringLogic()->progressBarMaximium();
|
||||
return serverConfiguringProgressLogic()->progressBarMaximium();
|
||||
};
|
||||
progressBar_new_server_configuring.setTextVisibleFunc = [this] (bool visible) ->void {
|
||||
newServerConfiguringLogic()->set_progressBarTextVisible(visible);
|
||||
serverConfiguringProgressLogic()->set_progressBarTextVisible(visible);
|
||||
};
|
||||
progressBar_new_server_configuring.setTextFunc = [this] (const QString& text) ->void {
|
||||
newServerConfiguringLogic()->set_progressBarText(text);
|
||||
serverConfiguringProgressLogic()->set_progressBarText(text);
|
||||
};
|
||||
bool ok = installContainers(installCredentials, containers,
|
||||
page_new_server_configuring,
|
||||
|
@ -452,16 +452,16 @@ void UiLogic::installServer(const QMap<DockerContainer, QJsonObject> &containers
|
|||
containerConfigs.append(cfg);
|
||||
}
|
||||
server.insert(config_key::containers, containerConfigs);
|
||||
server.insert(config_key::defaultContainer, containerToString(containers.firstKey()));
|
||||
server.insert(config_key::defaultContainer, ContainerProps::containerToString(containers.firstKey()));
|
||||
|
||||
m_settings.addServer(server);
|
||||
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
||||
|
||||
setStartPage(Page::Vpn);
|
||||
emit setStartPage(Page::Vpn);
|
||||
qApp->processEvents();
|
||||
}
|
||||
else {
|
||||
closePage();
|
||||
emit closePage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class AppSettingsLogic;
|
|||
class GeneralSettingsLogic;
|
||||
class NetworkSettingsLogic;
|
||||
class NewServerProtocolsLogic;
|
||||
class NewServerConfiguringLogic;
|
||||
class ServerConfiguringProgressLogic;
|
||||
class ServerListLogic;
|
||||
class ServerSettingsLogic;
|
||||
class ServerContainersLogic;
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
friend class AppSettingsLogic;
|
||||
friend class GeneralSettingsLogic;
|
||||
friend class NetworkSettingsLogic;
|
||||
friend class NewServerConfiguringLogic;
|
||||
friend class ServerConfiguringProgressLogic;
|
||||
friend class NewServerProtocolsLogic;
|
||||
friend class ServerListLogic;
|
||||
friend class ServerSettingsLogic;
|
||||
|
@ -168,7 +168,7 @@ public:
|
|||
AppSettingsLogic *appSettingsLogic() { return m_appSettingsLogic; }
|
||||
GeneralSettingsLogic *generalSettingsLogic() { return m_generalSettingsLogic; }
|
||||
NetworkSettingsLogic *networkSettingsLogic() { return m_networkSettingsLogic; }
|
||||
NewServerConfiguringLogic *newServerConfiguringLogic() { return m_newServerConfiguringLogic; }
|
||||
ServerConfiguringProgressLogic *serverConfiguringProgressLogic() { return m_serverConfiguringProgressLogic; }
|
||||
NewServerProtocolsLogic *newServerProtocolsLogic() { return m_newServerProtocolsLogic; }
|
||||
ServerListLogic *serverListLogic() { return m_serverListLogic; }
|
||||
ServerSettingsLogic *serverSettingsLogic() { return m_serverSettingsLogic; }
|
||||
|
@ -185,7 +185,7 @@ private:
|
|||
AppSettingsLogic *m_appSettingsLogic;
|
||||
GeneralSettingsLogic *m_generalSettingsLogic;
|
||||
NetworkSettingsLogic *m_networkSettingsLogic;
|
||||
NewServerConfiguringLogic *m_newServerConfiguringLogic;
|
||||
ServerConfiguringProgressLogic *m_serverConfiguringProgressLogic;
|
||||
NewServerProtocolsLogic *m_newServerProtocolsLogic;
|
||||
ServerListLogic *m_serverListLogic;
|
||||
ServerSettingsLogic *m_serverSettingsLogic;
|
||||
|
|
|
@ -133,7 +133,7 @@ QMap<Protocol, QString> VpnConnection::getLastVpnConfig(const QJsonObject &conta
|
|||
Protocol::Cloak,
|
||||
Protocol::WireGuard}) {
|
||||
|
||||
QString cfg = containerConfig.value(protoToString(proto)).toObject().value(config_key::last_config).toString();
|
||||
QString cfg = containerConfig.value(ProtocolProps::protoToString(proto)).toObject().value(config_key::last_config).toString();
|
||||
|
||||
if (!cfg.isEmpty()) configs.insert(proto, cfg);
|
||||
}
|
||||
|
@ -153,10 +153,10 @@ QString VpnConnection::createVpnConfigurationForProto(int serverIndex,
|
|||
if (proto == Protocol::OpenVpn) {
|
||||
configData = OpenVpnConfigurator::processConfigWithLocalSettings(configData);
|
||||
}
|
||||
qDebug() << "VpnConnection::createVpnConfiguration: using saved config for" << protoToString(proto);
|
||||
qDebug() << "VpnConnection::createVpnConfiguration: using saved config for" << ProtocolProps::protoToString(proto);
|
||||
}
|
||||
else {
|
||||
qDebug() << "VpnConnection::createVpnConfiguration: gen new config for" << protoToString(proto);
|
||||
qDebug() << "VpnConnection::createVpnConfiguration: gen new config for" << ProtocolProps::protoToString(proto);
|
||||
if (proto == Protocol::OpenVpn) {
|
||||
configData = OpenVpnConfigurator::genOpenVpnConfig(credentials,
|
||||
container, containerConfig, &e);
|
||||
|
@ -199,8 +199,8 @@ ErrorCode VpnConnection::createVpnConfiguration(int serverIndex,
|
|||
ErrorCode errorCode = ErrorCode::NoError;
|
||||
|
||||
if (container == DockerContainer::OpenVpn ||
|
||||
container == DockerContainer::OpenVpnOverShadowSocks ||
|
||||
container == DockerContainer::OpenVpnOverCloak) {
|
||||
container == DockerContainer::ShadowSocks ||
|
||||
container == DockerContainer::Cloak) {
|
||||
|
||||
QString openVpnConfigData =
|
||||
createVpnConfigurationForProto(
|
||||
|
@ -223,7 +223,7 @@ ErrorCode VpnConnection::createVpnConfiguration(int serverIndex,
|
|||
}
|
||||
}
|
||||
|
||||
if (container == DockerContainer::OpenVpnOverShadowSocks) {
|
||||
if (container == DockerContainer::ShadowSocks) {
|
||||
QJsonObject ssConfigData = QJsonDocument::fromJson(
|
||||
createVpnConfigurationForProto(
|
||||
serverIndex, credentials, container, containerConfig, Protocol::ShadowSocks, &errorCode).toUtf8()).
|
||||
|
@ -232,7 +232,7 @@ ErrorCode VpnConnection::createVpnConfiguration(int serverIndex,
|
|||
m_vpnConfiguration.insert(config::key_shadowsocks_config_data, ssConfigData);
|
||||
}
|
||||
|
||||
if (container == DockerContainer::OpenVpnOverCloak) {
|
||||
if (container == DockerContainer::Cloak) {
|
||||
QJsonObject cloakConfigData = QJsonDocument::fromJson(
|
||||
createVpnConfigurationForProto(
|
||||
serverIndex, credentials, container, containerConfig, Protocol::Cloak, &errorCode).toUtf8()).
|
||||
|
@ -256,7 +256,7 @@ ErrorCode VpnConnection::connectToVpn(int serverIndex,
|
|||
const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig)
|
||||
{
|
||||
qDebug() << QString("СonnectToVpn, Server index is %1, container is %2, route mode is")
|
||||
.arg(serverIndex).arg(containerToString(container)) << m_settings.routeMode();
|
||||
.arg(serverIndex).arg(ContainerProps::containerToString(container)) << m_settings.routeMode();
|
||||
m_remoteAddress = credentials.hostName;
|
||||
|
||||
emit connectionStateChanged(VpnProtocol::Connecting);
|
||||
|
@ -281,8 +281,8 @@ ErrorCode VpnConnection::connectToVpn(int serverIndex,
|
|||
return e;
|
||||
}
|
||||
}
|
||||
else if (container == DockerContainer::OpenVpnOverShadowSocks) {
|
||||
ErrorCode e = createVpnConfiguration(serverIndex, credentials, DockerContainer::OpenVpnOverShadowSocks, containerConfig);
|
||||
else if (container == DockerContainer::ShadowSocks) {
|
||||
ErrorCode e = createVpnConfiguration(serverIndex, credentials, DockerContainer::ShadowSocks, containerConfig);
|
||||
if (e) {
|
||||
emit connectionStateChanged(VpnProtocol::Error);
|
||||
return e;
|
||||
|
@ -295,8 +295,8 @@ ErrorCode VpnConnection::connectToVpn(int serverIndex,
|
|||
return e;
|
||||
}
|
||||
}
|
||||
else if (container == DockerContainer::OpenVpnOverCloak) {
|
||||
ErrorCode e = createVpnConfiguration(serverIndex, credentials, DockerContainer::OpenVpnOverCloak, containerConfig);
|
||||
else if (container == DockerContainer::Cloak) {
|
||||
ErrorCode e = createVpnConfiguration(serverIndex, credentials, DockerContainer::Cloak, containerConfig);
|
||||
if (e) {
|
||||
emit connectionStateChanged(VpnProtocol::Error);
|
||||
return e;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue