Merge branch 'feature/amnezia-wireguard-client-impl' of github.com:amnezia-vpn/desktop-client into feature/amnezia-wireguard-client-impl
This commit is contained in:
commit
c254f2fdc4
23 changed files with 96 additions and 25 deletions
6
.gitmodules
vendored
6
.gitmodules
vendored
|
|
@ -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"]
|
[submodule "client/3rd/OpenVPNAdapter"]
|
||||||
path = client/3rd/OpenVPNAdapter
|
path = client/3rd/OpenVPNAdapter
|
||||||
url = https://github.com/amnezia-vpn/OpenVPNAdapter.git
|
url = https://github.com/amnezia-vpn/OpenVPNAdapter.git
|
||||||
|
|
@ -25,3 +22,6 @@
|
||||||
[submodule "client/3rd-prebuilt"]
|
[submodule "client/3rd-prebuilt"]
|
||||||
path = client/3rd-prebuilt
|
path = client/3rd-prebuilt
|
||||||
url = https://github.com/amnezia-vpn/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
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit e8795854a5cf27004fe78caecc90a961688d1d41
|
Subproject commit 6f0d654a2409e2f634e7f7b95d34998c8eba2d7b
|
||||||
1
client/3rd/awg-apple
vendored
Submodule
1
client/3rd/awg-apple
vendored
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 5767a03f75a2b77d4f78fdd77ff51a1eefabe3b0
|
||||||
1
client/3rd/wireguard-apple
vendored
1
client/3rd/wireguard-apple
vendored
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 23618f994f17d8ad8f2f65d79b4a1e8a0830b334
|
|
||||||
|
|
@ -97,7 +97,7 @@ target_compile_options(${PROJECT} PRIVATE
|
||||||
-DVPN_NE_BUNDLEID=\"${BUILD_IOS_APP_IDENTIFIER}.network-extension\"
|
-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
|
target_sources(${PROJECT} PRIVATE
|
||||||
# ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/iosvpnprotocol.swift
|
# ${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/iosvpnprotocol.swift
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "amneziaWireGuardConfigurator.h"
|
#include "awg_configurator.h"
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include "shadowsocks_configurator.h"
|
#include "shadowsocks_configurator.h"
|
||||||
#include "ssh_configurator.h"
|
#include "ssh_configurator.h"
|
||||||
#include "wireguard_configurator.h"
|
#include "wireguard_configurator.h"
|
||||||
#include "amneziaWireGuardConfigurator.h"
|
#include "awg_configurator.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,7 @@ bool ContainerProps::isSupportedByCurrentPlatform(DockerContainer c)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case DockerContainer::WireGuard: return true;
|
case DockerContainer::WireGuard: return true;
|
||||||
case DockerContainer::OpenVpn: return true;
|
case DockerContainer::OpenVpn: return true;
|
||||||
|
case DockerContainer::AmneziaWireGuard: return true;
|
||||||
case DockerContainer::Cloak:
|
case DockerContainer::Cloak:
|
||||||
return true;
|
return true;
|
||||||
// case DockerContainer::ShadowSocks: return true;
|
// case DockerContainer::ShadowSocks: return true;
|
||||||
|
|
|
||||||
|
|
@ -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 -DGROUP_ID=\"${BUILD_IOS_GROUP_IDENTIFIER}\")
|
||||||
target_compile_options(networkextension PRIVATE -DNETWORK_EXTENSION=1)
|
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
|
target_sources(networkextension PRIVATE
|
||||||
${WG_APPLE_SOURCE_DIR}/WireGuardKit/WireGuardAdapter.swift
|
${WG_APPLE_SOURCE_DIR}/WireGuardKit/WireGuardAdapter.swift
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "wireguard-go-version.h"
|
#include "wireguard-go-version.h"
|
||||||
#include "3rd/wireguard-apple/Sources/WireGuardKitGo/wireguard.h"
|
#include "3rd/awg-apple/Sources/WireGuardKitGo/wireguard.h"
|
||||||
#include "3rd/wireguard-apple/Sources/WireGuardKitC/WireGuardKitC.h"
|
#include "3rd/awg-apple/Sources/WireGuardKitC/WireGuardKitC.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "wireguard-go-version.h"
|
#include "wireguard-go-version.h"
|
||||||
#include "3rd/wireguard-apple/Sources/WireGuardKitC/WireGuardKitC.h"
|
#include "3rd/awg-apple/Sources/WireGuardKitC/WireGuardKitC.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "macos/gobridge/wireguard.h"
|
#include "macos/gobridge/wireguard.h"
|
||||||
#include "wireguard-go-version.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 "3rd/ShadowSocks/ShadowSocks/ShadowSocks.h"
|
||||||
#include "platforms/ios/ssconnectivity.h"
|
#include "platforms/ios/ssconnectivity.h"
|
||||||
#include "platforms/ios/iosopenvpn2ssadapter.h"
|
#include "platforms/ios/iosopenvpn2ssadapter.h"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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 <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ private:
|
||||||
bool setupOpenVPN();
|
bool setupOpenVPN();
|
||||||
bool setupCloak();
|
bool setupCloak();
|
||||||
bool setupWireGuard();
|
bool setupWireGuard();
|
||||||
|
bool setupAmneziaWireGuard();
|
||||||
|
|
||||||
bool startOpenVPN(const QString &config);
|
bool startOpenVPN(const QString &config);
|
||||||
bool startWireGuard(const QString &jsonConfig);
|
bool startWireGuard(const QString &jsonConfig);
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,9 @@ bool IosController::connectVpn(amnezia::Proto proto, const QJsonObject& configur
|
||||||
if (proto == amnezia::Proto::WireGuard) {
|
if (proto == amnezia::Proto::WireGuard) {
|
||||||
return setupWireGuard();
|
return setupWireGuard();
|
||||||
}
|
}
|
||||||
|
if (proto == amnezia::Proto::AmneziaWireGuard) {
|
||||||
|
return setupAmneziaWireGuard();
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -307,6 +310,15 @@ bool IosController::setupWireGuard()
|
||||||
return startWireGuard(wgConfig);
|
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)
|
bool IosController::startOpenVPN(const QString &config)
|
||||||
{
|
{
|
||||||
qDebug() << "IosController::startOpenVPN";
|
qDebug() << "IosController::startOpenVPN";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "amneziaWireGuardProtocol.h"
|
#include "amneziawireguardprotocol.h"
|
||||||
|
|
||||||
AmneziaWireGuardProtocol::AmneziaWireGuardProtocol(const QJsonObject &configuration, QObject *parent)
|
AmneziaWireGuardProtocol::AmneziaWireGuardProtocol(const QJsonObject &configuration, QObject *parent)
|
||||||
: WireguardProtocol(configuration, parent)
|
: WireguardProtocol(configuration, parent)
|
||||||
|
|
@ -3,7 +3,7 @@ FROM amneziavpn/amnezia-wg:latest
|
||||||
LABEL maintainer="AmneziaVPN"
|
LABEL maintainer="AmneziaVPN"
|
||||||
|
|
||||||
#Install required packages
|
#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 apk --update upgrade --no-cache
|
||||||
|
|
||||||
RUN mkdir -p /opt/amnezia
|
RUN mkdir -p /opt/amnezia
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ echo $WIREGUARD_PSK > /opt/amnezia/amneziawireguard/wireguard_psk.key
|
||||||
cat > /opt/amnezia/amneziawireguard/wg0.conf <<EOF
|
cat > /opt/amnezia/amneziawireguard/wg0.conf <<EOF
|
||||||
[Interface]
|
[Interface]
|
||||||
PrivateKey = $WIREGUARD_SERVER_PRIVATE_KEY
|
PrivateKey = $WIREGUARD_SERVER_PRIVATE_KEY
|
||||||
Address = $WIREGUARD_SUBNET_IP/$WIREGUARD_SUBNET_CIDR
|
Address = 10.8.1.1/24
|
||||||
ListenPort = $AMNEZIAWIREGUARD_SERVER_PORT
|
ListenPort = $AMNEZIAWIREGUARD_SERVER_PORT
|
||||||
Jc = $JUNK_PACKET_COUNT
|
Jc = $JUNK_PACKET_COUNT
|
||||||
Jmin = $JUNK_PACKET_MIN_SIZE
|
Jmin = $JUNK_PACKET_MIN_SIZE
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
echo "Container startup"
|
echo "Container startup"
|
||||||
#ifconfig eth0:0 $SERVER_IP_ADDRESS netmask 255.255.255.255 up
|
#ifconfig eth0:0 $SERVER_IP_ADDRESS netmask 255.255.255.255 up
|
||||||
|
|
||||||
|
mkdir -p /dev/net
|
||||||
|
mknod /dev/net/tun c 10 200
|
||||||
|
|
||||||
# kill daemons in case of restart
|
# kill daemons in case of restart
|
||||||
wg-quick down /opt/amnezia/amneziawireguard/wg0.conf
|
wg-quick down /opt/amnezia/amneziawireguard/wg0.conf
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
sudo docker build -t $CONTAINER_NAME $DOCKERFILE_FOLDER --build-arg SERVER_ARCH=$(uname -m)
|
sudo docker build --no-cache --pull -t $CONTAINER_NAME $DOCKERFILE_FOLDER --build-arg SERVER_ARCH=$(uname -m)
|
||||||
|
|
|
||||||
|
|
@ -223,21 +223,75 @@ QJsonObject ImportController::extractOpenVpnConfig(const QString &data)
|
||||||
|
|
||||||
QJsonObject ImportController::extractWireGuardConfig(const QString &data)
|
QJsonObject ImportController::extractWireGuardConfig(const QString &data)
|
||||||
{
|
{
|
||||||
|
QMap<QString, QString> 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;
|
QJsonObject lastConfig;
|
||||||
lastConfig[config_key::config] = data;
|
lastConfig[config_key::config] = data;
|
||||||
|
|
||||||
const static QRegularExpression hostNameAndPortRegExp("Endpoint = (.*)(?::([0-9]*))?");
|
const static QRegularExpression hostNameAndPortRegExp("Endpoint = (.*):([0-9]*)");
|
||||||
QRegularExpressionMatch hostNameAndPortMatch = hostNameAndPortRegExp.match(data);
|
QRegularExpressionMatch hostNameAndPortMatch = hostNameAndPortRegExp.match(data);
|
||||||
QString hostName;
|
QString hostName;
|
||||||
QString port;
|
QString port;
|
||||||
if (hostNameAndPortMatch.hasCaptured(1)) {
|
if (hostNameAndPortMatch.hasCaptured(1)) {
|
||||||
hostName = hostNameAndPortMatch.captured(1);
|
hostName = hostNameAndPortMatch.captured(1);
|
||||||
} /*else {
|
} else {
|
||||||
qDebug() << "send error?"
|
qDebug() << "Failed to import profile";
|
||||||
}*/
|
emit importErrorOccurred(errorString(ErrorCode::ImportInvalidConfigError));
|
||||||
|
}
|
||||||
|
|
||||||
if (hostNameAndPortMatch.hasCaptured(2)) {
|
if (hostNameAndPortMatch.hasCaptured(2)) {
|
||||||
port = hostNameAndPortMatch.captured(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;
|
QJsonObject wireguardConfig;
|
||||||
|
|
@ -247,15 +301,15 @@ QJsonObject ImportController::extractWireGuardConfig(const QString &data)
|
||||||
wireguardConfig[config_key::transport_proto] = "udp";
|
wireguardConfig[config_key::transport_proto] = "udp";
|
||||||
|
|
||||||
QJsonObject containers;
|
QJsonObject containers;
|
||||||
containers.insert(config_key::container, QJsonValue("amnezia-wireguard"));
|
containers.insert(config_key::container, QJsonValue("amnezia-" + protocolName));
|
||||||
containers.insert(config_key::wireguard, QJsonValue(wireguardConfig));
|
containers.insert(protocolName, QJsonValue(wireguardConfig));
|
||||||
|
|
||||||
QJsonArray arr;
|
QJsonArray arr;
|
||||||
arr.push_back(containers);
|
arr.push_back(containers);
|
||||||
|
|
||||||
QJsonObject config;
|
QJsonObject config;
|
||||||
config[config_key::containers] = arr;
|
config[config_key::containers] = arr;
|
||||||
config[config_key::defaultContainer] = "amnezia-wireguard";
|
config[config_key::defaultContainer] = "amnezia-" + protocolName;
|
||||||
config[config_key::description] = m_settings->nextAvailableServerName();
|
config[config_key::description] = m_settings->nextAvailableServerName();
|
||||||
|
|
||||||
const static QRegularExpression dnsRegExp(
|
const static QRegularExpression dnsRegExp(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue