From 6afdd8375d83fb10604267a65ed969077655da2f Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Fri, 22 Sep 2023 00:37:55 +0500 Subject: [PATCH 01/30] added models, classes and ui files for amnezia wireguard --- client/CMakeLists.txt | 2 + client/amnezia_application.cpp | 7 +- client/amnezia_application.h | 4 +- .../amneziaWireGuardConfigurator.cpp | 15 + .../amneziaWireGuardConfigurator.h | 18 ++ client/configurators/vpn_configurator.cpp | 48 ++-- .../configurators/wireguard_configurator.cpp | 5 +- client/configurators/wireguard_configurator.h | 22 +- client/containers/containers_defs.cpp | 7 + client/containers/containers_defs.h | 1 + client/core/scripts_registry.cpp | 9 +- client/core/servercontroller.cpp | 2 + client/protocols/amneziaWireGuardProtocol.cpp | 10 + client/protocols/amneziaWireGuardProtocol.h | 17 ++ client/protocols/protocols_defs.cpp | 6 + client/protocols/protocols_defs.h | 3 +- client/protocols/vpnprotocol.cpp | 23 +- client/protocols/wireguardprotocol.cpp | 2 +- client/resources.qrc | 1 + client/ui/controllers/pageController.h | 1 + .../protocols/amneziaWireGuardConfigModel.cpp | 70 +++++ .../protocols/amneziaWireGuardConfigModel.h | 39 +++ .../qml/Components/HomeContainersListView.qml | 3 +- .../Components/SettingsContainersListView.qml | 5 + .../PageProtocolAmneziaWireGuardSettings.qml | 272 ++++++++++++++++++ client/ui/qml/Pages2/PageSetupWizardStart.qml | 2 +- 26 files changed, 534 insertions(+), 60 deletions(-) create mode 100644 client/configurators/amneziaWireGuardConfigurator.cpp create mode 100644 client/configurators/amneziaWireGuardConfigurator.h create mode 100644 client/protocols/amneziaWireGuardProtocol.cpp create mode 100644 client/protocols/amneziaWireGuardProtocol.h create mode 100644 client/ui/models/protocols/amneziaWireGuardConfigModel.cpp create mode 100644 client/ui/models/protocols/amneziaWireGuardConfigModel.h create mode 100644 client/ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index ca5161cf..f31a82ce 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -263,6 +263,7 @@ if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID)) ${CMAKE_CURRENT_LIST_DIR}/protocols/openvpnovercloakprotocol.h ${CMAKE_CURRENT_LIST_DIR}/protocols/shadowsocksvpnprotocol.h ${CMAKE_CURRENT_LIST_DIR}/protocols/wireguardprotocol.h + ${CMAKE_CURRENT_LIST_DIR}/protocols/amneziawireguardprotocol.h ) set(SOURCES ${SOURCES} @@ -273,6 +274,7 @@ if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID)) ${CMAKE_CURRENT_LIST_DIR}/protocols/openvpnovercloakprotocol.cpp ${CMAKE_CURRENT_LIST_DIR}/protocols/shadowsocksvpnprotocol.cpp ${CMAKE_CURRENT_LIST_DIR}/protocols/wireguardprotocol.cpp + ${CMAKE_CURRENT_LIST_DIR}/protocols/amneziawireguardprotocol.cpp ) endif() diff --git a/client/amnezia_application.cpp b/client/amnezia_application.cpp index 23157468..cef722b1 100644 --- a/client/amnezia_application.cpp +++ b/client/amnezia_application.cpp @@ -318,8 +318,11 @@ void AmneziaApplication::initModels() m_cloakConfigModel.reset(new CloakConfigModel(this)); m_engine->rootContext()->setContextProperty("CloakConfigModel", m_cloakConfigModel.get()); - m_wireguardConfigModel.reset(new WireGuardConfigModel(this)); - m_engine->rootContext()->setContextProperty("WireGuardConfigModel", m_wireguardConfigModel.get()); + m_wireGuardConfigModel.reset(new WireGuardConfigModel(this)); + m_engine->rootContext()->setContextProperty("WireGuardConfigModel", m_wireGuardConfigModel.get()); + + m_amneziaWireGuardConfigModel.reset(new AmneziaWireGuardConfigModel(this)); + m_engine->rootContext()->setContextProperty("AmneziaWireGuardConfigModel", m_amneziaWireGuardConfigModel.get()); #ifdef Q_OS_WINDOWS m_ikev2ConfigModel.reset(new Ikev2ConfigModel(this)); diff --git a/client/amnezia_application.h b/client/amnezia_application.h index 2dd74fcb..77e50c92 100644 --- a/client/amnezia_application.h +++ b/client/amnezia_application.h @@ -31,6 +31,7 @@ #ifdef Q_OS_WINDOWS #include "ui/models/protocols/ikev2ConfigModel.h" #endif +#include "ui/models/protocols/amneziaWireGuardConfigModel.h" #include "ui/models/protocols/openvpnConfigModel.h" #include "ui/models/protocols/shadowsocksConfigModel.h" #include "ui/models/protocols/wireguardConfigModel.h" @@ -97,7 +98,8 @@ private: QScopedPointer m_openVpnConfigModel; QScopedPointer m_shadowSocksConfigModel; QScopedPointer m_cloakConfigModel; - QScopedPointer m_wireguardConfigModel; + QScopedPointer m_wireGuardConfigModel; + QScopedPointer m_amneziaWireGuardConfigModel; #ifdef Q_OS_WINDOWS QScopedPointer m_ikev2ConfigModel; #endif diff --git a/client/configurators/amneziaWireGuardConfigurator.cpp b/client/configurators/amneziaWireGuardConfigurator.cpp new file mode 100644 index 00000000..56f0c68e --- /dev/null +++ b/client/configurators/amneziaWireGuardConfigurator.cpp @@ -0,0 +1,15 @@ +#include "amneziaWireGuardConfigurator.h" + +AmneziaWireGuardConfigurator::AmneziaWireGuardConfigurator(std::shared_ptr settings, QObject *parent) + : WireguardConfigurator(settings, parent) +{ +} + +QString AmneziaWireGuardConfigurator::genAmneziaWireGuardConfig(const ServerCredentials &credentials, + DockerContainer container, + const QJsonObject &containerConfig, ErrorCode *errorCode) +{ + auto config = WireguardConfigurator::genWireguardConfig(credentials, container, containerConfig, errorCode); + + return config; +} diff --git a/client/configurators/amneziaWireGuardConfigurator.h b/client/configurators/amneziaWireGuardConfigurator.h new file mode 100644 index 00000000..02961cf1 --- /dev/null +++ b/client/configurators/amneziaWireGuardConfigurator.h @@ -0,0 +1,18 @@ +#ifndef AMNEZIAWIREGUARDCONFIGURATOR_H +#define AMNEZIAWIREGUARDCONFIGURATOR_H + +#include + +#include "wireguard_configurator.h" + +class AmneziaWireGuardConfigurator : public WireguardConfigurator +{ + Q_OBJECT +public: + AmneziaWireGuardConfigurator(std::shared_ptr settings, QObject *parent = nullptr); + + QString genAmneziaWireGuardConfig(const ServerCredentials &credentials, DockerContainer container, + const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr); +}; + +#endif // AMNEZIAWIREGUARDCONFIGURATOR_H diff --git a/client/configurators/vpn_configurator.cpp b/client/configurators/vpn_configurator.cpp index ceb6a5a4..7f0e95df 100644 --- a/client/configurators/vpn_configurator.cpp +++ b/client/configurators/vpn_configurator.cpp @@ -1,21 +1,21 @@ #include "vpn_configurator.h" -#include "openvpn_configurator.h" #include "cloak_configurator.h" -#include "shadowsocks_configurator.h" -#include "wireguard_configurator.h" #include "ikev2_configurator.h" +#include "openvpn_configurator.h" +#include "shadowsocks_configurator.h" #include "ssh_configurator.h" +#include "wireguard_configurator.h" #include -#include #include +#include #include "containers/containers_defs.h" -#include "utilities.h" #include "settings.h" +#include "utilities.h" -VpnConfigurator::VpnConfigurator(std::shared_ptr settings, QObject *parent): - ConfiguratorBase(settings, parent) +VpnConfigurator::VpnConfigurator(std::shared_ptr settings, QObject *parent) + : ConfiguratorBase(settings, parent) { openVpnConfigurator = std::shared_ptr(new OpenVpnConfigurator(settings, this)); shadowSocksConfigurator = std::shared_ptr(new ShadowSocksConfigurator(settings, this)); @@ -25,8 +25,8 @@ VpnConfigurator::VpnConfigurator(std::shared_ptr settings, QObject *pa sshConfigurator = std::shared_ptr(new SshConfigurator(settings, this)); } -QString VpnConfigurator::genVpnProtocolConfig(const ServerCredentials &credentials, - DockerContainer container, const QJsonObject &containerConfig, Proto proto, ErrorCode *errorCode) +QString VpnConfigurator::genVpnProtocolConfig(const ServerCredentials &credentials, DockerContainer container, + const QJsonObject &containerConfig, Proto proto, ErrorCode *errorCode) { switch (proto) { case Proto::OpenVpn: @@ -35,17 +35,17 @@ QString VpnConfigurator::genVpnProtocolConfig(const ServerCredentials &credentia case Proto::ShadowSocks: return shadowSocksConfigurator->genShadowSocksConfig(credentials, container, containerConfig, errorCode); - case Proto::Cloak: - return cloakConfigurator->genCloakConfig(credentials, container, containerConfig, errorCode); + case Proto::Cloak: return cloakConfigurator->genCloakConfig(credentials, container, containerConfig, errorCode); case Proto::WireGuard: return wireguardConfigurator->genWireguardConfig(credentials, container, containerConfig, errorCode); - case Proto::Ikev2: - return ikev2Configurator->genIkev2Config(credentials, container, containerConfig, errorCode); + case Proto::AmneziaWireGuard: + return wireguardConfigurator->genWireguardConfig(credentials, container, containerConfig, errorCode); - default: - return ""; + case Proto::Ikev2: return ikev2Configurator->genIkev2Config(credentials, container, containerConfig, errorCode); + + default: return ""; } } @@ -62,8 +62,8 @@ QPair VpnConfigurator::getDnsForConfig(int serverIndex) if (dns.first.isEmpty() || !Utils::checkIPv4Format(dns.first)) { if (useAmneziaDns && m_settings->containers(serverIndex).contains(DockerContainer::Dns)) { dns.first = protocols::dns::amneziaDnsIp; - } - else dns.first = m_settings->primaryDns(); + } else + dns.first = m_settings->primaryDns(); } if (dns.second.isEmpty() || !Utils::checkIPv4Format(dns.second)) { dns.second = m_settings->secondaryDns(); @@ -73,8 +73,8 @@ QPair VpnConfigurator::getDnsForConfig(int serverIndex) return dns; } -QString &VpnConfigurator::processConfigWithDnsSettings(int serverIndex, DockerContainer container, - Proto proto, QString &config) +QString &VpnConfigurator::processConfigWithDnsSettings(int serverIndex, DockerContainer container, Proto proto, + QString &config) { auto dns = getDnsForConfig(serverIndex); @@ -84,8 +84,8 @@ QString &VpnConfigurator::processConfigWithDnsSettings(int serverIndex, DockerCo return config; } -QString &VpnConfigurator::processConfigWithLocalSettings(int serverIndex, DockerContainer container, - Proto proto, QString &config) +QString &VpnConfigurator::processConfigWithLocalSettings(int serverIndex, DockerContainer container, Proto proto, + QString &config) { processConfigWithDnsSettings(serverIndex, container, proto, config); @@ -95,8 +95,8 @@ QString &VpnConfigurator::processConfigWithLocalSettings(int serverIndex, Docker return config; } -QString &VpnConfigurator::processConfigWithExportSettings(int serverIndex, DockerContainer container, - Proto proto, QString &config) +QString &VpnConfigurator::processConfigWithExportSettings(int serverIndex, DockerContainer container, Proto proto, + QString &config) { processConfigWithDnsSettings(serverIndex, container, proto, config); @@ -107,7 +107,7 @@ QString &VpnConfigurator::processConfigWithExportSettings(int serverIndex, Docke } void VpnConfigurator::updateContainerConfigAfterInstallation(DockerContainer container, QJsonObject &containerConfig, - const QString &stdOut) + const QString &stdOut) { Proto mainProto = ContainerProps::defaultProtocol(container); diff --git a/client/configurators/wireguard_configurator.cpp b/client/configurators/wireguard_configurator.cpp index 14059977..02716b72 100644 --- a/client/configurators/wireguard_configurator.cpp +++ b/client/configurators/wireguard_configurator.cpp @@ -62,7 +62,10 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon { WireguardConfigurator::ConnectionData connData = WireguardConfigurator::genClientKeys(); connData.host = credentials.hostName; - connData.port = containerConfig.value(config_key::port).toString(protocols::wireguard::defaultPort); + connData.port = containerConfig.value(config_key::wireguard) + .toObject() + .value(config_key::port) + .toString(protocols::wireguard::defaultPort); if (connData.clientPrivKey.isEmpty() || connData.clientPubKey.isEmpty()) { if (errorCode) diff --git a/client/configurators/wireguard_configurator.h b/client/configurators/wireguard_configurator.h index 7674eb06..140acc47 100644 --- a/client/configurators/wireguard_configurator.h +++ b/client/configurators/wireguard_configurator.h @@ -7,32 +7,32 @@ #include "configurator_base.h" #include "core/defs.h" -class WireguardConfigurator : ConfiguratorBase +class WireguardConfigurator : public ConfiguratorBase { Q_OBJECT public: WireguardConfigurator(std::shared_ptr settings, QObject *parent = nullptr); - struct ConnectionData { + struct ConnectionData + { QString clientPrivKey; // client private key - QString clientPubKey; // client public key - QString clientIP; // internal client IP address - QString serverPubKey; // tls-auth key - QString pskKey; // preshared key - QString host; // host ip + QString clientPubKey; // client public key + QString clientIP; // internal client IP address + QString serverPubKey; // tls-auth key + QString pskKey; // preshared key + QString host; // host ip QString port; }; QString genWireguardConfig(const ServerCredentials &credentials, DockerContainer container, - const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr); + const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr); QString processConfigWithLocalSettings(QString config); QString processConfigWithExportSettings(QString config); - private: - ConnectionData prepareWireguardConfig(const ServerCredentials &credentials, - DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr); + ConnectionData prepareWireguardConfig(const ServerCredentials &credentials, DockerContainer container, + const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr); ConnectionData genClientKeys(); }; diff --git a/client/containers/containers_defs.cpp b/client/containers/containers_defs.cpp index 20fc59f4..21f7b044 100644 --- a/client/containers/containers_defs.cpp +++ b/client/containers/containers_defs.cpp @@ -84,6 +84,7 @@ QMap ContainerProps::containerHumanNames() { DockerContainer::ShadowSocks, "ShadowSocks" }, { DockerContainer::Cloak, "OpenVPN over Cloak" }, { DockerContainer::WireGuard, "WireGuard" }, + { DockerContainer::AmneziaWireGuard, "Amnezia WireGuard" }, { DockerContainer::Ipsec, QObject::tr("IPsec") }, { DockerContainer::TorWebSite, QObject::tr("Website in Tor network") }, @@ -107,6 +108,9 @@ QMap ContainerProps::containerDescriptions() { DockerContainer::WireGuard, QObject::tr("WireGuard - New popular VPN protocol with high performance, high speed and low power " "consumption. Recommended for regions with low levels of censorship.") }, + { DockerContainer::AmneziaWireGuard, + QObject::tr("WireGuard - New popular VPN protocol with high performance, high speed and low power " + "consumption. Recommended for regions with low levels of censorship.") }, { DockerContainer::Ipsec, QObject::tr("IKEv2 - Modern stable protocol, a bit faster than others, restores connection after " "signal loss. It has native support on the latest versions of Android and iOS.") }, @@ -127,6 +131,7 @@ QMap ContainerProps::containerDetailedDescriptions() 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("Amnezia WireGuard container") }, { DockerContainer::Ipsec, QObject::tr("IPsec container") }, { DockerContainer::TorWebSite, QObject::tr("Website in Tor network") }, @@ -143,6 +148,7 @@ amnezia::ServiceType ContainerProps::containerService(DockerContainer c) case DockerContainer::Cloak: return ServiceType::Vpn; case DockerContainer::ShadowSocks: return ServiceType::Vpn; case DockerContainer::WireGuard: return ServiceType::Vpn; + case DockerContainer::AmneziaWireGuard: return ServiceType::Vpn; case DockerContainer::Ipsec: return ServiceType::Vpn; case DockerContainer::TorWebSite: return ServiceType::Other; case DockerContainer::Dns: return ServiceType::Other; @@ -160,6 +166,7 @@ Proto ContainerProps::defaultProtocol(DockerContainer c) case DockerContainer::Cloak: return Proto::Cloak; case DockerContainer::ShadowSocks: return Proto::ShadowSocks; case DockerContainer::WireGuard: return Proto::WireGuard; + case DockerContainer::AmneziaWireGuard: return Proto::AmneziaWireGuard; case DockerContainer::Ipsec: return Proto::Ikev2; case DockerContainer::TorWebSite: return Proto::TorWebSite; diff --git a/client/containers/containers_defs.h b/client/containers/containers_defs.h index 9ca51a96..774611c8 100644 --- a/client/containers/containers_defs.h +++ b/client/containers/containers_defs.h @@ -20,6 +20,7 @@ namespace amnezia ShadowSocks, Cloak, WireGuard, + AmneziaWireGuard, Ipsec, // non-vpn diff --git a/client/core/scripts_registry.cpp b/client/core/scripts_registry.cpp index 1b379ea1..31508152 100644 --- a/client/core/scripts_registry.cpp +++ b/client/core/scripts_registry.cpp @@ -1,8 +1,8 @@ #include "scripts_registry.h" -#include #include #include +#include QString amnezia::scriptFolder(amnezia::DockerContainer container) { @@ -11,11 +11,12 @@ QString amnezia::scriptFolder(amnezia::DockerContainer container) case DockerContainer::Cloak: return QLatin1String("openvpn_cloak"); case DockerContainer::ShadowSocks: return QLatin1String("openvpn_shadowsocks"); case DockerContainer::WireGuard: return QLatin1String("wireguard"); + case DockerContainer::AmneziaWireGuard: return QLatin1String("wireguard"); case DockerContainer::Ipsec: return QLatin1String("ipsec"); case DockerContainer::TorWebSite: return QLatin1String("website_tor"); case DockerContainer::Dns: return QLatin1String("dns"); - //case DockerContainer::FileShare: return QLatin1String("file_share"); + // case DockerContainer::FileShare: return QLatin1String("file_share"); case DockerContainer::Sftp: return QLatin1String("sftp"); default: return ""; } @@ -52,7 +53,7 @@ QString amnezia::scriptData(amnezia::SharedScriptType type) { QString fileName = QString(":/server_scripts/%1").arg(amnezia::scriptName(type)); QFile file(fileName); - if (! file.open(QIODevice::ReadOnly)) { + if (!file.open(QIODevice::ReadOnly)) { qDebug() << "Warning: script missing" << fileName; return ""; } @@ -67,7 +68,7 @@ QString amnezia::scriptData(amnezia::ProtocolScriptType type, DockerContainer co { QString fileName = QString(":/server_scripts/%1/%2").arg(amnezia::scriptFolder(container), amnezia::scriptName(type)); QFile file(fileName); - if (! file.open(QIODevice::ReadOnly)) { + if (!file.open(QIODevice::ReadOnly)) { qDebug() << "Warning: script missing" << fileName; return ""; } diff --git a/client/core/servercontroller.cpp b/client/core/servercontroller.cpp index b0f8146f..27213dc3 100644 --- a/client/core/servercontroller.cpp +++ b/client/core/servercontroller.cpp @@ -486,6 +486,8 @@ ServerController::Vars ServerController::genVarsForScript(const ServerCredential const QJsonObject &cloakConfig = config.value(ProtocolProps::protoToString(Proto::Cloak)).toObject(); const QJsonObject &ssConfig = config.value(ProtocolProps::protoToString(Proto::ShadowSocks)).toObject(); const QJsonObject &wireguarConfig = config.value(ProtocolProps::protoToString(Proto::WireGuard)).toObject(); + const QJsonObject &amneziaWireguarConfig = + config.value(ProtocolProps::protoToString(Proto::AmneziaWireGuard)).toObject(); const QJsonObject &sftpConfig = config.value(ProtocolProps::protoToString(Proto::Sftp)).toObject(); Vars vars; diff --git a/client/protocols/amneziaWireGuardProtocol.cpp b/client/protocols/amneziaWireGuardProtocol.cpp new file mode 100644 index 00000000..b4c5b430 --- /dev/null +++ b/client/protocols/amneziaWireGuardProtocol.cpp @@ -0,0 +1,10 @@ +#include "amneziaWireGuardProtocol.h" + +AmneziaWireGuardProtocol::AmneziaWireGuardProtocol(const QJsonObject &configuration, QObject *parent) + : WireguardProtocol(configuration, parent) +{ +} + +AmneziaWireGuardProtocol::~AmneziaWireGuardProtocol() +{ +} diff --git a/client/protocols/amneziaWireGuardProtocol.h b/client/protocols/amneziaWireGuardProtocol.h new file mode 100644 index 00000000..329a585e --- /dev/null +++ b/client/protocols/amneziaWireGuardProtocol.h @@ -0,0 +1,17 @@ +#ifndef AMNEZIAWIREGUARDPROTOCOL_H +#define AMNEZIAWIREGUARDPROTOCOL_H + +#include + +#include "wireguardprotocol.h" + +class AmneziaWireGuardProtocol : public WireguardProtocol +{ + Q_OBJECT + +public: + explicit AmneziaWireGuardProtocol(const QJsonObject &configuration, QObject *parent = nullptr); + virtual ~AmneziaWireGuardProtocol() override; +}; + +#endif // AMNEZIAWIREGUARDPROTOCOL_H diff --git a/client/protocols/protocols_defs.cpp b/client/protocols/protocols_defs.cpp index 5f8600db..64cdd003 100644 --- a/client/protocols/protocols_defs.cpp +++ b/client/protocols/protocols_defs.cpp @@ -66,6 +66,7 @@ QMap ProtocolProps::protocolHumanNames() { Proto::ShadowSocks, "ShadowSocks" }, { Proto::Cloak, "Cloak" }, { Proto::WireGuard, "WireGuard" }, + { Proto::WireGuard, "Amnezia WireGuard" }, { Proto::Ikev2, "IKEv2" }, { Proto::L2tp, "L2TP" }, @@ -88,6 +89,7 @@ amnezia::ServiceType ProtocolProps::protocolService(Proto p) case Proto::Cloak: return ServiceType::Vpn; case Proto::ShadowSocks: return ServiceType::Vpn; case Proto::WireGuard: return ServiceType::Vpn; + case Proto::AmneziaWireGuard: return ServiceType::Vpn; case Proto::TorWebSite: return ServiceType::Other; case Proto::Dns: return ServiceType::Other; case Proto::FileShare: return ServiceType::Other; @@ -103,6 +105,7 @@ int ProtocolProps::defaultPort(Proto p) case Proto::Cloak: return 443; case Proto::ShadowSocks: return 6789; case Proto::WireGuard: return 51820; + case Proto::AmneziaWireGuard: return 55424; case Proto::Ikev2: return -1; case Proto::L2tp: return -1; @@ -122,6 +125,7 @@ bool ProtocolProps::defaultPortChangeable(Proto p) case Proto::Cloak: return true; case Proto::ShadowSocks: return true; case Proto::WireGuard: return true; + case Proto::AmneziaWireGuard: return true; case Proto::Ikev2: return false; case Proto::L2tp: return false; @@ -140,6 +144,7 @@ TransportProto ProtocolProps::defaultTransportProto(Proto p) case Proto::Cloak: return TransportProto::Tcp; case Proto::ShadowSocks: return TransportProto::Tcp; case Proto::WireGuard: return TransportProto::Udp; + case Proto::AmneziaWireGuard: return TransportProto::Udp; case Proto::Ikev2: return TransportProto::Udp; case Proto::L2tp: return TransportProto::Udp; // non-vpn @@ -158,6 +163,7 @@ bool ProtocolProps::defaultTransportProtoChangeable(Proto p) case Proto::Cloak: return false; case Proto::ShadowSocks: return false; case Proto::WireGuard: return false; + case Proto::AmneziaWireGuard: return false; case Proto::Ikev2: return false; case Proto::L2tp: return false; // non-vpn diff --git a/client/protocols/protocols_defs.h b/client/protocols/protocols_defs.h index 9472164b..4e72e318 100644 --- a/client/protocols/protocols_defs.h +++ b/client/protocols/protocols_defs.h @@ -2,8 +2,8 @@ #define PROTOCOLS_DEFS_H #include -#include #include +#include namespace amnezia { @@ -158,6 +158,7 @@ namespace amnezia ShadowSocks, Cloak, WireGuard, + AmneziaWireGuard, Ikev2, L2tp, diff --git a/client/protocols/vpnprotocol.cpp b/client/protocols/vpnprotocol.cpp index 841d307c..527ede47 100644 --- a/client/protocols/vpnprotocol.cpp +++ b/client/protocols/vpnprotocol.cpp @@ -1,22 +1,21 @@ #include #include -#include "vpnprotocol.h" #include "core/errorstrings.h" +#include "vpnprotocol.h" #if defined(Q_OS_WINDOWS) || defined(Q_OS_MACX) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) -#include "openvpnprotocol.h" -#include "shadowsocksvpnprotocol.h" -#include "openvpnovercloakprotocol.h" -#include "wireguardprotocol.h" + #include "openvpnovercloakprotocol.h" + #include "openvpnprotocol.h" + #include "shadowsocksvpnprotocol.h" + #include "wireguardprotocol.h" #endif #ifdef Q_OS_WINDOWS -#include "ikev2_vpn_protocol_windows.h" + #include "ikev2_vpn_protocol_windows.h" #endif - -VpnProtocol::VpnProtocol(const QJsonObject &configuration, QObject* parent) +VpnProtocol::VpnProtocol(const QJsonObject &configuration, QObject *parent) : QObject(parent), m_connectionState(Vpn::ConnectionState::Unknown), m_rawConfig(configuration), @@ -31,7 +30,7 @@ VpnProtocol::VpnProtocol(const QJsonObject &configuration, QObject* parent) void VpnProtocol::setLastError(ErrorCode lastError) { m_lastError = lastError; - if (lastError){ + if (lastError) { setConnectionState(Vpn::ConnectionState::Error); } qCritical().noquote() << "VpnProtocol error, code" << m_lastError << errorString(m_lastError); @@ -103,7 +102,7 @@ QString VpnProtocol::vpnGateway() const return m_vpnGateway; } -VpnProtocol *VpnProtocol::factory(DockerContainer container, const QJsonObject& configuration) +VpnProtocol *VpnProtocol::factory(DockerContainer container, const QJsonObject &configuration) { switch (container) { #if defined(Q_OS_WINDOWS) @@ -114,6 +113,7 @@ VpnProtocol *VpnProtocol::factory(DockerContainer container, const QJsonObject& case DockerContainer::Cloak: return new OpenVpnOverCloakProtocol(configuration); case DockerContainer::ShadowSocks: return new ShadowSocksVpnProtocol(configuration); case DockerContainer::WireGuard: return new WireguardProtocol(configuration); + case DockerContainer::AmneziaWireGuard: return new WireguardProtocol(configuration); #endif default: return nullptr; } @@ -135,8 +135,7 @@ QString VpnProtocol::textConnectionState(Vpn::ConnectionState connectionState) case Vpn::ConnectionState::Disconnecting: return tr("Disconnecting..."); case Vpn::ConnectionState::Reconnecting: return tr("Reconnecting..."); case Vpn::ConnectionState::Error: return tr("Error"); - default: - ; + default:; } return QString(); diff --git a/client/protocols/wireguardprotocol.cpp b/client/protocols/wireguardprotocol.cpp index 7466d1af..eb37f67a 100644 --- a/client/protocols/wireguardprotocol.cpp +++ b/client/protocols/wireguardprotocol.cpp @@ -18,7 +18,7 @@ WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject * // MZ #if defined(MZ_LINUX) - //m_impl.reset(new LinuxController()); + // m_impl.reset(new LinuxController()); #elif defined(Q_OS_MAC) || defined(Q_OS_WIN) m_impl.reset(new LocalSocketController()); connect(m_impl.get(), &ControllerImpl::connected, this, diff --git a/client/resources.qrc b/client/resources.qrc index 5b4d6ae7..44c61172 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -215,5 +215,6 @@ ui/qml/Controls2/ListViewWithLabelsType.qml ui/qml/Pages2/PageServiceDnsSettings.qml ui/qml/Controls2/TopCloseButtonType.qml + ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml diff --git a/client/ui/controllers/pageController.h b/client/ui/controllers/pageController.h index a8f883fe..cf248900 100644 --- a/client/ui/controllers/pageController.h +++ b/client/ui/controllers/pageController.h @@ -49,6 +49,7 @@ namespace PageLoader PageProtocolShadowSocksSettings, PageProtocolCloakSettings, PageProtocolWireGuardSettings, + PageProtocolAmneziaWireGuardSettings, PageProtocolIKev2Settings, PageProtocolRaw }; diff --git a/client/ui/models/protocols/amneziaWireGuardConfigModel.cpp b/client/ui/models/protocols/amneziaWireGuardConfigModel.cpp new file mode 100644 index 00000000..9cf4ed14 --- /dev/null +++ b/client/ui/models/protocols/amneziaWireGuardConfigModel.cpp @@ -0,0 +1,70 @@ +#include "amneziaWireGuardConfigModel.h" + +#include "protocols/protocols_defs.h" + +AmneziaWireGuardConfigModel::AmneziaWireGuardConfigModel(QObject *parent) : QAbstractListModel(parent) +{ +} + +int AmneziaWireGuardConfigModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return 1; +} + +bool AmneziaWireGuardConfigModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (!index.isValid() || index.row() < 0 || index.row() >= ContainerProps::allContainers().size()) { + return false; + } + + switch (role) { + case Roles::PortRole: m_protocolConfig.insert(config_key::port, value.toString()); break; + case Roles::CipherRole: m_protocolConfig.insert(config_key::cipher, value.toString()); break; + } + + emit dataChanged(index, index, QList { role }); + return true; +} + +QVariant AmneziaWireGuardConfigModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.row() < 0 || index.row() >= rowCount()) { + return false; + } + + switch (role) { + case Roles::PortRole: return m_protocolConfig.value(config_key::port).toString(protocols::shadowsocks::defaultPort); + case Roles::CipherRole: + return m_protocolConfig.value(config_key::cipher).toString(protocols::shadowsocks::defaultCipher); + } + + return QVariant(); +} + +void AmneziaWireGuardConfigModel::updateModel(const QJsonObject &config) +{ + beginResetModel(); + m_container = ContainerProps::containerFromString(config.value(config_key::container).toString()); + + m_fullConfig = config; + QJsonObject protocolConfig = config.value(config_key::wireguard).toObject(); + + endResetModel(); +} + +QJsonObject AmneziaWireGuardConfigModel::getConfig() +{ + m_fullConfig.insert(config_key::wireguard, m_protocolConfig); + return m_fullConfig; +} + +QHash AmneziaWireGuardConfigModel::roleNames() const +{ + QHash roles; + + roles[PortRole] = "port"; + roles[CipherRole] = "cipher"; + + return roles; +} diff --git a/client/ui/models/protocols/amneziaWireGuardConfigModel.h b/client/ui/models/protocols/amneziaWireGuardConfigModel.h new file mode 100644 index 00000000..b798c289 --- /dev/null +++ b/client/ui/models/protocols/amneziaWireGuardConfigModel.h @@ -0,0 +1,39 @@ +#ifndef AMNEZIAWIREGUARDCONFIGMODEL_H +#define AMNEZIAWIREGUARDCONFIGMODEL_H + +#include +#include + +#include "containers/containers_defs.h" + +class AmneziaWireGuardConfigModel : public QAbstractListModel +{ + Q_OBJECT + +public: + enum Roles { + PortRole = Qt::UserRole + 1, + CipherRole + }; + + explicit AmneziaWireGuardConfigModel(QObject *parent = nullptr); + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + + bool setData(const QModelIndex &index, const QVariant &value, int role) override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + +public slots: + void updateModel(const QJsonObject &config); + QJsonObject getConfig(); + +protected: + QHash roleNames() const override; + +private: + DockerContainer m_container; + QJsonObject m_protocolConfig; + QJsonObject m_fullConfig; +}; + +#endif // AMNEZIAWIREGUARDCONFIGMODEL_H diff --git a/client/ui/qml/Components/HomeContainersListView.qml b/client/ui/qml/Components/HomeContainersListView.qml index 4708128f..037a666d 100644 --- a/client/ui/qml/Components/HomeContainersListView.qml +++ b/client/ui/qml/Components/HomeContainersListView.qml @@ -72,8 +72,7 @@ ListView { containersDropDown.menuVisible = false - if (needReconnected && - (ConnectionController.isConnected || ConnectionController.isConnectionInProgress)) { + if (needReconnected && (ConnectionController.isConnected || ConnectionController.isConnectionInProgress)) { PageController.showNotificationMessage(qsTr("Reconnect via VPN Procotol: ") + name) PageController.goToPageHome() menu.visible = false diff --git a/client/ui/qml/Components/SettingsContainersListView.qml b/client/ui/qml/Components/SettingsContainersListView.qml index edd96bd7..250ba1eb 100644 --- a/client/ui/qml/Components/SettingsContainersListView.qml +++ b/client/ui/qml/Components/SettingsContainersListView.qml @@ -64,6 +64,11 @@ ListView { // goToPage(PageEnum.PageProtocolWireGuardSettings) break } + case ContainerEnum.AmneziaWireGuard: { + WireGuardConfigModel.updateModel(config) + PageController.goToPage(PageEnum.PageProtocolAmneziaWireGuardSettings) + break + } case ContainerEnum.Ipsec: { ProtocolsModel.updateModel(config) PageController.goToPage(PageEnum.PageProtocolRaw) diff --git a/client/ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml b/client/ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml new file mode 100644 index 00000000..a905f47a --- /dev/null +++ b/client/ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml @@ -0,0 +1,272 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +import SortFilterProxyModel 0.2 + +import "./" +import "../Controls2" +import "../Controls2/TextTypes" +import "../Config" +import "../Components" + +PageType { + id: root + + ColumnLayout { + id: backButton + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + + anchors.topMargin: 20 + + BackButtonType { + } + } + + FlickableType { + id: fl + anchors.top: backButton.bottom + anchors.bottom: parent.bottom + contentHeight: content.implicitHeight + + Column { + id: content + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + + enabled: ServersModel.isCurrentlyProcessedServerHasWriteAccess() + + ListView { + id: listview + + width: parent.width + height: listview.contentItem.height + + clip: true + interactive: false + + model: AmneziaWireGuardConfigModel + + delegate: Item { + implicitWidth: listview.width + implicitHeight: col.implicitHeight + + ColumnLayout { + id: col + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + + anchors.leftMargin: 16 + anchors.rightMargin: 16 + + spacing: 0 + + HeaderType { + Layout.fillWidth: true + + headerText: qsTr("Amnezia WireGuard settings") + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + Layout.topMargin: 40 + + headerText: qsTr("Port") + textFieldText: port + textField.maximumLength: 5 + textField.validator: IntValidator { bottom: 1; top: 65535 } + + textField.onEditingFinished: { + if (textFieldText !== port) { + port = textFieldText + } + } + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + Layout.topMargin: 16 + + headerText: qsTr("Junk packet count") + textFieldText: port + + textField.onEditingFinished: { + if (textFieldText !== port) { + port = textFieldText + } + } + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + Layout.topMargin: 16 + + headerText: qsTr("Junk packet minimum size") + textFieldText: port + + textField.onEditingFinished: { + if (textFieldText !== port) { + port = textFieldText + } + } + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + Layout.topMargin: 16 + + headerText: qsTr("Junk packet maximum size") + textFieldText: port + + textField.onEditingFinished: { + if (textFieldText !== port) { + port = textFieldText + } + } + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + Layout.topMargin: 16 + + headerText: qsTr("Init packet junk size") + textFieldText: port + + textField.onEditingFinished: { + if (textFieldText !== port) { + port = textFieldText + } + } + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + Layout.topMargin: 16 + + headerText: qsTr("Response packet junk size") + textFieldText: port + + textField.onEditingFinished: { + if (textFieldText !== port) { + port = textFieldText + } + } + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + Layout.topMargin: 16 + + headerText: qsTr("Init packet magic header") + textFieldText: port + + textField.onEditingFinished: { + if (textFieldText !== port) { + port = textFieldText + } + } + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + Layout.topMargin: 16 + + headerText: qsTr("Response packet magic header") + textFieldText: port + + textField.onEditingFinished: { + if (textFieldText !== port) { + port = textFieldText + } + } + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + Layout.topMargin: 16 + + headerText: qsTr("Transport packet magic header") + textFieldText: port + + textField.onEditingFinished: { + if (textFieldText !== port) { + port = textFieldText + } + } + } + + TextFieldWithHeaderType { + Layout.fillWidth: true + Layout.topMargin: 16 + + headerText: qsTr("Underload packet magic header") + textFieldText: port + + textField.onEditingFinished: { + if (textFieldText !== port) { + port = textFieldText + } + } + } + + BasicButtonType { + Layout.topMargin: 24 + Layout.leftMargin: -8 + implicitHeight: 32 + + defaultColor: "transparent" + hoveredColor: Qt.rgba(1, 1, 1, 0.08) + pressedColor: Qt.rgba(1, 1, 1, 0.12) + textColor: "#EB5757" + + text: qsTr("Remove Amnezia WireGuard") + + onClicked: { + questionDrawer.headerText = qsTr("Remove Amnezia WireGuard from server?") + questionDrawer.descriptionText = qsTr("All users with whom you shared a connection will no longer be able to connect to it") + questionDrawer.yesButtonText = qsTr("Continue") + questionDrawer.noButtonText = qsTr("Cancel") + + questionDrawer.yesButtonFunction = function() { + questionDrawer.visible = false + PageController.goToPage(PageEnum.PageDeinstalling) + InstallController.removeCurrentlyProcessedContainer() + } + questionDrawer.noButtonFunction = function() { + questionDrawer.visible = false + } + questionDrawer.visible = true + } + } + + BasicButtonType { + Layout.fillWidth: true + Layout.topMargin: 24 + Layout.bottomMargin: 24 + + text: qsTr("Save and Restart Amnezia") + + onClicked: { + forceActiveFocus() +// PageController.showBusyIndicator(true) +// InstallController.updateContainer(ShadowSocksConfigModel.getConfig()) +// PageController.showBusyIndicator(false) + } + } + } + } + } + } + + QuestionDrawer { + id: questionDrawer + } + } +} diff --git a/client/ui/qml/Pages2/PageSetupWizardStart.qml b/client/ui/qml/Pages2/PageSetupWizardStart.qml index 9f5e57a5..ba78c985 100644 --- a/client/ui/qml/Pages2/PageSetupWizardStart.qml +++ b/client/ui/qml/Pages2/PageSetupWizardStart.qml @@ -62,7 +62,7 @@ PageType { function onInstallationErrorOccurred(errorMessage) { PageController.showErrorMessage(errorMessage) - var currentPageName = tabBarStackView.currentItem.objectName + var currentPageName = stackView.currentItem.objectName if (currentPageName === PageController.getPagePath(PageEnum.PageSetupWizardInstalling)) { PageController.closePage() From af53c456ea91a187defc72844e4a23de26d92987 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Wed, 27 Sep 2023 00:40:01 +0500 Subject: [PATCH 02/30] added passing new wireguard config parameters over uapi and configuring the amneziawireguard container --- .../amneziaWireGuardConfigurator.cpp | 51 +++++++++++++++++-- client/configurators/vpn_configurator.cpp | 6 ++- client/configurators/vpn_configurator.h | 4 +- .../configurators/wireguard_configurator.cpp | 43 ++++++++-------- client/configurators/wireguard_configurator.h | 9 +++- client/core/scripts_registry.cpp | 3 +- client/core/scripts_registry.h | 3 +- client/core/servercontroller.cpp | 31 +++++++++++ client/daemon/daemon.cpp | 11 ++++ client/daemon/interfaceconfig.h | 10 ++++ client/mozilla/localsocketcontroller.cpp | 17 ++++++- .../macos/daemon/wireguardutilsmacos.cpp | 11 ++++ client/protocols/protocols_defs.h | 30 +++++++++++ client/resources.qrc | 5 ++ .../amnezia_wireguard/Dockerfile | 46 +++++++++++++++++ .../amnezia_wireguard/configure_container.sh | 26 ++++++++++ .../amnezia_wireguard/run_container.sh | 18 +++++++ .../server_scripts/amnezia_wireguard/start.sh | 28 ++++++++++ .../amnezia_wireguard/template.conf | 20 ++++++++ 19 files changed, 342 insertions(+), 30 deletions(-) create mode 100644 client/server_scripts/amnezia_wireguard/Dockerfile create mode 100644 client/server_scripts/amnezia_wireguard/configure_container.sh create mode 100644 client/server_scripts/amnezia_wireguard/run_container.sh create mode 100644 client/server_scripts/amnezia_wireguard/start.sh create mode 100644 client/server_scripts/amnezia_wireguard/template.conf diff --git a/client/configurators/amneziaWireGuardConfigurator.cpp b/client/configurators/amneziaWireGuardConfigurator.cpp index 56f0c68e..3ed27208 100644 --- a/client/configurators/amneziaWireGuardConfigurator.cpp +++ b/client/configurators/amneziaWireGuardConfigurator.cpp @@ -1,7 +1,10 @@ #include "amneziaWireGuardConfigurator.h" +#include +#include + AmneziaWireGuardConfigurator::AmneziaWireGuardConfigurator(std::shared_ptr settings, QObject *parent) - : WireguardConfigurator(settings, parent) + : WireguardConfigurator(settings, true, parent) { } @@ -9,7 +12,49 @@ QString AmneziaWireGuardConfigurator::genAmneziaWireGuardConfig(const ServerCred DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode) { - auto config = WireguardConfigurator::genWireguardConfig(credentials, container, containerConfig, errorCode); + QString config = WireguardConfigurator::genWireguardConfig(credentials, container, containerConfig, errorCode); - return config; + QJsonObject jsonConfig = QJsonDocument::fromJson(config.toUtf8()).object(); + QJsonObject awgConfig = containerConfig.value(config_key::amneziaWireguard).toObject(); + + auto junkPacketCount = + awgConfig.value(config_key::junkPacketCount).toString(protocols::amneziawireguard::defaultJunkPacketCount); + auto junkPacketMinSize = + awgConfig.value(config_key::junkPacketMinSize).toString(protocols::amneziawireguard::defaultJunkPacketMinSize); + auto junkPacketMaxSize = + awgConfig.value(config_key::junkPacketMaxSize).toString(protocols::amneziawireguard::defaultJunkPacketMaxSize); + auto initPacketJunkSize = + awgConfig.value(config_key::initPacketJunkSize).toString(protocols::amneziawireguard::defaultInitPacketJunkSize); + auto responsePacketJunkSize = + awgConfig.value(config_key::responsePacketJunkSize).toString(protocols::amneziawireguard::defaultResponsePacketJunkSize); + auto initPacketMagicHeader = + awgConfig.value(config_key::initPacketMagicHeader).toString(protocols::amneziawireguard::defaultInitPacketMagicHeader); + auto responsePacketMagicHeader = + awgConfig.value(config_key::responsePacketMagicHeader).toString(protocols::amneziawireguard::defaultResponsePacketMagicHeader); + auto underloadPacketMagicHeader = + awgConfig.value(config_key::underloadPacketMagicHeader).toString(protocols::amneziawireguard::defaultUnderloadPacketMagicHeader); + auto transportPacketMagicHeader = + awgConfig.value(config_key::transportPacketMagicHeader).toString(protocols::amneziawireguard::defaultTransportPacketMagicHeader); + + config.replace("$JUNK_PACKET_COUNT", junkPacketCount); + config.replace("$JUNK_PACKET_MIN_SIZE", junkPacketMinSize); + config.replace("$JUNK_PACKET_MAX_SIZE", junkPacketMaxSize); + config.replace("$INIT_PACKET_JUNK_SIZE", initPacketJunkSize); + config.replace("$RESPONSE_PACKET_JUNK_SIZE", responsePacketJunkSize); + config.replace("$INIT_PACKET_MAGIC_HEADER", initPacketMagicHeader); + config.replace("$RESPONSE_PACKET_MAGIC_HEADER", responsePacketMagicHeader); + config.replace("$UNDERLOAD_PACKET_MAGIC_HEADER", underloadPacketMagicHeader); + config.replace("$TRANSPORT_PACKET_MAGIC_HEADER", transportPacketMagicHeader); + + jsonConfig[config_key::junkPacketCount] = junkPacketCount; + jsonConfig[config_key::junkPacketMinSize] = junkPacketMinSize; + jsonConfig[config_key::junkPacketMaxSize] = junkPacketMaxSize; + jsonConfig[config_key::initPacketJunkSize] = initPacketJunkSize; + jsonConfig[config_key::responsePacketJunkSize] = responsePacketJunkSize; + jsonConfig[config_key::initPacketMagicHeader] = initPacketMagicHeader; + jsonConfig[config_key::responsePacketMagicHeader] = responsePacketMagicHeader; + jsonConfig[config_key::underloadPacketMagicHeader] = underloadPacketMagicHeader; + jsonConfig[config_key::transportPacketMagicHeader] = transportPacketMagicHeader; + + return QJsonDocument(jsonConfig).toJson(); } diff --git a/client/configurators/vpn_configurator.cpp b/client/configurators/vpn_configurator.cpp index 7f0e95df..6706deed 100644 --- a/client/configurators/vpn_configurator.cpp +++ b/client/configurators/vpn_configurator.cpp @@ -5,6 +5,7 @@ #include "shadowsocks_configurator.h" #include "ssh_configurator.h" #include "wireguard_configurator.h" +#include "amneziaWireGuardConfigurator.h" #include #include @@ -20,9 +21,10 @@ VpnConfigurator::VpnConfigurator(std::shared_ptr settings, QObject *pa openVpnConfigurator = std::shared_ptr(new OpenVpnConfigurator(settings, this)); shadowSocksConfigurator = std::shared_ptr(new ShadowSocksConfigurator(settings, this)); cloakConfigurator = std::shared_ptr(new CloakConfigurator(settings, this)); - wireguardConfigurator = std::shared_ptr(new WireguardConfigurator(settings, this)); + wireguardConfigurator = std::shared_ptr(new WireguardConfigurator(settings, false, this)); ikev2Configurator = std::shared_ptr(new Ikev2Configurator(settings, this)); sshConfigurator = std::shared_ptr(new SshConfigurator(settings, this)); + amneziaWireGuardConfigurator = std::shared_ptr(new AmneziaWireGuardConfigurator(settings, this)); } QString VpnConfigurator::genVpnProtocolConfig(const ServerCredentials &credentials, DockerContainer container, @@ -41,7 +43,7 @@ QString VpnConfigurator::genVpnProtocolConfig(const ServerCredentials &credentia return wireguardConfigurator->genWireguardConfig(credentials, container, containerConfig, errorCode); case Proto::AmneziaWireGuard: - return wireguardConfigurator->genWireguardConfig(credentials, container, containerConfig, errorCode); + return amneziaWireGuardConfigurator->genAmneziaWireGuardConfig(credentials, container, containerConfig, errorCode); case Proto::Ikev2: return ikev2Configurator->genIkev2Config(credentials, container, containerConfig, errorCode); diff --git a/client/configurators/vpn_configurator.h b/client/configurators/vpn_configurator.h index 3b9c761b..d304e4c3 100644 --- a/client/configurators/vpn_configurator.h +++ b/client/configurators/vpn_configurator.h @@ -13,13 +13,14 @@ class CloakConfigurator; class WireguardConfigurator; class Ikev2Configurator; class SshConfigurator; +class AmneziaWireGuardConfigurator; // Retrieve connection settings from server class VpnConfigurator : ConfiguratorBase { Q_OBJECT public: - VpnConfigurator(std::shared_ptr settings, QObject *parent = nullptr); + explicit VpnConfigurator(std::shared_ptr settings, QObject *parent = nullptr); QString genVpnProtocolConfig(const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig, Proto proto, ErrorCode *errorCode = nullptr); @@ -40,6 +41,7 @@ public: std::shared_ptr wireguardConfigurator; std::shared_ptr ikev2Configurator; std::shared_ptr sshConfigurator; + std::shared_ptr amneziaWireGuardConfigurator; }; #endif // VPN_CONFIGURATOR_H diff --git a/client/configurators/wireguard_configurator.cpp b/client/configurators/wireguard_configurator.cpp index 02716b72..dd836a18 100644 --- a/client/configurators/wireguard_configurator.cpp +++ b/client/configurators/wireguard_configurator.cpp @@ -19,9 +19,17 @@ #include "settings.h" #include "utilities.h" -WireguardConfigurator::WireguardConfigurator(std::shared_ptr settings, QObject *parent) - : ConfiguratorBase(settings, parent) +WireguardConfigurator::WireguardConfigurator(std::shared_ptr settings, bool isAmneziaWireGuard, QObject *parent) + : ConfiguratorBase(settings, parent), m_isAmneziaWireGuard(isAmneziaWireGuard) { + m_serverConfigPath = m_isAmneziaWireGuard ? amnezia::protocols::amneziawireguard::serverConfigPath + : amnezia::protocols::wireguard::serverConfigPath; + m_serverPublicKeyPath = m_isAmneziaWireGuard ? amnezia::protocols::amneziawireguard::serverPublicKeyPath + : amnezia::protocols::wireguard::serverPublicKeyPath; + m_serverPskKeyPath = m_isAmneziaWireGuard ? amnezia::protocols::amneziawireguard::serverPskKeyPath + : amnezia::protocols::wireguard::serverPskKeyPath; + m_configTemplate = m_isAmneziaWireGuard ? ProtocolScriptType::amnezia_wireguard_template + : ProtocolScriptType::wireguard_template; } WireguardConfigurator::ConnectionData WireguardConfigurator::genClientKeys() @@ -62,7 +70,7 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon { WireguardConfigurator::ConnectionData connData = WireguardConfigurator::genClientKeys(); connData.host = credentials.hostName; - connData.port = containerConfig.value(config_key::wireguard) + connData.port = containerConfig.value(m_isAmneziaWireGuard ? config_key::amneziaWireguard : config_key::wireguard) .toObject() .value(config_key::port) .toString(protocols::wireguard::defaultPort); @@ -79,7 +87,7 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon // Get list of already created clients (only IP addresses) QString nextIpNumber; { - QString script = QString("cat %1 | grep AllowedIPs").arg(amnezia::protocols::wireguard::serverConfigPath); + QString script = QString("cat %1 | grep AllowedIPs").arg(m_serverConfigPath); QString stdOut; auto cbReadStdOut = [&](const QString &data, libssh::Client &) { stdOut += data + "\n"; @@ -126,8 +134,7 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon } // Get keys - connData.serverPubKey = serverController.getTextFileFromContainer( - container, credentials, amnezia::protocols::wireguard::serverPublicKeyPath, &e); + connData.serverPubKey = serverController.getTextFileFromContainer(container, credentials, m_serverPublicKeyPath, &e); connData.serverPubKey.replace("\n", ""); if (e) { if (errorCode) @@ -135,8 +142,7 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon return connData; } - connData.pskKey = serverController.getTextFileFromContainer(container, credentials, - amnezia::protocols::wireguard::serverPskKeyPath, &e); + connData.pskKey = serverController.getTextFileFromContainer(container, credentials, m_serverPskKeyPath, &e); connData.pskKey.replace("\n", ""); if (e) { @@ -150,12 +156,9 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon "PublicKey = %1\n" "PresharedKey = %2\n" "AllowedIPs = %3/32\n\n") - .arg(connData.clientPubKey) - .arg(connData.pskKey) - .arg(connData.clientIP); + .arg(connData.clientPubKey, connData.pskKey, connData.clientIP); - e = serverController.uploadTextFileToContainer(container, credentials, configPart, - protocols::wireguard::serverConfigPath, + e = serverController.uploadTextFileToContainer(container, credentials, configPart, m_serverConfigPath, libssh::SftpOverwriteMode::SftpAppendToExisting); if (e) { @@ -164,11 +167,11 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon return connData; } + QString script = QString("sudo docker exec -i $CONTAINER_NAME bash -c 'wg syncconf wg0 <(wg-quick strip %1)'") + .arg(m_serverConfigPath); + e = serverController.runScript( - credentials, - serverController.replaceVars("sudo docker exec -i $CONTAINER_NAME bash -c 'wg syncconf wg0 <(wg-quick " - "strip /opt/amnezia/wireguard/wg0.conf)'", - serverController.genVarsForScript(credentials, container))); + credentials, serverController.replaceVars(script, serverController.genVarsForScript(credentials, container))); return connData; } @@ -177,9 +180,9 @@ QString WireguardConfigurator::genWireguardConfig(const ServerCredentials &crede const QJsonObject &containerConfig, ErrorCode *errorCode) { ServerController serverController(m_settings); - QString config = - serverController.replaceVars(amnezia::scriptData(ProtocolScriptType::wireguard_template, container), - serverController.genVarsForScript(credentials, container, containerConfig)); + QString scriptData = amnezia::scriptData(m_configTemplate, container); + QString config = serverController.replaceVars( + scriptData, serverController.genVarsForScript(credentials, container, containerConfig)); ConnectionData connData = prepareWireguardConfig(credentials, container, containerConfig, errorCode); if (errorCode && *errorCode) { diff --git a/client/configurators/wireguard_configurator.h b/client/configurators/wireguard_configurator.h index 140acc47..70ed729b 100644 --- a/client/configurators/wireguard_configurator.h +++ b/client/configurators/wireguard_configurator.h @@ -6,12 +6,13 @@ #include "configurator_base.h" #include "core/defs.h" +#include "core/scripts_registry.h" class WireguardConfigurator : public ConfiguratorBase { Q_OBJECT public: - WireguardConfigurator(std::shared_ptr settings, QObject *parent = nullptr); + WireguardConfigurator(std::shared_ptr settings, bool isAmneziaWireGuard, QObject *parent = nullptr); struct ConnectionData { @@ -35,6 +36,12 @@ private: const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr); ConnectionData genClientKeys(); + + bool m_isAmneziaWireGuard; + QString m_serverConfigPath; + QString m_serverPublicKeyPath; + QString m_serverPskKeyPath; + amnezia::ProtocolScriptType m_configTemplate; }; #endif // WIREGUARD_CONFIGURATOR_H diff --git a/client/core/scripts_registry.cpp b/client/core/scripts_registry.cpp index 31508152..24deb41a 100644 --- a/client/core/scripts_registry.cpp +++ b/client/core/scripts_registry.cpp @@ -11,7 +11,7 @@ QString amnezia::scriptFolder(amnezia::DockerContainer container) case DockerContainer::Cloak: return QLatin1String("openvpn_cloak"); case DockerContainer::ShadowSocks: return QLatin1String("openvpn_shadowsocks"); case DockerContainer::WireGuard: return QLatin1String("wireguard"); - case DockerContainer::AmneziaWireGuard: return QLatin1String("wireguard"); + case DockerContainer::AmneziaWireGuard: return QLatin1String("amnezia_wireguard"); case DockerContainer::Ipsec: return QLatin1String("ipsec"); case DockerContainer::TorWebSite: return QLatin1String("website_tor"); @@ -46,6 +46,7 @@ QString amnezia::scriptName(ProtocolScriptType type) case ProtocolScriptType::container_startup: return QLatin1String("start.sh"); case ProtocolScriptType::openvpn_template: return QLatin1String("template.ovpn"); case ProtocolScriptType::wireguard_template: return QLatin1String("template.conf"); + case ProtocolScriptType::amnezia_wireguard_template: return QLatin1String("template.conf"); } } diff --git a/client/core/scripts_registry.h b/client/core/scripts_registry.h index b30be2ff..5c7a1b6a 100644 --- a/client/core/scripts_registry.h +++ b/client/core/scripts_registry.h @@ -26,7 +26,8 @@ enum ProtocolScriptType { configure_container, container_startup, openvpn_template, - wireguard_template + wireguard_template, + amnezia_wireguard_template }; diff --git a/client/core/servercontroller.cpp b/client/core/servercontroller.cpp index 27213dc3..3b30451f 100644 --- a/client/core/servercontroller.cpp +++ b/client/core/servercontroller.cpp @@ -584,6 +584,37 @@ ServerController::Vars ServerController::genVarsForScript(const ServerCredential vars.append({ { "$SFTP_USER", sftpConfig.value(config_key::userName).toString() } }); vars.append({ { "$SFTP_PASSWORD", sftpConfig.value(config_key::password).toString() } }); + // Amnezia wireguard vars + vars.append({ { "$AMNEZIAWIREGUARD_SERVER_PORT", + amneziaWireguarConfig.value(config_key::port).toString(protocols::amneziawireguard::defaultPort) } }); + vars.append({ { "$JUNK_PACKET_COUNT", + amneziaWireguarConfig.value(config_key::junkPacketCount) + .toString(protocols::amneziawireguard::defaultJunkPacketCount) } }); + vars.append({ { "$JUNK_PACKET_MIN_SIZE", + amneziaWireguarConfig.value(config_key::junkPacketMinSize) + .toString(protocols::amneziawireguard::defaultJunkPacketMinSize) } }); + vars.append({ { "$JUNK_PACKET_MAX_SIZE", + amneziaWireguarConfig.value(config_key::junkPacketMaxSize) + .toString(protocols::amneziawireguard::defaultJunkPacketMaxSize) } }); + vars.append({ { "$INIT_PACKET_JUNK_SIZE", + amneziaWireguarConfig.value(config_key::initPacketJunkSize) + .toString(protocols::amneziawireguard::defaultInitPacketJunkSize) } }); + vars.append({ { "$RESPONSE_PACKET_JUNK_SIZE", + amneziaWireguarConfig.value(config_key::responsePacketJunkSize) + .toString(protocols::amneziawireguard::defaultResponsePacketJunkSize) } }); + vars.append({ { "$INIT_PACKET_MAGIC_HEADER", + amneziaWireguarConfig.value(config_key::initPacketMagicHeader) + .toString(protocols::amneziawireguard::defaultInitPacketMagicHeader) } }); + vars.append({ { "$RESPONSE_PACKET_MAGIC_HEADER", + amneziaWireguarConfig.value(config_key::responsePacketMagicHeader) + .toString(protocols::amneziawireguard::defaultResponsePacketMagicHeader) } }); + vars.append({ { "$UNDERLOAD_PACKET_MAGIC_HEADER", + amneziaWireguarConfig.value(config_key::underloadPacketMagicHeader) + .toString(protocols::amneziawireguard::defaultUnderloadPacketMagicHeader) } }); + vars.append({ { "$TRANSPORT_PACKET_MAGIC_HEADER", + amneziaWireguarConfig.value(config_key::transportPacketMagicHeader) + .toString(protocols::amneziawireguard::defaultTransportPacketMagicHeader) } }); + QString serverIp = Utils::getIPAddress(credentials.hostName); if (!serverIp.isEmpty()) { vars.append({ { "$SERVER_IP_ADDRESS", serverIp } }); diff --git a/client/daemon/daemon.cpp b/client/daemon/daemon.cpp index 3a0dc4d9..13310951 100644 --- a/client/daemon/daemon.cpp +++ b/client/daemon/daemon.cpp @@ -359,6 +359,17 @@ bool Daemon::parseConfig(const QJsonObject& obj, InterfaceConfig& config) { if (!parseStringList(obj, "vpnDisabledApps", config.m_vpnDisabledApps)) { return false; } + + config.m_junkPacketCount = obj.value("Jc").toString(); + config.m_junkPacketMinSize = obj.value("Jmin").toString(); + config.m_junkPacketMaxSize = obj.value("Jmax").toString(); + config.m_initPacketJunkSize = obj.value("S1").toString(); + config.m_responsePacketJunkSize = obj.value("S2").toString(); + config.m_initPacketMagicHeader = obj.value("H1").toString(); + config.m_responsePacketMagicHeader = obj.value("H2").toString(); + config.m_underloadPacketMagicHeader = obj.value("H3").toString(); + config.m_transportPacketMagicHeader = obj.value("H4").toString(); + return true; } diff --git a/client/daemon/interfaceconfig.h b/client/daemon/interfaceconfig.h index 61ffdd83..29aef085 100644 --- a/client/daemon/interfaceconfig.h +++ b/client/daemon/interfaceconfig.h @@ -40,6 +40,16 @@ class InterfaceConfig { QString m_installationId; #endif + QString m_junkPacketCount; + QString m_junkPacketMinSize; + QString m_junkPacketMaxSize; + QString m_initPacketJunkSize; + QString m_responsePacketJunkSize; + QString m_initPacketMagicHeader; + QString m_responsePacketMagicHeader; + QString m_underloadPacketMagicHeader; + QString m_transportPacketMagicHeader; + QJsonObject toJson() const; QString toWgConf( const QMap& extra = QMap()) const; diff --git a/client/mozilla/localsocketcontroller.cpp b/client/mozilla/localsocketcontroller.cpp index 40bc0bba..c9fa6a42 100644 --- a/client/mozilla/localsocketcontroller.cpp +++ b/client/mozilla/localsocketcontroller.cpp @@ -115,7 +115,9 @@ void LocalSocketController::daemonConnected() { } void LocalSocketController::activate(const QJsonObject &rawConfig) { - QJsonObject wgConfig = rawConfig.value("wireguard_config_data").toObject(); + QString protocolName = rawConfig.value("protocol").toString(); + + QJsonObject wgConfig = rawConfig.value(protocolName + "_config_data").toObject(); QJsonObject json; json.insert("type", "activate"); @@ -160,6 +162,19 @@ void LocalSocketController::activate(const QJsonObject &rawConfig) { // splitTunnelApps.append(QJsonValue(uri)); // } // json.insert("vpnDisabledApps", splitTunnelApps); + + if (protocolName == amnezia::config_key::amneziaWireguard) { + json.insert(amnezia::config_key::junkPacketCount, wgConfig.value(amnezia::config_key::junkPacketCount)); + json.insert(amnezia::config_key::junkPacketMinSize, wgConfig.value(amnezia::config_key::junkPacketMinSize)); + json.insert(amnezia::config_key::junkPacketMaxSize, wgConfig.value(amnezia::config_key::junkPacketMaxSize)); + json.insert(amnezia::config_key::initPacketJunkSize, wgConfig.value(amnezia::config_key::initPacketJunkSize)); + json.insert(amnezia::config_key::responsePacketJunkSize, wgConfig.value(amnezia::config_key::responsePacketJunkSize)); + json.insert(amnezia::config_key::initPacketMagicHeader, wgConfig.value(amnezia::config_key::initPacketMagicHeader)); + json.insert(amnezia::config_key::responsePacketMagicHeader, wgConfig.value(amnezia::config_key::responsePacketMagicHeader)); + json.insert(amnezia::config_key::underloadPacketMagicHeader, wgConfig.value(amnezia::config_key::underloadPacketMagicHeader)); + json.insert(amnezia::config_key::transportPacketMagicHeader, wgConfig.value(amnezia::config_key::transportPacketMagicHeader)); + } + write(json); } diff --git a/client/platforms/macos/daemon/wireguardutilsmacos.cpp b/client/platforms/macos/daemon/wireguardutilsmacos.cpp index 1f422462..ead53e23 100644 --- a/client/platforms/macos/daemon/wireguardutilsmacos.cpp +++ b/client/platforms/macos/daemon/wireguardutilsmacos.cpp @@ -163,6 +163,17 @@ bool WireguardUtilsMacos::updatePeer(const InterfaceConfig& config) { out << "allowed_ip=" << ip.toString() << "\n"; } + + out << "Jc=" << config.m_junkPacketCount << "\n"; + out << "jmin=" << config.m_junkPacketMinSize << "\n"; + out << "jmax=" << config.m_junkPacketMaxSize << "\n"; + out << "s1=" << config.m_initPacketJunkSize << "\n"; + out << "s2=" << config.m_responsePacketJunkSize << "\n"; + out << "h1=" << config.m_initPacketMagicHeader << "\n"; + out << "h2=" << config.m_responsePacketMagicHeader << "\n"; + out << "h3=" << config.m_underloadPacketMagicHeader << "\n"; + out << "h4=" << config.m_transportPacketMagicHeader << "\n"; + // Exclude the server address, except for multihop exit servers. if ((config.m_hopType != InterfaceConfig::MultiHopExit) && (m_rtmonitor != nullptr)) { diff --git a/client/protocols/protocols_defs.h b/client/protocols/protocols_defs.h index 4e72e318..e26e60a4 100644 --- a/client/protocols/protocols_defs.h +++ b/client/protocols/protocols_defs.h @@ -61,11 +61,22 @@ namespace amnezia constexpr char isThirdPartyConfig[] = "isThirdPartyConfig"; + constexpr char junkPacketCount[] = "Jc"; + constexpr char junkPacketMinSize[] = "Jmin"; + constexpr char junkPacketMaxSize[] = "Jmax"; + constexpr char initPacketJunkSize[] = "S1"; + constexpr char responsePacketJunkSize[] = "S2"; + constexpr char initPacketMagicHeader[] = "H1"; + constexpr char responsePacketMagicHeader[] = "H2"; + constexpr char underloadPacketMagicHeader[] = "H3"; + constexpr char transportPacketMagicHeader[] = "H4"; + constexpr char openvpn[] = "openvpn"; constexpr char wireguard[] = "wireguard"; constexpr char shadowsocks[] = "shadowsocks"; constexpr char cloak[] = "cloak"; constexpr char sftp[] = "sftp"; + constexpr char amneziaWireguard[] = "amneziawireguard"; } @@ -140,6 +151,25 @@ namespace amnezia } // namespace sftp + namespace amneziawireguard + { + constexpr char defaultPort[] = "55424"; + + constexpr char serverConfigPath[] = "/opt/amnezia/amneziawireguard/wg0.conf"; + constexpr char serverPublicKeyPath[] = "/opt/amnezia/amneziawireguard/wireguard_server_public_key.key"; + constexpr char serverPskKeyPath[] = "/opt/amnezia/amneziawireguard/wireguard_psk.key"; + + constexpr char defaultJunkPacketCount[] = "3"; + constexpr char defaultJunkPacketMinSize[] = "10"; + constexpr char defaultJunkPacketMaxSize[] = "30"; + constexpr char defaultInitPacketJunkSize[] = "15"; + constexpr char defaultResponsePacketJunkSize[] = "18"; + constexpr char defaultInitPacketMagicHeader[] = "1020325451"; + constexpr char defaultResponsePacketMagicHeader[] = "3288052141"; + constexpr char defaultTransportPacketMagicHeader[] = "2528465083"; + constexpr char defaultUnderloadPacketMagicHeader[] = "1766607858"; + } + } // namespace protocols namespace ProtocolEnumNS diff --git a/client/resources.qrc b/client/resources.qrc index 44c61172..b79ed3d2 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -216,5 +216,10 @@ ui/qml/Pages2/PageServiceDnsSettings.qml ui/qml/Controls2/TopCloseButtonType.qml ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml + server_scripts/amnezia_wireguard/template.conf + server_scripts/amnezia_wireguard/start.sh + server_scripts/amnezia_wireguard/configure_container.sh + server_scripts/amnezia_wireguard/run_container.sh + server_scripts/amnezia_wireguard/Dockerfile diff --git a/client/server_scripts/amnezia_wireguard/Dockerfile b/client/server_scripts/amnezia_wireguard/Dockerfile new file mode 100644 index 00000000..ed974dc6 --- /dev/null +++ b/client/server_scripts/amnezia_wireguard/Dockerfile @@ -0,0 +1,46 @@ +FROM amneziavpn/amnezia-wg:latest + +LABEL maintainer="AmneziaVPN" + +#Install required packages +RUN apk add --no-cache curl wireguard-tools dumb-init +RUN apk --update upgrade --no-cache + +RUN mkdir -p /opt/amnezia +RUN echo -e "#!/bin/bash\ntail -f /dev/null" > /opt/amnezia/start.sh +RUN chmod a+x /opt/amnezia/start.sh + +# Tune network +RUN echo -e " \n\ + fs.file-max = 51200 \n\ + \n\ + net.core.rmem_max = 67108864 \n\ + net.core.wmem_max = 67108864 \n\ + net.core.netdev_max_backlog = 250000 \n\ + net.core.somaxconn = 4096 \n\ + \n\ + net.ipv4.tcp_syncookies = 1 \n\ + net.ipv4.tcp_tw_reuse = 1 \n\ + net.ipv4.tcp_tw_recycle = 0 \n\ + net.ipv4.tcp_fin_timeout = 30 \n\ + net.ipv4.tcp_keepalive_time = 1200 \n\ + net.ipv4.ip_local_port_range = 10000 65000 \n\ + net.ipv4.tcp_max_syn_backlog = 8192 \n\ + net.ipv4.tcp_max_tw_buckets = 5000 \n\ + net.ipv4.tcp_fastopen = 3 \n\ + net.ipv4.tcp_mem = 25600 51200 102400 \n\ + net.ipv4.tcp_rmem = 4096 87380 67108864 \n\ + net.ipv4.tcp_wmem = 4096 65536 67108864 \n\ + net.ipv4.tcp_mtu_probing = 1 \n\ + net.ipv4.tcp_congestion_control = hybla \n\ + # for low-latency network, use cubic instead \n\ + # net.ipv4.tcp_congestion_control = cubic \n\ + " | sed -e 's/^\s\+//g' | tee -a /etc/sysctl.conf && \ + mkdir -p /etc/security && \ + echo -e " \n\ + * soft nofile 51200 \n\ + * hard nofile 51200 \n\ + " | sed -e 's/^\s\+//g' | tee -a /etc/security/limits.conf + +ENTRYPOINT [ "dumb-init", "/opt/amnezia/start.sh" ] +CMD [ "" ] diff --git a/client/server_scripts/amnezia_wireguard/configure_container.sh b/client/server_scripts/amnezia_wireguard/configure_container.sh new file mode 100644 index 00000000..8653a932 --- /dev/null +++ b/client/server_scripts/amnezia_wireguard/configure_container.sh @@ -0,0 +1,26 @@ +mkdir -p /opt/amnezia/amneziawireguard +cd /opt/amnezia/amneziawireguard +WIREGUARD_SERVER_PRIVATE_KEY=$(wg genkey) +echo $WIREGUARD_SERVER_PRIVATE_KEY > /opt/amnezia/amneziawireguard/wireguard_server_private_key.key + +WIREGUARD_SERVER_PUBLIC_KEY=$(echo $WIREGUARD_SERVER_PRIVATE_KEY | wg pubkey) +echo $WIREGUARD_SERVER_PUBLIC_KEY > /opt/amnezia/amneziawireguard/wireguard_server_public_key.key + +WIREGUARD_PSK=$(wg genpsk) +echo $WIREGUARD_PSK > /opt/amnezia/amneziawireguard/wireguard_psk.key + +cat > /opt/amnezia/amneziawireguard/wg0.conf < Date: Wed, 27 Sep 2023 00:45:42 +0500 Subject: [PATCH 03/30] added passing new amneziawireguard config parameters over uapi for all platforms --- client/platforms/linux/daemon/wireguardutilslinux.cpp | 10 ++++++++++ client/platforms/macos/daemon/wireguardutilsmacos.cpp | 2 +- .../platforms/windows/daemon/wireguardutilswindows.cpp | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/client/platforms/linux/daemon/wireguardutilslinux.cpp b/client/platforms/linux/daemon/wireguardutilslinux.cpp index a8b7b04a..dbb92f61 100644 --- a/client/platforms/linux/daemon/wireguardutilslinux.cpp +++ b/client/platforms/linux/daemon/wireguardutilslinux.cpp @@ -161,6 +161,16 @@ bool WireguardUtilsLinux::updatePeer(const InterfaceConfig& config) { out << "allowed_ip=" << ip.toString() << "\n"; } + out << "jc=" << config.m_junkPacketCount << "\n"; + out << "jmin=" << config.m_junkPacketMinSize << "\n"; + out << "jmax=" << config.m_junkPacketMaxSize << "\n"; + out << "s1=" << config.m_initPacketJunkSize << "\n"; + out << "s2=" << config.m_responsePacketJunkSize << "\n"; + out << "h1=" << config.m_initPacketMagicHeader << "\n"; + out << "h2=" << config.m_responsePacketMagicHeader << "\n"; + out << "h3=" << config.m_underloadPacketMagicHeader << "\n"; + out << "h4=" << config.m_transportPacketMagicHeader << "\n"; + // Exclude the server address, except for multihop exit servers. if ((config.m_hopType != InterfaceConfig::MultiHopExit) && (m_rtmonitor != nullptr)) { diff --git a/client/platforms/macos/daemon/wireguardutilsmacos.cpp b/client/platforms/macos/daemon/wireguardutilsmacos.cpp index ead53e23..2170d69e 100644 --- a/client/platforms/macos/daemon/wireguardutilsmacos.cpp +++ b/client/platforms/macos/daemon/wireguardutilsmacos.cpp @@ -164,7 +164,7 @@ bool WireguardUtilsMacos::updatePeer(const InterfaceConfig& config) { } - out << "Jc=" << config.m_junkPacketCount << "\n"; + out << "jc=" << config.m_junkPacketCount << "\n"; out << "jmin=" << config.m_junkPacketMinSize << "\n"; out << "jmax=" << config.m_junkPacketMaxSize << "\n"; out << "s1=" << config.m_initPacketJunkSize << "\n"; diff --git a/client/platforms/windows/daemon/wireguardutilswindows.cpp b/client/platforms/windows/daemon/wireguardutilswindows.cpp index 1e0a4752..21df2611 100644 --- a/client/platforms/windows/daemon/wireguardutilswindows.cpp +++ b/client/platforms/windows/daemon/wireguardutilswindows.cpp @@ -165,6 +165,16 @@ bool WireguardUtilsWindows::updatePeer(const InterfaceConfig& config) { out << "allowed_ip=" << ip.toString() << "\n"; } + out << "jc=" << config.m_junkPacketCount << "\n"; + out << "jmin=" << config.m_junkPacketMinSize << "\n"; + out << "jmax=" << config.m_junkPacketMaxSize << "\n"; + out << "s1=" << config.m_initPacketJunkSize << "\n"; + out << "s2=" << config.m_responsePacketJunkSize << "\n"; + out << "h1=" << config.m_initPacketMagicHeader << "\n"; + out << "h2=" << config.m_responsePacketMagicHeader << "\n"; + out << "h3=" << config.m_underloadPacketMagicHeader << "\n"; + out << "h4=" << config.m_transportPacketMagicHeader << "\n"; + // Exclude the server address, except for multihop exit servers. if (config.m_hopType != InterfaceConfig::MultiHopExit) { m_routeMonitor.addExclusionRoute(IPAddress(config.m_serverIpv4AddrIn)); From 423305c35a49e6949a4f62664dc5a9cf2d474a19 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Thu, 28 Sep 2023 02:14:07 +0500 Subject: [PATCH 04/30] moved the configuration of new parameters for awg to addInterface() --- client/daemon/daemon.cpp | 20 +++++++++------- .../linux/daemon/wireguardutilslinux.cpp | 23 ++++++++++-------- .../macos/daemon/wireguardutilsmacos.cpp | 24 ++++++++++--------- .../windows/daemon/wireguardutilswindows.cpp | 10 -------- 4 files changed, 37 insertions(+), 40 deletions(-) diff --git a/client/daemon/daemon.cpp b/client/daemon/daemon.cpp index 13310951..63a5c7f6 100644 --- a/client/daemon/daemon.cpp +++ b/client/daemon/daemon.cpp @@ -360,15 +360,17 @@ bool Daemon::parseConfig(const QJsonObject& obj, InterfaceConfig& config) { return false; } - config.m_junkPacketCount = obj.value("Jc").toString(); - config.m_junkPacketMinSize = obj.value("Jmin").toString(); - config.m_junkPacketMaxSize = obj.value("Jmax").toString(); - config.m_initPacketJunkSize = obj.value("S1").toString(); - config.m_responsePacketJunkSize = obj.value("S2").toString(); - config.m_initPacketMagicHeader = obj.value("H1").toString(); - config.m_responsePacketMagicHeader = obj.value("H2").toString(); - config.m_underloadPacketMagicHeader = obj.value("H3").toString(); - config.m_transportPacketMagicHeader = obj.value("H4").toString(); + if (!obj.value("Jc").isNull()) { + config.m_junkPacketCount = obj.value("Jc").toString(); + config.m_junkPacketMinSize = obj.value("Jmin").toString(); + config.m_junkPacketMaxSize = obj.value("Jmax").toString(); + config.m_initPacketJunkSize = obj.value("S1").toString(); + config.m_responsePacketJunkSize = obj.value("S2").toString(); + config.m_initPacketMagicHeader = obj.value("H1").toString(); + config.m_responsePacketMagicHeader = obj.value("H2").toString(); + config.m_underloadPacketMagicHeader = obj.value("H3").toString(); + config.m_transportPacketMagicHeader = obj.value("H4").toString(); + } return true; } diff --git a/client/platforms/linux/daemon/wireguardutilslinux.cpp b/client/platforms/linux/daemon/wireguardutilslinux.cpp index dbb92f61..792120a7 100644 --- a/client/platforms/linux/daemon/wireguardutilslinux.cpp +++ b/client/platforms/linux/daemon/wireguardutilslinux.cpp @@ -100,6 +100,19 @@ bool WireguardUtilsLinux::addInterface(const InterfaceConfig& config) { QTextStream out(&message); out << "private_key=" << QString(privateKey.toHex()) << "\n"; out << "replace_peers=true\n"; + + if (config.m_junkPacketCount != "") { + out << "jc=" << config.m_junkPacketCount << "\n"; + out << "jmin=" << config.m_junkPacketMinSize << "\n"; + out << "jmax=" << config.m_junkPacketMaxSize << "\n"; + out << "s1=" << config.m_initPacketJunkSize << "\n"; + out << "s2=" << config.m_responsePacketJunkSize << "\n"; + out << "h1=" << config.m_initPacketMagicHeader << "\n"; + out << "h2=" << config.m_responsePacketMagicHeader << "\n"; + out << "h3=" << config.m_underloadPacketMagicHeader << "\n"; + out << "h4=" << config.m_transportPacketMagicHeader << "\n"; + } + int err = uapiErrno(uapiCommand(message)); if (err != 0) { logger.error() << "Interface configuration failed:" << strerror(err); @@ -161,16 +174,6 @@ bool WireguardUtilsLinux::updatePeer(const InterfaceConfig& config) { out << "allowed_ip=" << ip.toString() << "\n"; } - out << "jc=" << config.m_junkPacketCount << "\n"; - out << "jmin=" << config.m_junkPacketMinSize << "\n"; - out << "jmax=" << config.m_junkPacketMaxSize << "\n"; - out << "s1=" << config.m_initPacketJunkSize << "\n"; - out << "s2=" << config.m_responsePacketJunkSize << "\n"; - out << "h1=" << config.m_initPacketMagicHeader << "\n"; - out << "h2=" << config.m_responsePacketMagicHeader << "\n"; - out << "h3=" << config.m_underloadPacketMagicHeader << "\n"; - out << "h4=" << config.m_transportPacketMagicHeader << "\n"; - // Exclude the server address, except for multihop exit servers. if ((config.m_hopType != InterfaceConfig::MultiHopExit) && (m_rtmonitor != nullptr)) { diff --git a/client/platforms/macos/daemon/wireguardutilsmacos.cpp b/client/platforms/macos/daemon/wireguardutilsmacos.cpp index 2170d69e..ef13f4c7 100644 --- a/client/platforms/macos/daemon/wireguardutilsmacos.cpp +++ b/client/platforms/macos/daemon/wireguardutilsmacos.cpp @@ -100,6 +100,19 @@ bool WireguardUtilsMacos::addInterface(const InterfaceConfig& config) { QTextStream out(&message); out << "private_key=" << QString(privateKey.toHex()) << "\n"; out << "replace_peers=true\n"; + + if (config.m_junkPacketCount != "") { + out << "jc=" << config.m_junkPacketCount << "\n"; + out << "jmin=" << config.m_junkPacketMinSize << "\n"; + out << "jmax=" << config.m_junkPacketMaxSize << "\n"; + out << "s1=" << config.m_initPacketJunkSize << "\n"; + out << "s2=" << config.m_responsePacketJunkSize << "\n"; + out << "h1=" << config.m_initPacketMagicHeader << "\n"; + out << "h2=" << config.m_responsePacketMagicHeader << "\n"; + out << "h3=" << config.m_underloadPacketMagicHeader << "\n"; + out << "h4=" << config.m_transportPacketMagicHeader << "\n"; + } + int err = uapiErrno(uapiCommand(message)); if (err != 0) { logger.error() << "Interface configuration failed:" << strerror(err); @@ -163,17 +176,6 @@ bool WireguardUtilsMacos::updatePeer(const InterfaceConfig& config) { out << "allowed_ip=" << ip.toString() << "\n"; } - - out << "jc=" << config.m_junkPacketCount << "\n"; - out << "jmin=" << config.m_junkPacketMinSize << "\n"; - out << "jmax=" << config.m_junkPacketMaxSize << "\n"; - out << "s1=" << config.m_initPacketJunkSize << "\n"; - out << "s2=" << config.m_responsePacketJunkSize << "\n"; - out << "h1=" << config.m_initPacketMagicHeader << "\n"; - out << "h2=" << config.m_responsePacketMagicHeader << "\n"; - out << "h3=" << config.m_underloadPacketMagicHeader << "\n"; - out << "h4=" << config.m_transportPacketMagicHeader << "\n"; - // Exclude the server address, except for multihop exit servers. if ((config.m_hopType != InterfaceConfig::MultiHopExit) && (m_rtmonitor != nullptr)) { diff --git a/client/platforms/windows/daemon/wireguardutilswindows.cpp b/client/platforms/windows/daemon/wireguardutilswindows.cpp index 21df2611..1e0a4752 100644 --- a/client/platforms/windows/daemon/wireguardutilswindows.cpp +++ b/client/platforms/windows/daemon/wireguardutilswindows.cpp @@ -165,16 +165,6 @@ bool WireguardUtilsWindows::updatePeer(const InterfaceConfig& config) { out << "allowed_ip=" << ip.toString() << "\n"; } - out << "jc=" << config.m_junkPacketCount << "\n"; - out << "jmin=" << config.m_junkPacketMinSize << "\n"; - out << "jmax=" << config.m_junkPacketMaxSize << "\n"; - out << "s1=" << config.m_initPacketJunkSize << "\n"; - out << "s2=" << config.m_responsePacketJunkSize << "\n"; - out << "h1=" << config.m_initPacketMagicHeader << "\n"; - out << "h2=" << config.m_responsePacketMagicHeader << "\n"; - out << "h3=" << config.m_underloadPacketMagicHeader << "\n"; - out << "h4=" << config.m_transportPacketMagicHeader << "\n"; - // Exclude the server address, except for multihop exit servers. if (config.m_hopType != InterfaceConfig::MultiHopExit) { m_routeMonitor.addExclusionRoute(IPAddress(config.m_serverIpv4AddrIn)); From 2986a18c8f3bc4bc54e2bfba97511f117f821cfe Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Thu, 28 Sep 2023 23:54:32 +0300 Subject: [PATCH 05/30] iOS AWG support --- .gitmodules | 6 +++--- client/3rd/awg-apple | 1 + client/3rd/wireguard-apple | 1 - client/cmake/ios.cmake | 2 +- client/ios/networkextension/CMakeLists.txt | 2 +- .../WireGuardNetworkExtension-Bridging-Header.h | 4 ++-- client/macos/app/WireGuard-Bridging-Header.h | 2 +- .../WireGuardNetworkExtension-Bridging-Header.h | 2 +- client/platforms/ios/WireGuard-Bridging-Header.h | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) create mode 160000 client/3rd/awg-apple delete mode 160000 client/3rd/wireguard-apple diff --git a/.gitmodules b/.gitmodules index 453a8ee4..c96dd6bc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "client/3rd/wireguard-apple"] - path = client/3rd/wireguard-apple - url = https://github.com/WireGuard/wireguard-apple [submodule "client/3rd/OpenVPNAdapter"] path = client/3rd/OpenVPNAdapter url = https://github.com/amnezia-vpn/OpenVPNAdapter.git @@ -25,3 +22,6 @@ [submodule "client/3rd-prebuilt"] path = client/3rd-prebuilt url = https://github.com/amnezia-vpn/3rd-prebuilt +[submodule "client/3rd/awg-apple"] + path = client/3rd/awg-apple + url = https://github.com/amnezia-vpn/awg-apple diff --git a/client/3rd/awg-apple b/client/3rd/awg-apple new file mode 160000 index 00000000..5767a03f --- /dev/null +++ b/client/3rd/awg-apple @@ -0,0 +1 @@ +Subproject commit 5767a03f75a2b77d4f78fdd77ff51a1eefabe3b0 diff --git a/client/3rd/wireguard-apple b/client/3rd/wireguard-apple deleted file mode 160000 index 23618f99..00000000 --- a/client/3rd/wireguard-apple +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 23618f994f17d8ad8f2f65d79b4a1e8a0830b334 diff --git a/client/cmake/ios.cmake b/client/cmake/ios.cmake index 5dc1b2e7..7aa9f1a9 100644 --- a/client/cmake/ios.cmake +++ b/client/cmake/ios.cmake @@ -97,7 +97,7 @@ target_compile_options(${PROJECT} PRIVATE -DVPN_NE_BUNDLEID=\"${BUILD_IOS_APP_IDENTIFIER}.network-extension\" ) -set(WG_APPLE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rd/wireguard-apple/Sources) +set(WG_APPLE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rd/awg-apple/Sources) target_sources(${PROJECT} PRIVATE # ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/iosvpnprotocol.swift diff --git a/client/ios/networkextension/CMakeLists.txt b/client/ios/networkextension/CMakeLists.txt index 29dc0bbe..16769ea3 100644 --- a/client/ios/networkextension/CMakeLists.txt +++ b/client/ios/networkextension/CMakeLists.txt @@ -58,7 +58,7 @@ target_link_libraries(networkextension PRIVATE ${FW_UI_KIT}) target_compile_options(networkextension PRIVATE -DGROUP_ID=\"${BUILD_IOS_GROUP_IDENTIFIER}\") target_compile_options(networkextension PRIVATE -DNETWORK_EXTENSION=1) -set(WG_APPLE_SOURCE_DIR ${CLIENT_ROOT_DIR}/3rd/wireguard-apple/Sources) +set(WG_APPLE_SOURCE_DIR ${CLIENT_ROOT_DIR}/3rd/awg-apple/Sources) target_sources(networkextension PRIVATE ${WG_APPLE_SOURCE_DIR}/WireGuardKit/WireGuardAdapter.swift diff --git a/client/ios/networkextension/WireGuardNetworkExtension-Bridging-Header.h b/client/ios/networkextension/WireGuardNetworkExtension-Bridging-Header.h index 03a987ad..44d0b6b0 100644 --- a/client/ios/networkextension/WireGuardNetworkExtension-Bridging-Header.h +++ b/client/ios/networkextension/WireGuardNetworkExtension-Bridging-Header.h @@ -1,6 +1,6 @@ #include "wireguard-go-version.h" -#include "3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard.h" -#include "3rd/wireguard-apple/Sources/WireGuardKitC/WireGuardKitC.h" +#include "3rd/awg-apple/Sources/WireGuardKitGo/wireguard.h" +#include "3rd/awg-apple/Sources/WireGuardKitC/WireGuardKitC.h" #include #include diff --git a/client/macos/app/WireGuard-Bridging-Header.h b/client/macos/app/WireGuard-Bridging-Header.h index 40b6c89d..da71002d 100644 --- a/client/macos/app/WireGuard-Bridging-Header.h +++ b/client/macos/app/WireGuard-Bridging-Header.h @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "wireguard-go-version.h" -#include "3rd/wireguard-apple/Sources/WireGuardKitC/WireGuardKitC.h" +#include "3rd/awg-apple/Sources/WireGuardKitC/WireGuardKitC.h" #include #include diff --git a/client/macos/networkextension/WireGuardNetworkExtension-Bridging-Header.h b/client/macos/networkextension/WireGuardNetworkExtension-Bridging-Header.h index 8a437ce0..ea5c8e38 100644 --- a/client/macos/networkextension/WireGuardNetworkExtension-Bridging-Header.h +++ b/client/macos/networkextension/WireGuardNetworkExtension-Bridging-Header.h @@ -4,7 +4,7 @@ #include "macos/gobridge/wireguard.h" #include "wireguard-go-version.h" -#include "3rd/wireguard-apple/Sources/WireGuardKitC/WireGuardKitC.h" +#include "3rd/awg-apple/Sources/WireGuardKitC/WireGuardKitC.h" #include "3rd/ShadowSocks/ShadowSocks/ShadowSocks.h" #include "platforms/ios/ssconnectivity.h" #include "platforms/ios/iosopenvpn2ssadapter.h" diff --git a/client/platforms/ios/WireGuard-Bridging-Header.h b/client/platforms/ios/WireGuard-Bridging-Header.h index e5dfa39f..fbccb2d4 100644 --- a/client/platforms/ios/WireGuard-Bridging-Header.h +++ b/client/platforms/ios/WireGuard-Bridging-Header.h @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "3rd/wireguard-apple/Sources/WireGuardKitC/WireGuardKitC.h" +#include "3rd/awg-apple/Sources/WireGuardKitC/WireGuardKitC.h" #include #include From 54b45a36e124176fe05ff620ef43ff9fccbd2c3f Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Fri, 29 Sep 2023 18:41:00 +0500 Subject: [PATCH 06/30] test configuration using wg instead of wg-quick to configure the server --- client/server_scripts/amnezia_wireguard/Dockerfile | 2 +- .../amnezia_wireguard/configure_container.sh | 2 +- client/server_scripts/amnezia_wireguard/start.sh | 7 ++++--- client/server_scripts/build_container.sh | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/client/server_scripts/amnezia_wireguard/Dockerfile b/client/server_scripts/amnezia_wireguard/Dockerfile index ed974dc6..8c536fc7 100644 --- a/client/server_scripts/amnezia_wireguard/Dockerfile +++ b/client/server_scripts/amnezia_wireguard/Dockerfile @@ -3,7 +3,7 @@ FROM amneziavpn/amnezia-wg:latest LABEL maintainer="AmneziaVPN" #Install required packages -RUN apk add --no-cache curl wireguard-tools dumb-init +RUN apk add --no-cache bash curl dumb-init RUN apk --update upgrade --no-cache RUN mkdir -p /opt/amnezia diff --git a/client/server_scripts/amnezia_wireguard/configure_container.sh b/client/server_scripts/amnezia_wireguard/configure_container.sh index 8653a932..fa7b09f9 100644 --- a/client/server_scripts/amnezia_wireguard/configure_container.sh +++ b/client/server_scripts/amnezia_wireguard/configure_container.sh @@ -12,7 +12,7 @@ echo $WIREGUARD_PSK > /opt/amnezia/amneziawireguard/wireguard_psk.key cat > /opt/amnezia/amneziawireguard/wg0.conf < Date: Sat, 30 Sep 2023 00:58:08 +0300 Subject: [PATCH 07/30] iOS AWG protocol Setup --- client/3rd-prebuilt | 2 +- client/containers/containers_defs.cpp | 1 + client/platforms/ios/ios_controller.h | 1 + client/platforms/ios/ios_controller.mm | 12 ++++++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/client/3rd-prebuilt b/client/3rd-prebuilt index e8795854..6f0d654a 160000 --- a/client/3rd-prebuilt +++ b/client/3rd-prebuilt @@ -1 +1 @@ -Subproject commit e8795854a5cf27004fe78caecc90a961688d1d41 +Subproject commit 6f0d654a2409e2f634e7f7b95d34998c8eba2d7b diff --git a/client/containers/containers_defs.cpp b/client/containers/containers_defs.cpp index 21f7b044..0b9e44a2 100644 --- a/client/containers/containers_defs.cpp +++ b/client/containers/containers_defs.cpp @@ -186,6 +186,7 @@ bool ContainerProps::isSupportedByCurrentPlatform(DockerContainer c) switch (c) { case DockerContainer::WireGuard: return true; case DockerContainer::OpenVpn: return true; + case DockerContainer::AmneziaWireGuard: return true; case DockerContainer::Cloak: return true; // case DockerContainer::ShadowSocks: return true; diff --git a/client/platforms/ios/ios_controller.h b/client/platforms/ios/ios_controller.h index ea8adbc0..6d10dc08 100644 --- a/client/platforms/ios/ios_controller.h +++ b/client/platforms/ios/ios_controller.h @@ -62,6 +62,7 @@ private: bool setupOpenVPN(); bool setupCloak(); bool setupWireGuard(); + bool setupAmneziaWireGuard(); bool startOpenVPN(const QString &config); bool startWireGuard(const QString &jsonConfig); diff --git a/client/platforms/ios/ios_controller.mm b/client/platforms/ios/ios_controller.mm index 57394383..6782c8da 100644 --- a/client/platforms/ios/ios_controller.mm +++ b/client/platforms/ios/ios_controller.mm @@ -204,6 +204,9 @@ bool IosController::connectVpn(amnezia::Proto proto, const QJsonObject& configur if (proto == amnezia::Proto::WireGuard) { return setupWireGuard(); } + if (proto == amnezia::Proto::AmneziaWireGuard) { + return setupAmneziaWireGuard(); + } return false; } @@ -307,6 +310,15 @@ bool IosController::setupWireGuard() return startWireGuard(wgConfig); } +bool IosController::setupAmneziaWireGuard() +{ + QJsonObject config = m_rawConfig[ProtocolProps::key_proto_config_data(amnezia::Proto::AmneziaWireGuard)].toObject(); + + QString wgConfig = config[config_key::config].toString(); + + return startWireGuard(wgConfig); +} + bool IosController::startOpenVPN(const QString &config) { qDebug() << "IosController::startOpenVPN"; From 4ed153373f585d93ddf3c566ba63fbf7cc43cba3 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Sat, 30 Sep 2023 16:05:23 -0400 Subject: [PATCH 08/30] Fix Linux build, some naming changes --- .../{amneziaWireGuardConfigurator.cpp => awg_configurator.cpp} | 2 +- .../{amneziaWireGuardConfigurator.h => awg_configurator.h} | 0 client/configurators/vpn_configurator.cpp | 2 +- ...mneziaWireGuardProtocol.cpp => amneziawireguardprotocol.cpp} | 2 +- .../{amneziaWireGuardProtocol.h => amneziawireguardprotocol.h} | 0 5 files changed, 3 insertions(+), 3 deletions(-) rename client/configurators/{amneziaWireGuardConfigurator.cpp => awg_configurator.cpp} (98%) rename client/configurators/{amneziaWireGuardConfigurator.h => awg_configurator.h} (100%) rename client/protocols/{amneziaWireGuardProtocol.cpp => amneziawireguardprotocol.cpp} (84%) rename client/protocols/{amneziaWireGuardProtocol.h => amneziawireguardprotocol.h} (100%) diff --git a/client/configurators/amneziaWireGuardConfigurator.cpp b/client/configurators/awg_configurator.cpp similarity index 98% rename from client/configurators/amneziaWireGuardConfigurator.cpp rename to client/configurators/awg_configurator.cpp index 3ed27208..85dbd6de 100644 --- a/client/configurators/amneziaWireGuardConfigurator.cpp +++ b/client/configurators/awg_configurator.cpp @@ -1,4 +1,4 @@ -#include "amneziaWireGuardConfigurator.h" +#include "awg_configurator.h" #include #include diff --git a/client/configurators/amneziaWireGuardConfigurator.h b/client/configurators/awg_configurator.h similarity index 100% rename from client/configurators/amneziaWireGuardConfigurator.h rename to client/configurators/awg_configurator.h diff --git a/client/configurators/vpn_configurator.cpp b/client/configurators/vpn_configurator.cpp index 6706deed..8ab43499 100644 --- a/client/configurators/vpn_configurator.cpp +++ b/client/configurators/vpn_configurator.cpp @@ -5,7 +5,7 @@ #include "shadowsocks_configurator.h" #include "ssh_configurator.h" #include "wireguard_configurator.h" -#include "amneziaWireGuardConfigurator.h" +#include "awg_configurator.h" #include #include diff --git a/client/protocols/amneziaWireGuardProtocol.cpp b/client/protocols/amneziawireguardprotocol.cpp similarity index 84% rename from client/protocols/amneziaWireGuardProtocol.cpp rename to client/protocols/amneziawireguardprotocol.cpp index b4c5b430..cab03da9 100644 --- a/client/protocols/amneziaWireGuardProtocol.cpp +++ b/client/protocols/amneziawireguardprotocol.cpp @@ -1,4 +1,4 @@ -#include "amneziaWireGuardProtocol.h" +#include "amneziawireguardprotocol.h" AmneziaWireGuardProtocol::AmneziaWireGuardProtocol(const QJsonObject &configuration, QObject *parent) : WireguardProtocol(configuration, parent) diff --git a/client/protocols/amneziaWireGuardProtocol.h b/client/protocols/amneziawireguardprotocol.h similarity index 100% rename from client/protocols/amneziaWireGuardProtocol.h rename to client/protocols/amneziawireguardprotocol.h From 39c2124a26d1401fa4434fb790ff2780f5a20d84 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Sun, 1 Oct 2023 21:43:30 +0500 Subject: [PATCH 09/30] returned the awg setting via wg-quick --- client/server_scripts/amnezia_wireguard/start.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client/server_scripts/amnezia_wireguard/start.sh b/client/server_scripts/amnezia_wireguard/start.sh index 505ce53e..b371d5b5 100644 --- a/client/server_scripts/amnezia_wireguard/start.sh +++ b/client/server_scripts/amnezia_wireguard/start.sh @@ -6,11 +6,10 @@ echo "Container startup" #ifconfig eth0:0 $SERVER_IP_ADDRESS netmask 255.255.255.255 up # kill daemons in case of restart -# wg-quick down /opt/amnezia/amneziawireguard/wg0.conf +wg-quick down /opt/amnezia/amneziawireguard/wg0.conf -/usr/bin/amnezia-wg wg0 && /usr/bin/wg setconf wg0 /opt/amnezia/amneziawireguard/wg0.conf && ip address add dev wg0 10.8.1.1/24 && ip link set up dev wg0 -# # # start daemons if configured -# # if [ -f /opt/amnezia/amneziawireguard/wg0.conf ]; then (wg-quick up /opt/amnezia/amneziawireguard/wg0.conf); fi +# start daemons if configured +if [ -f /opt/amnezia/amneziawireguard/wg0.conf ]; then (wg-quick up /opt/amnezia/amneziawireguard/wg0.conf); fi # Allow traffic on the TUN interface. iptables -A INPUT -i wg0 -j ACCEPT From 50b8b3d649714a3465fbebaa0aa26543fa0b3ad1 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Mon, 2 Oct 2023 18:30:32 +0500 Subject: [PATCH 10/30] added parsing of wireguard config parameters when importing native configs --- client/ui/controllers/importController.cpp | 68 +++++++++++++++++++--- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/client/ui/controllers/importController.cpp b/client/ui/controllers/importController.cpp index d9278ece..f9cc2d03 100644 --- a/client/ui/controllers/importController.cpp +++ b/client/ui/controllers/importController.cpp @@ -223,21 +223,75 @@ QJsonObject ImportController::extractOpenVpnConfig(const QString &data) QJsonObject ImportController::extractWireGuardConfig(const QString &data) { + QMap configMap; + auto configByLines = data.split("\n"); + for (const QString &line : configByLines) { + QString trimmedLine = line.trimmed(); + if (trimmedLine.startsWith("[") && trimmedLine.endsWith("]")) { + continue; + } else { + QStringList parts = trimmedLine.split(" = "); + if (parts.count() == 2) { + configMap[parts.at(0).trimmed()] = parts.at(1).trimmed(); + } + } + } + QJsonObject lastConfig; lastConfig[config_key::config] = data; - const static QRegularExpression hostNameAndPortRegExp("Endpoint = (.*)(?::([0-9]*))?"); + const static QRegularExpression hostNameAndPortRegExp("Endpoint = (.*):([0-9]*)"); QRegularExpressionMatch hostNameAndPortMatch = hostNameAndPortRegExp.match(data); QString hostName; QString port; if (hostNameAndPortMatch.hasCaptured(1)) { hostName = hostNameAndPortMatch.captured(1); - } /*else { - qDebug() << "send error?" - }*/ + } else { + qDebug() << "Failed to import profile"; + emit importErrorOccurred(errorString(ErrorCode::ImportInvalidConfigError)); + } if (hostNameAndPortMatch.hasCaptured(2)) { port = hostNameAndPortMatch.captured(2); + } else { + port = protocols::wireguard::defaultPort; + } + + lastConfig[config_key::hostName] = hostName; + lastConfig[config_key::port] = port.toInt(); + +// if (!configMap.value("PrivateKey").isEmpty() && !configMap.value("Address").isEmpty() +// && !configMap.value("PresharedKey").isEmpty() && !configMap.value("PublicKey").isEmpty()) { + lastConfig[config_key::client_priv_key] = configMap.value("PrivateKey"); + lastConfig[config_key::client_ip] = configMap.value("Address"); + lastConfig[config_key::psk_key] = configMap.value("PresharedKey"); + lastConfig[config_key::server_pub_key] = configMap.value("PublicKey"); +// } else { +// qDebug() << "Failed to import profile"; +// emit importErrorOccurred(errorString(ErrorCode::ImportInvalidConfigError)); +// return QJsonObject(); +// } + + QString protocolName = "wireguard"; + if (!configMap.value(config_key::junkPacketCount).isEmpty() + && !configMap.value(config_key::junkPacketMinSize).isEmpty() + && !configMap.value(config_key::junkPacketMaxSize).isEmpty() + && !configMap.value(config_key::initPacketJunkSize).isEmpty() + && !configMap.value(config_key::responsePacketJunkSize).isEmpty() + && !configMap.value(config_key::initPacketMagicHeader).isEmpty() + && !configMap.value(config_key::responsePacketMagicHeader).isEmpty() + && !configMap.value(config_key::underloadPacketMagicHeader).isEmpty() + && !configMap.value(config_key::transportPacketMagicHeader).isEmpty()) { + lastConfig[config_key::junkPacketCount] = configMap.value(config_key::junkPacketCount); + lastConfig[config_key::junkPacketMinSize] = configMap.value(config_key::junkPacketMinSize); + lastConfig[config_key::junkPacketMaxSize] = configMap.value(config_key::junkPacketMaxSize); + lastConfig[config_key::initPacketJunkSize] = configMap.value(config_key::initPacketJunkSize); + lastConfig[config_key::responsePacketJunkSize] = configMap.value(config_key::responsePacketJunkSize); + lastConfig[config_key::initPacketMagicHeader] = configMap.value(config_key::initPacketMagicHeader); + lastConfig[config_key::responsePacketMagicHeader] = configMap.value(config_key::responsePacketMagicHeader); + lastConfig[config_key::underloadPacketMagicHeader] = configMap.value(config_key::underloadPacketMagicHeader); + lastConfig[config_key::transportPacketMagicHeader] = configMap.value(config_key::transportPacketMagicHeader); + protocolName = "amneziawireguard"; } QJsonObject wireguardConfig; @@ -247,15 +301,15 @@ QJsonObject ImportController::extractWireGuardConfig(const QString &data) wireguardConfig[config_key::transport_proto] = "udp"; QJsonObject containers; - containers.insert(config_key::container, QJsonValue("amnezia-wireguard")); - containers.insert(config_key::wireguard, QJsonValue(wireguardConfig)); + containers.insert(config_key::container, QJsonValue("amnezia-" + protocolName)); + containers.insert(protocolName, QJsonValue(wireguardConfig)); QJsonArray arr; arr.push_back(containers); QJsonObject config; config[config_key::containers] = arr; - config[config_key::defaultContainer] = "amnezia-wireguard"; + config[config_key::defaultContainer] = "amnezia-" + protocolName; config[config_key::description] = m_settings->nextAvailableServerName(); const static QRegularExpression dnsRegExp( From 304f29bfac020be5600ef1a8c9c2dc59177a4805 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Mon, 2 Oct 2023 20:03:01 +0500 Subject: [PATCH 11/30] returned 'address' to awg server config and set it to 10.8.1.1/24 --- client/server_scripts/amnezia_wireguard/configure_container.sh | 2 +- client/server_scripts/amnezia_wireguard/start.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/client/server_scripts/amnezia_wireguard/configure_container.sh b/client/server_scripts/amnezia_wireguard/configure_container.sh index fa7b09f9..6ebebc4a 100644 --- a/client/server_scripts/amnezia_wireguard/configure_container.sh +++ b/client/server_scripts/amnezia_wireguard/configure_container.sh @@ -12,7 +12,7 @@ echo $WIREGUARD_PSK > /opt/amnezia/amneziawireguard/wireguard_psk.key cat > /opt/amnezia/amneziawireguard/wg0.conf < Date: Mon, 2 Oct 2023 18:48:11 +0300 Subject: [PATCH 12/30] added parsing parameters for windows --- client/daemon/daemon.cpp | 6 +++++- client/daemon/interfaceconfig.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/client/daemon/daemon.cpp b/client/daemon/daemon.cpp index 63a5c7f6..b85b2c33 100644 --- a/client/daemon/daemon.cpp +++ b/client/daemon/daemon.cpp @@ -360,7 +360,11 @@ bool Daemon::parseConfig(const QJsonObject& obj, InterfaceConfig& config) { return false; } - if (!obj.value("Jc").isNull()) { + if (!obj.value("Jc").isNull() && !obj.value("Jmin").isNull() + && !obj.value("Jmax").isNull() && !obj.value("S1").isNull() + && !obj.value("S2").isNull() && !obj.value("H1").isNull() + && !obj.value("H2").isNull() && !obj.value("H3").isNull() + && !obj.value("H4").isNull()) { config.m_junkPacketCount = obj.value("Jc").toString(); config.m_junkPacketMinSize = obj.value("Jmin").toString(); config.m_junkPacketMaxSize = obj.value("Jmax").toString(); diff --git a/client/daemon/interfaceconfig.cpp b/client/daemon/interfaceconfig.cpp index 68bebca0..b24a35c7 100644 --- a/client/daemon/interfaceconfig.cpp +++ b/client/daemon/interfaceconfig.cpp @@ -97,6 +97,37 @@ QString InterfaceConfig::toWgConf(const QMap& extra) const { out << "DNS = " << dnsServers.join(", ") << "\n"; } + if (!m_junkPacketCount.isNull()) { + out << "JunkPacketCount = " << m_junkPacketCount << "\n"; + } + if (!m_junkPacketMinSize.isNull()) { + out << "JunkPacketMinSize = " << m_junkPacketMinSize << "\n"; + } + if (!m_junkPacketMaxSize.isNull()) { + out << "JunkPacketMaxSize = " << m_junkPacketMaxSize << "\n"; + } + if (!m_initPacketJunkSize.isNull()) { + out << "InitPacketJunkSize = " << m_initPacketJunkSize << "\n"; + } + if (!m_responsePacketJunkSize.isNull()) { + out << "ResponsePacketJunkSize = " << m_responsePacketJunkSize << "\n"; + } + if (!m_initPacketMagicHeader.isNull()) { + out << "InitPacketMagicHeader = " << m_initPacketMagicHeader << "\n"; + } + if (!m_responsePacketMagicHeader.isNull()) { + out << "ResponsePacketMagicHeader = " << m_responsePacketMagicHeader + << "\n"; + } + if (!m_underloadPacketMagicHeader.isNull()) { + out << "UnderloadPacketMagicHeader = " << m_underloadPacketMagicHeader + << "\n"; + } + if (!m_transportPacketMagicHeader.isNull()) { + out << "TransportPacketMagicHeader = " << m_transportPacketMagicHeader + << "\n"; + } + // If any extra config was provided, append it now. for (const QString& key : extra.keys()) { out << key << " = " << extra[key] << "\n"; From 9df262d5028c36de1ac4b0af00c02dd7f7021bad Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Wed, 4 Oct 2023 19:14:27 +0300 Subject: [PATCH 13/30] fixed sending parameters to the awg daemon for windows --- client/daemon/interfaceconfig.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/client/daemon/interfaceconfig.cpp b/client/daemon/interfaceconfig.cpp index b24a35c7..8aa06b9b 100644 --- a/client/daemon/interfaceconfig.cpp +++ b/client/daemon/interfaceconfig.cpp @@ -98,34 +98,31 @@ QString InterfaceConfig::toWgConf(const QMap& extra) const { } if (!m_junkPacketCount.isNull()) { - out << "JunkPacketCount = " << m_junkPacketCount << "\n"; + out << "Jc = " << m_junkPacketCount << "\n"; } if (!m_junkPacketMinSize.isNull()) { - out << "JunkPacketMinSize = " << m_junkPacketMinSize << "\n"; + out << "JMin = " << m_junkPacketMinSize << "\n"; } if (!m_junkPacketMaxSize.isNull()) { - out << "JunkPacketMaxSize = " << m_junkPacketMaxSize << "\n"; + out << "JMax = " << m_junkPacketMaxSize << "\n"; } if (!m_initPacketJunkSize.isNull()) { - out << "InitPacketJunkSize = " << m_initPacketJunkSize << "\n"; + out << "S1 = " << m_initPacketJunkSize << "\n"; } if (!m_responsePacketJunkSize.isNull()) { - out << "ResponsePacketJunkSize = " << m_responsePacketJunkSize << "\n"; + out << "S2 = " << m_responsePacketJunkSize << "\n"; } if (!m_initPacketMagicHeader.isNull()) { - out << "InitPacketMagicHeader = " << m_initPacketMagicHeader << "\n"; + out << "H1 = " << m_initPacketMagicHeader << "\n"; } if (!m_responsePacketMagicHeader.isNull()) { - out << "ResponsePacketMagicHeader = " << m_responsePacketMagicHeader - << "\n"; + out << "H2 = " << m_responsePacketMagicHeader << "\n"; } if (!m_underloadPacketMagicHeader.isNull()) { - out << "UnderloadPacketMagicHeader = " << m_underloadPacketMagicHeader - << "\n"; + out << "H3 = " << m_underloadPacketMagicHeader << "\n"; } if (!m_transportPacketMagicHeader.isNull()) { - out << "TransportPacketMagicHeader = " << m_transportPacketMagicHeader - << "\n"; + out << "H4 = " << m_transportPacketMagicHeader << "\n"; } // If any extra config was provided, append it now. From 3a77705142d8ee99c73f3269986d27bda9499ed9 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Thu, 5 Oct 2023 15:55:32 -0400 Subject: [PATCH 14/30] Update AWG binary --- client/3rd-prebuilt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/3rd-prebuilt b/client/3rd-prebuilt index 6f0d654a..c6d77cff 160000 --- a/client/3rd-prebuilt +++ b/client/3rd-prebuilt @@ -1 +1 @@ -Subproject commit 6f0d654a2409e2f634e7f7b95d34998c8eba2d7b +Subproject commit c6d77cff35bcdef34306ab5ef594a313726949da From 08863edb520d99ac2931510469302ca1d755f730 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Thu, 5 Oct 2023 17:11:40 -0400 Subject: [PATCH 15/30] Update AWG iOS binary again --- client/3rd-prebuilt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/3rd-prebuilt b/client/3rd-prebuilt index c6d77cff..994f4f2b 160000 --- a/client/3rd-prebuilt +++ b/client/3rd-prebuilt @@ -1 +1 @@ -Subproject commit c6d77cff35bcdef34306ab5ef594a313726949da +Subproject commit 994f4f2b030600f2d8dbf9dccf409b1591c9e463 From d77be5a244252849720763ff7a2c7e672f53b520 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Fri, 6 Oct 2023 00:38:54 +0300 Subject: [PATCH 16/30] Update iOS network extension --- client/3rd/awg-apple | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/3rd/awg-apple b/client/3rd/awg-apple index 5767a03f..fab07138 160000 --- a/client/3rd/awg-apple +++ b/client/3rd/awg-apple @@ -1 +1 @@ -Subproject commit 5767a03f75a2b77d4f78fdd77ff51a1eefabe3b0 +Subproject commit fab07138dbab06ac0de256021e47e273f4df8e88 From b7a65343af4373753841b7db3c8f2bd5c4260cc6 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Fri, 6 Oct 2023 16:43:52 +0500 Subject: [PATCH 17/30] added the ability to change awg parameters on the protocol settings page --- client/configurators/awg_configurator.cpp | 73 ++++++----- .../configurators/wireguard_configurator.cpp | 8 +- client/configurators/wireguard_configurator.h | 2 + client/core/servercontroller.cpp | 4 + .../protocols/amneziaWireGuardConfigModel.cpp | 81 ++++++++++-- .../protocols/amneziaWireGuardConfigModel.h | 10 +- .../Components/SettingsContainersListView.qml | 2 +- .../qml/Controls2/TextFieldWithHeaderType.qml | 7 ++ .../PageProtocolAmneziaWireGuardSettings.qml | 117 +++++++++++++----- 9 files changed, 224 insertions(+), 80 deletions(-) diff --git a/client/configurators/awg_configurator.cpp b/client/configurators/awg_configurator.cpp index 85dbd6de..6ed1cd1b 100644 --- a/client/configurators/awg_configurator.cpp +++ b/client/configurators/awg_configurator.cpp @@ -3,6 +3,8 @@ #include #include +#include "core/servercontroller.h" + AmneziaWireGuardConfigurator::AmneziaWireGuardConfigurator(std::shared_ptr settings, QObject *parent) : WireguardConfigurator(settings, true, parent) { @@ -15,46 +17,43 @@ QString AmneziaWireGuardConfigurator::genAmneziaWireGuardConfig(const ServerCred QString config = WireguardConfigurator::genWireguardConfig(credentials, container, containerConfig, errorCode); QJsonObject jsonConfig = QJsonDocument::fromJson(config.toUtf8()).object(); - QJsonObject awgConfig = containerConfig.value(config_key::amneziaWireguard).toObject(); - auto junkPacketCount = - awgConfig.value(config_key::junkPacketCount).toString(protocols::amneziawireguard::defaultJunkPacketCount); - auto junkPacketMinSize = - awgConfig.value(config_key::junkPacketMinSize).toString(protocols::amneziawireguard::defaultJunkPacketMinSize); - auto junkPacketMaxSize = - awgConfig.value(config_key::junkPacketMaxSize).toString(protocols::amneziawireguard::defaultJunkPacketMaxSize); - auto initPacketJunkSize = - awgConfig.value(config_key::initPacketJunkSize).toString(protocols::amneziawireguard::defaultInitPacketJunkSize); - auto responsePacketJunkSize = - awgConfig.value(config_key::responsePacketJunkSize).toString(protocols::amneziawireguard::defaultResponsePacketJunkSize); - auto initPacketMagicHeader = - awgConfig.value(config_key::initPacketMagicHeader).toString(protocols::amneziawireguard::defaultInitPacketMagicHeader); - auto responsePacketMagicHeader = - awgConfig.value(config_key::responsePacketMagicHeader).toString(protocols::amneziawireguard::defaultResponsePacketMagicHeader); - auto underloadPacketMagicHeader = - awgConfig.value(config_key::underloadPacketMagicHeader).toString(protocols::amneziawireguard::defaultUnderloadPacketMagicHeader); - auto transportPacketMagicHeader = - awgConfig.value(config_key::transportPacketMagicHeader).toString(protocols::amneziawireguard::defaultTransportPacketMagicHeader); + ServerController serverController(m_settings); + QString serverConfig = serverController.getTextFileFromContainer(container, credentials, protocols::amneziawireguard::serverConfigPath, errorCode); - config.replace("$JUNK_PACKET_COUNT", junkPacketCount); - config.replace("$JUNK_PACKET_MIN_SIZE", junkPacketMinSize); - config.replace("$JUNK_PACKET_MAX_SIZE", junkPacketMaxSize); - config.replace("$INIT_PACKET_JUNK_SIZE", initPacketJunkSize); - config.replace("$RESPONSE_PACKET_JUNK_SIZE", responsePacketJunkSize); - config.replace("$INIT_PACKET_MAGIC_HEADER", initPacketMagicHeader); - config.replace("$RESPONSE_PACKET_MAGIC_HEADER", responsePacketMagicHeader); - config.replace("$UNDERLOAD_PACKET_MAGIC_HEADER", underloadPacketMagicHeader); - config.replace("$TRANSPORT_PACKET_MAGIC_HEADER", transportPacketMagicHeader); + QMap serverConfigMap; + auto serverConfigLines = serverConfig.split("\n"); + for (auto &line : serverConfigLines) { + auto trimmedLine = line.trimmed(); + if (trimmedLine.startsWith("[") && trimmedLine.endsWith("]")) { + continue; + } else { + QStringList parts = trimmedLine.split(" = "); + if (parts.count() == 2) { + serverConfigMap.insert(parts[0].trimmed(), parts[1].trimmed()); + } + } + } - jsonConfig[config_key::junkPacketCount] = junkPacketCount; - jsonConfig[config_key::junkPacketMinSize] = junkPacketMinSize; - jsonConfig[config_key::junkPacketMaxSize] = junkPacketMaxSize; - jsonConfig[config_key::initPacketJunkSize] = initPacketJunkSize; - jsonConfig[config_key::responsePacketJunkSize] = responsePacketJunkSize; - jsonConfig[config_key::initPacketMagicHeader] = initPacketMagicHeader; - jsonConfig[config_key::responsePacketMagicHeader] = responsePacketMagicHeader; - jsonConfig[config_key::underloadPacketMagicHeader] = underloadPacketMagicHeader; - jsonConfig[config_key::transportPacketMagicHeader] = transportPacketMagicHeader; + config.replace("$JUNK_PACKET_COUNT", serverConfigMap.value(config_key::junkPacketCount)); + config.replace("$JUNK_PACKET_MIN_SIZE", serverConfigMap.value(config_key::junkPacketMinSize)); + config.replace("$JUNK_PACKET_MAX_SIZE", serverConfigMap.value(config_key::junkPacketMaxSize)); + config.replace("$INIT_PACKET_JUNK_SIZE", serverConfigMap.value(config_key::initPacketJunkSize)); + config.replace("$RESPONSE_PACKET_JUNK_SIZE", serverConfigMap.value(config_key::responsePacketJunkSize)); + config.replace("$INIT_PACKET_MAGIC_HEADER", serverConfigMap.value(config_key::initPacketMagicHeader)); + config.replace("$RESPONSE_PACKET_MAGIC_HEADER", serverConfigMap.value(config_key::responsePacketMagicHeader)); + config.replace("$UNDERLOAD_PACKET_MAGIC_HEADER", serverConfigMap.value(config_key::underloadPacketMagicHeader)); + config.replace("$TRANSPORT_PACKET_MAGIC_HEADER", serverConfigMap.value(config_key::transportPacketMagicHeader)); + + jsonConfig[config_key::junkPacketCount] = serverConfigMap.value(config_key::junkPacketCount); + jsonConfig[config_key::junkPacketMinSize] = serverConfigMap.value(config_key::junkPacketMinSize); + jsonConfig[config_key::junkPacketMaxSize] = serverConfigMap.value(config_key::junkPacketMaxSize); + jsonConfig[config_key::initPacketJunkSize] = serverConfigMap.value(config_key::initPacketJunkSize); + jsonConfig[config_key::responsePacketJunkSize] = serverConfigMap.value(config_key::responsePacketJunkSize); + jsonConfig[config_key::initPacketMagicHeader] = serverConfigMap.value(config_key::initPacketMagicHeader); + jsonConfig[config_key::responsePacketMagicHeader] = serverConfigMap.value(config_key::responsePacketMagicHeader); + jsonConfig[config_key::underloadPacketMagicHeader] = serverConfigMap.value(config_key::underloadPacketMagicHeader); + jsonConfig[config_key::transportPacketMagicHeader] = serverConfigMap.value(config_key::transportPacketMagicHeader); return QJsonDocument(jsonConfig).toJson(); } diff --git a/client/configurators/wireguard_configurator.cpp b/client/configurators/wireguard_configurator.cpp index dd836a18..5ea042c1 100644 --- a/client/configurators/wireguard_configurator.cpp +++ b/client/configurators/wireguard_configurator.cpp @@ -30,6 +30,9 @@ WireguardConfigurator::WireguardConfigurator(std::shared_ptr settings, : amnezia::protocols::wireguard::serverPskKeyPath; m_configTemplate = m_isAmneziaWireGuard ? ProtocolScriptType::amnezia_wireguard_template : ProtocolScriptType::wireguard_template; + + m_protocolName = m_isAmneziaWireGuard ? config_key::amneziaWireguard : config_key::wireguard; + m_defaultPort = m_isAmneziaWireGuard ? protocols::wireguard::defaultPort : protocols::amneziawireguard::defaultPort; } WireguardConfigurator::ConnectionData WireguardConfigurator::genClientKeys() @@ -70,10 +73,7 @@ WireguardConfigurator::ConnectionData WireguardConfigurator::prepareWireguardCon { WireguardConfigurator::ConnectionData connData = WireguardConfigurator::genClientKeys(); connData.host = credentials.hostName; - connData.port = containerConfig.value(m_isAmneziaWireGuard ? config_key::amneziaWireguard : config_key::wireguard) - .toObject() - .value(config_key::port) - .toString(protocols::wireguard::defaultPort); + connData.port = containerConfig.value(m_protocolName).toObject().value(config_key::port).toString(m_defaultPort); if (connData.clientPrivKey.isEmpty() || connData.clientPubKey.isEmpty()) { if (errorCode) diff --git a/client/configurators/wireguard_configurator.h b/client/configurators/wireguard_configurator.h index 70ed729b..10eecbb4 100644 --- a/client/configurators/wireguard_configurator.h +++ b/client/configurators/wireguard_configurator.h @@ -42,6 +42,8 @@ private: QString m_serverPublicKeyPath; QString m_serverPskKeyPath; amnezia::ProtocolScriptType m_configTemplate; + QString m_protocolName; + QString m_defaultPort; }; #endif // WIREGUARD_CONFIGURATOR_H diff --git a/client/core/servercontroller.cpp b/client/core/servercontroller.cpp index 3b30451f..b5467dac 100644 --- a/client/core/servercontroller.cpp +++ b/client/core/servercontroller.cpp @@ -338,6 +338,10 @@ bool ServerController::isReinstallContainerRequired(DockerContainer container, c return true; } + if (container == DockerContainer::AmneziaWireGuard) { + return true; + } + return false; } diff --git a/client/ui/models/protocols/amneziaWireGuardConfigModel.cpp b/client/ui/models/protocols/amneziaWireGuardConfigModel.cpp index 9cf4ed14..a1ce4385 100644 --- a/client/ui/models/protocols/amneziaWireGuardConfigModel.cpp +++ b/client/ui/models/protocols/amneziaWireGuardConfigModel.cpp @@ -1,5 +1,7 @@ #include "amneziaWireGuardConfigModel.h" +#include + #include "protocols/protocols_defs.h" AmneziaWireGuardConfigModel::AmneziaWireGuardConfigModel(QObject *parent) : QAbstractListModel(parent) @@ -20,7 +22,27 @@ bool AmneziaWireGuardConfigModel::setData(const QModelIndex &index, const QVaria switch (role) { case Roles::PortRole: m_protocolConfig.insert(config_key::port, value.toString()); break; - case Roles::CipherRole: m_protocolConfig.insert(config_key::cipher, value.toString()); break; + case Roles::JunkPacketCountRole: m_protocolConfig.insert(config_key::junkPacketCount, value.toString()); break; + case Roles::JunkPacketMinSizeRole: m_protocolConfig.insert(config_key::junkPacketMinSize, value.toString()); break; + case Roles::JunkPacketMaxSizeRole: m_protocolConfig.insert(config_key::junkPacketMaxSize, value.toString()); break; + case Roles::InitPacketJunkSizeRole: + m_protocolConfig.insert(config_key::initPacketJunkSize, value.toString()); + break; + case Roles::ResponsePacketJunkSizeRole: + m_protocolConfig.insert(config_key::responsePacketJunkSize, value.toString()); + break; + case Roles::InitPacketMagicHeaderRole: + m_protocolConfig.insert(config_key::initPacketMagicHeader, value.toString()); + break; + case Roles::ResponsePacketMagicHeaderRole: + m_protocolConfig.insert(config_key::responsePacketMagicHeader, value.toString()); + break; + case Roles::UnderloadPacketMagicHeaderRole: + m_protocolConfig.insert(config_key::underloadPacketMagicHeader, value.toString()); + break; + case Roles::TransportPacketMagicHeaderRole: + m_protocolConfig.insert(config_key::transportPacketMagicHeader, value.toString()); + break; } emit dataChanged(index, index, QList { role }); @@ -34,9 +56,16 @@ QVariant AmneziaWireGuardConfigModel::data(const QModelIndex &index, int role) c } switch (role) { - case Roles::PortRole: return m_protocolConfig.value(config_key::port).toString(protocols::shadowsocks::defaultPort); - case Roles::CipherRole: - return m_protocolConfig.value(config_key::cipher).toString(protocols::shadowsocks::defaultCipher); + case Roles::PortRole: return m_protocolConfig.value(config_key::port).toString(); + case Roles::JunkPacketCountRole: return m_protocolConfig.value(config_key::junkPacketCount); + case Roles::JunkPacketMinSizeRole: return m_protocolConfig.value(config_key::junkPacketMinSize); + case Roles::JunkPacketMaxSizeRole: return m_protocolConfig.value(config_key::junkPacketMaxSize); + case Roles::InitPacketJunkSizeRole: return m_protocolConfig.value(config_key::initPacketJunkSize); + case Roles::ResponsePacketJunkSizeRole: return m_protocolConfig.value(config_key::responsePacketJunkSize); + case Roles::InitPacketMagicHeaderRole: return m_protocolConfig.value(config_key::initPacketMagicHeader); + case Roles::ResponsePacketMagicHeaderRole: return m_protocolConfig.value(config_key::responsePacketMagicHeader); + case Roles::UnderloadPacketMagicHeaderRole: return m_protocolConfig.value(config_key::underloadPacketMagicHeader); + case Roles::TransportPacketMagicHeaderRole: return m_protocolConfig.value(config_key::transportPacketMagicHeader); } return QVariant(); @@ -48,14 +77,44 @@ void AmneziaWireGuardConfigModel::updateModel(const QJsonObject &config) m_container = ContainerProps::containerFromString(config.value(config_key::container).toString()); m_fullConfig = config; - QJsonObject protocolConfig = config.value(config_key::wireguard).toObject(); + + QJsonObject protocolConfig = config.value(config_key::amneziaWireguard).toObject(); + + m_protocolConfig[config_key::port] = + protocolConfig.value(config_key::port).toString(protocols::amneziawireguard::defaultPort); + m_protocolConfig[config_key::junkPacketCount] = + protocolConfig.value(config_key::junkPacketCount).toString(protocols::amneziawireguard::defaultJunkPacketCount); + m_protocolConfig[config_key::junkPacketMinSize] = + protocolConfig.value(config_key::junkPacketMinSize) + .toString(protocols::amneziawireguard::defaultJunkPacketMinSize); + m_protocolConfig[config_key::junkPacketMaxSize] = + protocolConfig.value(config_key::junkPacketMaxSize) + .toString(protocols::amneziawireguard::defaultJunkPacketMaxSize); + m_protocolConfig[config_key::initPacketJunkSize] = + protocolConfig.value(config_key::initPacketJunkSize) + .toString(protocols::amneziawireguard::defaultInitPacketJunkSize); + m_protocolConfig[config_key::responsePacketJunkSize] = + protocolConfig.value(config_key::responsePacketJunkSize) + .toString(protocols::amneziawireguard::defaultResponsePacketJunkSize); + m_protocolConfig[config_key::initPacketMagicHeader] = + protocolConfig.value(config_key::initPacketMagicHeader) + .toString(protocols::amneziawireguard::defaultInitPacketMagicHeader); + m_protocolConfig[config_key::responsePacketMagicHeader] = + protocolConfig.value(config_key::responsePacketMagicHeader) + .toString(protocols::amneziawireguard::defaultResponsePacketMagicHeader); + m_protocolConfig[config_key::underloadPacketMagicHeader] = + protocolConfig.value(config_key::underloadPacketMagicHeader) + .toString(protocols::amneziawireguard::defaultUnderloadPacketMagicHeader); + m_protocolConfig[config_key::transportPacketMagicHeader] = + protocolConfig.value(config_key::transportPacketMagicHeader) + .toString(protocols::amneziawireguard::defaultTransportPacketMagicHeader); endResetModel(); } QJsonObject AmneziaWireGuardConfigModel::getConfig() { - m_fullConfig.insert(config_key::wireguard, m_protocolConfig); + m_fullConfig.insert(config_key::amneziaWireguard, m_protocolConfig); return m_fullConfig; } @@ -64,7 +123,15 @@ QHash AmneziaWireGuardConfigModel::roleNames() const QHash roles; roles[PortRole] = "port"; - roles[CipherRole] = "cipher"; + roles[JunkPacketCountRole] = "junkPacketCount"; + roles[JunkPacketMinSizeRole] = "junkPacketMinSize"; + roles[JunkPacketMaxSizeRole] = "junkPacketMaxSize"; + roles[InitPacketJunkSizeRole] = "initPacketJunkSize"; + roles[ResponsePacketJunkSizeRole] = "responsePacketJunkSize"; + roles[InitPacketMagicHeaderRole] = "initPacketMagicHeader"; + roles[ResponsePacketMagicHeaderRole] = "responsePacketMagicHeader"; + roles[UnderloadPacketMagicHeaderRole] = "underloadPacketMagicHeader"; + roles[TransportPacketMagicHeaderRole] = "transportPacketMagicHeader"; return roles; } diff --git a/client/ui/models/protocols/amneziaWireGuardConfigModel.h b/client/ui/models/protocols/amneziaWireGuardConfigModel.h index b798c289..9419d5c9 100644 --- a/client/ui/models/protocols/amneziaWireGuardConfigModel.h +++ b/client/ui/models/protocols/amneziaWireGuardConfigModel.h @@ -13,7 +13,15 @@ class AmneziaWireGuardConfigModel : public QAbstractListModel public: enum Roles { PortRole = Qt::UserRole + 1, - CipherRole + JunkPacketCountRole, + JunkPacketMinSizeRole, + JunkPacketMaxSizeRole, + InitPacketJunkSizeRole, + ResponsePacketJunkSizeRole, + InitPacketMagicHeaderRole, + ResponsePacketMagicHeaderRole, + UnderloadPacketMagicHeaderRole, + TransportPacketMagicHeaderRole }; explicit AmneziaWireGuardConfigModel(QObject *parent = nullptr); diff --git a/client/ui/qml/Components/SettingsContainersListView.qml b/client/ui/qml/Components/SettingsContainersListView.qml index 250ba1eb..df25b492 100644 --- a/client/ui/qml/Components/SettingsContainersListView.qml +++ b/client/ui/qml/Components/SettingsContainersListView.qml @@ -65,7 +65,7 @@ ListView { break } case ContainerEnum.AmneziaWireGuard: { - WireGuardConfigModel.updateModel(config) + AmneziaWireGuardConfigModel.updateModel(config) PageController.goToPage(PageEnum.PageProtocolAmneziaWireGuardSettings) break } diff --git a/client/ui/qml/Controls2/TextFieldWithHeaderType.qml b/client/ui/qml/Controls2/TextFieldWithHeaderType.qml index 3f80428e..a23e9354 100644 --- a/client/ui/qml/Controls2/TextFieldWithHeaderType.qml +++ b/client/ui/qml/Controls2/TextFieldWithHeaderType.qml @@ -12,6 +12,7 @@ Item { property string headerTextColor: "#878b91" property alias errorText: errorField.text + property bool checkEmptyText: false property string buttonText property string buttonImageSource @@ -98,6 +99,12 @@ Item { root.errorText = "" } + onActiveFocusChanged: { + if (checkEmptyText && textFieldText === "") { + errorText = qsTr("The field can't be empty") + } + } + MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton diff --git a/client/ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml b/client/ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml index a905f47a..35edb15c 100644 --- a/client/ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml @@ -4,6 +4,8 @@ import QtQuick.Layouts import SortFilterProxyModel 0.2 +import PageEnum 1.0 + import "./" import "../Controls2" import "../Controls2/TextTypes" @@ -75,6 +77,7 @@ PageType { } TextFieldWithHeaderType { + id: portTextField Layout.fillWidth: true Layout.topMargin: 40 @@ -88,132 +91,175 @@ PageType { port = textFieldText } } + + checkEmptyText: true } TextFieldWithHeaderType { + id: junkPacketCountTextField Layout.fillWidth: true Layout.topMargin: 16 headerText: qsTr("Junk packet count") - textFieldText: port + textFieldText: junkPacketCount + textField.validator: IntValidator { bottom: 0 } textField.onEditingFinished: { - if (textFieldText !== port) { - port = textFieldText + console.log("1") + if (textFieldText === "") { + textFieldText = "0" + } + + if (textFieldText !== junkPacketCount) { + junkPacketCount = textFieldText } } + + checkEmptyText: true } TextFieldWithHeaderType { + id: junkPacketMinSizeTextField Layout.fillWidth: true Layout.topMargin: 16 headerText: qsTr("Junk packet minimum size") - textFieldText: port + textFieldText: junkPacketMinSize + textField.validator: IntValidator { bottom: 0 } textField.onEditingFinished: { - if (textFieldText !== port) { - port = textFieldText + if (textFieldText !== junkPacketMinSize) { + junkPacketMinSize = textFieldText } } + + checkEmptyText: true } TextFieldWithHeaderType { + id: junkPacketMaxSizeTextField Layout.fillWidth: true Layout.topMargin: 16 headerText: qsTr("Junk packet maximum size") - textFieldText: port + textFieldText: junkPacketMaxSize + textField.validator: IntValidator { bottom: 0 } textField.onEditingFinished: { - if (textFieldText !== port) { - port = textFieldText + if (textFieldText !== junkPacketMaxSize) { + junkPacketMaxSize = textFieldText } } + + checkEmptyText: true } TextFieldWithHeaderType { + id: initPacketJunkSizeTextField Layout.fillWidth: true Layout.topMargin: 16 headerText: qsTr("Init packet junk size") - textFieldText: port + textFieldText: initPacketJunkSize + textField.validator: IntValidator { bottom: 0 } textField.onEditingFinished: { - if (textFieldText !== port) { - port = textFieldText + if (textFieldText !== initPacketJunkSize) { + initPacketJunkSize = textFieldText } } + + checkEmptyText: true } TextFieldWithHeaderType { + id: responsePacketJunkSizeTextField Layout.fillWidth: true Layout.topMargin: 16 headerText: qsTr("Response packet junk size") - textFieldText: port + textFieldText: responsePacketJunkSize + textField.validator: IntValidator { bottom: 0 } textField.onEditingFinished: { - if (textFieldText !== port) { - port = textFieldText + if (textFieldText !== responsePacketJunkSize) { + responsePacketJunkSize = textFieldText } } + + checkEmptyText: true } TextFieldWithHeaderType { + id: initPacketMagicHeaderTextField Layout.fillWidth: true Layout.topMargin: 16 headerText: qsTr("Init packet magic header") - textFieldText: port + textFieldText: initPacketMagicHeader + textField.validator: IntValidator { bottom: 0 } textField.onEditingFinished: { - if (textFieldText !== port) { - port = textFieldText + if (textFieldText !== initPacketMagicHeader) { + initPacketMagicHeader = textFieldText } } + + checkEmptyText: true } TextFieldWithHeaderType { + id: responsePacketMagicHeaderTextField Layout.fillWidth: true Layout.topMargin: 16 headerText: qsTr("Response packet magic header") - textFieldText: port + textFieldText: responsePacketMagicHeader + textField.validator: IntValidator { bottom: 0 } textField.onEditingFinished: { - if (textFieldText !== port) { - port = textFieldText + if (textFieldText !== responsePacketMagicHeader) { + responsePacketMagicHeader = textFieldText } } + + checkEmptyText: true } TextFieldWithHeaderType { + id: transportPacketMagicHeaderTextField Layout.fillWidth: true Layout.topMargin: 16 headerText: qsTr("Transport packet magic header") - textFieldText: port + textFieldText: transportPacketMagicHeader + textField.validator: IntValidator { bottom: 0 } textField.onEditingFinished: { - if (textFieldText !== port) { - port = textFieldText + if (textFieldText !== transportPacketMagicHeader) { + transportPacketMagicHeader = textFieldText } } + + checkEmptyText: true } TextFieldWithHeaderType { + id: underloadPacketMagicHeaderTextField Layout.fillWidth: true Layout.topMargin: 16 headerText: qsTr("Underload packet magic header") - textFieldText: port + textFieldText: underloadPacketMagicHeader + textField.validator: IntValidator { bottom: 0 } textField.onEditingFinished: { - if (textFieldText !== port) { - port = textFieldText + if (textFieldText !== underloadPacketMagicHeader) { + underloadPacketMagicHeader = textFieldText } } + + checkEmptyText: true } BasicButtonType { @@ -251,13 +297,24 @@ PageType { Layout.topMargin: 24 Layout.bottomMargin: 24 + enabled: underloadPacketMagicHeaderTextField.errorText === "" && + transportPacketMagicHeaderTextField.errorText === "" && + responsePacketMagicHeaderTextField.errorText === "" && + initPacketMagicHeaderTextField.errorText === "" && + responsePacketJunkSizeTextField.errorText === "" && + initPacketJunkSizeTextField.errorText === "" && + junkPacketMaxSizeTextField.errorText === "" && + junkPacketMinSizeTextField.errorText === "" && + junkPacketCountTextField.errorText === "" && + portTextField.errorText === "" + text: qsTr("Save and Restart Amnezia") onClicked: { forceActiveFocus() -// PageController.showBusyIndicator(true) -// InstallController.updateContainer(ShadowSocksConfigModel.getConfig()) -// PageController.showBusyIndicator(false) + PageController.showBusyIndicator(true) + InstallController.updateContainer(AmneziaWireGuardConfigModel.getConfig()) + PageController.showBusyIndicator(false) } } } From 16fc0617e479a1e4b4b1dd1b320765af4bc117ba Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Fri, 6 Oct 2023 17:02:28 +0500 Subject: [PATCH 18/30] renamed amneziawireguard files to awg --- .../{amneziaWireGuardConfigModel.cpp => awgConfigModel.cpp} | 0 .../protocols/{amneziaWireGuardConfigModel.h => awgConfigModel.h} | 0 ...olAmneziaWireGuardSettings.qml => PageProtocolAwgSettings.qml} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename client/ui/models/protocols/{amneziaWireGuardConfigModel.cpp => awgConfigModel.cpp} (100%) rename client/ui/models/protocols/{amneziaWireGuardConfigModel.h => awgConfigModel.h} (100%) rename client/ui/qml/Pages2/{PageProtocolAmneziaWireGuardSettings.qml => PageProtocolAwgSettings.qml} (100%) diff --git a/client/ui/models/protocols/amneziaWireGuardConfigModel.cpp b/client/ui/models/protocols/awgConfigModel.cpp similarity index 100% rename from client/ui/models/protocols/amneziaWireGuardConfigModel.cpp rename to client/ui/models/protocols/awgConfigModel.cpp diff --git a/client/ui/models/protocols/amneziaWireGuardConfigModel.h b/client/ui/models/protocols/awgConfigModel.h similarity index 100% rename from client/ui/models/protocols/amneziaWireGuardConfigModel.h rename to client/ui/models/protocols/awgConfigModel.h diff --git a/client/ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml b/client/ui/qml/Pages2/PageProtocolAwgSettings.qml similarity index 100% rename from client/ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml rename to client/ui/qml/Pages2/PageProtocolAwgSettings.qml From aa4a79934a90e71c9f48a345ddcfcd22224214c8 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Fri, 6 Oct 2023 17:19:44 +0500 Subject: [PATCH 19/30] renamed amenziawireguard to awg --- client/amnezia_application.cpp | 4 +-- client/amnezia_application.h | 4 +-- client/configurators/awg_configurator.cpp | 6 ++-- client/configurators/awg_configurator.h | 12 ++++---- client/configurators/vpn_configurator.cpp | 6 ++-- client/configurators/vpn_configurator.h | 4 +-- .../configurators/wireguard_configurator.cpp | 16 +++++------ client/configurators/wireguard_configurator.h | 6 ++-- client/containers/containers_defs.cpp | 10 +++---- client/containers/containers_defs.h | 2 +- client/core/scripts_registry.cpp | 2 +- client/core/servercontroller.cpp | 28 +++++++++---------- client/mozilla/localsocketcontroller.cpp | 4 +-- client/protocols/amneziawireguardprotocol.cpp | 4 +-- client/protocols/amneziawireguardprotocol.h | 12 ++++---- client/protocols/protocols_defs.cpp | 10 +++---- client/protocols/protocols_defs.h | 12 ++++---- client/protocols/vpnprotocol.cpp | 2 +- client/resources.qrc | 2 +- .../amnezia_wireguard/configure_container.sh | 16 +++++------ .../amnezia_wireguard/run_container.sh | 2 +- .../server_scripts/amnezia_wireguard/start.sh | 7 ++--- .../amnezia_wireguard/template.conf | 2 +- client/ui/controllers/importController.cpp | 2 +- client/ui/controllers/pageController.h | 2 +- client/ui/models/protocols/awgConfigModel.cpp | 16 +++++------ client/ui/models/protocols/awgConfigModel.h | 10 +++---- .../Components/SettingsContainersListView.qml | 6 ++-- .../ui/qml/Pages2/PageProtocolAwgSettings.qml | 4 +-- 29 files changed, 105 insertions(+), 108 deletions(-) diff --git a/client/amnezia_application.cpp b/client/amnezia_application.cpp index cef722b1..f372a1d8 100644 --- a/client/amnezia_application.cpp +++ b/client/amnezia_application.cpp @@ -321,8 +321,8 @@ void AmneziaApplication::initModels() m_wireGuardConfigModel.reset(new WireGuardConfigModel(this)); m_engine->rootContext()->setContextProperty("WireGuardConfigModel", m_wireGuardConfigModel.get()); - m_amneziaWireGuardConfigModel.reset(new AmneziaWireGuardConfigModel(this)); - m_engine->rootContext()->setContextProperty("AmneziaWireGuardConfigModel", m_amneziaWireGuardConfigModel.get()); + m_awgConfigModel.reset(new AwgConfigModel(this)); + m_engine->rootContext()->setContextProperty("AwgConfigModel", m_awgConfigModel.get()); #ifdef Q_OS_WINDOWS m_ikev2ConfigModel.reset(new Ikev2ConfigModel(this)); diff --git a/client/amnezia_application.h b/client/amnezia_application.h index 77e50c92..32300421 100644 --- a/client/amnezia_application.h +++ b/client/amnezia_application.h @@ -31,7 +31,7 @@ #ifdef Q_OS_WINDOWS #include "ui/models/protocols/ikev2ConfigModel.h" #endif -#include "ui/models/protocols/amneziaWireGuardConfigModel.h" +#include "ui/models/protocols/awgConfigModel.h" #include "ui/models/protocols/openvpnConfigModel.h" #include "ui/models/protocols/shadowsocksConfigModel.h" #include "ui/models/protocols/wireguardConfigModel.h" @@ -99,7 +99,7 @@ private: QScopedPointer m_shadowSocksConfigModel; QScopedPointer m_cloakConfigModel; QScopedPointer m_wireGuardConfigModel; - QScopedPointer m_amneziaWireGuardConfigModel; + QScopedPointer m_awgConfigModel; #ifdef Q_OS_WINDOWS QScopedPointer m_ikev2ConfigModel; #endif diff --git a/client/configurators/awg_configurator.cpp b/client/configurators/awg_configurator.cpp index 6ed1cd1b..8962067a 100644 --- a/client/configurators/awg_configurator.cpp +++ b/client/configurators/awg_configurator.cpp @@ -5,12 +5,12 @@ #include "core/servercontroller.h" -AmneziaWireGuardConfigurator::AmneziaWireGuardConfigurator(std::shared_ptr settings, QObject *parent) +AwgConfigurator::AwgConfigurator(std::shared_ptr settings, QObject *parent) : WireguardConfigurator(settings, true, parent) { } -QString AmneziaWireGuardConfigurator::genAmneziaWireGuardConfig(const ServerCredentials &credentials, +QString AwgConfigurator::genAwgConfig(const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode) { @@ -19,7 +19,7 @@ QString AmneziaWireGuardConfigurator::genAmneziaWireGuardConfig(const ServerCred QJsonObject jsonConfig = QJsonDocument::fromJson(config.toUtf8()).object(); ServerController serverController(m_settings); - QString serverConfig = serverController.getTextFileFromContainer(container, credentials, protocols::amneziawireguard::serverConfigPath, errorCode); + QString serverConfig = serverController.getTextFileFromContainer(container, credentials, protocols::awg::serverConfigPath, errorCode); QMap serverConfigMap; auto serverConfigLines = serverConfig.split("\n"); diff --git a/client/configurators/awg_configurator.h b/client/configurators/awg_configurator.h index 02961cf1..cf0f2cae 100644 --- a/client/configurators/awg_configurator.h +++ b/client/configurators/awg_configurator.h @@ -1,18 +1,18 @@ -#ifndef AMNEZIAWIREGUARDCONFIGURATOR_H -#define AMNEZIAWIREGUARDCONFIGURATOR_H +#ifndef AWGCONFIGURATOR_H +#define AWGCONFIGURATOR_H #include #include "wireguard_configurator.h" -class AmneziaWireGuardConfigurator : public WireguardConfigurator +class AwgConfigurator : public WireguardConfigurator { Q_OBJECT public: - AmneziaWireGuardConfigurator(std::shared_ptr settings, QObject *parent = nullptr); + AwgConfigurator(std::shared_ptr settings, QObject *parent = nullptr); - QString genAmneziaWireGuardConfig(const ServerCredentials &credentials, DockerContainer container, + QString genAwgConfig(const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr); }; -#endif // AMNEZIAWIREGUARDCONFIGURATOR_H +#endif // AWGCONFIGURATOR_H diff --git a/client/configurators/vpn_configurator.cpp b/client/configurators/vpn_configurator.cpp index 8ab43499..6c5286c2 100644 --- a/client/configurators/vpn_configurator.cpp +++ b/client/configurators/vpn_configurator.cpp @@ -24,7 +24,7 @@ VpnConfigurator::VpnConfigurator(std::shared_ptr settings, QObject *pa wireguardConfigurator = std::shared_ptr(new WireguardConfigurator(settings, false, this)); ikev2Configurator = std::shared_ptr(new Ikev2Configurator(settings, this)); sshConfigurator = std::shared_ptr(new SshConfigurator(settings, this)); - amneziaWireGuardConfigurator = std::shared_ptr(new AmneziaWireGuardConfigurator(settings, this)); + awgConfigurator = std::shared_ptr(new AwgConfigurator(settings, this)); } QString VpnConfigurator::genVpnProtocolConfig(const ServerCredentials &credentials, DockerContainer container, @@ -42,8 +42,8 @@ QString VpnConfigurator::genVpnProtocolConfig(const ServerCredentials &credentia case Proto::WireGuard: return wireguardConfigurator->genWireguardConfig(credentials, container, containerConfig, errorCode); - case Proto::AmneziaWireGuard: - return amneziaWireGuardConfigurator->genAmneziaWireGuardConfig(credentials, container, containerConfig, errorCode); + case Proto::Awg: + return awgConfigurator->genAwgConfig(credentials, container, containerConfig, errorCode); case Proto::Ikev2: return ikev2Configurator->genIkev2Config(credentials, container, containerConfig, errorCode); diff --git a/client/configurators/vpn_configurator.h b/client/configurators/vpn_configurator.h index d304e4c3..ac89b0e4 100644 --- a/client/configurators/vpn_configurator.h +++ b/client/configurators/vpn_configurator.h @@ -13,7 +13,7 @@ class CloakConfigurator; class WireguardConfigurator; class Ikev2Configurator; class SshConfigurator; -class AmneziaWireGuardConfigurator; +class AwgConfigurator; // Retrieve connection settings from server class VpnConfigurator : ConfiguratorBase @@ -41,7 +41,7 @@ public: std::shared_ptr wireguardConfigurator; std::shared_ptr ikev2Configurator; std::shared_ptr sshConfigurator; - std::shared_ptr amneziaWireGuardConfigurator; + std::shared_ptr awgConfigurator; }; #endif // VPN_CONFIGURATOR_H diff --git a/client/configurators/wireguard_configurator.cpp b/client/configurators/wireguard_configurator.cpp index 5ea042c1..a526e109 100644 --- a/client/configurators/wireguard_configurator.cpp +++ b/client/configurators/wireguard_configurator.cpp @@ -19,20 +19,20 @@ #include "settings.h" #include "utilities.h" -WireguardConfigurator::WireguardConfigurator(std::shared_ptr settings, bool isAmneziaWireGuard, QObject *parent) - : ConfiguratorBase(settings, parent), m_isAmneziaWireGuard(isAmneziaWireGuard) +WireguardConfigurator::WireguardConfigurator(std::shared_ptr settings, bool isAwg, QObject *parent) + : ConfiguratorBase(settings, parent), m_isAwg(isAwg) { - m_serverConfigPath = m_isAmneziaWireGuard ? amnezia::protocols::amneziawireguard::serverConfigPath + m_serverConfigPath = m_isAwg ? amnezia::protocols::awg::serverConfigPath : amnezia::protocols::wireguard::serverConfigPath; - m_serverPublicKeyPath = m_isAmneziaWireGuard ? amnezia::protocols::amneziawireguard::serverPublicKeyPath + m_serverPublicKeyPath = m_isAwg ? amnezia::protocols::awg::serverPublicKeyPath : amnezia::protocols::wireguard::serverPublicKeyPath; - m_serverPskKeyPath = m_isAmneziaWireGuard ? amnezia::protocols::amneziawireguard::serverPskKeyPath + m_serverPskKeyPath = m_isAwg ? amnezia::protocols::awg::serverPskKeyPath : amnezia::protocols::wireguard::serverPskKeyPath; - m_configTemplate = m_isAmneziaWireGuard ? ProtocolScriptType::amnezia_wireguard_template + m_configTemplate = m_isAwg ? ProtocolScriptType::amnezia_wireguard_template : ProtocolScriptType::wireguard_template; - m_protocolName = m_isAmneziaWireGuard ? config_key::amneziaWireguard : config_key::wireguard; - m_defaultPort = m_isAmneziaWireGuard ? protocols::wireguard::defaultPort : protocols::amneziawireguard::defaultPort; + m_protocolName = m_isAwg ? config_key::awg : config_key::wireguard; + m_defaultPort = m_isAwg ? protocols::wireguard::defaultPort : protocols::awg::defaultPort; } WireguardConfigurator::ConnectionData WireguardConfigurator::genClientKeys() diff --git a/client/configurators/wireguard_configurator.h b/client/configurators/wireguard_configurator.h index 10eecbb4..7f8e1587 100644 --- a/client/configurators/wireguard_configurator.h +++ b/client/configurators/wireguard_configurator.h @@ -12,7 +12,7 @@ class WireguardConfigurator : public ConfiguratorBase { Q_OBJECT public: - WireguardConfigurator(std::shared_ptr settings, bool isAmneziaWireGuard, QObject *parent = nullptr); + WireguardConfigurator(std::shared_ptr settings, bool isAwg, QObject *parent = nullptr); struct ConnectionData { @@ -36,8 +36,8 @@ private: const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr); ConnectionData genClientKeys(); - - bool m_isAmneziaWireGuard; + + bool m_isAwg; QString m_serverConfigPath; QString m_serverPublicKeyPath; QString m_serverPskKeyPath; diff --git a/client/containers/containers_defs.cpp b/client/containers/containers_defs.cpp index 0b9e44a2..5f8d2e51 100644 --- a/client/containers/containers_defs.cpp +++ b/client/containers/containers_defs.cpp @@ -84,7 +84,7 @@ QMap ContainerProps::containerHumanNames() { DockerContainer::ShadowSocks, "ShadowSocks" }, { DockerContainer::Cloak, "OpenVPN over Cloak" }, { DockerContainer::WireGuard, "WireGuard" }, - { DockerContainer::AmneziaWireGuard, "Amnezia WireGuard" }, + { DockerContainer::Awg, "Amnezia WireGuard" }, { DockerContainer::Ipsec, QObject::tr("IPsec") }, { DockerContainer::TorWebSite, QObject::tr("Website in Tor network") }, @@ -108,7 +108,7 @@ QMap ContainerProps::containerDescriptions() { DockerContainer::WireGuard, QObject::tr("WireGuard - New popular VPN protocol with high performance, high speed and low power " "consumption. Recommended for regions with low levels of censorship.") }, - { DockerContainer::AmneziaWireGuard, + { DockerContainer::Awg, QObject::tr("WireGuard - New popular VPN protocol with high performance, high speed and low power " "consumption. Recommended for regions with low levels of censorship.") }, { DockerContainer::Ipsec, @@ -148,7 +148,7 @@ amnezia::ServiceType ContainerProps::containerService(DockerContainer c) case DockerContainer::Cloak: return ServiceType::Vpn; case DockerContainer::ShadowSocks: return ServiceType::Vpn; case DockerContainer::WireGuard: return ServiceType::Vpn; - case DockerContainer::AmneziaWireGuard: return ServiceType::Vpn; + case DockerContainer::Awg: return ServiceType::Vpn; case DockerContainer::Ipsec: return ServiceType::Vpn; case DockerContainer::TorWebSite: return ServiceType::Other; case DockerContainer::Dns: return ServiceType::Other; @@ -166,7 +166,7 @@ Proto ContainerProps::defaultProtocol(DockerContainer c) case DockerContainer::Cloak: return Proto::Cloak; case DockerContainer::ShadowSocks: return Proto::ShadowSocks; case DockerContainer::WireGuard: return Proto::WireGuard; - case DockerContainer::AmneziaWireGuard: return Proto::AmneziaWireGuard; + case DockerContainer::Awg: return Proto::Awg; case DockerContainer::Ipsec: return Proto::Ikev2; case DockerContainer::TorWebSite: return Proto::TorWebSite; @@ -186,7 +186,7 @@ bool ContainerProps::isSupportedByCurrentPlatform(DockerContainer c) switch (c) { case DockerContainer::WireGuard: return true; case DockerContainer::OpenVpn: return true; - case DockerContainer::AmneziaWireGuard: return true; + case DockerContainer::Awg: return true; case DockerContainer::Cloak: return true; // case DockerContainer::ShadowSocks: return true; diff --git a/client/containers/containers_defs.h b/client/containers/containers_defs.h index 774611c8..ce8a2683 100644 --- a/client/containers/containers_defs.h +++ b/client/containers/containers_defs.h @@ -20,7 +20,7 @@ namespace amnezia ShadowSocks, Cloak, WireGuard, - AmneziaWireGuard, + Awg, Ipsec, // non-vpn diff --git a/client/core/scripts_registry.cpp b/client/core/scripts_registry.cpp index 24deb41a..82ae1fce 100644 --- a/client/core/scripts_registry.cpp +++ b/client/core/scripts_registry.cpp @@ -11,7 +11,7 @@ QString amnezia::scriptFolder(amnezia::DockerContainer container) case DockerContainer::Cloak: return QLatin1String("openvpn_cloak"); case DockerContainer::ShadowSocks: return QLatin1String("openvpn_shadowsocks"); case DockerContainer::WireGuard: return QLatin1String("wireguard"); - case DockerContainer::AmneziaWireGuard: return QLatin1String("amnezia_wireguard"); + case DockerContainer::Awg: return QLatin1String("amnezia_wireguard"); case DockerContainer::Ipsec: return QLatin1String("ipsec"); case DockerContainer::TorWebSite: return QLatin1String("website_tor"); diff --git a/client/core/servercontroller.cpp b/client/core/servercontroller.cpp index b5467dac..60691759 100644 --- a/client/core/servercontroller.cpp +++ b/client/core/servercontroller.cpp @@ -337,8 +337,8 @@ bool ServerController::isReinstallContainerRequired(DockerContainer container, c != newProtoConfig.value(config_key::port).toString(protocols::shadowsocks::defaultPort)) return true; } - - if (container == DockerContainer::AmneziaWireGuard) { + + if (container == DockerContainer::Awg) { return true; } @@ -491,7 +491,7 @@ ServerController::Vars ServerController::genVarsForScript(const ServerCredential const QJsonObject &ssConfig = config.value(ProtocolProps::protoToString(Proto::ShadowSocks)).toObject(); const QJsonObject &wireguarConfig = config.value(ProtocolProps::protoToString(Proto::WireGuard)).toObject(); const QJsonObject &amneziaWireguarConfig = - config.value(ProtocolProps::protoToString(Proto::AmneziaWireGuard)).toObject(); + config.value(ProtocolProps::protoToString(Proto::Awg)).toObject(); const QJsonObject &sftpConfig = config.value(ProtocolProps::protoToString(Proto::Sftp)).toObject(); Vars vars; @@ -589,35 +589,35 @@ ServerController::Vars ServerController::genVarsForScript(const ServerCredential vars.append({ { "$SFTP_PASSWORD", sftpConfig.value(config_key::password).toString() } }); // Amnezia wireguard vars - vars.append({ { "$AMNEZIAWIREGUARD_SERVER_PORT", - amneziaWireguarConfig.value(config_key::port).toString(protocols::amneziawireguard::defaultPort) } }); + vars.append({ { "$AWG_SERVER_PORT", + amneziaWireguarConfig.value(config_key::port).toString(protocols::awg::defaultPort) } }); vars.append({ { "$JUNK_PACKET_COUNT", amneziaWireguarConfig.value(config_key::junkPacketCount) - .toString(protocols::amneziawireguard::defaultJunkPacketCount) } }); + .toString(protocols::awg::defaultJunkPacketCount) } }); vars.append({ { "$JUNK_PACKET_MIN_SIZE", amneziaWireguarConfig.value(config_key::junkPacketMinSize) - .toString(protocols::amneziawireguard::defaultJunkPacketMinSize) } }); + .toString(protocols::awg::defaultJunkPacketMinSize) } }); vars.append({ { "$JUNK_PACKET_MAX_SIZE", amneziaWireguarConfig.value(config_key::junkPacketMaxSize) - .toString(protocols::amneziawireguard::defaultJunkPacketMaxSize) } }); + .toString(protocols::awg::defaultJunkPacketMaxSize) } }); vars.append({ { "$INIT_PACKET_JUNK_SIZE", amneziaWireguarConfig.value(config_key::initPacketJunkSize) - .toString(protocols::amneziawireguard::defaultInitPacketJunkSize) } }); + .toString(protocols::awg::defaultInitPacketJunkSize) } }); vars.append({ { "$RESPONSE_PACKET_JUNK_SIZE", amneziaWireguarConfig.value(config_key::responsePacketJunkSize) - .toString(protocols::amneziawireguard::defaultResponsePacketJunkSize) } }); + .toString(protocols::awg::defaultResponsePacketJunkSize) } }); vars.append({ { "$INIT_PACKET_MAGIC_HEADER", amneziaWireguarConfig.value(config_key::initPacketMagicHeader) - .toString(protocols::amneziawireguard::defaultInitPacketMagicHeader) } }); + .toString(protocols::awg::defaultInitPacketMagicHeader) } }); vars.append({ { "$RESPONSE_PACKET_MAGIC_HEADER", amneziaWireguarConfig.value(config_key::responsePacketMagicHeader) - .toString(protocols::amneziawireguard::defaultResponsePacketMagicHeader) } }); + .toString(protocols::awg::defaultResponsePacketMagicHeader) } }); vars.append({ { "$UNDERLOAD_PACKET_MAGIC_HEADER", amneziaWireguarConfig.value(config_key::underloadPacketMagicHeader) - .toString(protocols::amneziawireguard::defaultUnderloadPacketMagicHeader) } }); + .toString(protocols::awg::defaultUnderloadPacketMagicHeader) } }); vars.append({ { "$TRANSPORT_PACKET_MAGIC_HEADER", amneziaWireguarConfig.value(config_key::transportPacketMagicHeader) - .toString(protocols::amneziawireguard::defaultTransportPacketMagicHeader) } }); + .toString(protocols::awg::defaultTransportPacketMagicHeader) } }); QString serverIp = Utils::getIPAddress(credentials.hostName); if (!serverIp.isEmpty()) { diff --git a/client/mozilla/localsocketcontroller.cpp b/client/mozilla/localsocketcontroller.cpp index d454c16e..2f6fe371 100644 --- a/client/mozilla/localsocketcontroller.cpp +++ b/client/mozilla/localsocketcontroller.cpp @@ -162,8 +162,8 @@ void LocalSocketController::activate(const QJsonObject &rawConfig) { // splitTunnelApps.append(QJsonValue(uri)); // } // json.insert("vpnDisabledApps", splitTunnelApps); - - if (protocolName == amnezia::config_key::amneziaWireguard) { + + if (protocolName == amnezia::config_key::awg) { json.insert(amnezia::config_key::junkPacketCount, wgConfig.value(amnezia::config_key::junkPacketCount)); json.insert(amnezia::config_key::junkPacketMinSize, wgConfig.value(amnezia::config_key::junkPacketMinSize)); json.insert(amnezia::config_key::junkPacketMaxSize, wgConfig.value(amnezia::config_key::junkPacketMaxSize)); diff --git a/client/protocols/amneziawireguardprotocol.cpp b/client/protocols/amneziawireguardprotocol.cpp index cab03da9..e0e51296 100644 --- a/client/protocols/amneziawireguardprotocol.cpp +++ b/client/protocols/amneziawireguardprotocol.cpp @@ -1,10 +1,10 @@ #include "amneziawireguardprotocol.h" -AmneziaWireGuardProtocol::AmneziaWireGuardProtocol(const QJsonObject &configuration, QObject *parent) +Awg::Awg(const QJsonObject &configuration, QObject *parent) : WireguardProtocol(configuration, parent) { } -AmneziaWireGuardProtocol::~AmneziaWireGuardProtocol() +Awg::~Awg() { } diff --git a/client/protocols/amneziawireguardprotocol.h b/client/protocols/amneziawireguardprotocol.h index 329a585e..d7fc9c92 100644 --- a/client/protocols/amneziawireguardprotocol.h +++ b/client/protocols/amneziawireguardprotocol.h @@ -1,17 +1,17 @@ -#ifndef AMNEZIAWIREGUARDPROTOCOL_H -#define AMNEZIAWIREGUARDPROTOCOL_H +#ifndef AWGPROTOCOL_H +#define AWGPROTOCOL_H #include #include "wireguardprotocol.h" -class AmneziaWireGuardProtocol : public WireguardProtocol +class Awg : public WireguardProtocol { Q_OBJECT public: - explicit AmneziaWireGuardProtocol(const QJsonObject &configuration, QObject *parent = nullptr); - virtual ~AmneziaWireGuardProtocol() override; + explicit Awg(const QJsonObject &configuration, QObject *parent = nullptr); + virtual ~Awg() override; }; -#endif // AMNEZIAWIREGUARDPROTOCOL_H +#endif // AWGPROTOCOL_H diff --git a/client/protocols/protocols_defs.cpp b/client/protocols/protocols_defs.cpp index 64cdd003..3982ef9c 100644 --- a/client/protocols/protocols_defs.cpp +++ b/client/protocols/protocols_defs.cpp @@ -89,7 +89,7 @@ amnezia::ServiceType ProtocolProps::protocolService(Proto p) case Proto::Cloak: return ServiceType::Vpn; case Proto::ShadowSocks: return ServiceType::Vpn; case Proto::WireGuard: return ServiceType::Vpn; - case Proto::AmneziaWireGuard: return ServiceType::Vpn; + case Proto::Awg: return ServiceType::Vpn; case Proto::TorWebSite: return ServiceType::Other; case Proto::Dns: return ServiceType::Other; case Proto::FileShare: return ServiceType::Other; @@ -105,7 +105,7 @@ int ProtocolProps::defaultPort(Proto p) case Proto::Cloak: return 443; case Proto::ShadowSocks: return 6789; case Proto::WireGuard: return 51820; - case Proto::AmneziaWireGuard: return 55424; + case Proto::Awg: return 55424; case Proto::Ikev2: return -1; case Proto::L2tp: return -1; @@ -125,7 +125,7 @@ bool ProtocolProps::defaultPortChangeable(Proto p) case Proto::Cloak: return true; case Proto::ShadowSocks: return true; case Proto::WireGuard: return true; - case Proto::AmneziaWireGuard: return true; + case Proto::Awg: return true; case Proto::Ikev2: return false; case Proto::L2tp: return false; @@ -144,7 +144,7 @@ TransportProto ProtocolProps::defaultTransportProto(Proto p) case Proto::Cloak: return TransportProto::Tcp; case Proto::ShadowSocks: return TransportProto::Tcp; case Proto::WireGuard: return TransportProto::Udp; - case Proto::AmneziaWireGuard: return TransportProto::Udp; + case Proto::Awg: return TransportProto::Udp; case Proto::Ikev2: return TransportProto::Udp; case Proto::L2tp: return TransportProto::Udp; // non-vpn @@ -163,7 +163,7 @@ bool ProtocolProps::defaultTransportProtoChangeable(Proto p) case Proto::Cloak: return false; case Proto::ShadowSocks: return false; case Proto::WireGuard: return false; - case Proto::AmneziaWireGuard: return false; + case Proto::Awg: return false; case Proto::Ikev2: return false; case Proto::L2tp: return false; // non-vpn diff --git a/client/protocols/protocols_defs.h b/client/protocols/protocols_defs.h index e26e60a4..d6af132b 100644 --- a/client/protocols/protocols_defs.h +++ b/client/protocols/protocols_defs.h @@ -76,7 +76,7 @@ namespace amnezia constexpr char shadowsocks[] = "shadowsocks"; constexpr char cloak[] = "cloak"; constexpr char sftp[] = "sftp"; - constexpr char amneziaWireguard[] = "amneziawireguard"; + constexpr char awg[] = "awg"; } @@ -151,13 +151,13 @@ namespace amnezia } // namespace sftp - namespace amneziawireguard + namespace awg { constexpr char defaultPort[] = "55424"; - constexpr char serverConfigPath[] = "/opt/amnezia/amneziawireguard/wg0.conf"; - constexpr char serverPublicKeyPath[] = "/opt/amnezia/amneziawireguard/wireguard_server_public_key.key"; - constexpr char serverPskKeyPath[] = "/opt/amnezia/amneziawireguard/wireguard_psk.key"; + constexpr char serverConfigPath[] = "/opt/amnezia/awg/wg0.conf"; + constexpr char serverPublicKeyPath[] = "/opt/amnezia/awg/wireguard_server_public_key.key"; + constexpr char serverPskKeyPath[] = "/opt/amnezia/awg/wireguard_psk.key"; constexpr char defaultJunkPacketCount[] = "3"; constexpr char defaultJunkPacketMinSize[] = "10"; @@ -188,7 +188,7 @@ namespace amnezia ShadowSocks, Cloak, WireGuard, - AmneziaWireGuard, + Awg, Ikev2, L2tp, diff --git a/client/protocols/vpnprotocol.cpp b/client/protocols/vpnprotocol.cpp index 527ede47..2ddc0684 100644 --- a/client/protocols/vpnprotocol.cpp +++ b/client/protocols/vpnprotocol.cpp @@ -113,7 +113,7 @@ VpnProtocol *VpnProtocol::factory(DockerContainer container, const QJsonObject & case DockerContainer::Cloak: return new OpenVpnOverCloakProtocol(configuration); case DockerContainer::ShadowSocks: return new ShadowSocksVpnProtocol(configuration); case DockerContainer::WireGuard: return new WireguardProtocol(configuration); - case DockerContainer::AmneziaWireGuard: return new WireguardProtocol(configuration); + case DockerContainer::Awg: return new WireguardProtocol(configuration); #endif default: return nullptr; } diff --git a/client/resources.qrc b/client/resources.qrc index b79ed3d2..1688d79e 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -215,7 +215,7 @@ ui/qml/Controls2/ListViewWithLabelsType.qml ui/qml/Pages2/PageServiceDnsSettings.qml ui/qml/Controls2/TopCloseButtonType.qml - ui/qml/Pages2/PageProtocolAmneziaWireGuardSettings.qml + ui/qml/Pages2/PageProtocolAwgSettings.qml server_scripts/amnezia_wireguard/template.conf server_scripts/amnezia_wireguard/start.sh server_scripts/amnezia_wireguard/configure_container.sh diff --git a/client/server_scripts/amnezia_wireguard/configure_container.sh b/client/server_scripts/amnezia_wireguard/configure_container.sh index 6ebebc4a..322cc38f 100644 --- a/client/server_scripts/amnezia_wireguard/configure_container.sh +++ b/client/server_scripts/amnezia_wireguard/configure_container.sh @@ -1,19 +1,19 @@ -mkdir -p /opt/amnezia/amneziawireguard -cd /opt/amnezia/amneziawireguard +mkdir -p /opt/amnezia/awg +cd /opt/amnezia/awg WIREGUARD_SERVER_PRIVATE_KEY=$(wg genkey) -echo $WIREGUARD_SERVER_PRIVATE_KEY > /opt/amnezia/amneziawireguard/wireguard_server_private_key.key +echo $WIREGUARD_SERVER_PRIVATE_KEY > /opt/amnezia/awg/wireguard_server_private_key.key WIREGUARD_SERVER_PUBLIC_KEY=$(echo $WIREGUARD_SERVER_PRIVATE_KEY | wg pubkey) -echo $WIREGUARD_SERVER_PUBLIC_KEY > /opt/amnezia/amneziawireguard/wireguard_server_public_key.key +echo $WIREGUARD_SERVER_PUBLIC_KEY > /opt/amnezia/awg/wireguard_server_public_key.key WIREGUARD_PSK=$(wg genpsk) -echo $WIREGUARD_PSK > /opt/amnezia/amneziawireguard/wireguard_psk.key +echo $WIREGUARD_PSK > /opt/amnezia/awg/wireguard_psk.key -cat > /opt/amnezia/amneziawireguard/wg0.conf < /opt/amnezia/awg/wg0.conf < #include "protocols/protocols_defs.h" -AmneziaWireGuardConfigModel::AmneziaWireGuardConfigModel(QObject *parent) : QAbstractListModel(parent) +AwgConfigModel::AwgConfigModel(QObject *parent) : QAbstractListModel(parent) { } -int AmneziaWireGuardConfigModel::rowCount(const QModelIndex &parent) const +int AwgConfigModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); return 1; } -bool AmneziaWireGuardConfigModel::setData(const QModelIndex &index, const QVariant &value, int role) +bool AwgConfigModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (!index.isValid() || index.row() < 0 || index.row() >= ContainerProps::allContainers().size()) { return false; @@ -49,7 +49,7 @@ bool AmneziaWireGuardConfigModel::setData(const QModelIndex &index, const QVaria return true; } -QVariant AmneziaWireGuardConfigModel::data(const QModelIndex &index, int role) const +QVariant AwgConfigModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() < 0 || index.row() >= rowCount()) { return false; @@ -71,7 +71,7 @@ QVariant AmneziaWireGuardConfigModel::data(const QModelIndex &index, int role) c return QVariant(); } -void AmneziaWireGuardConfigModel::updateModel(const QJsonObject &config) +void AwgConfigModel::updateModel(const QJsonObject &config) { beginResetModel(); m_container = ContainerProps::containerFromString(config.value(config_key::container).toString()); @@ -112,13 +112,13 @@ void AmneziaWireGuardConfigModel::updateModel(const QJsonObject &config) endResetModel(); } -QJsonObject AmneziaWireGuardConfigModel::getConfig() +QJsonObject AwgConfigModel::getConfig() { m_fullConfig.insert(config_key::amneziaWireguard, m_protocolConfig); return m_fullConfig; } -QHash AmneziaWireGuardConfigModel::roleNames() const +QHash AwgConfigModel::roleNames() const { QHash roles; diff --git a/client/ui/models/protocols/awgConfigModel.h b/client/ui/models/protocols/awgConfigModel.h index 9419d5c9..e67a3708 100644 --- a/client/ui/models/protocols/awgConfigModel.h +++ b/client/ui/models/protocols/awgConfigModel.h @@ -1,12 +1,12 @@ -#ifndef AMNEZIAWIREGUARDCONFIGMODEL_H -#define AMNEZIAWIREGUARDCONFIGMODEL_H +#ifndef AWGCONFIGMODEL_H +#define AWGCONFIGMODEL_H #include #include #include "containers/containers_defs.h" -class AmneziaWireGuardConfigModel : public QAbstractListModel +class AwgConfigModel : public QAbstractListModel { Q_OBJECT @@ -24,7 +24,7 @@ public: TransportPacketMagicHeaderRole }; - explicit AmneziaWireGuardConfigModel(QObject *parent = nullptr); + explicit AwgConfigModel(QObject *parent = nullptr); int rowCount(const QModelIndex &parent = QModelIndex()) const override; @@ -44,4 +44,4 @@ private: QJsonObject m_fullConfig; }; -#endif // AMNEZIAWIREGUARDCONFIGMODEL_H +#endif // AWGCONFIGMODEL_H diff --git a/client/ui/qml/Components/SettingsContainersListView.qml b/client/ui/qml/Components/SettingsContainersListView.qml index df25b492..89eb727e 100644 --- a/client/ui/qml/Components/SettingsContainersListView.qml +++ b/client/ui/qml/Components/SettingsContainersListView.qml @@ -64,9 +64,9 @@ ListView { // goToPage(PageEnum.PageProtocolWireGuardSettings) break } - case ContainerEnum.AmneziaWireGuard: { - AmneziaWireGuardConfigModel.updateModel(config) - PageController.goToPage(PageEnum.PageProtocolAmneziaWireGuardSettings) + case ContainerEnum.Awg: { + AwgConfigModel.updateModel(config) + PageController.goToPage(PageEnum.PageProtocolAwgSettings) break } case ContainerEnum.Ipsec: { diff --git a/client/ui/qml/Pages2/PageProtocolAwgSettings.qml b/client/ui/qml/Pages2/PageProtocolAwgSettings.qml index 35edb15c..69d34114 100644 --- a/client/ui/qml/Pages2/PageProtocolAwgSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolAwgSettings.qml @@ -52,7 +52,7 @@ PageType { clip: true interactive: false - model: AmneziaWireGuardConfigModel + model: AwgConfigModel delegate: Item { implicitWidth: listview.width @@ -313,7 +313,7 @@ PageType { onClicked: { forceActiveFocus() PageController.showBusyIndicator(true) - InstallController.updateContainer(AmneziaWireGuardConfigModel.getConfig()) + InstallController.updateContainer(AwgConfigModel.getConfig()) PageController.showBusyIndicator(false) } } From 671ca0a66fa1f7fef101f9cf3a835940847e770b Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Fri, 6 Oct 2023 17:26:45 +0500 Subject: [PATCH 20/30] renamed amneziawireguard to awg --- client/CMakeLists.txt | 4 ++-- ...awireguardprotocol.cpp => awgprotocol.cpp} | 2 +- ...neziawireguardprotocol.h => awgprotocol.h} | 0 client/ui/models/protocols/awgConfigModel.cpp | 24 +++++++++---------- client/ui/qml/Pages2/PageShare.qml | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) rename client/protocols/{amneziawireguardprotocol.cpp => awgprotocol.cpp} (77%) rename client/protocols/{amneziawireguardprotocol.h => awgprotocol.h} (100%) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index f0f71f52..3988f9b5 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -263,7 +263,7 @@ if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID)) ${CMAKE_CURRENT_LIST_DIR}/protocols/openvpnovercloakprotocol.h ${CMAKE_CURRENT_LIST_DIR}/protocols/shadowsocksvpnprotocol.h ${CMAKE_CURRENT_LIST_DIR}/protocols/wireguardprotocol.h - ${CMAKE_CURRENT_LIST_DIR}/protocols/amneziawireguardprotocol.h + ${CMAKE_CURRENT_LIST_DIR}/protocols/awgprotocol.h ) set(SOURCES ${SOURCES} @@ -274,7 +274,7 @@ if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID)) ${CMAKE_CURRENT_LIST_DIR}/protocols/openvpnovercloakprotocol.cpp ${CMAKE_CURRENT_LIST_DIR}/protocols/shadowsocksvpnprotocol.cpp ${CMAKE_CURRENT_LIST_DIR}/protocols/wireguardprotocol.cpp - ${CMAKE_CURRENT_LIST_DIR}/protocols/amneziawireguardprotocol.cpp + ${CMAKE_CURRENT_LIST_DIR}/protocols/awgprotocol.cpp ) endif() diff --git a/client/protocols/amneziawireguardprotocol.cpp b/client/protocols/awgprotocol.cpp similarity index 77% rename from client/protocols/amneziawireguardprotocol.cpp rename to client/protocols/awgprotocol.cpp index e0e51296..64415dbe 100644 --- a/client/protocols/amneziawireguardprotocol.cpp +++ b/client/protocols/awgprotocol.cpp @@ -1,4 +1,4 @@ -#include "amneziawireguardprotocol.h" +#include "awgprotocol.h" Awg::Awg(const QJsonObject &configuration, QObject *parent) : WireguardProtocol(configuration, parent) diff --git a/client/protocols/amneziawireguardprotocol.h b/client/protocols/awgprotocol.h similarity index 100% rename from client/protocols/amneziawireguardprotocol.h rename to client/protocols/awgprotocol.h diff --git a/client/ui/models/protocols/awgConfigModel.cpp b/client/ui/models/protocols/awgConfigModel.cpp index 7e12be0d..7d0277b9 100644 --- a/client/ui/models/protocols/awgConfigModel.cpp +++ b/client/ui/models/protocols/awgConfigModel.cpp @@ -78,43 +78,43 @@ void AwgConfigModel::updateModel(const QJsonObject &config) m_fullConfig = config; - QJsonObject protocolConfig = config.value(config_key::amneziaWireguard).toObject(); + QJsonObject protocolConfig = config.value(config_key::awg).toObject(); m_protocolConfig[config_key::port] = - protocolConfig.value(config_key::port).toString(protocols::amneziawireguard::defaultPort); + protocolConfig.value(config_key::port).toString(protocols::awg::defaultPort); m_protocolConfig[config_key::junkPacketCount] = - protocolConfig.value(config_key::junkPacketCount).toString(protocols::amneziawireguard::defaultJunkPacketCount); + protocolConfig.value(config_key::junkPacketCount).toString(protocols::awg::defaultJunkPacketCount); m_protocolConfig[config_key::junkPacketMinSize] = protocolConfig.value(config_key::junkPacketMinSize) - .toString(protocols::amneziawireguard::defaultJunkPacketMinSize); + .toString(protocols::awg::defaultJunkPacketMinSize); m_protocolConfig[config_key::junkPacketMaxSize] = protocolConfig.value(config_key::junkPacketMaxSize) - .toString(protocols::amneziawireguard::defaultJunkPacketMaxSize); + .toString(protocols::awg::defaultJunkPacketMaxSize); m_protocolConfig[config_key::initPacketJunkSize] = protocolConfig.value(config_key::initPacketJunkSize) - .toString(protocols::amneziawireguard::defaultInitPacketJunkSize); + .toString(protocols::awg::defaultInitPacketJunkSize); m_protocolConfig[config_key::responsePacketJunkSize] = protocolConfig.value(config_key::responsePacketJunkSize) - .toString(protocols::amneziawireguard::defaultResponsePacketJunkSize); + .toString(protocols::awg::defaultResponsePacketJunkSize); m_protocolConfig[config_key::initPacketMagicHeader] = protocolConfig.value(config_key::initPacketMagicHeader) - .toString(protocols::amneziawireguard::defaultInitPacketMagicHeader); + .toString(protocols::awg::defaultInitPacketMagicHeader); m_protocolConfig[config_key::responsePacketMagicHeader] = protocolConfig.value(config_key::responsePacketMagicHeader) - .toString(protocols::amneziawireguard::defaultResponsePacketMagicHeader); + .toString(protocols::awg::defaultResponsePacketMagicHeader); m_protocolConfig[config_key::underloadPacketMagicHeader] = protocolConfig.value(config_key::underloadPacketMagicHeader) - .toString(protocols::amneziawireguard::defaultUnderloadPacketMagicHeader); + .toString(protocols::awg::defaultUnderloadPacketMagicHeader); m_protocolConfig[config_key::transportPacketMagicHeader] = protocolConfig.value(config_key::transportPacketMagicHeader) - .toString(protocols::amneziawireguard::defaultTransportPacketMagicHeader); + .toString(protocols::awg::defaultTransportPacketMagicHeader); endResetModel(); } QJsonObject AwgConfigModel::getConfig() { - m_fullConfig.insert(config_key::amneziaWireguard, m_protocolConfig); + m_fullConfig.insert(config_key::awg, m_protocolConfig); return m_fullConfig; } diff --git a/client/ui/qml/Pages2/PageShare.qml b/client/ui/qml/Pages2/PageShare.qml index a03b3717..16759da1 100644 --- a/client/ui/qml/Pages2/PageShare.qml +++ b/client/ui/qml/Pages2/PageShare.qml @@ -317,7 +317,7 @@ PageType { if (index === ContainerProps.containerFromString("amnezia-openvpn")) { root.connectionTypesModel.push(openVpnConnectionFormat) - } else if (index === ContainerProps.containerFromString("amnezia-wireguard")) { + } else if (index === ContainerProps.containerFromString("amnezia-awg")) { root.connectionTypesModel.push(wireGuardConnectionFormat) } } From 445fc6efb1ccd1717530a2bb80b1c41d55839159 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Fri, 6 Oct 2023 22:05:48 +0500 Subject: [PATCH 21/30] renamed amneziawireguard to awg in ios controller --- client/platforms/ios/ios_controller.h | 2 +- client/platforms/ios/ios_controller.mm | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/platforms/ios/ios_controller.h b/client/platforms/ios/ios_controller.h index 6d10dc08..68f30ce8 100644 --- a/client/platforms/ios/ios_controller.h +++ b/client/platforms/ios/ios_controller.h @@ -62,7 +62,7 @@ private: bool setupOpenVPN(); bool setupCloak(); bool setupWireGuard(); - bool setupAmneziaWireGuard(); + bool setupAwg(); bool startOpenVPN(const QString &config); bool startWireGuard(const QString &jsonConfig); diff --git a/client/platforms/ios/ios_controller.mm b/client/platforms/ios/ios_controller.mm index 6782c8da..5665ff1d 100644 --- a/client/platforms/ios/ios_controller.mm +++ b/client/platforms/ios/ios_controller.mm @@ -204,8 +204,8 @@ bool IosController::connectVpn(amnezia::Proto proto, const QJsonObject& configur if (proto == amnezia::Proto::WireGuard) { return setupWireGuard(); } - if (proto == amnezia::Proto::AmneziaWireGuard) { - return setupAmneziaWireGuard(); + if (proto == amnezia::Proto::Awg) { + return setupAwg(); } return false; @@ -310,9 +310,9 @@ bool IosController::setupWireGuard() return startWireGuard(wgConfig); } -bool IosController::setupAmneziaWireGuard() +bool IosController::setupAwg() { - QJsonObject config = m_rawConfig[ProtocolProps::key_proto_config_data(amnezia::Proto::AmneziaWireGuard)].toObject(); + QJsonObject config = m_rawConfig[ProtocolProps::key_proto_config_data(amnezia::Proto::Awg)].toObject(); QString wgConfig = config[config_key::config].toString(); From 7f2ef65fe6acc1215633d0900cbe2e7a95bf3b92 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Fri, 6 Oct 2023 17:20:41 -0400 Subject: [PATCH 22/30] Update WG to AWG for Android --- client/3rd-prebuilt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/3rd-prebuilt b/client/3rd-prebuilt index 994f4f2b..fbb5f586 160000 --- a/client/3rd-prebuilt +++ b/client/3rd-prebuilt @@ -1 +1 @@ -Subproject commit 994f4f2b030600f2d8dbf9dccf409b1591c9e463 +Subproject commit fbb5f586b94efc3f65edeaf9559c8a5c4e752d66 From bdfa8bfe5b78d4ff55dad27853c2a67cf44350af Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Sat, 7 Oct 2023 09:01:29 -0400 Subject: [PATCH 23/30] AWG Android support --- .../wireguard/config/BadConfigException.java | 9 + .../src/com/wireguard/config/Interface.java | 278 +++++++++++++++++- .../android/src/org/amnezia/vpn/VPNService.kt | 31 +- client/containers/containers_defs.cpp | 1 + 4 files changed, 309 insertions(+), 10 deletions(-) diff --git a/client/android/src/com/wireguard/config/BadConfigException.java b/client/android/src/com/wireguard/config/BadConfigException.java index 33910501..af909b0d 100644 --- a/client/android/src/com/wireguard/config/BadConfigException.java +++ b/client/android/src/com/wireguard/config/BadConfigException.java @@ -70,6 +70,15 @@ public class BadConfigException extends Exception { EXCLUDED_APPLICATIONS("ExcludedApplications"), INCLUDED_APPLICATIONS("IncludedApplications"), LISTEN_PORT("ListenPort"), + JC("Jc"), + JMIN("Jmin"), + JMAX("Jmax"), + S1("S1"), + S2("S2"), + H1("H1"), + H2("H2"), + H3("H3"), + H4("H4"), MTU("MTU"), PERSISTENT_KEEPALIVE("PersistentKeepalive"), PRE_SHARED_KEY("PresharedKey"), diff --git a/client/android/src/com/wireguard/config/Interface.java b/client/android/src/com/wireguard/config/Interface.java index 2594d701..df6b7fb1 100644 --- a/client/android/src/com/wireguard/config/Interface.java +++ b/client/android/src/com/wireguard/config/Interface.java @@ -44,6 +44,15 @@ public final class Interface { private final KeyPair keyPair; private final Optional listenPort; private final Optional mtu; + private final Optional jc; + private final Optional jmin; + private final Optional jmax; + private final Optional s1; + private final Optional s2; + private final Optional h1; + private final Optional h2; + private final Optional h3; + private final Optional h4; private Interface(final Builder builder) { // Defensively copy to ensure immutability even if the Builder is reused. @@ -56,6 +65,15 @@ public final class Interface { keyPair = Objects.requireNonNull(builder.keyPair, "Interfaces must have a private key"); listenPort = builder.listenPort; mtu = builder.mtu; + jc = builder.jc; + jmax = builder.jmax; + jmin = builder.jmin; + s1 = builder.s1; + s2 = builder.s2; + h1 = builder.h1; + h2 = builder.h2; + h3 = builder.h3; + h4 = builder.h4; } /** @@ -95,6 +113,33 @@ public final class Interface { case "privatekey": builder.parsePrivateKey(attribute.getValue()); break; + case "jc": + builder.parseJc(attribute.getValue()); + break; + case "jmin": + builder.parseJmin(attribute.getValue()); + break; + case "jmax": + builder.parseJmax(attribute.getValue()); + break; + case "s1": + builder.parseS1(attribute.getValue()); + break; + case "s2": + builder.parseS2(attribute.getValue()); + break; + case "h1": + builder.parseH1(attribute.getValue()); + break; + case "h2": + builder.parseH2(attribute.getValue()); + break; + case "h3": + builder.parseH3(attribute.getValue()); + break; + case "h4": + builder.parseH4(attribute.getValue()); + break; default: throw new BadConfigException( Section.INTERFACE, Location.TOP_LEVEL, Reason.UNKNOWN_ATTRIBUTE, attribute.getKey()); @@ -111,7 +156,9 @@ public final class Interface { return addresses.equals(other.addresses) && dnsServers.equals(other.dnsServers) && excludedApplications.equals(other.excludedApplications) && includedApplications.equals(other.includedApplications) && keyPair.equals(other.keyPair) - && listenPort.equals(other.listenPort) && mtu.equals(other.mtu); + && listenPort.equals(other.listenPort) && mtu.equals(other.mtu) && jc.equals(other.jc) && jmin.equals(other.jmin) + && jmax.equals(other.jmax) && s1.equals(other.s1) && s2.equals(other.s2) && h1.equals(other.h1) && h2.equals(other.h2) + && h3.equals(other.h3) && h4.equals(other.h4); } /** @@ -180,6 +227,42 @@ public final class Interface { public Optional getMtu() { return mtu; } + + public Optional getJc() { + return jc; + } + + public Optional getJmin() { + return jmin; + } + + public Optional getJmax() { + return jmax; + } + + public Optional getS1() { + return s1; + } + + public Optional getS2() { + return s2; + } + + public Optional getH1() { + return h1; + } + + public Optional getH2() { + return h2; + } + + public Optional getH3() { + return h3; + } + + public Optional getH4() { + return h4; + } @Override public int hashCode() { @@ -191,6 +274,15 @@ public final class Interface { hash = 31 * hash + keyPair.hashCode(); hash = 31 * hash + listenPort.hashCode(); hash = 31 * hash + mtu.hashCode(); + hash = 31 * hash + jc.hashCode(); + hash = 31 * hash + jmin.hashCode(); + hash = 31 * hash + jmax.hashCode(); + hash = 31 * hash + s1.hashCode(); + hash = 31 * hash + s2.hashCode(); + hash = 31 * hash + h1.hashCode(); + hash = 31 * hash + h2.hashCode(); + hash = 31 * hash + h3.hashCode(); + hash = 31 * hash + h4.hashCode(); return hash; } @@ -234,6 +326,19 @@ public final class Interface { .append('\n'); listenPort.ifPresent(lp -> sb.append("ListenPort = ").append(lp).append('\n')); mtu.ifPresent(m -> sb.append("MTU = ").append(m).append('\n')); + + jc.ifPresent(t_jc -> sb.append("Jc = ").append(t_jc).append('\n')); + jmin.ifPresent(t_jmin -> sb.append("Jmin = ").append(t_jmin).append('\n')); + jmax.ifPresent(t_jmax -> sb.append("Jmax = ").append(t_jmax).append('\n')); + + s1.ifPresent(t_s1 -> sb.append("S1 = ").append(t_s1).append('\n')); + s2.ifPresent(t_s2 -> sb.append("S2 = ").append(t_s2).append('\n')); + + h1.ifPresent(t_h1 -> sb.append("H1 = ").append(t_h1).append('\n')); + h2.ifPresent(t_h2 -> sb.append("H2 = ").append(t_h2).append('\n')); + h3.ifPresent(t_h3 -> sb.append("H3 = ").append(t_h3).append('\n')); + h4.ifPresent(t_h4 -> sb.append("H4 = ").append(t_h4).append('\n')); + sb.append("PrivateKey = ").append(keyPair.getPrivateKey().toBase64()).append('\n'); return sb.toString(); } @@ -248,6 +353,18 @@ public final class Interface { final StringBuilder sb = new StringBuilder(); sb.append("private_key=").append(keyPair.getPrivateKey().toHex()).append('\n'); listenPort.ifPresent(lp -> sb.append("listen_port=").append(lp).append('\n')); + + jc.ifPresent(t_jc -> sb.append("jc=").append(t_jc).append('\n')); + jmin.ifPresent(t_jmin -> sb.append("jmin=").append(t_jmin).append('\n')); + jmax.ifPresent(t_jmax -> sb.append("jmax=").append(t_jmax).append('\n')); + + s1.ifPresent(t_s1 -> sb.append("s1=").append(t_s1).append('\n')); + s2.ifPresent(t_s2 -> sb.append("s2=").append(t_s2).append('\n')); + + h1.ifPresent(t_h1 -> sb.append("h1=").append(t_h1).append('\n')); + h2.ifPresent(t_h2 -> sb.append("h2=").append(t_h2).append('\n')); + h3.ifPresent(t_h3 -> sb.append("h3=").append(t_h3).append('\n')); + h4.ifPresent(t_h4 -> sb.append("h4=").append(t_h4).append('\n')); return sb.toString(); } @@ -267,6 +384,17 @@ public final class Interface { private Optional listenPort = Optional.empty(); // Defaults to not present. private Optional mtu = Optional.empty(); + private Optional jc = Optional.empty(); + private Optional jmin = Optional.empty(); + private Optional jmax = Optional.empty(); + + private Optional s1 = Optional.empty(); + private Optional s2 = Optional.empty(); + + private Optional h1 = Optional.empty(); + private Optional h2 = Optional.empty(); + private Optional h3 = Optional.empty(); + private Optional h4 = Optional.empty(); public Builder addAddress(final InetNetwork address) { addresses.add(address); @@ -362,6 +490,78 @@ public final class Interface { } } + public Builder parseJc(final String jc) throws BadConfigException { + try { + return setJc(Integer.parseInt(jc)); + } catch (final NumberFormatException e) { + throw new BadConfigException(Section.INTERFACE, Location.JC, jc, e); + } + } + + public Builder parseJmax(final String jmax) throws BadConfigException { + try { + return setJmax(Integer.parseInt(jmax)); + } catch (final NumberFormatException e) { + throw new BadConfigException(Section.INTERFACE, Location.JMAX, jmax, e); + } + } + + public Builder parseJmin(final String jmin) throws BadConfigException { + try { + return setJmin(Integer.parseInt(jmin)); + } catch (final NumberFormatException e) { + throw new BadConfigException(Section.INTERFACE, Location.JMIN, jmin, e); + } + } + + public Builder parseS1(final String s1) throws BadConfigException { + try { + return setS1(Integer.parseInt(s1)); + } catch (final NumberFormatException e) { + throw new BadConfigException(Section.INTERFACE, Location.S1, s1, e); + } + } + + public Builder parseS2(final String s2) throws BadConfigException { + try { + return setS2(Integer.parseInt(s2)); + } catch (final NumberFormatException e) { + throw new BadConfigException(Section.INTERFACE, Location.S2, s2, e); + } + } + + public Builder parseH1(final String h1) throws BadConfigException { + try { + return setH1(Long.parseLong(h1)); + } catch (final NumberFormatException e) { + throw new BadConfigException(Section.INTERFACE, Location.H1, h1, e); + } + } + + public Builder parseH2(final String h2) throws BadConfigException { + try { + return setH2(Long.parseLong(h2)); + } catch (final NumberFormatException e) { + throw new BadConfigException(Section.INTERFACE, Location.H2, h2, e); + } + } + + public Builder parseH3(final String h3) throws BadConfigException { + try { + return setH3(Long.parseLong(h3)); + } catch (final NumberFormatException e) { + throw new BadConfigException(Section.INTERFACE, Location.H3, h3, e); + } + } + + public Builder parseH4(final String h4) throws BadConfigException { + try { + return setH4(Long.parseLong(h4)); + } catch (final NumberFormatException e) { + throw new BadConfigException(Section.INTERFACE, Location.H4, h4, e); + } + } + public Builder parsePrivateKey(final String privateKey) throws BadConfigException { try { return setKeyPair(new KeyPair(Key.fromBase64(privateKey))); @@ -386,9 +586,81 @@ public final class Interface { public Builder setMtu(final int mtu) throws BadConfigException { if (mtu < 0) throw new BadConfigException( - Section.INTERFACE, Location.LISTEN_PORT, Reason.INVALID_VALUE, String.valueOf(mtu)); + Section.INTERFACE, Location.MTU, Reason.INVALID_VALUE, String.valueOf(mtu)); this.mtu = mtu == 0 ? Optional.empty() : Optional.of(mtu); return this; } + + public Builder setJc(final int jc) throws BadConfigException { + if (jc < 0) + throw new BadConfigException( + Section.INTERFACE, Location.JC, Reason.INVALID_VALUE, String.valueOf(jc)); + this.jc = jc == 0 ? Optional.empty() : Optional.of(jc); + return this; + } + + public Builder setJmin(final int jmin) throws BadConfigException { + if (jmin < 0) + throw new BadConfigException( + Section.INTERFACE, Location.JMIN, Reason.INVALID_VALUE, String.valueOf(jmin)); + this.jmin = jmin == 0 ? Optional.empty() : Optional.of(jmin); + return this; + } + + public Builder setJmax(final int jmax) throws BadConfigException { + if (jmax < 0) + throw new BadConfigException( + Section.INTERFACE, Location.JMAX, Reason.INVALID_VALUE, String.valueOf(jmax)); + this.jmax = jmax == 0 ? Optional.empty() : Optional.of(jmax); + return this; + } + + public Builder setS1(final int s1) throws BadConfigException { + if (s1 < 0) + throw new BadConfigException( + Section.INTERFACE, Location.S1, Reason.INVALID_VALUE, String.valueOf(s1)); + this.s1 = s1 == 0 ? Optional.empty() : Optional.of(s1); + return this; + } + + public Builder setS2(final int s2) throws BadConfigException { + if (s2 < 0) + throw new BadConfigException( + Section.INTERFACE, Location.S2, Reason.INVALID_VALUE, String.valueOf(s2)); + this.s2 = s2 == 0 ? Optional.empty() : Optional.of(s2); + return this; + } + + public Builder setH1(final long h1) throws BadConfigException { + if (h1 < 0) + throw new BadConfigException( + Section.INTERFACE, Location.H1, Reason.INVALID_VALUE, String.valueOf(h1)); + this.h1 = h1 == 0 ? Optional.empty() : Optional.of(h1); + return this; + } + + public Builder setH2(final long h2) throws BadConfigException { + if (h2 < 0) + throw new BadConfigException( + Section.INTERFACE, Location.H2, Reason.INVALID_VALUE, String.valueOf(h2)); + this.h2 = h2 == 0 ? Optional.empty() : Optional.of(h2); + return this; + } + + public Builder setH3(final long h3) throws BadConfigException { + if (h3 < 0) + throw new BadConfigException( + Section.INTERFACE, Location.H3, Reason.INVALID_VALUE, String.valueOf(h3)); + this.h3 = h3 == 0 ? Optional.empty() : Optional.of(h3); + return this; + } + + public Builder setH4(final long h4) throws BadConfigException { + if (h4 < 0) + throw new BadConfigException( + Section.INTERFACE, Location.H4, Reason.INVALID_VALUE, String.valueOf(h4)); + this.h4 = h4 == 0 ? Optional.empty() : Optional.of(h4); + return this; + } } -} +} diff --git a/client/android/src/org/amnezia/vpn/VPNService.kt b/client/android/src/org/amnezia/vpn/VPNService.kt index 082fe412..fe08a3cf 100644 --- a/client/android/src/org/amnezia/vpn/VPNService.kt +++ b/client/android/src/org/amnezia/vpn/VPNService.kt @@ -380,7 +380,10 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { mNetworkState.bindNetworkListener() } "wireguard" -> { - startWireGuard() + startWireGuard("wireguard") + } + "awg" -> { + startWireGuard("awg") } "shadowsocks" -> { startShadowsocks() @@ -457,7 +460,8 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { fun turnOff() { Log.v(tag, "Aman: turnOff....................") when (mProtocol) { - "wireguard" -> { + "wireguard", + "awg" -> { GoBackend.wgTurnOff(currentTunnelHandle) } "cloak", @@ -559,14 +563,14 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { } return parseData } - + /** * Create a Wireguard [Config] from a [json] string - * The [json] will be created in AndroidVpnProtocol.cpp */ - private fun buildWireguardConfig(obj: JSONObject): Config { + private fun buildWireguardConfig(obj: JSONObject, type: String): Config { val confBuilder = Config.Builder() - val wireguardConfigData = obj.getJSONObject("wireguard_config_data") + val wireguardConfigData = obj.getJSONObject(type) val config = parseConfigData(wireguardConfigData.getString("config")) val peerBuilder = Peer.Builder() val peerConfig = config["Peer"]!! @@ -599,6 +603,19 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { ifaceConfig["DNS"]!!.split(",").forEach { ifaceBuilder.addDnsServer(InetNetwork.parse(it.trim()).address) } + + ifaceBuilder.parsePrivateKey(ifaceConfig["PrivateKey"]) + if (type == "awg_config_data") { + ifaceBuilder.parseJc(ifaceConfig["Jc"]) + ifaceBuilder.parseJmin(ifaceConfig["Jmin"]) + ifaceBuilder.parseJmax(ifaceConfig["Jmax"]) + ifaceBuilder.parseS1(ifaceConfig["S1"]) + ifaceBuilder.parseS2(ifaceConfig["S2"]) + ifaceBuilder.parseH1(ifaceConfig["H1"]) + ifaceBuilder.parseH2(ifaceConfig["H2"]) + ifaceBuilder.parseH3(ifaceConfig["H3"]) + ifaceBuilder.parseH4(ifaceConfig["H4"]) + } /*val jExcludedApplication = obj.getJSONArray("excludedApps") (0 until jExcludedApplication.length()).toList().forEach { val appName = jExcludedApplication.get(it).toString() @@ -716,8 +733,8 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { }).start() } - private fun startWireGuard() { - val wireguard_conf = buildWireguardConfig(mConfig!!) + private fun startWireGuard(type: String) { + val wireguard_conf = buildWireguardConfig(mConfig!!, type + "_config_data") Log.i(tag, "startWireGuard: wireguard_conf : $wireguard_conf") if (currentTunnelHandle != -1) { Log.e(tag, "Tunnel already up") diff --git a/client/containers/containers_defs.cpp b/client/containers/containers_defs.cpp index 5f8d2e51..0337eb44 100644 --- a/client/containers/containers_defs.cpp +++ b/client/containers/containers_defs.cpp @@ -204,6 +204,7 @@ bool ContainerProps::isSupportedByCurrentPlatform(DockerContainer c) case DockerContainer::WireGuard: return true; case DockerContainer::OpenVpn: return true; case DockerContainer::ShadowSocks: return true; + case DockerContainer::Awg: return true; case DockerContainer::Cloak: return true; default: return false; } From c08e23085ed9361fd19d75008f99542d59d0d9f4 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Mon, 9 Oct 2023 10:29:42 -0400 Subject: [PATCH 24/30] Fix protocol change from AWG to WG for Android --- client/3rd-prebuilt | 2 +- .../src/com/wireguard/config/Interface.java | 18 ++++++++-------- .../android/src/org/amnezia/vpn/VPNService.kt | 21 +++++++++++++++++-- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/client/3rd-prebuilt b/client/3rd-prebuilt index fbb5f586..c3ca525f 160000 --- a/client/3rd-prebuilt +++ b/client/3rd-prebuilt @@ -1 +1 @@ -Subproject commit fbb5f586b94efc3f65edeaf9559c8a5c4e752d66 +Subproject commit c3ca525f92e57fecdd6047e35b4ccded8b173407 diff --git a/client/android/src/com/wireguard/config/Interface.java b/client/android/src/com/wireguard/config/Interface.java index df6b7fb1..4b561680 100644 --- a/client/android/src/com/wireguard/config/Interface.java +++ b/client/android/src/com/wireguard/config/Interface.java @@ -595,7 +595,7 @@ public final class Interface { if (jc < 0) throw new BadConfigException( Section.INTERFACE, Location.JC, Reason.INVALID_VALUE, String.valueOf(jc)); - this.jc = jc == 0 ? Optional.empty() : Optional.of(jc); + this.jc = Optional.of(jc); return this; } @@ -603,7 +603,7 @@ public final class Interface { if (jmin < 0) throw new BadConfigException( Section.INTERFACE, Location.JMIN, Reason.INVALID_VALUE, String.valueOf(jmin)); - this.jmin = jmin == 0 ? Optional.empty() : Optional.of(jmin); + this.jmin = Optional.of(jmin); return this; } @@ -611,7 +611,7 @@ public final class Interface { if (jmax < 0) throw new BadConfigException( Section.INTERFACE, Location.JMAX, Reason.INVALID_VALUE, String.valueOf(jmax)); - this.jmax = jmax == 0 ? Optional.empty() : Optional.of(jmax); + this.jmax = Optional.of(jmax); return this; } @@ -619,7 +619,7 @@ public final class Interface { if (s1 < 0) throw new BadConfigException( Section.INTERFACE, Location.S1, Reason.INVALID_VALUE, String.valueOf(s1)); - this.s1 = s1 == 0 ? Optional.empty() : Optional.of(s1); + this.s1 = Optional.of(s1); return this; } @@ -627,7 +627,7 @@ public final class Interface { if (s2 < 0) throw new BadConfigException( Section.INTERFACE, Location.S2, Reason.INVALID_VALUE, String.valueOf(s2)); - this.s2 = s2 == 0 ? Optional.empty() : Optional.of(s2); + this.s2 = Optional.of(s2); return this; } @@ -635,7 +635,7 @@ public final class Interface { if (h1 < 0) throw new BadConfigException( Section.INTERFACE, Location.H1, Reason.INVALID_VALUE, String.valueOf(h1)); - this.h1 = h1 == 0 ? Optional.empty() : Optional.of(h1); + this.h1 = Optional.of(h1); return this; } @@ -643,7 +643,7 @@ public final class Interface { if (h2 < 0) throw new BadConfigException( Section.INTERFACE, Location.H2, Reason.INVALID_VALUE, String.valueOf(h2)); - this.h2 = h2 == 0 ? Optional.empty() : Optional.of(h2); + this.h2 = Optional.of(h2); return this; } @@ -651,7 +651,7 @@ public final class Interface { if (h3 < 0) throw new BadConfigException( Section.INTERFACE, Location.H3, Reason.INVALID_VALUE, String.valueOf(h3)); - this.h3 = h3 == 0 ? Optional.empty() : Optional.of(h3); + this.h3 = Optional.of(h3); return this; } @@ -659,7 +659,7 @@ public final class Interface { if (h4 < 0) throw new BadConfigException( Section.INTERFACE, Location.H4, Reason.INVALID_VALUE, String.valueOf(h4)); - this.h4 = h4 == 0 ? Optional.empty() : Optional.of(h4); + this.h4 = Optional.of(h4); return this; } } diff --git a/client/android/src/org/amnezia/vpn/VPNService.kt b/client/android/src/org/amnezia/vpn/VPNService.kt index fe08a3cf..06f58980 100644 --- a/client/android/src/org/amnezia/vpn/VPNService.kt +++ b/client/android/src/org/amnezia/vpn/VPNService.kt @@ -615,6 +615,17 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { ifaceBuilder.parseH2(ifaceConfig["H2"]) ifaceBuilder.parseH3(ifaceConfig["H3"]) ifaceBuilder.parseH4(ifaceConfig["H4"]) + } else { + ifaceBuilder.parseJc("0") + ifaceBuilder.parseJmin("0") + ifaceBuilder.parseJmax("0") + ifaceBuilder.parseS1("0") + ifaceBuilder.parseS2("0") + ifaceBuilder.parseH1("0") + ifaceBuilder.parseH2("0") + ifaceBuilder.parseH3("0") + ifaceBuilder.parseH4("0") + } /*val jExcludedApplication = obj.getJSONArray("excludedApps") (0 until jExcludedApplication.length()).toList().forEach { @@ -745,9 +756,15 @@ class VPNService : BaseVpnService(), LocalDnsService.Interface { val builder = Builder() setupBuilder(wireguard_conf, builder) builder.setSession("Amnezia") + + builder.establish().use { tun -> - if (tun == null) return - currentTunnelHandle = GoBackend.wgTurnOn("Amnezia", tun.detachFd(), wgConfig) + if (tun == null) return + if (type == "awg"){ + currentTunnelHandle = GoBackend.wgTurnOn("awg0", tun.detachFd(), wgConfig) + } else { + currentTunnelHandle = GoBackend.wgTurnOn("amn0", tun.detachFd(), wgConfig) + } } if (currentTunnelHandle < 0) { Log.e(tag, "Activation Error Code -> $currentTunnelHandle") From bb2d794b6fe596b11321e9fbb0e8cc828ea59c01 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Mon, 9 Oct 2023 23:18:24 +0500 Subject: [PATCH 25/30] corrections to the text --- client/containers/containers_defs.cpp | 4 +- client/protocols/protocols_defs.cpp | 2 +- client/translations/amneziavpn_ru.ts | 298 ++++++++++++------ client/translations/amneziavpn_zh_CN.ts | 294 ++++++++++++----- .../ui/qml/Pages2/PageProtocolAwgSettings.qml | 8 +- 5 files changed, 431 insertions(+), 175 deletions(-) diff --git a/client/containers/containers_defs.cpp b/client/containers/containers_defs.cpp index 0337eb44..fd13bfe0 100644 --- a/client/containers/containers_defs.cpp +++ b/client/containers/containers_defs.cpp @@ -84,7 +84,7 @@ QMap ContainerProps::containerHumanNames() { DockerContainer::ShadowSocks, "ShadowSocks" }, { DockerContainer::Cloak, "OpenVPN over Cloak" }, { DockerContainer::WireGuard, "WireGuard" }, - { DockerContainer::Awg, "Amnezia WireGuard" }, + { DockerContainer::Awg, "AmneziaWG" }, { DockerContainer::Ipsec, QObject::tr("IPsec") }, { DockerContainer::TorWebSite, QObject::tr("Website in Tor network") }, @@ -131,7 +131,7 @@ QMap ContainerProps::containerDetailedDescriptions() 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("Amnezia WireGuard container") }, + { DockerContainer::WireGuard, QObject::tr("AmneziaWG container") }, { DockerContainer::Ipsec, QObject::tr("IPsec container") }, { DockerContainer::TorWebSite, QObject::tr("Website in Tor network") }, diff --git a/client/protocols/protocols_defs.cpp b/client/protocols/protocols_defs.cpp index 3982ef9c..b7f6b1d8 100644 --- a/client/protocols/protocols_defs.cpp +++ b/client/protocols/protocols_defs.cpp @@ -66,7 +66,7 @@ QMap ProtocolProps::protocolHumanNames() { Proto::ShadowSocks, "ShadowSocks" }, { Proto::Cloak, "Cloak" }, { Proto::WireGuard, "WireGuard" }, - { Proto::WireGuard, "Amnezia WireGuard" }, + { Proto::WireGuard, "AmneziaWG" }, { Proto::Ikev2, "IKEv2" }, { Proto::L2tp, "L2TP" }, diff --git a/client/translations/amneziavpn_ru.ts b/client/translations/amneziavpn_ru.ts index e0bab018..f2e7a811 100644 --- a/client/translations/amneziavpn_ru.ts +++ b/client/translations/amneziavpn_ru.ts @@ -26,41 +26,41 @@ ConnectionController - + VPN Protocols is not installed. Please install VPN container at first - + Connection... - + Connected - + Settings updated successfully, Reconnnection... - + Reconnection... - - - + + + Connect - + Disconnection... @@ -122,7 +122,7 @@ - + Reconnect via VPN Procotol: @@ -130,7 +130,7 @@ ImportController - + Scanned %1 of %2. @@ -139,50 +139,55 @@ InstallController - + %1 installed successfully. - + %1 is already installed on the server. - + +Added containers that were already installed on the server + + + + Already installed containers were found on the server. All installed containers have been added to the application - + Settings updated successfully - + Server '%1' was removed - + All containers from server '%1' have been removed - + %1 has been removed from the server '%2' - + Please login as the user - + Server added successfully @@ -250,16 +255,104 @@ Already installed containers were found on the server. All installed containers PageHome - + VPN protocol - + Servers + + PageProtocolAwgSettings + + + AmneziaWG settings + + + + + Port + + + + + Junk packet count + + + + + Junk packet minimum size + + + + + Junk packet maximum size + + + + + Init packet junk size + + + + + Response packet junk size + + + + + Init packet magic header + + + + + Response packet magic header + + + + + Transport packet magic header + + + + + Underload packet magic header + + + + + Remove AmneziaWG + + + + + Remove AmneziaWG from server? + + + + + All users who you shared a connection with will no longer be able to connect to it. + + + + + Continue + Продолжить + + + + Cancel + + + + + Save and Restart Amnezia + + + PageProtocolCloakSettings @@ -865,71 +958,76 @@ And if you don't like the app, all the more support it - the donation will + Allow application screenshots + + + + Auto start - + Launch the application every time - + starts - + Start minimized - + Launch application minimized - + Language - + Logging - + Enabled - + Disabled - + Reset settings and remove all data from the application - + Reset settings and remove all data from the application? - + All settings will be reset to default. All installed AmneziaVPN services will still remain on the server. - + Continue Продолжить - + Cancel @@ -1525,17 +1623,17 @@ It's okay as long as it's from someone you trust. PageSetupWizardEasy - + What is the level of internet control in your region? - + Set up a VPN yourself - + I want to choose a VPN protocol @@ -1545,7 +1643,7 @@ It's okay as long as it's from someone you trust. Продолжить - + Set up later @@ -1749,11 +1847,6 @@ It's okay as long as it's from someone you trust. VPN access without the ability to manage the server - - - Full access to server - - Server @@ -1765,13 +1858,17 @@ It's okay as long as it's from someone you trust. - + + File with accessing settings to + + + + Connection to - - + File with connection settings to @@ -1795,29 +1892,30 @@ It's okay as long as it's from someone you trust. Full access + + + Access to server management. The user with whom you share full access to the connection will be able to add and remove your protocols and services to the servers, as well as change settings. + + Servers - - Protocols - - - - + + Protocol - - + + Connection format - + Share @@ -2273,103 +2371,109 @@ It's okay as long as it's from someone you trust. - + IPsec - + DNS Service - + Sftp file sharing service - - + + Website in Tor network - + Amnezia DNS - + OpenVPN is the most popular VPN protocol, with flexible configuration options. It uses its own security protocol with SSL/TLS for key exchange. - + ShadowSocks - masks VPN traffic, making it similar to normal web traffic, but is recognised by analysis systems in some highly censored regions. - + OpenVPN over Cloak - OpenVPN with VPN masquerading as web traffic and protection against active-probbing detection. Ideal for bypassing blocking in regions with the highest levels of censorship. - + + WireGuard - New popular VPN protocol with high performance, high speed and low power consumption. Recommended for regions with low levels of censorship. - + IKEv2 - Modern stable protocol, a bit faster than others, restores connection after signal loss. It has native support on the latest versions of Android and iOS. - + Deploy a WordPress site on the Tor network in two clicks. - + Replace the current DNS server with your own. This will increase your privacy level. - + Creates a file vault on your server to securely store and transfer files. - + OpenVPN container - + Container with OpenVpn and ShadowSocks - + Container with OpenVpn and ShadowSocks protocols configured with traffic masking by Cloak plugin - + WireGuard container - - IPsec container + + AmneziaWG container + IPsec container + + + + Sftp file sharing service - is secure FTP service - + Sftp service @@ -2433,6 +2537,16 @@ It's okay as long as it's from someone you trust. error 0x%1: %2 + + + WireGuard Configuration Highlighter + + + + + &Randomize colors + + SelectLanguageDrawer @@ -2459,22 +2573,22 @@ It's okay as long as it's from someone you trust. SettingsController - + Software version - + All settings have been reset to default values - + Cached profiles cleared - + Backup file is corrupted @@ -2504,7 +2618,7 @@ It's okay as long as it's from someone you trust. - Show content + Show connection settings @@ -2589,6 +2703,14 @@ It's okay as long as it's from someone you trust. + + TextFieldWithHeaderType + + + The field can't be empty + + + VpnConnection @@ -2643,32 +2765,32 @@ It's okay as long as it's from someone you trust. amnezia::ContainerProps - + Low - + High - + Medium - + Many foreign websites and VPN providers are blocked - + Some foreign sites are blocked, but VPN providers are not blocked - + I just want to increase the level of privacy diff --git a/client/translations/amneziavpn_zh_CN.ts b/client/translations/amneziavpn_zh_CN.ts index 37e27786..cbf0caa1 100644 --- a/client/translations/amneziavpn_zh_CN.ts +++ b/client/translations/amneziavpn_zh_CN.ts @@ -27,40 +27,40 @@ ConnectionController - - - + + + Connect 连接 - + VPN Protocols is not installed. Please install VPN container at first 不存在VPN协议,请先安装 - + Connection... 连接中 - + Connected 已连接 - + Reconnection... 重连中 - + Disconnection... 断开中 - + Settings updated successfully, Reconnnection... 配置已更新,重连中 @@ -122,7 +122,7 @@ 当前平台不支持所选协议 - + Reconnect via VPN Procotol: 重连基于VPN协议: @@ -130,7 +130,7 @@ ImportController - + Scanned %1 of %2. 扫描 %1 of %2. @@ -147,41 +147,46 @@ - + %1 installed successfully. %1 安装成功。 - + %1 is already installed on the server. 服务器上已经安装 %1。 - + +Added containers that were already installed on the server + + + + Already installed containers were found on the server. All installed containers have been added to the application 在服务上发现已经安装协议并添加到应用程序 - + Settings updated successfully 配置更新成功 - + Server '%1' was removed 已移除服务器 '%1' - + All containers from server '%1' have been removed 服务器 '%1' 的所有容器已移除 - + %1 has been removed from the server '%2' %1 已从服务器 '%2' 上移除 @@ -202,12 +207,12 @@ Already installed containers were found on the server. All installed containers 协议已从 - + Please login as the user 请以用户身份登录 - + Server added successfully 服务器添加成功 @@ -275,16 +280,104 @@ Already installed containers were found on the server. All installed containers PageHome - + VPN protocol VPN协议 - + Servers 服务器 + + PageProtocolAwgSettings + + + AmneziaWG settings + + + + + Port + 端口 + + + + Junk packet count + + + + + Junk packet minimum size + + + + + Junk packet maximum size + + + + + Init packet junk size + + + + + Response packet junk size + + + + + Init packet magic header + + + + + Response packet magic header + + + + + Transport packet magic header + + + + + Underload packet magic header + + + + + Remove AmneziaWG + + + + + Remove AmneziaWG from server? + + + + + All users who you shared a connection with will no longer be able to connect to it. + + + + + Continue + 继续 + + + + Cancel + 取消 + + + + Save and Restart Amnezia + 保存并重启Amnezia + + PageProtocolCloakSettings @@ -892,71 +985,76 @@ And if you don't like the app, all the more support it - the donation will + Allow application screenshots + + + + Auto start 自动运行 - + Launch the application every time 总是在系统 - + starts 启动时自动运行运用程序 - + Start minimized 最小化 - + Launch application minimized 开启应用程序时窗口最小化 - + Language 语言 - + Logging 日志 - + Enabled 开启 - + Disabled 禁用 - + Reset settings and remove all data from the application 重置并清理应用的所有数据 - + Reset settings and remove all data from the application? 重置并清理应用的所有数据? - + All settings will be reset to default. All installed AmneziaVPN services will still remain on the server. 所有配置恢复为默认值。在服务器上保留所有已安装的AmneziaVPN服务。 - + Continue 继续 - + Cancel 取消 @@ -1561,17 +1659,17 @@ It's okay as long as it's from someone you trust. PageSetupWizardEasy - + What is the level of internet control in your region? 您所在地区的互联网控制力度如何? - + Set up a VPN yourself 自己架设VPN - + I want to choose a VPN protocol 我想选择VPN协议 @@ -1581,7 +1679,7 @@ It's okay as long as it's from someone you trust. 继续 - + Set up later 稍后设置 @@ -1807,8 +1905,12 @@ It's okay as long as it's from someone you trust. + Access to server management. The user with whom you share full access to the connection will be able to add and remove your protocols and services to the servers, as well as change settings. + + + Full access to server - 获得服务器完整授权 + 获得服务器完整授权 @@ -1827,33 +1929,37 @@ It's okay as long as it's from someone you trust. - + File with accessing settings to + + + + File with connection settings to 连接配置文件的内容为: - Protocols - 协议 + 协议 - + + Protocol 协议 - + Connection to 连接到 - - + + Connection format 连接方式 - + Share 共享 @@ -2104,7 +2210,7 @@ It's okay as long as it's from someone you trust. QObject - + Sftp service Sftp 服务 @@ -2314,98 +2420,104 @@ It's okay as long as it's from someone you trust. 内部错误 - + IPsec - - + + Website in Tor network 在 Tor 网络中架设网站 - + Amnezia DNS - + Sftp file sharing service SFTP文件共享服务 - + OpenVPN is the most popular VPN protocol, with flexible configuration options. It uses its own security protocol with SSL/TLS for key exchange. OpenVPN 是最流行的 VPN 协议,具有灵活的配置选项。它使用自己的安全协议与 SSL/TLS 进行密钥交换。 - + ShadowSocks - masks VPN traffic, making it similar to normal web traffic, but is recognised by analysis systems in some highly censored regions. ShadowSocks - 混淆 VPN 流量,使其与正常的 Web 流量相似,但在一些审查力度高的地区可以被分析系统识别。 - + OpenVPN over Cloak - OpenVPN with VPN masquerading as web traffic and protection against active-probbing detection. Ideal for bypassing blocking in regions with the highest levels of censorship. OpenVPN over Cloak - OpenVPN 与 VPN 具有伪装成网络流量和防止主动探测检测的保护。非常适合绕过审查力度特别强的地区的封锁。 - + + WireGuard - New popular VPN protocol with high performance, high speed and low power consumption. Recommended for regions with low levels of censorship. WireGuard - 新型流行的VPN协议,具有高性能、高速度和低功耗。建议用于审查力度较低的地区 - + IKEv2 - Modern stable protocol, a bit faster than others, restores connection after signal loss. It has native support on the latest versions of Android and iOS. IKEv2 - 现代稳定协议,相比其他协议较快一些,在信号丢失后恢复连接。Android 和 iOS最新版原生支持。 - + Deploy a WordPress site on the Tor network in two clicks. 只需点击两次即可架设 WordPress 网站到 Tor 网络 - + Replace the current DNS server with your own. This will increase your privacy level. 将当前的 DNS 服务器替换为您自己的。这将提高您的隐私级别。 - + Creates a file vault on your server to securely store and transfer files. 在您的服务器上创建文件库以安全地存储和传输文件 - + OpenVPN container OpenVPN容器 - + Container with OpenVpn and ShadowSocks 带有 OpenVpn 和 ShadowSocks 的容器 - + Container with OpenVpn and ShadowSocks protocols configured with traffic masking by Cloak plugin 具有 OpenVpn 和 ShadowSocks 协议的容器,通过 Cloak 插件配置混淆流量 - + WireGuard container WireGuard 容器 - + + AmneziaWG container + + + + IPsec container IPsec 容器 - + DNS Service DNS 服务 - + Sftp file sharing service - is secure FTP service Sftp 文件共享服务 - 安全的 FTP 服务 @@ -2469,6 +2581,16 @@ It's okay as long as it's from someone you trust. error 0x%1: %2 错误 0x%1: %2 + + + WireGuard Configuration Highlighter + + + + + &Randomize colors + + SelectLanguageDrawer @@ -2495,22 +2617,22 @@ It's okay as long as it's from someone you trust. SettingsController - + Software version 软件版本 - + Backup file is corrupted 备份文件已损坏 - + All settings have been reset to default values 所配置恢复为默认值 - + Cached profiles cleared 缓存的配置文件已清除 @@ -2540,8 +2662,12 @@ It's okay as long as it's from someone you trust. + Show connection settings + + + Show content - 展示内容 + 展示内容 @@ -2625,6 +2751,14 @@ It's okay as long as it's from someone you trust. 退出 + + TextFieldWithHeaderType + + + The field can't be empty + + + VpnConnection @@ -2679,32 +2813,32 @@ It's okay as long as it's from someone you trust. amnezia::ContainerProps - + Low - + High - + Medium - + I just want to increase the level of privacy 我只是想提高隐私级别 - + Many foreign websites and VPN providers are blocked 大多国外网站和VPN提供商被屏蔽 - + Some foreign sites are blocked, but VPN providers are not blocked 一些国外网站被屏蔽,但VPN提供商未被屏蔽 diff --git a/client/ui/qml/Pages2/PageProtocolAwgSettings.qml b/client/ui/qml/Pages2/PageProtocolAwgSettings.qml index 69d34114..079c85a1 100644 --- a/client/ui/qml/Pages2/PageProtocolAwgSettings.qml +++ b/client/ui/qml/Pages2/PageProtocolAwgSettings.qml @@ -73,7 +73,7 @@ PageType { HeaderType { Layout.fillWidth: true - headerText: qsTr("Amnezia WireGuard settings") + headerText: qsTr("AmneziaWG settings") } TextFieldWithHeaderType { @@ -272,11 +272,11 @@ PageType { pressedColor: Qt.rgba(1, 1, 1, 0.12) textColor: "#EB5757" - text: qsTr("Remove Amnezia WireGuard") + text: qsTr("Remove AmneziaWG") onClicked: { - questionDrawer.headerText = qsTr("Remove Amnezia WireGuard from server?") - questionDrawer.descriptionText = qsTr("All users with whom you shared a connection will no longer be able to connect to it") + questionDrawer.headerText = qsTr("Remove AmneziaWG from server?") + questionDrawer.descriptionText = qsTr("All users who you shared a connection with will no longer be able to connect to it.") questionDrawer.yesButtonText = qsTr("Continue") questionDrawer.noButtonText = qsTr("Cancel") From 992961c4888cd848b6ae86fbb3a8def9bb586d1a Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Mon, 9 Oct 2023 16:32:43 -0400 Subject: [PATCH 26/30] Update Windows WG to AWG protocol support --- client/3rd-prebuilt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/3rd-prebuilt b/client/3rd-prebuilt index c3ca525f..15b0ff39 160000 --- a/client/3rd-prebuilt +++ b/client/3rd-prebuilt @@ -1 +1 @@ -Subproject commit c3ca525f92e57fecdd6047e35b4ccded8b173407 +Subproject commit 15b0ff395d9d372339c5ea8ea35cb2715b975ea9 From 9d6559f0d732008387936addf1e9c3061019bf59 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Tue, 10 Oct 2023 12:50:41 +0500 Subject: [PATCH 27/30] fixed an error when after the first connection with admin config the container model was not updated --- client/amnezia_application.cpp | 2 + client/translations/amneziavpn_ru.ts | 54 ++++++++-------- client/translations/amneziavpn_zh_CN.ts | 86 ++++++++++++++++--------- client/ui/models/containers_model.cpp | 5 ++ client/ui/models/containers_model.h | 2 + client/vpnconnection.cpp | 1 + client/vpnconnection.h | 2 + 7 files changed, 95 insertions(+), 57 deletions(-) diff --git a/client/amnezia_application.cpp b/client/amnezia_application.cpp index 5b6d2491..4e6bce2b 100644 --- a/client/amnezia_application.cpp +++ b/client/amnezia_application.cpp @@ -279,6 +279,8 @@ void AmneziaApplication::initModels() { m_containersModel.reset(new ContainersModel(m_settings, this)); m_engine->rootContext()->setContextProperty("ContainersModel", m_containersModel.get()); + connect(m_vpnConnection.get(), &VpnConnection::newVpnConfigurationCreated, m_containersModel.get(), + &ContainersModel::updateContainersConfig); m_serversModel.reset(new ServersModel(m_settings, this)); m_engine->rootContext()->setContextProperty("ServersModel", m_serversModel.get()); diff --git a/client/translations/amneziavpn_ru.ts b/client/translations/amneziavpn_ru.ts index 47d0510f..27cb25e2 100644 --- a/client/translations/amneziavpn_ru.ts +++ b/client/translations/amneziavpn_ru.ts @@ -4,7 +4,7 @@ AmneziaApplication - + Split tunneling for WireGuard is not implemented, the option was disabled @@ -130,7 +130,7 @@ ImportController - + Scanned %1 of %2. @@ -162,32 +162,32 @@ Already installed containers were found on the server. All installed containers - + Settings updated successfully - + Server '%1' was removed - + All containers from server '%1' have been removed - + %1 has been removed from the server '%2' - + Please login as the user - + Server added successfully @@ -559,7 +559,7 @@ Already installed containers were found on the server. All installed containers - All users with whom you shared a connection will no longer be able to connect to it + All users who you shared a connection with will no longer be able to connect to it. @@ -607,7 +607,7 @@ Already installed containers were found on the server. All installed containers - All users with whom you shared a connection will no longer be able to connect to it + All users who you shared a connection with will no longer be able to connect to it. @@ -879,8 +879,12 @@ Already installed containers were found on the server. All installed containers - This is a free and open source application. If you like it, support the developers with a donation. -And if you don't like the app, all the more support it - the donation will be used to improve the app. + This is a free and open source application. If you like it, support the developers with a donation. + + + + + And if you don’t like the application, all the more reason to support it - the donation will be used for the improving the application. @@ -1056,7 +1060,7 @@ And if you don't like the app, all the more support it - the donation will - It will help you instantly restore connection settings at the next installation + You can save your settings to a backup file to restore them the next time you install the application. @@ -1150,7 +1154,7 @@ And if you don't like the app, all the more support it - the donation will - Allows you to connect to some sites through a secure connection, and to others bypassing it + Allows you to choose which sites you want to use the VPN for. @@ -1414,7 +1418,7 @@ And if you don't like the app, all the more support it - the donation will - All users with whom you shared a connection will no longer be able to connect to it + All users who you shared a connection with will no longer be able to connect to it. @@ -1800,27 +1804,27 @@ It's okay as long as it's from someone you trust. PageSetupWizardViewConfig - + New connection - + Do not use connection code from public sources. It could be created to intercept your data. - + Collapse content - + Show content - + Connect @@ -1853,6 +1857,7 @@ It's okay as long as it's from someone you trust. + Server @@ -1902,11 +1907,6 @@ It's okay as long as it's from someone you trust. Access to server management. The user with whom you share full access to the connection will be able to add and remove your protocols and services to the servers, as well as change settings. - - - Servers - - @@ -2627,7 +2627,7 @@ It's okay as long as it's from someone you trust. - + To read the QR code in the Amnezia app, select "Add server" → "I have data to connect" → "QR code, key or settings file" @@ -2719,7 +2719,7 @@ It's okay as long as it's from someone you trust. VpnConnection - + Mbps diff --git a/client/translations/amneziavpn_zh_CN.ts b/client/translations/amneziavpn_zh_CN.ts index e9d73b46..32d2d742 100644 --- a/client/translations/amneziavpn_zh_CN.ts +++ b/client/translations/amneziavpn_zh_CN.ts @@ -4,7 +4,7 @@ AmneziaApplication - + Split tunneling for WireGuard is not implemented, the option was disabled 未启用选项,还未实现基于WireGuard协议的VPN分流 @@ -30,9 +30,6 @@ - - - Connect 连接 @@ -133,7 +130,7 @@ ImportController - + Scanned %1 of %2. 扫描 %1 of %2. @@ -174,22 +171,22 @@ Already installed containers were found on the server. All installed containers 在服务上发现已经安装协议并添加到应用程序 - + Settings updated successfully 配置更新成功 - + Server '%1' was removed 已移除服务器 '%1' - + All containers from server '%1' have been removed 服务器 '%1' 的所有容器已移除 - + %1 has been removed from the server '%2' %1 已从服务器 '%2' 上移除 @@ -210,12 +207,12 @@ Already installed containers were found on the server. All installed containers 协议已从 - + Please login as the user 请以用户身份登录 - + Server added successfully 服务器添加成功 @@ -587,8 +584,12 @@ Already installed containers were found on the server. All installed containers + All users who you shared a connection with will no longer be able to connect to it. + + + All users with whom you shared a connection will no longer be able to connect to it - 与您共享连接的所有用户将无法再连接到此链接 + 与您共享连接的所有用户将无法再连接到此链接 @@ -633,14 +634,18 @@ Already installed containers were found on the server. All installed containers Remove %1 from server? 从服务器移除 %1 ? + + + All users who you shared a connection with will no longer be able to connect to it. + + from server? 从服务器 - All users with whom you shared a connection will no longer be able to connect to it - 与您共享连接的所有用户将无法再连接到此链接 + 与您共享连接的所有用户将无法再连接到此链接 @@ -907,12 +912,21 @@ Already installed containers were found on the server. All installed containers 捐款 - This is a free and open source application. If you like it, support the developers with a donation. And if you don't like the app, all the more support it - the donation will be used to improve the app. - 这是一个免费且开源的应用软件。如果您喜欢它,请捐助支持我们继续研发。 + 这是一个免费且开源的应用软件。如果您喜欢它,请捐助支持我们继续研发。 如果您不喜欢,请捐助支持我们改进它。 + + + This is a free and open source application. If you like it, support the developers with a donation. + + + + + And if you don’t like the application, all the more reason to support it - the donation will be used for the improving the application. + + Card on Patreon @@ -1085,9 +1099,13 @@ And if you don't like the app, all the more support it - the donation will 配置备份 - It will help you instantly restore connection settings at the next installation - 帮助您在下次安装时立即恢复连接设置 + 帮助您在下次安装时立即恢复连接设置 + + + + You can save your settings to a backup file to restore them the next time you install the application. + @@ -1184,8 +1202,12 @@ And if you don't like the app, all the more support it - the donation will + Allows you to choose which sites you want to use the VPN for. + + + Allows you to connect to some sites through a secure connection, and to others bypassing it - 使用VPN访问指定网站,其他的则绕过 + 使用VPN访问指定网站,其他的则绕过 @@ -1441,6 +1463,11 @@ And if you don't like the app, all the more support it - the donation will Remove 移除 + + + All users who you shared a connection with will no longer be able to connect to it. + + from server? 从服务器 @@ -1451,9 +1478,8 @@ And if you don't like the app, all the more support it - the donation will 从服务器移除 %1 ? - All users with whom you shared a connection will no longer be able to connect to it - 与您共享连接的所有用户将无法再连接到此链接 + 与您共享连接的所有用户将无法再连接到此链接 @@ -1839,27 +1865,27 @@ It's okay as long as it's from someone you trust. PageSetupWizardViewConfig - + New connection 新连接 - + Do not use connection code from public sources. It could be created to intercept your data. 请勿使用公共来源的连接代码。它可以被创建来拦截您的数据。 - + Collapse content - + Show content 展示内容 - + Connect 连接 @@ -1921,11 +1947,11 @@ It's okay as long as it's from someone you trust. 获得服务器完整授权 - Servers - 服务器 + 服务器 + Server 服务器 @@ -2678,7 +2704,7 @@ It's okay as long as it's from someone you trust. 展示内容 - + To read the QR code in the Amnezia app, select "Add server" → "I have data to connect" → "QR code, key or settings file" 要读取 Amnezia 应用程序中的二维码,请选择“添加服务器”→“我有数据要连接”→“二维码、密钥或配置文件” @@ -2770,7 +2796,7 @@ It's okay as long as it's from someone you trust. VpnConnection - + Mbps diff --git a/client/ui/models/containers_model.cpp b/client/ui/models/containers_model.cpp index 6cf855a6..0c99041e 100644 --- a/client/ui/models/containers_model.cpp +++ b/client/ui/models/containers_model.cpp @@ -228,6 +228,11 @@ bool ContainersModel::isAnyContainerInstalled() return false; } +void ContainersModel::updateContainersConfig() +{ + m_containers = m_settings->containers(m_currentlyProcessedServerIndex); +} + QHash ContainersModel::roleNames() const { QHash roles; diff --git a/client/ui/models/containers_model.h b/client/ui/models/containers_model.h index 2cc41cbf..cc549bb3 100644 --- a/client/ui/models/containers_model.h +++ b/client/ui/models/containers_model.h @@ -65,6 +65,8 @@ public slots: bool isAnyContainerInstalled(); + void updateContainersConfig(); + protected: QHash roleNames() const override; diff --git a/client/vpnconnection.cpp b/client/vpnconnection.cpp index 1cff01e6..46e8be60 100644 --- a/client/vpnconnection.cpp +++ b/client/vpnconnection.cpp @@ -323,6 +323,7 @@ void VpnConnection::connectToVpn(int serverIndex, const ServerCredentials &crede ErrorCode e = ErrorCode::NoError; m_vpnConfiguration = createVpnConfiguration(serverIndex, credentials, container, containerConfig, &e); + emit newVpnConfigurationCreated(); if (e) { emit connectionStateChanged(Vpn::ConnectionState::Error); return; diff --git a/client/vpnconnection.h b/client/vpnconnection.h index 20ee14fa..f6b2343c 100644 --- a/client/vpnconnection.h +++ b/client/vpnconnection.h @@ -79,6 +79,8 @@ signals: void serviceIsNotReady(); + void newVpnConfigurationCreated(); + protected slots: void onBytesChanged(quint64 receivedBytes, quint64 sentBytes); void onConnectionStateChanged(Vpn::ConnectionState state); From fa06dbbd291712c5fa1aba2f32fabf03e45a01e1 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Tue, 10 Oct 2023 08:52:36 -0400 Subject: [PATCH 28/30] Bump Android verion --- client/android/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/android/build.gradle b/client/android/build.gradle index cfc53460..49e378a0 100644 --- a/client/android/build.gradle +++ b/client/android/build.gradle @@ -138,8 +138,8 @@ android { resConfig "en" minSdkVersion = 24 targetSdkVersion = 34 - versionCode 32 // Change to a higher number - versionName "3.0.9" // Change to a higher number + versionCode 36 // Change to a higher number + versionName "4.0.8" // Change to a higher number javaCompileOptions.annotationProcessorOptions.arguments = [ "room.schemaLocation": "${qtAndroidDir}/schemas".toString() From 10435cea69b369fc6c85b633582b6e34ffa6b698 Mon Sep 17 00:00:00 2001 From: pokamest Date: Thu, 12 Oct 2023 01:15:05 +0100 Subject: [PATCH 29/30] Tiny refactoring and text fixes --- .../configurators/wireguard_configurator.cpp | 2 +- client/core/scripts_registry.cpp | 4 +- client/core/scripts_registry.h | 2 +- client/resources.qrc | 10 ++-- .../{amnezia_wireguard => awg}/Dockerfile | 0 .../configure_container.sh | 0 .../run_container.sh | 0 .../{amnezia_wireguard => awg}/start.sh | 0 .../{amnezia_wireguard => awg}/template.conf | 0 client/translations/amneziavpn_ru.ts | 28 ++++------- client/translations/amneziavpn_zh_CN.ts | 48 +++++++++++-------- client/ui/qml/Pages2/PageSettings.qml | 2 + .../ui/qml/Pages2/PageSettingsConnection.qml | 9 ++-- .../qml/Pages2/PageSettingsSplitTunneling.qml | 6 +-- deploy/build_windows.bat | 2 +- 15 files changed, 58 insertions(+), 55 deletions(-) rename client/server_scripts/{amnezia_wireguard => awg}/Dockerfile (100%) rename client/server_scripts/{amnezia_wireguard => awg}/configure_container.sh (100%) rename client/server_scripts/{amnezia_wireguard => awg}/run_container.sh (100%) rename client/server_scripts/{amnezia_wireguard => awg}/start.sh (100%) rename client/server_scripts/{amnezia_wireguard => awg}/template.conf (100%) diff --git a/client/configurators/wireguard_configurator.cpp b/client/configurators/wireguard_configurator.cpp index a526e109..e22c8282 100644 --- a/client/configurators/wireguard_configurator.cpp +++ b/client/configurators/wireguard_configurator.cpp @@ -28,7 +28,7 @@ WireguardConfigurator::WireguardConfigurator(std::shared_ptr settings, : amnezia::protocols::wireguard::serverPublicKeyPath; m_serverPskKeyPath = m_isAwg ? amnezia::protocols::awg::serverPskKeyPath : amnezia::protocols::wireguard::serverPskKeyPath; - m_configTemplate = m_isAwg ? ProtocolScriptType::amnezia_wireguard_template + m_configTemplate = m_isAwg ? ProtocolScriptType::awg_template : ProtocolScriptType::wireguard_template; m_protocolName = m_isAwg ? config_key::awg : config_key::wireguard; diff --git a/client/core/scripts_registry.cpp b/client/core/scripts_registry.cpp index 82ae1fce..f209a2b1 100644 --- a/client/core/scripts_registry.cpp +++ b/client/core/scripts_registry.cpp @@ -11,7 +11,7 @@ QString amnezia::scriptFolder(amnezia::DockerContainer container) case DockerContainer::Cloak: return QLatin1String("openvpn_cloak"); case DockerContainer::ShadowSocks: return QLatin1String("openvpn_shadowsocks"); case DockerContainer::WireGuard: return QLatin1String("wireguard"); - case DockerContainer::Awg: return QLatin1String("amnezia_wireguard"); + case DockerContainer::Awg: return QLatin1String("awg"); case DockerContainer::Ipsec: return QLatin1String("ipsec"); case DockerContainer::TorWebSite: return QLatin1String("website_tor"); @@ -46,7 +46,7 @@ QString amnezia::scriptName(ProtocolScriptType type) case ProtocolScriptType::container_startup: return QLatin1String("start.sh"); case ProtocolScriptType::openvpn_template: return QLatin1String("template.ovpn"); case ProtocolScriptType::wireguard_template: return QLatin1String("template.conf"); - case ProtocolScriptType::amnezia_wireguard_template: return QLatin1String("template.conf"); + case ProtocolScriptType::awg_template: return QLatin1String("template.conf"); } } diff --git a/client/core/scripts_registry.h b/client/core/scripts_registry.h index 5c7a1b6a..02fc94fd 100644 --- a/client/core/scripts_registry.h +++ b/client/core/scripts_registry.h @@ -27,7 +27,7 @@ enum ProtocolScriptType { container_startup, openvpn_template, wireguard_template, - amnezia_wireguard_template + awg_template }; diff --git a/client/resources.qrc b/client/resources.qrc index 1b639266..4c63383c 100644 --- a/client/resources.qrc +++ b/client/resources.qrc @@ -217,10 +217,10 @@ ui/qml/Controls2/TopCloseButtonType.qml images/controls/x-circle.svg ui/qml/Pages2/PageProtocolAwgSettings.qml - server_scripts/amnezia_wireguard/template.conf - server_scripts/amnezia_wireguard/start.sh - server_scripts/amnezia_wireguard/configure_container.sh - server_scripts/amnezia_wireguard/run_container.sh - server_scripts/amnezia_wireguard/Dockerfile + server_scripts/awg/template.conf + server_scripts/awg/start.sh + server_scripts/awg/configure_container.sh + server_scripts/awg/run_container.sh + server_scripts/awg/Dockerfile diff --git a/client/server_scripts/amnezia_wireguard/Dockerfile b/client/server_scripts/awg/Dockerfile similarity index 100% rename from client/server_scripts/amnezia_wireguard/Dockerfile rename to client/server_scripts/awg/Dockerfile diff --git a/client/server_scripts/amnezia_wireguard/configure_container.sh b/client/server_scripts/awg/configure_container.sh similarity index 100% rename from client/server_scripts/amnezia_wireguard/configure_container.sh rename to client/server_scripts/awg/configure_container.sh diff --git a/client/server_scripts/amnezia_wireguard/run_container.sh b/client/server_scripts/awg/run_container.sh similarity index 100% rename from client/server_scripts/amnezia_wireguard/run_container.sh rename to client/server_scripts/awg/run_container.sh diff --git a/client/server_scripts/amnezia_wireguard/start.sh b/client/server_scripts/awg/start.sh similarity index 100% rename from client/server_scripts/amnezia_wireguard/start.sh rename to client/server_scripts/awg/start.sh diff --git a/client/server_scripts/amnezia_wireguard/template.conf b/client/server_scripts/awg/template.conf similarity index 100% rename from client/server_scripts/amnezia_wireguard/template.conf rename to client/server_scripts/awg/template.conf diff --git a/client/translations/amneziavpn_ru.ts b/client/translations/amneziavpn_ru.ts index 27cb25e2..c46bebd9 100644 --- a/client/translations/amneziavpn_ru.ts +++ b/client/translations/amneziavpn_ru.ts @@ -1149,7 +1149,12 @@ Already installed containers were found on the server. All installed containers - Split site tunneling + Split tunneling + + + + + App-based split tunneling @@ -1157,11 +1162,6 @@ Already installed containers were found on the server. All installed containers Allows you to choose which sites you want to use the VPN for. - - - Separate application tunneling - - Allows you to use the VPN only for certain applications @@ -1444,17 +1444,17 @@ Already installed containers were found on the server. All installed containers PageSettingsSplitTunneling - Only the addresses in the list must be opened via VPN + Addresses from the list should be accessed via VPN - Addresses from the list should never be opened via VPN + Addresses from the list should not be accessed via VPN - Split site tunneling + Split tunneling @@ -2542,16 +2542,6 @@ It's okay as long as it's from someone you trust. error 0x%1: %2 - - - WireGuard Configuration Highlighter - - - - - &Randomize colors - - SelectLanguageDrawer diff --git a/client/translations/amneziavpn_zh_CN.ts b/client/translations/amneziavpn_zh_CN.ts index 32d2d742..b4855a72 100644 --- a/client/translations/amneziavpn_zh_CN.ts +++ b/client/translations/amneziavpn_zh_CN.ts @@ -1197,8 +1197,17 @@ And if you don't like the app, all the more support it - the donation will + Split tunneling + + + + + App-based split tunneling + + + Split site tunneling - 网站级VPN分流 + 网站级VPN分流 @@ -1210,9 +1219,8 @@ And if you don't like the app, all the more support it - the donation will 使用VPN访问指定网站,其他的则绕过 - Separate application tunneling - 应用级VPN分流 + 应用级VPN分流 @@ -1503,19 +1511,31 @@ And if you don't like the app, all the more support it - the donation will PageSettingsSplitTunneling - Only the addresses in the list must be opened via VPN - 仅列表中的地址须通过VPN访问 + 仅列表中的地址须通过VPN访问 + + + Addresses from the list should never be opened via VPN + 勿通过VPN访问列表中的地址 + + + Split site tunneling + 网站级VPN分流 + + + + Addresses from the list should be accessed via VPN + - Addresses from the list should never be opened via VPN - 勿通过VPN访问列表中的地址 + Addresses from the list should not be accessed via VPN + - Split site tunneling - 网站级VPN分流 + Split tunneling + @@ -2615,16 +2635,6 @@ It's okay as long as it's from someone you trust. error 0x%1: %2 错误 0x%1: %2 - - - WireGuard Configuration Highlighter - - - - - &Randomize colors - - SelectLanguageDrawer diff --git a/client/ui/qml/Pages2/PageSettings.qml b/client/ui/qml/Pages2/PageSettings.qml index a806d472..d90f3ec8 100644 --- a/client/ui/qml/Pages2/PageSettings.qml +++ b/client/ui/qml/Pages2/PageSettings.qml @@ -95,6 +95,7 @@ PageType { DividerType {} LabelWithButtonType { + id: about Layout.fillWidth: true text: qsTr("About AmneziaVPN") @@ -110,6 +111,7 @@ PageType { LabelWithButtonType { Layout.fillWidth: true + Layout.preferredHeight: about.height text: qsTr("Close application") leftImageSource: "qrc:/images/controls/x-circle.svg" diff --git a/client/ui/qml/Pages2/PageSettingsConnection.qml b/client/ui/qml/Pages2/PageSettingsConnection.qml index 374e1ce4..b5343d24 100644 --- a/client/ui/qml/Pages2/PageSettingsConnection.qml +++ b/client/ui/qml/Pages2/PageSettingsConnection.qml @@ -96,8 +96,8 @@ PageType { LabelWithButtonType { Layout.fillWidth: true - text: qsTr("Split site tunneling") - descriptionText: qsTr("Allows you to choose which sites you want to use the VPN for.") + text: qsTr("Site-based split tunneling") + descriptionText: qsTr("Allows you to select which sites you want to access through the VPN") rightImageSource: "qrc:/images/controls/chevron-right.svg" clickedFunction: function() { @@ -109,8 +109,9 @@ PageType { LabelWithButtonType { Layout.fillWidth: true + visible: false - text: qsTr("Separate application tunneling") + text: qsTr("App-based split tunneling") descriptionText: qsTr("Allows you to use the VPN only for certain applications") rightImageSource: "qrc:/images/controls/chevron-right.svg" @@ -118,7 +119,7 @@ PageType { } } - DividerType {} + // DividerType {} } } } diff --git a/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml b/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml index b79d5d22..45f2dae9 100644 --- a/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml +++ b/client/ui/qml/Pages2/PageSettingsSplitTunneling.qml @@ -46,12 +46,12 @@ PageType { QtObject { id: onlyForwardSites - property string name: qsTr("Only the addresses in the list must be opened via VPN") + property string name: qsTr("Addresses from the list should be accessed via VPN") property int type: routeMode.onlyForwardSites } QtObject { id: allExceptSites - property string name: qsTr("Addresses from the list should never be opened via VPN") + property string name: qsTr("Addresses from the list should not be accessed via VPN") property int type: routeMode.allExceptSites } @@ -81,7 +81,7 @@ PageType { Layout.fillWidth: true Layout.leftMargin: 16 - headerText: qsTr("Split site tunneling") + headerText: qsTr("Split tunneling") } SwitcherType { diff --git a/deploy/build_windows.bat b/deploy/build_windows.bat index c4b7b8cf..7ac37f14 100644 --- a/deploy/build_windows.bat +++ b/deploy/build_windows.bat @@ -47,7 +47,7 @@ cd %PROJECT_DIR% call "%QT_BIN_DIR:"=%\qt-cmake" . -B %WORK_DIR% cd %WORK_DIR% -cmake --build . --config release +cmake --build . --config release -- /p:UseMultiToolTask=true /m if %errorlevel% neq 0 exit /b %errorlevel% cmake --build . --target clean From d1f66cbf4d64549a340d682b5f1d3da361160479 Mon Sep 17 00:00:00 2001 From: ronoaer Date: Thu, 12 Oct 2023 16:26:37 +0800 Subject: [PATCH 30/30] updated translations for branch feature/amnezia-wireguard-client-impl --- client/translations/amneziavpn_ru.ts | 29 +- client/translations/amneziavpn_zh_CN.ts | 1061 +++++++++-------- client/ui/controllers/sitesController.cpp | 2 +- client/ui/qml/Pages2/PageProtocolRaw.qml | 2 +- .../ui/qml/Pages2/PageSettingsApplication.qml | 2 +- 5 files changed, 550 insertions(+), 546 deletions(-) diff --git a/client/translations/amneziavpn_ru.ts b/client/translations/amneziavpn_ru.ts index c46bebd9..ac099552 100644 --- a/client/translations/amneziavpn_ru.ts +++ b/client/translations/amneziavpn_ru.ts @@ -592,7 +592,7 @@ Already installed containers were found on the server. All installed containers - Connection options + Connection options %1 @@ -860,12 +860,12 @@ Already installed containers were found on the server. All installed containers - + About AmneziaVPN - + Close application @@ -977,12 +977,7 @@ Already installed containers were found on the server. All installed containers - Launch the application every time - - - - - starts + Launch the application every time %1 starts @@ -1149,21 +1144,21 @@ Already installed containers were found on the server. All installed containers - Split tunneling - - - - - App-based split tunneling + Site-based split tunneling - Allows you to choose which sites you want to use the VPN for. + Allows you to select which sites you want to access through the VPN + App-based split tunneling + + + + Allows you to use the VPN only for certain applications @@ -2651,7 +2646,7 @@ It's okay as long as it's from someone you trust. - The JSON data is not an array in file: + The JSON data is not an array in file: %1 diff --git a/client/translations/amneziavpn_zh_CN.ts b/client/translations/amneziavpn_zh_CN.ts index b4855a72..7a08682c 100644 --- a/client/translations/amneziavpn_zh_CN.ts +++ b/client/translations/amneziavpn_zh_CN.ts @@ -6,7 +6,7 @@ Split tunneling for WireGuard is not implemented, the option was disabled - 未启用选项,还未实现基于WireGuard协议的VPN分流 + 未启用选项,还未实现基于WireGuard协议的VPN分离 @@ -14,13 +14,13 @@ AmneziaVPN - + VPN Connected Refers to the app - which is currently running the background and waiting - VPN已连接 + VPN已连接 @@ -31,38 +31,38 @@ Connect - 连接 + 连接 VPN Protocols is not installed. Please install VPN container at first - 不存在VPN协议,请先安装 + 请先安装VPN协议 Connection... - 连接中 + 连接中 Connected - 已连接 + 已连接 Reconnection... - 重连中 + 重连中 Disconnection... - 断开中 + 断开中 Settings updated successfully, Reconnnection... - 配置已更新,重连中 + 配置已更新,重连中 @@ -70,17 +70,17 @@ Connection data - 连接数据 + 连接方式 Server IP, login and password - 服务器IP,用户名和密码 + 服务器IP,用户名和密码 QR code, key or configuration file - 二维码,授权码或者配置文件 + 二维码,授权码或者配置文件 @@ -88,22 +88,22 @@ C&ut - 剪切 + 剪切 &Copy - 拷贝 + 拷贝 &Paste - 粘贴 + 粘贴 &SelectAll - 全选 + 全选 @@ -111,7 +111,7 @@ Access error! - 访问错误 + 访问错误 @@ -119,12 +119,12 @@ The selected protocol is not supported on the current platform - 当前平台不支持所选协议 + 当前平台不支持所选协议 Reconnect via VPN Procotol: - 重连基于VPN协议: + 重连VPN基于协议: @@ -132,7 +132,7 @@ Scanned %1 of %2. - 扫描 %1 of %2. + 扫描 %1 of %2. @@ -149,46 +149,46 @@ %1 installed successfully. - %1 安装成功。 + %1 安装成功。 %1 is already installed on the server. - 服务器上已经安装 %1。 + 服务器上已经安装 %1。 Added containers that were already installed on the server - + 添加已安装在服务器上的容器 Already installed containers were found on the server. All installed containers have been added to the application - -在服务上发现已经安装协议并添加到应用程序 + +在服务上发现已经安装协议并添加至应用 Settings updated successfully - 配置更新成功 + 配置更新成功 Server '%1' was removed - 已移除服务器 '%1' + 已移除服务器 '%1' All containers from server '%1' have been removed - 服务器 '%1' 的所有容器已移除 + 服务器 '%1' 的所有容器已移除 %1 has been removed from the server '%2' - %1 已从服务器 '%2' 上移除 + %1 已从服务器 '%2' 上移除 1% has been removed from the server '%2' @@ -209,12 +209,12 @@ Already installed containers were found on the server. All installed containers Please login as the user - 请以用户身份登录 + 请以用户身份登录 Server added successfully - 服务器添加成功 + 增加服务器成功 @@ -222,17 +222,17 @@ Already installed containers were found on the server. All installed containers Read key failed: %1 - 获取授权码失败: %1 + 获取授权码失败: %1 Write key failed: %1 - 写入授权码失败: %1 + 写入授权码失败: %1 Delete key failed: %1 - 删除授权码失败: %1 + 删除授权码失败: %1 @@ -241,27 +241,27 @@ Already installed containers were found on the server. All installed containers AmneziaVPN - + VPN Connected - 已连接到VPN + 已连接到VPN VPN Disconnected - 已从VPN断开 + 已从VPN断开 AmneziaVPN notification - AmneziaVPN 提示 + AmneziaVPN 提示 Unsecured network detected: - 发现不安全网络 + 发现不安全网络 @@ -269,12 +269,12 @@ Already installed containers were found on the server. All installed containers Removing services from %1 - 正从 %1 移除服务 + 正从 %1 移除服务 Usually it takes no more than 5 minutes - 通常5分钟之内完成 + 大约5分钟之内完成 @@ -282,12 +282,12 @@ Already installed containers were found on the server. All installed containers VPN protocol - VPN协议 + VPN协议 Servers - 服务器 + 服务器 @@ -295,87 +295,87 @@ Already installed containers were found on the server. All installed containers AmneziaWG settings - + AmneziaWG 配置 Port - 端口 + 端口 Junk packet count - + 垃圾包数量 Junk packet minimum size - + 垃圾包最小值 Junk packet maximum size - + 垃圾包最大值 Init packet junk size - + 初始化垃圾包大小 Response packet junk size - + 响应垃圾包大小 Init packet magic header - + 初始化数据包魔数头 Response packet magic header - + 响应包魔数头 Transport packet magic header - + 传输包魔数头 Underload packet magic header - + 低负载数据包魔数头 Remove AmneziaWG - + 移除AmneziaWG Remove AmneziaWG from server? - + 从服务上移除AmneziaWG? All users who you shared a connection with will no longer be able to connect to it. - + 使用此共享连接的所有用户,将无法再连接它。 Continue - 继续 + 继续 Cancel - 取消 + 取消 Save and Restart Amnezia - 保存并重启Amnezia + 保存并重启Amnezia @@ -383,28 +383,28 @@ Already installed containers were found on the server. All installed containers Cloak settings - Cloak 配置 + Cloak 配置 Disguised as traffic from - 伪装流量来自 + 伪装流量为 Port - 端口 + 端口 Cipher - 解码 + 加密算法 Save and Restart Amnezia - 保存并重启Amnezia + 保存并重启Amnezia @@ -412,180 +412,180 @@ Already installed containers were found on the server. All installed containers OpenVPN settings - OpenVPN 配置 + OpenVPN 配置 VPN Addresses Subnet - VPN子网掩码 + VPN子网掩码 Network protocol - 网络协议 + 网络协议 Port - 端口 + 端口 Auto-negotiate encryption - 自动协商加密 + 自定义加密方式 Hash - + SHA512 - + SHA384 - + SHA256 - + SHA3-512 - + SHA3-384 - + SHA3-256 - + whirlpool - + BLAKE2b512 - + BLAKE2s256 - + SHA1 - + Cipher - 解码 + AES-256-GCM - + AES-192-GCM - + AES-128-GCM - + AES-256-CBC - + AES-192-CBC - + AES-128-CBC - + ChaCha20-Poly1305 - + ARIA-256-CBC - + CAMELLIA-256-CBC - + none - + TLS auth - TLS认证 + TLS认证 Block DNS requests outside of VPN - 阻止VPN外的DNS请求 + 阻止VPN外的DNS请求 Additional client configuration commands - 附加客户端配置命令 + 附加客户端配置命令 Commands: - 命令: + 命令: Additional server configuration commands - 附加服务器端配置命令 + 附加服务器端配置命令 Remove OpenVPN - 移除OpenVPN + 移除OpenVPN Remove OpenVpn from server? - 从服务器移除OpenVPN吗? + 从服务器移除OpenVPN吗? All users who you shared a connection with will no longer be able to connect to it. - + 使用此共享连接的所有用户,将无法再连接它。 All users with whom you shared a connection will no longer be able to connect to it @@ -594,17 +594,17 @@ Already installed containers were found on the server. All installed containers Continue - 继续 + 继续 Cancel - 取消 + 取消 Save and Restart Amnezia - 保存并重启Amnezia + 保存并重启Amnezia @@ -612,32 +612,36 @@ Already installed containers were found on the server. All installed containers settings - 配置 + 配置 Show connection options - 展示连接选项 + 显示连接选项 + + + Connection options + 连接选项 - Connection options - 连接选项 + Connection options %1 + %1 连接选项 Remove - 移除 + 移除 Remove %1 from server? - 从服务器移除 %1 ? + 从服务器移除 %1 ? All users who you shared a connection with will no longer be able to connect to it. - + 使用此共享连接的所有用户,将无法再连接它。 from server? @@ -650,12 +654,12 @@ Already installed containers were found on the server. All installed containers Continue - 继续 + 继续 Cancel - 取消 + 取消 @@ -663,23 +667,23 @@ Already installed containers were found on the server. All installed containers ShadowSocks settings - ShadowSocks 配置 + ShadowSocks 配置 Port - 端口 + 端口 Cipher - 解码 + 加密算法 Save and Restart Amnezia - 保存并重启Amnezia + 保存并重启Amnezia @@ -688,22 +692,23 @@ Already installed containers were found on the server. All installed containers A DNS service is installed on your server, and it is only accessible via VPN. - 您的服务器上安装了DNS服务,并且只能通过VPN访问。 + 您的服务器已安装DNS服务,仅能通过VPN访问。 + The DNS address is the same as the address of your server. You can configure DNS in the settings, under the connections tab. - DNS地址与您的服务器地址相同。您可以在连接选项卡下的设置中配置 DNS + 其地址与您的服务器地址相同。您可以在 设置 连接 中进行配置。 Remove - 移除 + 移除 Remove %1 from server? - 从服务器移除 %1 ? + 从服务器移除 %1 ? from server? @@ -712,12 +717,12 @@ Already installed containers were found on the server. All installed containers Continue - 继续 + 继续 Cancel - 取消 + 取消 @@ -725,17 +730,17 @@ Already installed containers were found on the server. All installed containers Settings updated successfully - 配置更新成功 + 配置更新成功 SFTP settings - SFTP 配置 + SFTP 配置 Host - 主机 + 主机 @@ -743,69 +748,69 @@ Already installed containers were found on the server. All installed containers Copied - 拷贝 + 拷贝 Port - 端口 + 端口 Login - 用户 + 用户 Password - 密码 + 密码 Mount folder on device - 在设备上挂载文件夹 + 挂载文件夹 In order to mount remote SFTP folder as local drive, perform following steps: <br> - 要将远程 SFTP 文件夹安装为本地驱动器,请执行以下步骤: <br> + 为将远程 SFTP 文件夹挂载到本地,请执行以下步骤: <br> <br>1. Install the latest version of - <br>1. 安装最新版的 + <br>1. 安装最新版的 <br>2. Install the latest version of - <br>2. 安装最新版的 + <br>2. 安装最新版的 Detailed instructions - 详细说明 + 详细说明 Remove SFTP and all data stored there - 移除SFTP和其本地所有数据 + 移除SFTP和其本地所有数据 Remove SFTP and all data stored there? - 移除SFTP和其本地所有数据? + 移除SFTP和其本地所有数据? Continue - 继续 + 继续 Cancel - 取消 + 取消 @@ -813,57 +818,57 @@ Already installed containers were found on the server. All installed containers Settings updated successfully - 配置更新成功 + 配置更新成功 Tor website settings - Tor网站配置 + Tor网站配置 Website address - 网址 + 网址 Copied - 拷贝 + 已拷贝 Use <a href="https://www.torproject.org/download/" style="color: #FBB26A;">Tor Browser</a> to open this url. - 用 <a href="https://www.torproject.org/download/" style="color: #FBB26A;">Tor 浏览器</a> 打开上面网址 + 用 <a href="https://www.torproject.org/download/" style="color: #FBB26A;">Tor 浏览器</a> 打开上面网址 After installation it takes several minutes while your onion site will become available in the Tor Network. - 安装几分钟后,洋葱站点才会在 Tor 网络中生效。 + 完成安装几分钟后,洋葱站点才会在 Tor 网络中生效。 When configuring WordPress set the domain as this onion address. - 配置 WordPress 时,将域设置为此洋葱地址。 + 配置 WordPress 时,将域设置为此洋葱地址。 Remove website - 移除网站 + 移除网站 The site with all data will be removed from the tor network. - 网站及其所有数据将从 Tor 网络中删除 + 网站及其所有数据将从 Tor 网络中删除 Continue - 继续 + 继续 Cancel - 取消 + 取消 @@ -871,37 +876,37 @@ Already installed containers were found on the server. All installed containers Settings - 设置 + 设置 Servers - 服务器 + 服务器 Connection - 连接 + 连接 Application - 应用 + 应用 Backup - 备份 + 备份 - + About AmneziaVPN - 关于 + 关于 - + Close application - + 关闭应用 @@ -909,7 +914,7 @@ Already installed containers were found on the server. All installed containers Support the project with a donation - 捐款 + 捐款 This is a free and open source application. If you like it, support the developers with a donation. @@ -920,82 +925,83 @@ And if you don't like the app, all the more support it - the donation will This is a free and open source application. If you like it, support the developers with a donation. - + 这是一个免费且开源的软件。如果您喜欢它,请捐助开发者们。 + And if you don’t like the application, all the more reason to support it - the donation will be used for the improving the application. - + 如果您不喜欢,请捐助支持我们改进它。 Card on Patreon - Patreon订阅 + Patreon订阅 https://www.patreon.com/amneziavpn - + Show other methods on Github - 其他捐款途径 + 其他捐款途径 Contacts - 联系方式 + 联系方式 Telegram group - 电报群 + 电报群 To discuss features - 用于功能讨论 + 用于功能讨论 https://t.me/amnezia_vpn_en - + Mail - 邮件 + 邮件 For reviews and bug reports - 用于评论和提交软件的缺陷 + 用于评论和提交软件的缺陷 Github - + https://github.com/amnezia-vpn/amnezia-client - + Website - 官网 + 官网 https://amnezia.org - + Check for updates - 更新 + 检查更新 @@ -1003,82 +1009,85 @@ And if you don't like the app, all the more support it - the donation will Application - 应用 + 应用 Allow application screenshots - + 允许截屏 Auto start - 自动运行 + 自动运行 - Launch the application every time - 总是在系统 + 总是在系统 + + + starts + 启动时自动运行运用程序 - starts - 启动时自动运行运用程序 + Launch the application every time %1 starts + 运行应用软件在%1系统启动时 Start minimized - 最小化 + 最小化 Launch application minimized - 开启应用程序时窗口最小化 + 开启应用软件时窗口最小化 Language - 语言 + 语言 Logging - 日志 + 日志 Enabled - 开启 + 开启 Disabled - 禁用 + 禁用 Reset settings and remove all data from the application - 重置并清理应用的所有数据 + 重置并清理应用的所有数据 Reset settings and remove all data from the application? - 重置并清理应用的所有数据? + 重置并清理应用的所有数据? All settings will be reset to default. All installed AmneziaVPN services will still remain on the server. - 所有配置恢复为默认值。在服务器上保留所有已安装的AmneziaVPN服务。 + 所有配置恢复为默认值。服务器已安装的AmneziaVPN服务将被保留。 Continue - 继续 + 继续 Cancel - 取消 + 取消 @@ -1086,17 +1095,17 @@ And if you don't like the app, all the more support it - the donation will Settings restored from backup file - 从备份文件还原配置 + 从备份文件还原配置 Backup - 备份 + 备份 Configuration backup - 配置备份 + 备份设置 It will help you instantly restore connection settings at the next installation @@ -1105,53 +1114,53 @@ And if you don't like the app, all the more support it - the donation will You can save your settings to a backup file to restore them the next time you install the application. - + 您可以将配置信息备份到文件中,以便在下次安装应用软件时恢复配置 Make a backup - 进行备份 + 进行备份 Save backup file - 保存备份 + 保存备份 Backup files (*.backup) - + Restore from backup - 从备份还原 + 从备份还原 Open backup file - 打开备份文件 + 打开备份文件 Import settings from a backup file? - 从备份文件导入设置? + 从备份文件导入设置? All current settings will be reset - 当前所有设置将重置 + 当前所有设置将重置 Continue - 继续 + 继续 Cancel - 取消 + 取消 @@ -1159,17 +1168,17 @@ And if you don't like the app, all the more support it - the donation will Connection - 连接 + 连接 Auto connect - 自动连接 + 自动连接 Connect to VPN on app start - 应用开启时连接VPN + 应用开启时连接VPN Use AmneziaDNS if installed on the server @@ -1178,42 +1187,42 @@ And if you don't like the app, all the more support it - the donation will Use AmneziaDNS - 使用AmneziaDNS + 使用AmneziaDNS If AmneziaDNS is installed on the server - 如其已安装至服务器上 + 如果已在服务器安装AmneziaDNS DNS servers - DNS服务器列表 + DNS服务器 If AmneziaDNS is not used or installed - 如果未使用或未安装AmneziaDNS + 如果未使用或未安装AmneziaDNS - Split tunneling - + Site-based split tunneling + 基于网站的隧道分离 - + + Allows you to select which sites you want to access through the VPN + 配置想要通过VPN访问网站 + + + App-based split tunneling - + 基于应用的隧道分离 Split site tunneling 网站级VPN分流 - - - Allows you to choose which sites you want to use the VPN for. - - Allows you to connect to some sites through a secure connection, and to others bypassing it 使用VPN访问指定网站,其他的则绕过 @@ -1223,9 +1232,9 @@ And if you don't like the app, all the more support it - the donation will 应用级VPN分流 - + Allows you to use the VPN only for certain applications - 仅限指定应用使用VPN + 仅指定应用使用VPN @@ -1233,57 +1242,57 @@ And if you don't like the app, all the more support it - the donation will DNS servers - DNS服务器 + DNS服务器 If AmneziaDNS is not used or installed - 如果未使用或未安装Amnezia DNS + 如果未使用或未安装AmneziaDNS Primary DNS - 首选 DNS + 首选 DNS Secondary DNS - 备用 DNS + 备用 DNS Restore default - 恢复默认配置 + 恢复默认配置 Restore default DNS settings? - 是否恢复默认DNS配置? + 是否恢复默认DNS配置? Continue - 继续 + 继续 Cancel - 取消 + 取消 Settings have been reset - 已重置 + 已重置 Save - 保存 + 保存 Settings saved - 配置已保存 + 配置已保存 @@ -1291,57 +1300,57 @@ And if you don't like the app, all the more support it - the donation will Logging - 日志 + 日志 Save logs - 记录日志 + 记录日志 Open folder with logs - 打开日志文件夹 + 打开日志文件夹 Save - 保存 + 保存 Logs files (*.log) - + Save logs to file - 保存日志到文件 + 保存日志到文件 Clear logs? - 清除日志? + 清理日志? Continue - 继续 + 继续 Cancel - 取消 + 取消 Logs have been cleaned up - 已清理日志 + 日志已清理 Clear logs - 清理日志 + 清理日志 @@ -1349,27 +1358,27 @@ And if you don't like the app, all the more support it - the donation will All installed containers have been added to the application - 所有已安装的容器已添加到应用程序中 + 所有已安装的容器,已被添加到应用软件 No new installed containers found - 未找到新安装的容器 + 未发现新安装的容器 Clear Amnezia cache - 清除 Amnezia 缓存 + 清除 Amnezia 缓存 May be needed when changing other settings - 更改其他设置时可能需要 + 更改其他设置时可能需要缓存 Clear cached profiles? - 清除缓存的配置文件? + 清除缓存? @@ -1381,54 +1390,54 @@ And if you don't like the app, all the more support it - the donation will Continue - 继续 + 继续 Cancel - 取消 + 取消 Check the server for previously installed Amnezia services - 检查服务器上是否存在 Amnezia 服务 + 检查服务器上,是否存在之前安装的 Amnezia 服务 Add them to the application if they were not displayed - 如果存在且未被显示,则添加到应用程序里 + 如果存在且未显示,则添加到应用软件 Remove server from application - 移除本地服务器信息 + 移除本地服务器信息 Remove server? - 移除本地服务器信息? + 移除本地服务器信息? All installed AmneziaVPN services will still remain on the server. - 所有已安装的 AmneziaVPN 服务仍将保留在服务器上。 + 所有已安装的 AmneziaVPN 服务仍将保留在服务器上。 Clear server from Amnezia software - 移除Amnezia中服务器信息 + 清理Amnezia中服务器信息 Clear server from Amnezia software? - 从Amnezia中清除服务器? + 清理Amnezia中服务器信息 All containers will be deleted on the server. This means that configuration files, keys and certificates will be deleted. - 服务器上的所有容器都将被删除。这意味着配置文件、密钥和证书将被删除。 + 服务器上的所有容器都将被删除。配置文件、密钥和证书也将被删除。 @@ -1436,27 +1445,27 @@ And if you don't like the app, all the more support it - the donation will Server name - 服务器名称 + 服务器名 Save - 保存 + 保存 Protocols - 协议 + 协议 Services - 服务 + 服务 Data - 数据 + 数据 @@ -1464,17 +1473,17 @@ And if you don't like the app, all the more support it - the donation will settings - 配置 + 配置 Remove - 移除 + 移除 All users who you shared a connection with will no longer be able to connect to it. - + 使用此共享连接的所有用户,将无法再连接它。 from server? @@ -1483,7 +1492,7 @@ And if you don't like the app, all the more support it - the donation will Remove %1 from server? - 从服务器移除 %1 ? + 从服务器移除 %1 ? All users with whom you shared a connection will no longer be able to connect to it @@ -1492,12 +1501,12 @@ And if you don't like the app, all the more support it - the donation will Continue - 继续 + 继续 Cancel - 取消 + 取消 @@ -1505,7 +1514,7 @@ And if you don't like the app, all the more support it - the donation will Servers - 服务器 + 服务器 @@ -1525,90 +1534,90 @@ And if you don't like the app, all the more support it - the donation will Addresses from the list should be accessed via VPN - + 仅使用VPN访问 Addresses from the list should not be accessed via VPN - + 不使用VPN访问 Split tunneling - + 隧道分离 Mode - 方式 + 规则 Remove - 移除 + 移除 Continue - 继续 + 继续 Cancel - 取消 + 取消 Site or IP - 网址或IP地址 + 网站或IP地址 Import/Export Sites - 导入/导出网址 + 导入/导出网站 Import - 导入 + 导入 Save site list - 保存网址 + 保存网址 Save sites - 保存网址 + 保存网址 Sites files (*.json) - + Import a list of sites - 导入网址列表 + 导入网址列表 Replace site list - 替换网址列表 + 替换网址列表 Open sites file - 打开网址文件 + 打开网址文件 Add imported sites to existing ones - 将导入的网址添加到现有网址中 + 将导入的网址添加到现有网址中 @@ -1616,45 +1625,45 @@ And if you don't like the app, all the more support it - the donation will Server connection - 服务器连接 + 服务器连接 Do not use connection code from public sources. It may have been created to intercept your data. It's okay as long as it's from someone you trust. - 请勿使用公共来源的连接代码。它可能是为了拦截您的数据而创建的。 -最好是来源可信。 + 请勿使用公共来源的连接码。它可能是为了拦截您的数据而创建的。 +请确保连接码来源可信。 What do you have? - + 你用什么方式创建连接? File with connection settings or backup - 包含连接配置或备份的文件 + 包含连接配置或备份的文件 File with connection settings - 包含连接配置的文件 + 包含连接配置的文件 Open config file - 打开配置文件 + 打开配置文件 QR-code - 二维码 + 二维码 Key as text - 授权码文本 + 授权码文本 @@ -1662,52 +1671,52 @@ It's okay as long as it's from someone you trust. Server connection - 服务器连接 + 连接服务器 Server IP address [:port] - 服务器IP [:端口] + 服务器IP [:端口] 255.255.255.255:88 - + Login to connect via SSH - 用户名 + ssh账号 Password / SSH private key - 密码 或者 私钥 + 密码 或 私钥 Continue - 继续 + 继续 Ip address cannot be empty - IP不能为空 + IP不能为空 Enter the address in the format 255.255.255.255:88 - 按照这种格式输入 255.255.255.255:88 + 按照这种格式输入 255.255.255.255:88 Login cannot be empty - 用户名不能为空 + 账号不能为空 Password/private key cannot be empty - 密码或者私钥不能为空 + 密码或私钥不能为空 @@ -1715,27 +1724,27 @@ It's okay as long as it's from someone you trust. What is the level of internet control in your region? - 您所在地区的互联网控制力度如何? + 您所在地区的互联网管控力度如何? Set up a VPN yourself - 自己架设VPN + 自己架设VPN I want to choose a VPN protocol - 我想选择VPN协议 + 我想选择VPN协议 Continue - 继续 + 继续 Set up later - 稍后设置 + 稍后设置 @@ -1744,32 +1753,32 @@ It's okay as long as it's from someone you trust. Usually it takes no more than 5 minutes - 通常不超过5分钟 + 通常不超过5分钟 The server has already been added to the application - 服务器已添加到应用程序中 + 服务器已添加到应用软件中 Amnesia has detected that your server is currently - Amnezia 检测到您的服务器当前 + Amnezia 检测到您的服务器当前 busy installing other software. Amnesia installation - 正安装其他软件。Amnezia安装 + 正安装其他软件。Amnezia安装 will pause until the server finishes installing other software - 将暂停,直到服务器完成安装其他软件。 + 将暂停,直到其他软件安装完成。 Installing - 安装中 + 安装中 @@ -1777,32 +1786,32 @@ It's okay as long as it's from someone you trust. Installing %1 - 正在安装 %1 + 正在安装 %1 More detailed - 更多细节 + 更多细节 Close - 关闭 + 关闭 Network protocol - 网络协议 + 网络协议 Port - 端口 + 端口 Install - 安装 + 安装 @@ -1810,12 +1819,12 @@ It's okay as long as it's from someone you trust. VPN protocol - VPN 协议 + VPN 协议 Choose the one with the highest priority for you. Later, you can install other protocols and additional services, such as DNS proxy and SFTP. - 选择最适合您的一项。稍后,您可以安装其他协议和附加服务,例如 DNS 代理和 SFTP。 + 选择你认为优先级最高的一项。稍后,您可以安装其他协议和附加服务,例如 DNS 代理和 SFTP。 @@ -1823,7 +1832,7 @@ It's okay as long as it's from someone you trust. Point the camera at the QR code and hold for a couple of seconds. - 将相机对准二维码并按住几秒钟 + 将相机对准二维码并按住几秒钟 @@ -1831,27 +1840,27 @@ It's okay as long as it's from someone you trust. Settings restored from backup file - 从备份文件还原配置 + 从备份文件还原配置 Free service for creating a personal VPN on your server. - + 在您的服务器上架设私人免费VPN服务。 Helps you access blocked content without revealing your privacy, even to VPN providers. - + 帮助您访问受限内容,保护您的隐私,即使是VPN提供商也无法获取。 I have the data to connect - + 我有连接配置 I have nothing - + 我没有 @@ -1859,27 +1868,27 @@ It's okay as long as it's from someone you trust. Connection key - 连接授权码 + 连接授权码 A line that starts with vpn://... - 以 vpn://... 开始的行 + 以 vpn://... 开始的行 Key - 授权码 + 授权码 Insert - 插入 + 插入 Continue - 继续 + 继续 @@ -1887,27 +1896,27 @@ It's okay as long as it's from someone you trust. New connection - 新连接 + 新连接 Do not use connection code from public sources. It could be created to intercept your data. - 请勿使用公共来源的连接代码。它可以被创建来拦截您的数据。 + 请勿使用公共来源的连接码。它可以被创建来拦截您的数据。 Collapse content - + 折叠内容 Show content - 展示内容 + 显示内容 Connect - 连接 + 连接 @@ -1915,52 +1924,52 @@ It's okay as long as it's from someone you trust. Save OpenVPN config - 保存OpenVPN配置 + 保存OpenVPN配置 Save WireGuard config - 保存WireGuard配置 + 保存WireGuard配置 For the AmneziaVPN app - AmneziaVPN 应用 + AmneziaVPN 应用 OpenVpn native format - OpenVPN原生格式 + OpenVPN原生格式 WireGuard native format - WireGuard原生格式 + WireGuard原生格式 VPN Access - 访问VPN + 访问VPN Connection - 连接 + 连接 Full access - 完整授权 + 完全访问 VPN access without the ability to manage the server - 无权控制服务器 + 访问VPN,但没有权限管理服务。 Access to server management. The user with whom you share full access to the connection will be able to add and remove your protocols and services to the servers, as well as change settings. - + 除访问VPN外,用户还能添加和删除协议、服务以及更改配置信息 Full access to server @@ -1974,22 +1983,22 @@ It's okay as long as it's from someone you trust. Server - 服务器 + 服务器 Accessing - 访问 + 访问 File with accessing settings to - + 访问配置文件的内容为: File with connection settings to - 连接配置文件的内容为: + 连接配置文件的内容为: Protocols @@ -1999,23 +2008,23 @@ It's okay as long as it's from someone you trust. Protocol - 协议 + 协议 Connection to - 连接到 + 连接到 Connection format - 连接方式 + 连接格式 Share - 共享 + 共享 @@ -2023,7 +2032,7 @@ It's okay as long as it's from someone you trust. Close - 关闭 + 关闭 @@ -2031,38 +2040,38 @@ It's okay as long as it's from someone you trust. Password entry not found - 没有密码输入 + 未发现秘密 Could not decrypt data - 不能加密数据 + 数据无法加密 Unknown error - 位置错误 + 未知错误 Could not open wallet: %1; %2 - 无法打开钱包: %1; %2 + 无法打开钱包: %1; %2 Password not found - 未发现密码 + 未发现密码 Could not open keystore - 无法打开密钥库 + 无法打开密钥库 Could not remove private key from keystore - 无法从密钥库中删除私钥 + 无法从密钥库中删除私钥 @@ -2070,12 +2079,12 @@ It's okay as long as it's from someone you trust. Unknown error - 未知错误 + 未知错误 Access to keychain denied - 访问钥匙串被拒绝 + 访问钥匙串被拒绝 @@ -2083,27 +2092,27 @@ It's okay as long as it's from someone you trust. Could not store data in settings: access error - 无法在配置中存储数据:访问错误 + 无法在配置中存储数据:访问错误 Could not store data in settings: format error - 无法在陪置中存储数据:格式错误 + 无法在陪置中存储数据:格式错误 Could not delete data from settings: access error - 无法在配置中删除数据:访问错误 + 无法在配置中删除数据:访问错误 Could not delete data from settings: format error - 无法在配置中删除数据:格式错误 + 无法在配置中删除数据:格式错误 Entry not found - 未找到条目 + 未找到条目 @@ -2111,80 +2120,80 @@ It's okay as long as it's from someone you trust. Password entry not found - 没有密码输入 + 未发现密码 Could not decrypt data - 不能加密数据 + 数据无法加密 D-Bus is not running - + D-Bus未运行 Unknown error - + 未知错误 No keychain service available - + 没有有效的钥匙串服务 Could not open wallet: %1; %2 - 无法打开钱包: %1; %2 + 无法打开钱包: %1; %2 Access to keychain denied - 访问钥匙串被拒绝 + 访问钥匙串被拒绝 Could not determine data type: %1; %2 - + 无法确定数据类型: %1; %2 Entry not found - + 未找到记录 Unsupported entry type 'Map' - + 不支持的记录类型 'Map' Unknown kwallet entry type '%1' - + 未知钱包类型 '%1' Password not found - 未发现密码 + 未发现密码 Could not open keystore - 无法打开密钥库 + 无法打开密钥库 Could not retrieve private key from keystore - 无法从密钥存储库中检索私钥 + 无法从密钥存储库中检索私钥 Could not create decryption cipher - 无法创建解密密码 + 无法创建解密算法 @@ -2192,73 +2201,73 @@ It's okay as long as it's from someone you trust. Credential size exceeds maximum size of %1 - + 证书大小超过上限,最大为: %1 Credential key exceeds maximum size of %1 - + 凭证密钥大小超过上限,最大为: %1 Writing credentials failed: Win32 error code %1 - + 写入凭证失败,Win32错误码: %1 Encryption failed - + 加密失败 D-Bus is not running - + D-Bus未运行 Unknown error - + 未知错误 Could not open wallet: %1; %2 - 无法打开钱包: %1; %2 + 无法打开钱包: %1; %2 Password not found - 未发现密码 + 未发现密码 Could not open keystore - 无法打开密钥库 + 无法打开密钥库 Could not create private key generator - 无法创建私钥生成器 + 无法创建私钥生成器 Could not generate new private key - 无法生成新的私钥 + 无法生成新的私钥 Could not retrieve private key from keystore - 无法从密钥库检索私钥 + 无法从密钥库检索私钥 Could not create encryption cipher - 无法创建加密密码 + 无法创建加密密码 Could not encrypt data - 无法加密数据 + 无法加密数据 @@ -2266,374 +2275,374 @@ It's okay as long as it's from someone you trust. Sftp service - Sftp 服务 + Sftp 服务 No error - 没有错误 + 没有错误 Unknown Error - 位置错误 + 未知错误 Function not implemented - 功能未实现 + 功能未实现 Server check failed - 服务器检测失败 + 服务器检测失败 Server port already used. Check for another software - 检测服务器该端口是否被其他软件被占用 + 检测服务器该端口是否被其他软件被占用 Server error: Docker container missing - Server error: Docker容器丢失 + 服务器错误: Docker容器丢失 Server error: Docker failed - Server error: Docker失败 + 服务器错误: Docker失败 Installation canceled by user - 用户取消安装 + 用户取消安装 The user does not have permission to use sudo - 用户没有root权限 + 用户没有root权限 Ssh request was denied - ssh请求被拒绝 + ssh请求被拒绝 Ssh request was interrupted - ssh请求中断 + ssh请求中断 Ssh internal error - ssh内部错误 + ssh内部错误 Invalid private key or invalid passphrase entered - 输入的私钥或密码无效 + 输入的私钥或密码无效 The selected private key format is not supported, use openssh ED25519 key types or PEM key types - 不支持所选私钥格式,请使用 openssh ED25519 密钥类型或 PEM 密钥类型 + 不支持所选私钥格式,请使用 openssh ED25519 密钥类型或 PEM 密钥类型 Timeout connecting to server - 连接服务器超时 + 连接服务器超时 Sftp error: End-of-file encountered - Sftp错误: 遇到文件结尾 + Sftp错误: End-of-file encountered Sftp error: File does not exist - Sftp错误: 文件不存在 + Sftp错误: 文件不存在 Sftp error: Permission denied - Sftp错误: 权限受限 + Sftp错误: 权限不足 Sftp error: Generic failure - Sftp错误: 一般失败 + Sftp错误: 一般失败 Sftp error: Garbage received from server - Sftp错误: 从服务器收到垃圾信息 + Sftp错误: 从服务器收到垃圾信息 Sftp error: No connection has been set up - + Sftp 错误: 未建立连接 Sftp error: There was a connection, but we lost it - + Sftp 错误: 已有连接丢失 Sftp error: Operation not supported by libssh yet - + Sftp error: libssh不支持该操作 Sftp error: Invalid file handle - + Sftp error: 无效的文件句柄 Sftp error: No such file or directory path exists - + Sftp 错误: 文件夹或文件不存在 Sftp error: An attempt to create an already existing file or directory has been made - + Sftp 错误: 文件或目录已存在 Sftp error: Write-protected filesystem - + Sftp 错误: 文件系统写保护 Sftp error: No media was in remote drive - + Sftp 错误: 远程驱动器中没有媒介 Failed to save config to disk - 配置保存到磁盘失败 + 配置保存到磁盘失败 OpenVPN config missing - OpenVPN配置丢失 + OpenVPN配置丢失 OpenVPN management server error - OpenVPN 管理服务器错误 + OpenVPN 管理服务器错误 OpenVPN executable missing - OpenVPN 可执行文件丢失 + OpenVPN 可执行文件丢失 ShadowSocks (ss-local) executable missing - ShadowSocks (ss-local) 执行文件丢失 + ShadowSocks (ss-local) 执行文件丢失 Cloak (ck-client) executable missing - Cloak (ck-client) 执行文件丢失 + Cloak (ck-client) 执行文件丢失 Amnezia helper service error - Amnezia 帮助服务错误 + Amnezia 服务连接失败 OpenSSL failed - OpenSSL失败 + OpenSSL错误 Can't connect: another VPN connection is active - 无法连接:另一个VPN连接处于活动状态 + 无法连接:另一个VPN连接处于活跃状态 Can't setup OpenVPN TAP network adapter - 无法设置 OpenVPN TAP 网络适配器 + 无法设置 OpenVPN TAP 网络适配器 VPN pool error: no available addresses - VPN 池错误:没有可用地址 + VPN 池错误:没有可用地址 The config does not contain any containers and credentiaks for connecting to the server - 该配置不包含任何用于连接到服务器的容器和凭据。 + 该配置不包含任何用于连接到服务器的容器和凭据。 Internal error - 内部错误 + 内部错误 IPsec - + Website in Tor network - 在 Tor 网络中架设网站 + 在 Tor 网络中架设网站 Amnezia DNS - + Sftp file sharing service - SFTP文件共享服务 + SFTP文件共享服务 OpenVPN is the most popular VPN protocol, with flexible configuration options. It uses its own security protocol with SSL/TLS for key exchange. - OpenVPN 是最流行的 VPN 协议,具有灵活的配置选项。它使用自己的安全协议与 SSL/TLS 进行密钥交换。 + OpenVPN 是最流行的 VPN 协议,具有灵活的配置选项。它使用自己的安全协议与 SSL/TLS 进行密钥交换。 ShadowSocks - masks VPN traffic, making it similar to normal web traffic, but is recognised by analysis systems in some highly censored regions. - ShadowSocks - 混淆 VPN 流量,使其与正常的 Web 流量相似,但在一些审查力度高的地区可以被分析系统识别。 + ShadowSocks - 混淆 VPN 流量,使其与正常的 Web 流量相似,但在一些审查力度高的地区可以被分析系统识别。 OpenVPN over Cloak - OpenVPN with VPN masquerading as web traffic and protection against active-probbing detection. Ideal for bypassing blocking in regions with the highest levels of censorship. - OpenVPN over Cloak - OpenVPN 与 VPN 具有伪装成网络流量和防止主动探测检测的保护。非常适合绕过审查力度特别强的地区的封锁。 + OpenVPN over Cloak - OpenVPN 与 VPN 具有伪装成网络流量和防止主动探测检测的保护。非常适合绕过审查力度特别强的地区的封锁。 WireGuard - New popular VPN protocol with high performance, high speed and low power consumption. Recommended for regions with low levels of censorship. - WireGuard - 新型流行的VPN协议,具有高性能、高速度和低功耗。建议用于审查力度较低的地区 + WireGuard - 新型流行的VPN协议,具有高性能、高速度和低功耗。建议用于审查力度较低的地区 IKEv2 - Modern stable protocol, a bit faster than others, restores connection after signal loss. It has native support on the latest versions of Android and iOS. - IKEv2 - 现代稳定协议,相比其他协议较快一些,在信号丢失后恢复连接。Android 和 iOS最新版原生支持。 + IKEv2 - 现代稳定协议,相比其他协议较快一些,在信号丢失后恢复连接。Android 和 iOS最新版原生支持。 Deploy a WordPress site on the Tor network in two clicks. - 只需点击两次即可架设 WordPress 网站到 Tor 网络 + 只需点击两次即可架设 WordPress 网站到 Tor 网络 Replace the current DNS server with your own. This will increase your privacy level. - 将当前的 DNS 服务器替换为您自己的。这将提高您的隐私级别。 + 将当前的 DNS 服务器替换为您自己的。这将提高您的隐私保护级别。 Creates a file vault on your server to securely store and transfer files. - 在您的服务器上创建文件库以安全地存储和传输文件 + 在您的服务器上创建文件仓库,以便安全地存储和传输文件 OpenVPN container - OpenVPN容器 + OpenVPN容器 Container with OpenVpn and ShadowSocks - 带有 OpenVpn 和 ShadowSocks 的容器 + 含 OpenVpn 和 ShadowSocks 的容器 Container with OpenVpn and ShadowSocks protocols configured with traffic masking by Cloak plugin - 具有 OpenVpn 和 ShadowSocks 协议的容器,通过 Cloak 插件配置混淆流量 + 含 OpenVpn 和 ShadowSocks 协议的容器,通过 Cloak 插件配置混淆流量 WireGuard container - WireGuard 容器 + WireGuard 容器 AmneziaWG container - + IPsec container - IPsec 容器 + IPsec 容器 DNS Service - DNS 服务 + DNS 服务 Sftp file sharing service - is secure FTP service - Sftp 文件共享服务 - 安全的 FTP 服务 + Sftp 文件共享服务 - 安全的 FTP 服务 Entry not found - 未找到记录 + 未找到记录 Access to keychain denied - 访问钥匙串被拒绝 + 访问钥匙串被拒绝 No keyring daemon - 没有密钥环守护进程 + 没有密钥环守护进程 Already unlocked - 已经解锁 + 已经解锁 No such keyring - 没有这样的密钥环 + 没有这样的密钥环 Bad arguments - 错误参数 + 错误参数 I/O error - I/O错误 + I/O错误 Cancelled - 已取消 + 已取消 Keyring already exists - 密匙环已经存在 + 密匙环已经存在 No match - 不匹配 + 不匹配 Unknown error - 未知错误 + 未知错误 error 0x%1: %2 - 错误 0x%1: %2 + 错误 0x%1: %2 @@ -2641,7 +2650,7 @@ It's okay as long as it's from someone you trust. Choose language - 选择语言 + 选择语言 @@ -2649,13 +2658,13 @@ It's okay as long as it's from someone you trust. Server #1 - + Server - 服务器 + 服务器 @@ -2663,22 +2672,22 @@ It's okay as long as it's from someone you trust. Software version - 软件版本 + 软件版本 Backup file is corrupted - 备份文件已损坏 + 备份文件已损坏 All settings have been reset to default values - 所配置恢复为默认值 + 所配置恢复为默认值 Cached profiles cleared - 缓存的配置文件已清除 + 缓存的配置文件已清除 @@ -2687,27 +2696,27 @@ It's okay as long as it's from someone you trust. Save AmneziaVPN config - 保存配置 + 保存配置 Share - 共享 + 共享 Copy - 拷贝 + 拷贝 Copied - 已拷贝 + 已拷贝 Show connection settings - + 显示连接配置 Show content @@ -2716,7 +2725,7 @@ It's okay as long as it's from someone you trust. To read the QR code in the Amnezia app, select "Add server" → "I have data to connect" → "QR code, key or settings file" - 要读取 Amnezia 应用程序中的二维码,请选择“添加服务器”→“我有数据要连接”→“二维码、密钥或配置文件” + 要应用二维码到 Amnezia,请底部工具栏点击“+”→“连接方式”→“二维码、授权码或配置文件” @@ -2724,42 +2733,42 @@ It's okay as long as it's from someone you trust. Hostname not look like ip adress or domain name - + 请输入有效的域名或IP地址 New site added: %1 - + 已经添加新网站: %1 Site removed: %1 - + 已移除网站: %1 Can't open file: %1 - + 无法打开文件: %1 Failed to parse JSON data from file: %1 - + JSON解析失败,文件: %1 - The JSON data is not an array in file: - + The JSON data is not an array in file: %1 + 文件中的JSON数据不是一个数组,文件: %1 Import completed - + 完成导入 Export completed - + 完成导出 @@ -2768,31 +2777,31 @@ It's okay as long as it's from someone you trust. Show - 界面 + 显示 Connect - 连接 + 连接 Disconnect - 断开 + 断开 Visit Website - 官网 + 官网 Quit - 退出 + 退出 @@ -2800,7 +2809,7 @@ It's okay as long as it's from someone you trust. The field can't be empty - + 输入不能为空 @@ -2808,7 +2817,7 @@ It's okay as long as it's from someone you trust. Mbps - + @@ -2816,42 +2825,42 @@ It's okay as long as it's from someone you trust. Unknown - 未知 + 未知 Disconnected - 断开连接 + 连接已断开 Preparing - 准备中 + 准备中 Connecting... - 连接中 + 连接中 Connected - 已连接 + 已连接 Disconnecting... - 断开中 + 断开中 Reconnecting... - 重连中 + 重连中 Error - 错误 + 错误 @@ -2859,32 +2868,32 @@ It's okay as long as it's from someone you trust. Low - + High - + Medium - + I just want to increase the level of privacy - 我只是想提高隐私级别 + 我只是想提高隐私保护级别 Many foreign websites and VPN providers are blocked - 大多国外网站和VPN提供商被屏蔽 + 大多国外网站和VPN提供商被屏蔽 Some foreign sites are blocked, but VPN providers are not blocked - 一些国外网站被屏蔽,但VPN提供商未被屏蔽 + 一些国外网站被屏蔽,但VPN提供商未被屏蔽 @@ -2892,12 +2901,12 @@ It's okay as long as it's from someone you trust. Private key passphrase - 私钥密码 + 私钥密码 Save - 保存 + 保存 diff --git a/client/ui/controllers/sitesController.cpp b/client/ui/controllers/sitesController.cpp index 4d0391be..8c420899 100644 --- a/client/ui/controllers/sitesController.cpp +++ b/client/ui/controllers/sitesController.cpp @@ -97,7 +97,7 @@ void SitesController::importSites(const QString &fileName, bool replaceExisting) } if (!jsonDocument.isArray()) { - emit errorOccurred(tr("The JSON data is not an array in file: ").arg(fileName)); + emit errorOccurred(tr("The JSON data is not an array in file: %1").arg(fileName)); return; } diff --git a/client/ui/qml/Pages2/PageProtocolRaw.qml b/client/ui/qml/Pages2/PageProtocolRaw.qml index 2324c091..f0959143 100644 --- a/client/ui/qml/Pages2/PageProtocolRaw.qml +++ b/client/ui/qml/Pages2/PageProtocolRaw.qml @@ -127,7 +127,7 @@ PageType { Layout.fillWidth: true Layout.topMargin: 16 - headerText: qsTr("Connection options ") + protocolName + headerText: qsTr("Connection options %1").arg(protocolName) } TextArea { diff --git a/client/ui/qml/Pages2/PageSettingsApplication.qml b/client/ui/qml/Pages2/PageSettingsApplication.qml index c5536fdb..49e3a5d9 100644 --- a/client/ui/qml/Pages2/PageSettingsApplication.qml +++ b/client/ui/qml/Pages2/PageSettingsApplication.qml @@ -70,7 +70,7 @@ PageType { Layout.margins: 16 text: qsTr("Auto start") - descriptionText: qsTr("Launch the application every time ") + Qt.platform.os + qsTr(" starts") + descriptionText: qsTr("Launch the application every time %1 starts").arg(Qt.platform.os) checked: SettingsController.isAutoStartEnabled() onCheckedChanged: {