Merge branch 'dev' of github.com:amnezia-vpn/amnezia-client into HEAD
This commit is contained in:
commit
e3375e9f5f
50 changed files with 964 additions and 481 deletions
18
.github/workflows/deploy.yml
vendored
18
.github/workflows/deploy.yml
vendored
|
|
@ -255,7 +255,6 @@ jobs:
|
||||||
env:
|
env:
|
||||||
# Keep compat with MacOS 10.15 aka Catalina by Qt 6.4
|
# Keep compat with MacOS 10.15 aka Catalina by Qt 6.4
|
||||||
QT_VERSION: 6.4.3
|
QT_VERSION: 6.4.3
|
||||||
QIF_VERSION: 4.6
|
|
||||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||||
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
||||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
||||||
|
|
@ -283,11 +282,6 @@ jobs:
|
||||||
set-env: 'true'
|
set-env: 'true'
|
||||||
extra: '--external 7z --base ${{ env.QT_MIRROR }}'
|
extra: '--external 7z --base ${{ env.QT_MIRROR }}'
|
||||||
|
|
||||||
- name: 'Install Qt Installer Framework ${{ env.QIF_VERSION }}'
|
|
||||||
run: |
|
|
||||||
mkdir -pv ${{ runner.temp }}/Qt/Tools/QtInstallerFramework
|
|
||||||
wget https://qt.amzsvc.com/tools/ifw/${{ env.QIF_VERSION }}.zip
|
|
||||||
unzip ${{ env.QIF_VERSION }}.zip -d ${{ runner.temp }}/Qt/Tools/QtInstallerFramework/
|
|
||||||
|
|
||||||
- name: 'Get sources'
|
- name: 'Get sources'
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
@ -301,14 +295,13 @@ jobs:
|
||||||
- name: 'Build project'
|
- name: 'Build project'
|
||||||
run: |
|
run: |
|
||||||
export QT_BIN_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/macos/bin"
|
export QT_BIN_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/macos/bin"
|
||||||
export QIF_BIN_DIR="${{ runner.temp }}/Qt/Tools/QtInstallerFramework/${{ env.QIF_VERSION }}/bin"
|
|
||||||
bash deploy/build_macos.sh
|
bash deploy/build_macos.sh
|
||||||
|
|
||||||
- name: 'Upload installer artifact'
|
- name: 'Upload installer artifact'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: AmneziaVPN_MacOS_old_installer
|
name: AmneziaVPN_MacOS_old_installer
|
||||||
path: AmneziaVPN.dmg
|
path: deploy/build/pkg/AmneziaVPN.pkg
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|
||||||
- name: 'Upload unpacked artifact'
|
- name: 'Upload unpacked artifact'
|
||||||
|
|
@ -325,7 +318,6 @@ jobs:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
QT_VERSION: 6.8.0
|
QT_VERSION: 6.8.0
|
||||||
QIF_VERSION: 4.8.1
|
|
||||||
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }}
|
||||||
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }}
|
||||||
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }}
|
||||||
|
|
@ -353,11 +345,6 @@ jobs:
|
||||||
set-env: 'true'
|
set-env: 'true'
|
||||||
extra: '--external 7z --base ${{ env.QT_MIRROR }}'
|
extra: '--external 7z --base ${{ env.QT_MIRROR }}'
|
||||||
|
|
||||||
- name: 'Install Qt Installer Framework ${{ env.QIF_VERSION }}'
|
|
||||||
run: |
|
|
||||||
mkdir -pv ${{ runner.temp }}/Qt/Tools/QtInstallerFramework
|
|
||||||
wget https://qt.amzsvc.com/tools/ifw/${{ env.QIF_VERSION }}.zip
|
|
||||||
unzip ${{ env.QIF_VERSION }}.zip -d ${{ runner.temp }}/Qt/Tools/QtInstallerFramework/
|
|
||||||
|
|
||||||
- name: 'Get sources'
|
- name: 'Get sources'
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
@ -371,14 +358,13 @@ jobs:
|
||||||
- name: 'Build project'
|
- name: 'Build project'
|
||||||
run: |
|
run: |
|
||||||
export QT_BIN_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/macos/bin"
|
export QT_BIN_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/macos/bin"
|
||||||
export QIF_BIN_DIR="${{ runner.temp }}/Qt/Tools/QtInstallerFramework/${{ env.QIF_VERSION }}/bin"
|
|
||||||
bash deploy/build_macos.sh
|
bash deploy/build_macos.sh
|
||||||
|
|
||||||
- name: 'Upload installer artifact'
|
- name: 'Upload installer artifact'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: AmneziaVPN_MacOS_installer
|
name: AmneziaVPN_MacOS_installer
|
||||||
path: AmneziaVPN.dmg
|
path: deploy/build/pkg/AmneziaVPN.pkg
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|
||||||
- name: 'Upload unpacked artifact'
|
- name: 'Upload unpacked artifact'
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,12 @@ QString OpenVpnConfigurator::processConfigWithLocalSettings(const QPair<QString,
|
||||||
QRegularExpression regex("redirect-gateway.*");
|
QRegularExpression regex("redirect-gateway.*");
|
||||||
config.replace(regex, "");
|
config.replace(regex, "");
|
||||||
|
|
||||||
|
// We don't use secondary DNS if primary DNS is AmneziaDNS
|
||||||
|
if (dns.first.contains(protocols::dns::amneziaDnsIp)) {
|
||||||
|
QRegularExpression dnsRegex("dhcp-option DNS " + dns.second);
|
||||||
|
config.replace(dnsRegex, "");
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_settings->isSitesSplitTunnelingEnabled()) {
|
if (!m_settings->isSitesSplitTunnelingEnabled()) {
|
||||||
config.append("\nredirect-gateway def1 ipv6 bypass-dhcp\n");
|
config.append("\nredirect-gateway def1 ipv6 bypass-dhcp\n");
|
||||||
config.append("block-ipv6\n");
|
config.append("block-ipv6\n");
|
||||||
|
|
@ -161,6 +167,12 @@ QString OpenVpnConfigurator::processConfigWithExportSettings(const QPair<QString
|
||||||
QRegularExpression regex("redirect-gateway.*");
|
QRegularExpression regex("redirect-gateway.*");
|
||||||
config.replace(regex, "");
|
config.replace(regex, "");
|
||||||
|
|
||||||
|
// We don't use secondary DNS if primary DNS is AmneziaDNS
|
||||||
|
if (dns.first.contains(protocols::dns::amneziaDnsIp)) {
|
||||||
|
QRegularExpression dnsRegex("dhcp-option DNS " + dns.second);
|
||||||
|
config.replace(dnsRegex, "");
|
||||||
|
}
|
||||||
|
|
||||||
config.append("\nredirect-gateway def1 ipv6 bypass-dhcp\n");
|
config.append("\nredirect-gateway def1 ipv6 bypass-dhcp\n");
|
||||||
|
|
||||||
// Prevent ipv6 leak
|
// Prevent ipv6 leak
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ namespace apiDefs
|
||||||
constexpr QLatin1String stackType("stack_type");
|
constexpr QLatin1String stackType("stack_type");
|
||||||
constexpr QLatin1String serviceType("service_type");
|
constexpr QLatin1String serviceType("service_type");
|
||||||
constexpr QLatin1String cliVersion("cli_version");
|
constexpr QLatin1String cliVersion("cli_version");
|
||||||
|
constexpr QLatin1String supportedProtocols("supported_protocols");
|
||||||
|
|
||||||
constexpr QLatin1String vpnKey("vpn_key");
|
constexpr QLatin1String vpnKey("vpn_key");
|
||||||
constexpr QLatin1String config("config");
|
constexpr QLatin1String config("config");
|
||||||
|
|
|
||||||
|
|
@ -483,6 +483,8 @@ ErrorCode ServerController::buildContainerWorker(const ServerCredentials &creden
|
||||||
return ErrorCode::ServerDockerOnCgroupsV2;
|
return ErrorCode::ServerDockerOnCgroupsV2;
|
||||||
if (stdOut.contains("cgroup mountpoint does not exist"))
|
if (stdOut.contains("cgroup mountpoint does not exist"))
|
||||||
return ErrorCode::ServerCgroupMountpoint;
|
return ErrorCode::ServerCgroupMountpoint;
|
||||||
|
if (stdOut.contains("have reached") && stdOut.contains("pull rate limit"))
|
||||||
|
return ErrorCode::DockerPullRateLimit;
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
@ -859,7 +861,7 @@ ErrorCode ServerController::isServerDpkgBusy(const ServerCredentials &credential
|
||||||
|
|
||||||
if (stdOut.contains("Packet manager not found"))
|
if (stdOut.contains("Packet manager not found"))
|
||||||
return ErrorCode::ServerPacketManagerError;
|
return ErrorCode::ServerPacketManagerError;
|
||||||
if (stdOut.contains("fuser not installed"))
|
if (stdOut.contains("fuser not installed") || stdOut.contains("cat not installed"))
|
||||||
return ErrorCode::NoError;
|
return ErrorCode::NoError;
|
||||||
|
|
||||||
if (stdOut.isEmpty()) {
|
if (stdOut.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ namespace amnezia
|
||||||
ServerUserPasswordRequired = 210,
|
ServerUserPasswordRequired = 210,
|
||||||
ServerDockerOnCgroupsV2 = 211,
|
ServerDockerOnCgroupsV2 = 211,
|
||||||
ServerCgroupMountpoint = 212,
|
ServerCgroupMountpoint = 212,
|
||||||
|
DockerPullRateLimit = 213,
|
||||||
|
|
||||||
// Ssh connection errors
|
// Ssh connection errors
|
||||||
SshRequestDeniedError = 300,
|
SshRequestDeniedError = 300,
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ QString errorString(ErrorCode code) {
|
||||||
case(ErrorCode::ServerUserPasswordRequired): errorMessage = QObject::tr("The user's password is required"); break;
|
case(ErrorCode::ServerUserPasswordRequired): errorMessage = QObject::tr("The user's password is required"); break;
|
||||||
case(ErrorCode::ServerDockerOnCgroupsV2): errorMessage = QObject::tr("Docker error: runc doesn't work on cgroups v2"); break;
|
case(ErrorCode::ServerDockerOnCgroupsV2): errorMessage = QObject::tr("Docker error: runc doesn't work on cgroups v2"); break;
|
||||||
case(ErrorCode::ServerCgroupMountpoint): errorMessage = QObject::tr("Server error: cgroup mountpoint does not exist"); break;
|
case(ErrorCode::ServerCgroupMountpoint): errorMessage = QObject::tr("Server error: cgroup mountpoint does not exist"); break;
|
||||||
|
case(ErrorCode::DockerPullRateLimit): errorMessage = QObject::tr("Docker error: The pull rate limit has been reached"); break;
|
||||||
|
|
||||||
// Libssh errors
|
// Libssh errors
|
||||||
case(ErrorCode::SshRequestDeniedError): errorMessage = QObject::tr("SSH request was denied"); break;
|
case(ErrorCode::SshRequestDeniedError): errorMessage = QObject::tr("SSH request was denied"); break;
|
||||||
|
|
|
||||||
|
|
@ -169,11 +169,14 @@ bool Daemon::maybeUpdateResolvers(const InterfaceConfig& config) {
|
||||||
if ((config.m_hopType == InterfaceConfig::MultiHopExit) ||
|
if ((config.m_hopType == InterfaceConfig::MultiHopExit) ||
|
||||||
(config.m_hopType == InterfaceConfig::SingleHop)) {
|
(config.m_hopType == InterfaceConfig::SingleHop)) {
|
||||||
QList<QHostAddress> resolvers;
|
QList<QHostAddress> resolvers;
|
||||||
resolvers.append(QHostAddress(config.m_dnsServer));
|
resolvers.append(QHostAddress(config.m_primaryDnsServer));
|
||||||
|
if (!config.m_secondaryDnsServer.isEmpty()) {
|
||||||
|
resolvers.append(QHostAddress(config.m_secondaryDnsServer));
|
||||||
|
}
|
||||||
|
|
||||||
// If the DNS is not the Gateway, it's a user defined DNS
|
// If the DNS is not the Gateway, it's a user defined DNS
|
||||||
// thus, not add any other :)
|
// thus, not add any other :)
|
||||||
if (config.m_dnsServer == config.m_serverIpv4Gateway) {
|
if (config.m_primaryDnsServer == config.m_serverIpv4Gateway) {
|
||||||
resolvers.append(QHostAddress(config.m_serverIpv6Gateway));
|
resolvers.append(QHostAddress(config.m_serverIpv6Gateway));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,15 +282,26 @@ bool Daemon::parseConfig(const QJsonObject& obj, InterfaceConfig& config) {
|
||||||
config.m_serverIpv4Gateway = obj.value("serverIpv4Gateway").toString();
|
config.m_serverIpv4Gateway = obj.value("serverIpv4Gateway").toString();
|
||||||
config.m_serverIpv6Gateway = obj.value("serverIpv6Gateway").toString();
|
config.m_serverIpv6Gateway = obj.value("serverIpv6Gateway").toString();
|
||||||
|
|
||||||
if (!obj.contains("dnsServer")) {
|
if (!obj.contains("primaryDnsServer")) {
|
||||||
config.m_dnsServer = QString();
|
config.m_primaryDnsServer = QString();
|
||||||
} else {
|
} else {
|
||||||
QJsonValue value = obj.value("dnsServer");
|
QJsonValue value = obj.value("primaryDnsServer");
|
||||||
if (!value.isString()) {
|
if (!value.isString()) {
|
||||||
logger.error() << "dnsServer is not a string";
|
logger.error() << "dnsServer is not a string";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
config.m_dnsServer = value.toString();
|
config.m_primaryDnsServer = value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!obj.contains("secondaryDnsServer")) {
|
||||||
|
config.m_secondaryDnsServer = QString();
|
||||||
|
} else {
|
||||||
|
QJsonValue value = obj.value("secondaryDnsServer");
|
||||||
|
if (!value.isString()) {
|
||||||
|
logger.error() << "dnsServer is not a string";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
config.m_secondaryDnsServer = value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!obj.contains("hopType")) {
|
if (!obj.contains("hopType")) {
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ QJsonObject InterfaceConfig::toJson() const {
|
||||||
(m_hopType == InterfaceConfig::SingleHop)) {
|
(m_hopType == InterfaceConfig::SingleHop)) {
|
||||||
json.insert("serverIpv4Gateway", QJsonValue(m_serverIpv4Gateway));
|
json.insert("serverIpv4Gateway", QJsonValue(m_serverIpv4Gateway));
|
||||||
json.insert("serverIpv6Gateway", QJsonValue(m_serverIpv6Gateway));
|
json.insert("serverIpv6Gateway", QJsonValue(m_serverIpv6Gateway));
|
||||||
json.insert("dnsServer", QJsonValue(m_dnsServer));
|
json.insert("primaryDnsServer", QJsonValue(m_primaryDnsServer));
|
||||||
|
json.insert("secondaryDnsServer", QJsonValue(m_secondaryDnsServer));
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray allowedIPAddesses;
|
QJsonArray allowedIPAddesses;
|
||||||
|
|
@ -100,11 +101,15 @@ QString InterfaceConfig::toWgConf(const QMap<QString, QString>& extra) const {
|
||||||
out << "MTU = " << m_deviceMTU << "\n";
|
out << "MTU = " << m_deviceMTU << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_dnsServer.isNull()) {
|
if (!m_primaryDnsServer.isNull()) {
|
||||||
QStringList dnsServers(m_dnsServer);
|
QStringList dnsServers;
|
||||||
|
dnsServers.append(m_primaryDnsServer);
|
||||||
|
if (!m_secondaryDnsServer.isNull()) {
|
||||||
|
dnsServers.append(m_secondaryDnsServer);
|
||||||
|
}
|
||||||
// If the DNS is not the Gateway, it's a user defined DNS
|
// If the DNS is not the Gateway, it's a user defined DNS
|
||||||
// thus, not add any other :)
|
// thus, not add any other :)
|
||||||
if (m_dnsServer == m_serverIpv4Gateway) {
|
if (m_primaryDnsServer == m_serverIpv4Gateway) {
|
||||||
dnsServers.append(m_serverIpv6Gateway);
|
dnsServers.append(m_serverIpv6Gateway);
|
||||||
}
|
}
|
||||||
out << "DNS = " << dnsServers.join(", ") << "\n";
|
out << "DNS = " << dnsServers.join(", ") << "\n";
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ class InterfaceConfig {
|
||||||
QString m_serverIpv4AddrIn;
|
QString m_serverIpv4AddrIn;
|
||||||
QString m_serverPskKey;
|
QString m_serverPskKey;
|
||||||
QString m_serverIpv6AddrIn;
|
QString m_serverIpv6AddrIn;
|
||||||
QString m_dnsServer;
|
QString m_primaryDnsServer;
|
||||||
|
QString m_secondaryDnsServer;
|
||||||
int m_serverPort = 0;
|
int m_serverPort = 0;
|
||||||
int m_deviceMTU = 1420;
|
int m_deviceMTU = 1420;
|
||||||
QList<IPAddress> m_allowedIPAddressRanges;
|
QList<IPAddress> m_allowedIPAddressRanges;
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,14 @@ void LocalSocketController::activate(const QJsonObject &rawConfig) {
|
||||||
json.insert("serverPort", wgConfig.value(amnezia::config_key::port).toInt());
|
json.insert("serverPort", wgConfig.value(amnezia::config_key::port).toInt());
|
||||||
json.insert("serverIpv4Gateway", wgConfig.value(amnezia::config_key::hostName));
|
json.insert("serverIpv4Gateway", wgConfig.value(amnezia::config_key::hostName));
|
||||||
// json.insert("serverIpv6Gateway", QJsonValue(hop.m_server.ipv6Gateway()));
|
// json.insert("serverIpv6Gateway", QJsonValue(hop.m_server.ipv6Gateway()));
|
||||||
json.insert("dnsServer", rawConfig.value(amnezia::config_key::dns1));
|
|
||||||
|
json.insert("primaryDnsServer", rawConfig.value(amnezia::config_key::dns1));
|
||||||
|
|
||||||
|
// We don't use secondary DNS if primary DNS is AmneziaDNS
|
||||||
|
if (!rawConfig.value(amnezia::config_key::dns1).toString().
|
||||||
|
contains(amnezia::protocols::dns::amneziaDnsIp)) {
|
||||||
|
json.insert("secondaryDnsServer", rawConfig.value(amnezia::config_key::dns2));
|
||||||
|
}
|
||||||
|
|
||||||
QJsonArray jsAllowedIPAddesses;
|
QJsonArray jsAllowedIPAddesses;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,10 @@ bool WireguardUtilsLinux::addInterface(const InterfaceConfig& config) {
|
||||||
} else {
|
} else {
|
||||||
if (config.m_killSwitchEnabled) {
|
if (config.m_killSwitchEnabled) {
|
||||||
FirewallParams params { };
|
FirewallParams params { };
|
||||||
params.dnsServers.append(config.m_dnsServer);
|
params.dnsServers.append(config.m_primaryDnsServer);
|
||||||
|
if (!config.m_secondaryDnsServer.isEmpty()) {
|
||||||
|
params.dnsServers.append(config.m_secondaryDnsServer);
|
||||||
|
}
|
||||||
if (config.m_allowedIPAddressRanges.contains(IPAddress("0.0.0.0/0"))) {
|
if (config.m_allowedIPAddressRanges.contains(IPAddress("0.0.0.0/0"))) {
|
||||||
params.blockAll = true;
|
params.blockAll = true;
|
||||||
if (config.m_excludedAddresses.size()) {
|
if (config.m_excludedAddresses.size()) {
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,16 @@ namespace {
|
||||||
|
|
||||||
#include "macosfirewall.h"
|
#include "macosfirewall.h"
|
||||||
|
|
||||||
#define ResourceDir qApp->applicationDirPath() + "/pf"
|
#include <QDir>
|
||||||
#define DaemonDataDir qApp->applicationDirPath() + "/pf"
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
// Read-only rules bundled with the application.
|
||||||
|
#define ResourceDir (qApp->applicationDirPath() + "/pf")
|
||||||
|
|
||||||
|
// Writable location that does NOT live inside the signed bundle. Using a
|
||||||
|
// constant path under /Library/Application Support keeps the signature intact
|
||||||
|
// and is accessible to the root helper.
|
||||||
|
#define DaemonDataDir QStringLiteral("/Library/Application Support/AmneziaVPN/pf")
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
|
|
@ -121,6 +129,8 @@ void MacOSFirewall::install()
|
||||||
logger.info() << "Installing PF root anchor";
|
logger.info() << "Installing PF root anchor";
|
||||||
|
|
||||||
installRootAnchors();
|
installRootAnchors();
|
||||||
|
// Ensure writable directory exists, then store the token there.
|
||||||
|
QDir().mkpath(DaemonDataDir);
|
||||||
execute(QStringLiteral("pfctl -E 2>&1 | grep -F 'Token : ' | cut -c9- > '%1/pf.token'").arg(DaemonDataDir));
|
execute(QStringLiteral("pfctl -E 2>&1 | grep -F 'Token : ' | cut -c9- > '%1/pf.token'").arg(DaemonDataDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,26 +142,29 @@ bool WireguardUtilsMacos::addInterface(const InterfaceConfig& config) {
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
logger.error() << "Interface configuration failed:" << strerror(err);
|
logger.error() << "Interface configuration failed:" << strerror(err);
|
||||||
} else {
|
} else {
|
||||||
if (config.m_killSwitchEnabled) {
|
if (config.m_killSwitchEnabled) {
|
||||||
FirewallParams params { };
|
FirewallParams params { };
|
||||||
params.dnsServers.append(config.m_dnsServer);
|
params.dnsServers.append(config.m_primaryDnsServer);
|
||||||
|
if (!config.m_secondaryDnsServer.isEmpty()) {
|
||||||
|
params.dnsServers.append(config.m_secondaryDnsServer);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.m_allowedIPAddressRanges.contains(IPAddress("0.0.0.0/0"))) {
|
if (config.m_allowedIPAddressRanges.contains(IPAddress("0.0.0.0/0"))) {
|
||||||
params.blockAll = true;
|
params.blockAll = true;
|
||||||
if (config.m_excludedAddresses.size()) {
|
if (config.m_excludedAddresses.size()) {
|
||||||
params.allowNets = true;
|
params.allowNets = true;
|
||||||
foreach (auto net, config.m_excludedAddresses) {
|
foreach (auto net, config.m_excludedAddresses) {
|
||||||
params.allowAddrs.append(net.toUtf8());
|
params.allowAddrs.append(net.toUtf8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
params.blockNets = true;
|
params.blockNets = true;
|
||||||
foreach (auto net, config.m_allowedIPAddressRanges) {
|
foreach (auto net, config.m_allowedIPAddressRanges) {
|
||||||
params.blockAddrs.append(net.toString());
|
params.blockAddrs.append(net.toString());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
applyFirewallRules(params);
|
|
||||||
}
|
}
|
||||||
|
applyFirewallRules(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (err == 0);
|
return (err == 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -291,15 +291,32 @@ bool WindowsFirewall::enablePeerTraffic(const InterfaceConfig& config) {
|
||||||
"Block Internet", config.m_serverPublicKey)) {
|
"Block Internet", config.m_serverPublicKey)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!config.m_dnsServer.isEmpty()) {
|
if (!config.m_primaryDnsServer.isEmpty()) {
|
||||||
if (!allowTrafficTo(QHostAddress(config.m_dnsServer), 53, HIGH_WEIGHT,
|
if (!allowTrafficTo(QHostAddress(config.m_primaryDnsServer), 53, HIGH_WEIGHT,
|
||||||
"Allow DNS-Server", config.m_serverPublicKey)) {
|
"Allow DNS-Server", config.m_serverPublicKey)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// In some cases, we might configure a 2nd DNS server for IPv6, however
|
// In some cases, we might configure a 2nd DNS server for IPv6, however
|
||||||
// this should probably be cleaned up by converting m_dnsServer into
|
// this should probably be cleaned up by converting m_dnsServer into
|
||||||
// a QStringList instead.
|
// a QStringList instead.
|
||||||
if (config.m_dnsServer == config.m_serverIpv4Gateway) {
|
if (config.m_primaryDnsServer == config.m_serverIpv4Gateway) {
|
||||||
|
if (!allowTrafficTo(QHostAddress(config.m_serverIpv6Gateway), 53,
|
||||||
|
HIGH_WEIGHT, "Allow extra IPv6 DNS-Server",
|
||||||
|
config.m_serverPublicKey)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config.m_secondaryDnsServer.isEmpty()) {
|
||||||
|
if (!allowTrafficTo(QHostAddress(config.m_secondaryDnsServer), 53, HIGH_WEIGHT,
|
||||||
|
"Allow DNS-Server", config.m_serverPublicKey)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// In some cases, we might configure a 2nd DNS server for IPv6, however
|
||||||
|
// this should probably be cleaned up by converting m_dnsServer into
|
||||||
|
// a QStringList instead.
|
||||||
|
if (config.m_secondaryDnsServer == config.m_serverIpv4Gateway) {
|
||||||
if (!allowTrafficTo(QHostAddress(config.m_serverIpv6Gateway), 53,
|
if (!allowTrafficTo(QHostAddress(config.m_serverIpv6Gateway), 53,
|
||||||
HIGH_WEIGHT, "Allow extra IPv6 DNS-Server",
|
HIGH_WEIGHT, "Allow extra IPv6 DNS-Server",
|
||||||
config.m_serverPublicKey)) {
|
config.m_serverPublicKey)) {
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ bool WireguardUtilsWindows::addInterface(const InterfaceConfig& config) {
|
||||||
// Enable the windows firewall
|
// Enable the windows firewall
|
||||||
NET_IFINDEX ifindex;
|
NET_IFINDEX ifindex;
|
||||||
ConvertInterfaceLuidToIndex(&luid, &ifindex);
|
ConvertInterfaceLuidToIndex(&luid, &ifindex);
|
||||||
|
m_firewall->allowAllTraffic();
|
||||||
m_firewall->enableInterface(ifindex);
|
m_firewall->enableInterface(ifindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,7 @@ void OpenVpnProtocol::updateVpnGateway(const QString &line)
|
||||||
// killSwitch toggle
|
// killSwitch toggle
|
||||||
if (m_vpnLocalAddress == netInterfaces.at(i).addressEntries().at(j).ip().toString()) {
|
if (m_vpnLocalAddress == netInterfaces.at(i).addressEntries().at(j).ip().toString()) {
|
||||||
if (QVariant(m_configData.value(config_key::killSwitchOption).toString()).toBool()) {
|
if (QVariant(m_configData.value(config_key::killSwitchOption).toString()).toBool()) {
|
||||||
IpcClient::Interface()->enableKillSwitch(QJsonObject(), netInterfaces.at(i).index());
|
IpcClient::Interface()->enableKillSwitch(m_configData, netInterfaces.at(i).index());
|
||||||
}
|
}
|
||||||
m_configData.insert("vpnAdapterIndex", netInterfaces.at(i).index());
|
m_configData.insert("vpnAdapterIndex", netInterfaces.at(i).index());
|
||||||
m_configData.insert("vpnGateway", m_vpnGateway);
|
m_configData.insert("vpnGateway", m_vpnGateway);
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,8 @@ namespace amnezia
|
||||||
|
|
||||||
constexpr char clientId[] = "clientId";
|
constexpr char clientId[] = "clientId";
|
||||||
|
|
||||||
|
constexpr char nameOverriddenByUser[] = "nameOverriddenByUser";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace protocols
|
namespace protocols
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,13 @@ ErrorCode XrayProtocol::startTun2Sock()
|
||||||
if (vpnState == Vpn::ConnectionState::Connected) {
|
if (vpnState == Vpn::ConnectionState::Connected) {
|
||||||
setConnectionState(Vpn::ConnectionState::Connecting);
|
setConnectionState(Vpn::ConnectionState::Connecting);
|
||||||
QList<QHostAddress> dnsAddr;
|
QList<QHostAddress> dnsAddr;
|
||||||
|
|
||||||
dnsAddr.push_back(QHostAddress(m_configData.value(config_key::dns1).toString()));
|
dnsAddr.push_back(QHostAddress(m_configData.value(config_key::dns1).toString()));
|
||||||
dnsAddr.push_back(QHostAddress(m_configData.value(config_key::dns2).toString()));
|
// We don't use secondary DNS if primary DNS is AmneziaDNS
|
||||||
|
if (!m_configData.value(amnezia::config_key::dns1).toString().
|
||||||
|
contains(amnezia::protocols::dns::amneziaDnsIp)) {
|
||||||
|
dnsAddr.push_back(QHostAddress(m_configData.value(config_key::dns2).toString()));
|
||||||
|
}
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QThread::msleep(8000);
|
QThread::msleep(8000);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -134,7 +139,7 @@ ErrorCode XrayProtocol::startTun2Sock()
|
||||||
// killSwitch toggle
|
// killSwitch toggle
|
||||||
if (m_vpnLocalAddress == netInterfaces.at(i).addressEntries().at(j).ip().toString()) {
|
if (m_vpnLocalAddress == netInterfaces.at(i).addressEntries().at(j).ip().toString()) {
|
||||||
if (QVariant(m_configData.value(config_key::killSwitchOption).toString()).toBool()) {
|
if (QVariant(m_configData.value(config_key::killSwitchOption).toString()).toBool()) {
|
||||||
IpcClient::Interface()->enableKillSwitch(QJsonObject(), netInterfaces.at(i).index());
|
IpcClient::Interface()->enableKillSwitch(m_configData, netInterfaces.at(i).index());
|
||||||
}
|
}
|
||||||
m_configData.insert("vpnAdapterIndex", netInterfaces.at(i).index());
|
m_configData.insert("vpnAdapterIndex", netInterfaces.at(i).index());
|
||||||
m_configData.insert("vpnGateway", m_vpnGateway);
|
m_configData.insert("vpnGateway", m_vpnGateway);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
if which apt-get > /dev/null 2>&1; then LOCK_FILE="/var/lib/dpkg/lock-frontend";\
|
if which apt-get > /dev/null 2>&1; then LOCK_CMD="fuser"; LOCK_FILE="/var/lib/dpkg/lock-frontend";\
|
||||||
elif which dnf > /dev/null 2>&1; then LOCK_FILE="/var/run/dnf.pid";\
|
elif which dnf > /dev/null 2>&1; then LOCK_CMD="fuser"; LOCK_FILE="/var/cache/dnf/* /var/run/dnf/* /var/lib/dnf/* /var/lib/rpm/*";\
|
||||||
elif which yum > /dev/null 2>&1; then LOCK_FILE="/var/run/yum.pid";\
|
elif which yum > /dev/null 2>&1; then LOCK_CMD="cat"; LOCK_FILE="/var/run/yum.pid";\
|
||||||
elif which pacman > /dev/null 2>&1; then LOCK_FILE="/var/lib/pacman/db.lck";\
|
elif which zypper > /dev/null 2>&1; then LOCK_CMD="cat"; LOCK_FILE="/var/run/zypp.pid";\
|
||||||
|
elif which pacman > /dev/null 2>&1; then LOCK_CMD="fuser"; LOCK_FILE="/var/lib/pacman/db.lck";\
|
||||||
else echo "Packet manager not found"; echo "Internal error"; exit 1; fi;\
|
else echo "Packet manager not found"; echo "Internal error"; exit 1; fi;\
|
||||||
if command -v fuser > /dev/null 2>&1; then sudo fuser $LOCK_FILE 2>/dev/null; else echo "fuser not installed"; fi
|
if command -v $LOCK_CMD > /dev/null 2>&1; then sudo $LOCK_CMD $LOCK_FILE 2>/dev/null; else echo "$LOCK_CMD not installed"; fi
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
if which apt-get > /dev/null 2>&1; then pm=$(which apt-get); opt="--version";\
|
if which apt-get > /dev/null 2>&1; then pm=$(which apt-get); opt="--version";\
|
||||||
elif which dnf > /dev/null 2>&1; then pm=$(which dnf); opt="--version";\
|
elif which dnf > /dev/null 2>&1; then pm=$(which dnf); opt="--version";\
|
||||||
elif which yum > /dev/null 2>&1; then pm=$(which yum); opt="--version";\
|
elif which yum > /dev/null 2>&1; then pm=$(which yum); opt="--version";\
|
||||||
|
elif which zypper > /dev/null 2>&1; then pm=$(which zypper); opt="--version";\
|
||||||
elif which pacman > /dev/null 2>&1; then pm=$(which pacman); opt="--version";\
|
elif which pacman > /dev/null 2>&1; then pm=$(which pacman); opt="--version";\
|
||||||
else pm="uname"; opt="-a";\
|
else pm="uname"; opt="-a";\
|
||||||
fi;\
|
fi;\
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
if which apt-get > /dev/null 2>&1; then pm=$(which apt-get); silent_inst="-yq install"; check_pkgs="-yq update"; docker_pkg="docker.io"; dist="debian";\
|
if which apt-get > /dev/null 2>&1; then pm=$(which apt-get); silent_inst="-yq install"; check_pkgs="-yq update"; docker_pkg="docker.io"; dist="debian";\
|
||||||
elif which dnf > /dev/null 2>&1; then pm=$(which dnf); silent_inst="-yq install"; check_pkgs="-yq check-update"; docker_pkg="docker"; dist="fedora";\
|
elif which dnf > /dev/null 2>&1; then pm=$(which dnf); silent_inst="-yq install"; check_pkgs="-yq check-update"; docker_pkg="docker"; dist="fedora";\
|
||||||
elif which yum > /dev/null 2>&1; then pm=$(which yum); silent_inst="-y -q install"; check_pkgs="-y -q check-update"; docker_pkg="docker"; dist="centos";\
|
elif which yum > /dev/null 2>&1; then pm=$(which yum); silent_inst="-y -q install"; check_pkgs="-y -q check-update"; docker_pkg="docker"; dist="centos";\
|
||||||
|
elif which zypper > /dev/null 2>&1; then pm=$(which zypper); silent_inst="-nq install"; check_pkgs="-nq refresh"; docker_pkg="docker"; dist="opensuse";\
|
||||||
elif which pacman > /dev/null 2>&1; then pm=$(which pacman); silent_inst="-S --noconfirm --noprogressbar --quiet"; check_pkgs="-Sup"; docker_pkg="docker"; dist="archlinux";\
|
elif which pacman > /dev/null 2>&1; then pm=$(which pacman); silent_inst="-S --noconfirm --noprogressbar --quiet"; check_pkgs="-Sup"; docker_pkg="docker"; dist="archlinux";\
|
||||||
else echo "Packet manager not found"; exit 1; fi;\
|
else echo "Packet manager not found"; exit 1; fi;\
|
||||||
echo "Dist: $dist, Packet manager: $pm, Install command: $silent_inst, Check pkgs command: $check_pkgs, Docker pkg: $docker_pkg";\
|
echo "Dist: $dist, Packet manager: $pm, Install command: $silent_inst, Check pkgs command: $check_pkgs, Docker pkg: $docker_pkg";\
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ namespace
|
||||||
{
|
{
|
||||||
constexpr char cloak[] = "cloak";
|
constexpr char cloak[] = "cloak";
|
||||||
constexpr char awg[] = "awg";
|
constexpr char awg[] = "awg";
|
||||||
|
constexpr char vless[] = "vless";
|
||||||
|
|
||||||
constexpr char apiEndpoint[] = "api_endpoint";
|
constexpr char apiEndpoint[] = "api_endpoint";
|
||||||
constexpr char accessToken[] = "api_key";
|
constexpr char accessToken[] = "api_key";
|
||||||
|
|
@ -35,10 +36,6 @@ namespace
|
||||||
constexpr char serviceInfo[] = "service_info";
|
constexpr char serviceInfo[] = "service_info";
|
||||||
constexpr char serviceProtocol[] = "service_protocol";
|
constexpr char serviceProtocol[] = "service_protocol";
|
||||||
|
|
||||||
constexpr char aesKey[] = "aes_key";
|
|
||||||
constexpr char aesIv[] = "aes_iv";
|
|
||||||
constexpr char aesSalt[] = "aes_salt";
|
|
||||||
|
|
||||||
constexpr char apiPayload[] = "api_payload";
|
constexpr char apiPayload[] = "api_payload";
|
||||||
constexpr char keyPayload[] = "key_payload";
|
constexpr char keyPayload[] = "key_payload";
|
||||||
|
|
||||||
|
|
@ -47,6 +44,182 @@ namespace
|
||||||
|
|
||||||
constexpr char config[] = "config";
|
constexpr char config[] = "config";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ProtocolData
|
||||||
|
{
|
||||||
|
OpenVpnConfigurator::ConnectionData certRequest;
|
||||||
|
|
||||||
|
QString wireGuardClientPrivKey;
|
||||||
|
QString wireGuardClientPubKey;
|
||||||
|
|
||||||
|
QString xrayUuid;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GatewayRequestData
|
||||||
|
{
|
||||||
|
QString osVersion;
|
||||||
|
QString appVersion;
|
||||||
|
|
||||||
|
QString installationUuid;
|
||||||
|
|
||||||
|
QString userCountryCode;
|
||||||
|
QString serverCountryCode;
|
||||||
|
QString serviceType;
|
||||||
|
QString serviceProtocol;
|
||||||
|
|
||||||
|
QJsonObject authData;
|
||||||
|
|
||||||
|
QJsonObject toJsonObject() const
|
||||||
|
{
|
||||||
|
QJsonObject obj;
|
||||||
|
if (!osVersion.isEmpty()) {
|
||||||
|
obj[configKey::osVersion] = osVersion;
|
||||||
|
}
|
||||||
|
if (!appVersion.isEmpty()) {
|
||||||
|
obj[configKey::appVersion] = appVersion;
|
||||||
|
}
|
||||||
|
if (!installationUuid.isEmpty()) {
|
||||||
|
obj[configKey::uuid] = installationUuid;
|
||||||
|
}
|
||||||
|
if (!userCountryCode.isEmpty()) {
|
||||||
|
obj[configKey::userCountryCode] = userCountryCode;
|
||||||
|
}
|
||||||
|
if (!serverCountryCode.isEmpty()) {
|
||||||
|
obj[configKey::serverCountryCode] = serverCountryCode;
|
||||||
|
}
|
||||||
|
if (!serviceType.isEmpty()) {
|
||||||
|
obj[configKey::serviceType] = serviceType;
|
||||||
|
}
|
||||||
|
if (!serviceProtocol.isEmpty()) {
|
||||||
|
obj[configKey::serviceProtocol] = serviceProtocol;
|
||||||
|
}
|
||||||
|
if (!authData.isEmpty()) {
|
||||||
|
obj[configKey::authData] = authData;
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ProtocolData generateProtocolData(const QString &protocol)
|
||||||
|
{
|
||||||
|
ProtocolData protocolData;
|
||||||
|
if (protocol == configKey::cloak) {
|
||||||
|
protocolData.certRequest = OpenVpnConfigurator::createCertRequest();
|
||||||
|
} else if (protocol == configKey::awg) {
|
||||||
|
auto connData = WireguardConfigurator::genClientKeys();
|
||||||
|
protocolData.wireGuardClientPubKey = connData.clientPubKey;
|
||||||
|
protocolData.wireGuardClientPrivKey = connData.clientPrivKey;
|
||||||
|
} else if (protocol == configKey::vless) {
|
||||||
|
protocolData.xrayUuid = QUuid::createUuid().toString(QUuid::WithoutBraces);
|
||||||
|
}
|
||||||
|
|
||||||
|
return protocolData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void appendProtocolDataToApiPayload(const QString &protocol, const ProtocolData &protocolData, QJsonObject &apiPayload)
|
||||||
|
{
|
||||||
|
if (protocol == configKey::cloak) {
|
||||||
|
apiPayload[configKey::certificate] = protocolData.certRequest.request;
|
||||||
|
} else if (protocol == configKey::awg) {
|
||||||
|
apiPayload[configKey::publicKey] = protocolData.wireGuardClientPubKey;
|
||||||
|
} else if (protocol == configKey::vless) {
|
||||||
|
apiPayload[configKey::publicKey] = protocolData.xrayUuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode fillServerConfig(const QString &protocol, const ProtocolData &apiPayloadData, const QByteArray &apiResponseBody,
|
||||||
|
QJsonObject &serverConfig)
|
||||||
|
{
|
||||||
|
QString data = QJsonDocument::fromJson(apiResponseBody).object().value(config_key::config).toString();
|
||||||
|
|
||||||
|
data.replace("vpn://", "");
|
||||||
|
QByteArray ba = QByteArray::fromBase64(data.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||||
|
|
||||||
|
if (ba.isEmpty()) {
|
||||||
|
qDebug() << "empty vpn key";
|
||||||
|
return ErrorCode::ApiConfigEmptyError;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray ba_uncompressed = qUncompress(ba);
|
||||||
|
if (!ba_uncompressed.isEmpty()) {
|
||||||
|
ba = ba_uncompressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString configStr = ba;
|
||||||
|
if (protocol == configKey::cloak) {
|
||||||
|
configStr.replace("<key>", "<key>\n");
|
||||||
|
configStr.replace("$OPENVPN_PRIV_KEY", apiPayloadData.certRequest.privKey);
|
||||||
|
} else if (protocol == configKey::awg) {
|
||||||
|
configStr.replace("$WIREGUARD_CLIENT_PRIVATE_KEY", apiPayloadData.wireGuardClientPrivKey);
|
||||||
|
auto newServerConfig = QJsonDocument::fromJson(configStr.toUtf8()).object();
|
||||||
|
auto containers = newServerConfig.value(config_key::containers).toArray();
|
||||||
|
if (containers.isEmpty()) {
|
||||||
|
qDebug() << "missing containers field";
|
||||||
|
return ErrorCode::ApiConfigEmptyError;
|
||||||
|
}
|
||||||
|
auto container = containers.at(0).toObject();
|
||||||
|
QString containerName = ContainerProps::containerTypeToString(DockerContainer::Awg);
|
||||||
|
auto serverProtocolConfig = container.value(containerName).toObject();
|
||||||
|
auto clientProtocolConfig =
|
||||||
|
QJsonDocument::fromJson(serverProtocolConfig.value(config_key::last_config).toString().toUtf8()).object();
|
||||||
|
serverProtocolConfig[config_key::junkPacketCount] = clientProtocolConfig.value(config_key::junkPacketCount);
|
||||||
|
serverProtocolConfig[config_key::junkPacketMinSize] = clientProtocolConfig.value(config_key::junkPacketMinSize);
|
||||||
|
serverProtocolConfig[config_key::junkPacketMaxSize] = clientProtocolConfig.value(config_key::junkPacketMaxSize);
|
||||||
|
serverProtocolConfig[config_key::initPacketJunkSize] = clientProtocolConfig.value(config_key::initPacketJunkSize);
|
||||||
|
serverProtocolConfig[config_key::responsePacketJunkSize] = clientProtocolConfig.value(config_key::responsePacketJunkSize);
|
||||||
|
serverProtocolConfig[config_key::initPacketMagicHeader] = clientProtocolConfig.value(config_key::initPacketMagicHeader);
|
||||||
|
serverProtocolConfig[config_key::responsePacketMagicHeader] = clientProtocolConfig.value(config_key::responsePacketMagicHeader);
|
||||||
|
serverProtocolConfig[config_key::underloadPacketMagicHeader] = clientProtocolConfig.value(config_key::underloadPacketMagicHeader);
|
||||||
|
serverProtocolConfig[config_key::transportPacketMagicHeader] = clientProtocolConfig.value(config_key::transportPacketMagicHeader);
|
||||||
|
|
||||||
|
serverProtocolConfig[config_key::cookieReplyPacketJunkSize] = clientProtocolConfig.value(config_key::cookieReplyPacketJunkSize);
|
||||||
|
serverProtocolConfig[config_key::transportPacketJunkSize] = clientProtocolConfig.value(config_key::transportPacketJunkSize);
|
||||||
|
serverProtocolConfig[config_key::specialJunk1] = clientProtocolConfig.value(config_key::specialJunk1);
|
||||||
|
serverProtocolConfig[config_key::specialJunk2] = clientProtocolConfig.value(config_key::specialJunk2);
|
||||||
|
serverProtocolConfig[config_key::specialJunk3] = clientProtocolConfig.value(config_key::specialJunk3);
|
||||||
|
serverProtocolConfig[config_key::specialJunk4] = clientProtocolConfig.value(config_key::specialJunk4);
|
||||||
|
serverProtocolConfig[config_key::specialJunk5] = clientProtocolConfig.value(config_key::specialJunk5);
|
||||||
|
serverProtocolConfig[config_key::controlledJunk1] = clientProtocolConfig.value(config_key::controlledJunk1);
|
||||||
|
serverProtocolConfig[config_key::controlledJunk2] = clientProtocolConfig.value(config_key::controlledJunk2);
|
||||||
|
serverProtocolConfig[config_key::controlledJunk3] = clientProtocolConfig.value(config_key::controlledJunk3);
|
||||||
|
serverProtocolConfig[config_key::specialHandshakeTimeout] = clientProtocolConfig.value(config_key::specialHandshakeTimeout);
|
||||||
|
|
||||||
|
container[containerName] = serverProtocolConfig;
|
||||||
|
containers.replace(0, container);
|
||||||
|
newServerConfig[config_key::containers] = containers;
|
||||||
|
configStr = QString(QJsonDocument(newServerConfig).toJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject newServerConfig = QJsonDocument::fromJson(configStr.toUtf8()).object();
|
||||||
|
serverConfig[config_key::dns1] = newServerConfig.value(config_key::dns1);
|
||||||
|
serverConfig[config_key::dns2] = newServerConfig.value(config_key::dns2);
|
||||||
|
serverConfig[config_key::containers] = newServerConfig.value(config_key::containers);
|
||||||
|
serverConfig[config_key::hostName] = newServerConfig.value(config_key::hostName);
|
||||||
|
|
||||||
|
if (newServerConfig.value(config_key::configVersion).toInt() == apiDefs::ConfigSource::AmneziaGateway) {
|
||||||
|
serverConfig[config_key::configVersion] = newServerConfig.value(config_key::configVersion);
|
||||||
|
serverConfig[config_key::description] = newServerConfig.value(config_key::description);
|
||||||
|
serverConfig[config_key::name] = newServerConfig.value(config_key::name);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto defaultContainer = newServerConfig.value(config_key::defaultContainer).toString();
|
||||||
|
serverConfig[config_key::defaultContainer] = defaultContainer;
|
||||||
|
|
||||||
|
QVariantMap map = serverConfig.value(configKey::apiConfig).toObject().toVariantMap();
|
||||||
|
map.insert(newServerConfig.value(configKey::apiConfig).toObject().toVariantMap());
|
||||||
|
auto apiConfig = QJsonObject::fromVariantMap(map);
|
||||||
|
|
||||||
|
if (newServerConfig.value(config_key::configVersion).toInt() == apiDefs::ConfigSource::AmneziaGateway) {
|
||||||
|
apiConfig.insert(apiDefs::key::supportedProtocols,
|
||||||
|
QJsonDocument::fromJson(apiResponseBody).object().value(apiDefs::key::supportedProtocols).toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
serverConfig[configKey::apiConfig] = apiConfig;
|
||||||
|
|
||||||
|
qDebug() << serverConfig;
|
||||||
|
|
||||||
|
return ErrorCode::NoError;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiConfigsController::ApiConfigsController(const QSharedPointer<ServersModel> &serversModel,
|
ApiConfigsController::ApiConfigsController(const QSharedPointer<ServersModel> &serversModel,
|
||||||
|
|
@ -63,24 +236,26 @@ bool ApiConfigsController::exportNativeConfig(const QString &serverCountryCode,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GatewayController gatewayController(m_settings->getGatewayEndpoint(), m_settings->isDevGatewayEnv(), apiDefs::requestTimeoutMsecs,
|
|
||||||
m_settings->isStrictKillSwitchEnabled());
|
|
||||||
|
|
||||||
auto serverConfigObject = m_serversModel->getServerConfig(m_serversModel->getProcessedServerIndex());
|
auto serverConfigObject = m_serversModel->getServerConfig(m_serversModel->getProcessedServerIndex());
|
||||||
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
||||||
|
|
||||||
QString protocol = apiConfigObject.value(configKey::serviceProtocol).toString();
|
GatewayRequestData gatewayRequestData { QSysInfo::productType(),
|
||||||
ApiPayloadData apiPayloadData = generateApiPayloadData(protocol);
|
QString(APP_VERSION),
|
||||||
|
m_settings->getInstallationUuid(true),
|
||||||
|
apiConfigObject.value(configKey::userCountryCode).toString(),
|
||||||
|
serverCountryCode,
|
||||||
|
apiConfigObject.value(configKey::serviceType).toString(),
|
||||||
|
m_apiServicesModel->getSelectedServiceProtocol(),
|
||||||
|
serverConfigObject.value(configKey::authData).toObject() };
|
||||||
|
|
||||||
QJsonObject apiPayload = fillApiPayload(protocol, apiPayloadData);
|
QString protocol = apiConfigObject.value(configKey::serviceProtocol).toString();
|
||||||
apiPayload[configKey::userCountryCode] = apiConfigObject.value(configKey::userCountryCode);
|
ProtocolData protocolData = generateProtocolData(protocol);
|
||||||
apiPayload[configKey::serverCountryCode] = serverCountryCode;
|
|
||||||
apiPayload[configKey::serviceType] = apiConfigObject.value(configKey::serviceType);
|
QJsonObject apiPayload = gatewayRequestData.toJsonObject();
|
||||||
apiPayload[configKey::authData] = serverConfigObject.value(configKey::authData);
|
appendProtocolDataToApiPayload(gatewayRequestData.serviceProtocol, protocolData, apiPayload);
|
||||||
apiPayload[apiDefs::key::cliVersion] = QString(APP_VERSION);
|
|
||||||
|
|
||||||
QByteArray responseBody;
|
QByteArray responseBody;
|
||||||
ErrorCode errorCode = gatewayController.post(QString("%1v1/native_config"), apiPayload, responseBody);
|
ErrorCode errorCode = executeRequest(QString("%1v1/native_config"), apiPayload, responseBody);
|
||||||
if (errorCode != ErrorCode::NoError) {
|
if (errorCode != ErrorCode::NoError) {
|
||||||
emit errorOccurred(errorCode);
|
emit errorOccurred(errorCode);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -88,7 +263,7 @@ bool ApiConfigsController::exportNativeConfig(const QString &serverCountryCode,
|
||||||
|
|
||||||
QJsonObject jsonConfig = QJsonDocument::fromJson(responseBody).object();
|
QJsonObject jsonConfig = QJsonDocument::fromJson(responseBody).object();
|
||||||
QString nativeConfig = jsonConfig.value(configKey::config).toString();
|
QString nativeConfig = jsonConfig.value(configKey::config).toString();
|
||||||
nativeConfig.replace("$WIREGUARD_CLIENT_PRIVATE_KEY", apiPayloadData.wireGuardClientPrivKey);
|
nativeConfig.replace("$WIREGUARD_CLIENT_PRIVATE_KEY", protocolData.wireGuardClientPrivKey);
|
||||||
|
|
||||||
SystemController::saveFile(fileName, nativeConfig);
|
SystemController::saveFile(fileName, nativeConfig);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -96,24 +271,22 @@ bool ApiConfigsController::exportNativeConfig(const QString &serverCountryCode,
|
||||||
|
|
||||||
bool ApiConfigsController::revokeNativeConfig(const QString &serverCountryCode)
|
bool ApiConfigsController::revokeNativeConfig(const QString &serverCountryCode)
|
||||||
{
|
{
|
||||||
GatewayController gatewayController(m_settings->getGatewayEndpoint(), m_settings->isDevGatewayEnv(), apiDefs::requestTimeoutMsecs,
|
|
||||||
m_settings->isStrictKillSwitchEnabled());
|
|
||||||
|
|
||||||
auto serverConfigObject = m_serversModel->getServerConfig(m_serversModel->getProcessedServerIndex());
|
auto serverConfigObject = m_serversModel->getServerConfig(m_serversModel->getProcessedServerIndex());
|
||||||
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
||||||
|
|
||||||
QString protocol = apiConfigObject.value(configKey::serviceProtocol).toString();
|
GatewayRequestData gatewayRequestData { QSysInfo::productType(),
|
||||||
ApiPayloadData apiPayloadData = generateApiPayloadData(protocol);
|
QString(APP_VERSION),
|
||||||
|
m_settings->getInstallationUuid(true),
|
||||||
|
apiConfigObject.value(configKey::userCountryCode).toString(),
|
||||||
|
serverCountryCode,
|
||||||
|
apiConfigObject.value(configKey::serviceType).toString(),
|
||||||
|
m_apiServicesModel->getSelectedServiceProtocol(),
|
||||||
|
serverConfigObject.value(configKey::authData).toObject() };
|
||||||
|
|
||||||
QJsonObject apiPayload = fillApiPayload(protocol, apiPayloadData);
|
QJsonObject apiPayload = gatewayRequestData.toJsonObject();
|
||||||
apiPayload[configKey::userCountryCode] = apiConfigObject.value(configKey::userCountryCode);
|
|
||||||
apiPayload[configKey::serverCountryCode] = serverCountryCode;
|
|
||||||
apiPayload[configKey::serviceType] = apiConfigObject.value(configKey::serviceType);
|
|
||||||
apiPayload[configKey::authData] = serverConfigObject.value(configKey::authData);
|
|
||||||
apiPayload[apiDefs::key::cliVersion] = QString(APP_VERSION);
|
|
||||||
|
|
||||||
QByteArray responseBody;
|
QByteArray responseBody;
|
||||||
ErrorCode errorCode = gatewayController.post(QString("%1v1/revoke_native_config"), apiPayload, responseBody);
|
ErrorCode errorCode = executeRequest(QString("%1v1/revoke_native_config"), apiPayload, responseBody);
|
||||||
if (errorCode != ErrorCode::NoError && errorCode != ErrorCode::ApiNotFoundError) {
|
if (errorCode != ErrorCode::NoError && errorCode != ErrorCode::ApiNotFoundError) {
|
||||||
emit errorOccurred(errorCode);
|
emit errorOccurred(errorCode);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -144,14 +317,11 @@ void ApiConfigsController::copyVpnKeyToClipboard()
|
||||||
|
|
||||||
bool ApiConfigsController::fillAvailableServices()
|
bool ApiConfigsController::fillAvailableServices()
|
||||||
{
|
{
|
||||||
GatewayController gatewayController(m_settings->getGatewayEndpoint(), m_settings->isDevGatewayEnv(), apiDefs::requestTimeoutMsecs,
|
|
||||||
m_settings->isStrictKillSwitchEnabled());
|
|
||||||
|
|
||||||
QJsonObject apiPayload;
|
QJsonObject apiPayload;
|
||||||
apiPayload[configKey::osVersion] = QSysInfo::productType();
|
apiPayload[configKey::osVersion] = QSysInfo::productType();
|
||||||
|
|
||||||
QByteArray responseBody;
|
QByteArray responseBody;
|
||||||
ErrorCode errorCode = gatewayController.post(QString("%1v1/services"), apiPayload, responseBody);
|
ErrorCode errorCode = executeRequest(QString("%1v1/services"), apiPayload, responseBody);
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
if (!responseBody.contains("services")) {
|
if (!responseBody.contains("services")) {
|
||||||
errorCode = ErrorCode::ApiServicesMissingError;
|
errorCode = ErrorCode::ApiServicesMissingError;
|
||||||
|
|
@ -170,34 +340,36 @@ bool ApiConfigsController::fillAvailableServices()
|
||||||
|
|
||||||
bool ApiConfigsController::importServiceFromGateway()
|
bool ApiConfigsController::importServiceFromGateway()
|
||||||
{
|
{
|
||||||
if (m_serversModel->isServerFromApiAlreadyExists(m_apiServicesModel->getCountryCode(), m_apiServicesModel->getSelectedServiceType(),
|
GatewayRequestData gatewayRequestData { QSysInfo::productType(),
|
||||||
m_apiServicesModel->getSelectedServiceProtocol())) {
|
QString(APP_VERSION),
|
||||||
|
m_settings->getInstallationUuid(true),
|
||||||
|
m_apiServicesModel->getCountryCode(),
|
||||||
|
"",
|
||||||
|
m_apiServicesModel->getSelectedServiceType(),
|
||||||
|
m_apiServicesModel->getSelectedServiceProtocol(),
|
||||||
|
QJsonObject() };
|
||||||
|
|
||||||
|
if (m_serversModel->isServerFromApiAlreadyExists(gatewayRequestData.userCountryCode, gatewayRequestData.serviceType,
|
||||||
|
gatewayRequestData.serviceProtocol)) {
|
||||||
emit errorOccurred(ErrorCode::ApiConfigAlreadyAdded);
|
emit errorOccurred(ErrorCode::ApiConfigAlreadyAdded);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GatewayController gatewayController(m_settings->getGatewayEndpoint(), m_settings->isDevGatewayEnv(), apiDefs::requestTimeoutMsecs,
|
ProtocolData protocolData = generateProtocolData(gatewayRequestData.serviceProtocol);
|
||||||
m_settings->isStrictKillSwitchEnabled());
|
|
||||||
|
|
||||||
auto installationUuid = m_settings->getInstallationUuid(true);
|
QJsonObject apiPayload = gatewayRequestData.toJsonObject();
|
||||||
auto userCountryCode = m_apiServicesModel->getCountryCode();
|
appendProtocolDataToApiPayload(gatewayRequestData.serviceProtocol, protocolData, apiPayload);
|
||||||
auto serviceType = m_apiServicesModel->getSelectedServiceType();
|
|
||||||
auto serviceProtocol = m_apiServicesModel->getSelectedServiceProtocol();
|
|
||||||
|
|
||||||
ApiPayloadData apiPayloadData = generateApiPayloadData(serviceProtocol);
|
|
||||||
|
|
||||||
QJsonObject apiPayload = fillApiPayload(serviceProtocol, apiPayloadData);
|
|
||||||
apiPayload[configKey::userCountryCode] = userCountryCode;
|
|
||||||
apiPayload[configKey::serviceType] = serviceType;
|
|
||||||
apiPayload[configKey::uuid] = installationUuid;
|
|
||||||
apiPayload[apiDefs::key::cliVersion] = QString(APP_VERSION);
|
|
||||||
|
|
||||||
QByteArray responseBody;
|
QByteArray responseBody;
|
||||||
ErrorCode errorCode = gatewayController.post(QString("%1v1/config"), apiPayload, responseBody);
|
ErrorCode errorCode = executeRequest(QString("%1v1/config"), apiPayload, responseBody);
|
||||||
|
|
||||||
QJsonObject serverConfig;
|
QJsonObject serverConfig;
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
fillServerConfig(serviceProtocol, apiPayloadData, responseBody, serverConfig);
|
errorCode = fillServerConfig(gatewayRequestData.serviceProtocol, protocolData, responseBody, serverConfig);
|
||||||
|
if (errorCode != ErrorCode::NoError) {
|
||||||
|
emit errorOccurred(errorCode);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QJsonObject apiConfig = serverConfig.value(configKey::apiConfig).toObject();
|
QJsonObject apiConfig = serverConfig.value(configKey::apiConfig).toObject();
|
||||||
apiConfig.insert(configKey::userCountryCode, m_apiServicesModel->getCountryCode());
|
apiConfig.insert(configKey::userCountryCode, m_apiServicesModel->getCountryCode());
|
||||||
|
|
@ -218,39 +390,33 @@ bool ApiConfigsController::importServiceFromGateway()
|
||||||
bool ApiConfigsController::updateServiceFromGateway(const int serverIndex, const QString &newCountryCode, const QString &newCountryName,
|
bool ApiConfigsController::updateServiceFromGateway(const int serverIndex, const QString &newCountryCode, const QString &newCountryName,
|
||||||
bool reloadServiceConfig)
|
bool reloadServiceConfig)
|
||||||
{
|
{
|
||||||
GatewayController gatewayController(m_settings->getGatewayEndpoint(), m_settings->isDevGatewayEnv(), apiDefs::requestTimeoutMsecs,
|
|
||||||
m_settings->isStrictKillSwitchEnabled());
|
|
||||||
|
|
||||||
auto serverConfig = m_serversModel->getServerConfig(serverIndex);
|
auto serverConfig = m_serversModel->getServerConfig(serverIndex);
|
||||||
auto apiConfig = serverConfig.value(configKey::apiConfig).toObject();
|
auto apiConfig = serverConfig.value(configKey::apiConfig).toObject();
|
||||||
auto authData = serverConfig.value(configKey::authData).toObject();
|
|
||||||
|
|
||||||
auto installationUuid = m_settings->getInstallationUuid(true);
|
GatewayRequestData gatewayRequestData { QSysInfo::productType(),
|
||||||
auto userCountryCode = apiConfig.value(configKey::userCountryCode).toString();
|
QString(APP_VERSION),
|
||||||
auto serviceType = apiConfig.value(configKey::serviceType).toString();
|
m_settings->getInstallationUuid(true),
|
||||||
auto serviceProtocol = apiConfig.value(configKey::serviceProtocol).toString();
|
apiConfig.value(configKey::userCountryCode).toString(),
|
||||||
|
newCountryCode,
|
||||||
|
apiConfig.value(configKey::serviceType).toString(),
|
||||||
|
apiConfig.value(configKey::serviceProtocol).toString(),
|
||||||
|
serverConfig.value(configKey::authData).toObject() };
|
||||||
|
|
||||||
ApiPayloadData apiPayloadData = generateApiPayloadData(serviceProtocol);
|
ProtocolData protocolData = generateProtocolData(gatewayRequestData.serviceProtocol);
|
||||||
|
|
||||||
QJsonObject apiPayload = fillApiPayload(serviceProtocol, apiPayloadData);
|
QJsonObject apiPayload = gatewayRequestData.toJsonObject();
|
||||||
apiPayload[configKey::userCountryCode] = userCountryCode;
|
appendProtocolDataToApiPayload(gatewayRequestData.serviceProtocol, protocolData, apiPayload);
|
||||||
apiPayload[configKey::serviceType] = serviceType;
|
|
||||||
apiPayload[configKey::uuid] = installationUuid;
|
|
||||||
apiPayload[apiDefs::key::cliVersion] = QString(APP_VERSION);
|
|
||||||
|
|
||||||
if (!newCountryCode.isEmpty()) {
|
|
||||||
apiPayload[configKey::serverCountryCode] = newCountryCode;
|
|
||||||
}
|
|
||||||
if (!authData.isEmpty()) {
|
|
||||||
apiPayload[configKey::authData] = authData;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray responseBody;
|
QByteArray responseBody;
|
||||||
ErrorCode errorCode = gatewayController.post(QString("%1v1/config"), apiPayload, responseBody);
|
ErrorCode errorCode = executeRequest(QString("%1v1/config"), apiPayload, responseBody);
|
||||||
|
|
||||||
QJsonObject newServerConfig;
|
QJsonObject newServerConfig;
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
fillServerConfig(serviceProtocol, apiPayloadData, responseBody, newServerConfig);
|
errorCode = fillServerConfig(gatewayRequestData.serviceProtocol, protocolData, responseBody, newServerConfig);
|
||||||
|
if (errorCode != ErrorCode::NoError) {
|
||||||
|
emit errorOccurred(errorCode);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QJsonObject newApiConfig = newServerConfig.value(configKey::apiConfig).toObject();
|
QJsonObject newApiConfig = newServerConfig.value(configKey::apiConfig).toObject();
|
||||||
newApiConfig.insert(configKey::userCountryCode, apiConfig.value(configKey::userCountryCode));
|
newApiConfig.insert(configKey::userCountryCode, apiConfig.value(configKey::userCountryCode));
|
||||||
|
|
@ -259,8 +425,12 @@ bool ApiConfigsController::updateServiceFromGateway(const int serverIndex, const
|
||||||
newApiConfig.insert(apiDefs::key::vpnKey, apiConfig.value(apiDefs::key::vpnKey));
|
newApiConfig.insert(apiDefs::key::vpnKey, apiConfig.value(apiDefs::key::vpnKey));
|
||||||
|
|
||||||
newServerConfig.insert(configKey::apiConfig, newApiConfig);
|
newServerConfig.insert(configKey::apiConfig, newApiConfig);
|
||||||
newServerConfig.insert(configKey::authData, authData);
|
newServerConfig.insert(configKey::authData, gatewayRequestData.authData);
|
||||||
|
|
||||||
|
if (serverConfig.value(config_key::nameOverriddenByUser).toBool()) {
|
||||||
|
newServerConfig.insert(config_key::name, serverConfig.value(config_key::name));
|
||||||
|
newServerConfig.insert(config_key::nameOverriddenByUser, true);
|
||||||
|
}
|
||||||
m_serversModel->editServer(newServerConfig, serverIndex);
|
m_serversModel->editServer(newServerConfig, serverIndex);
|
||||||
if (reloadServiceConfig) {
|
if (reloadServiceConfig) {
|
||||||
emit reloadServerFromApiFinished(tr("API config reloaded"));
|
emit reloadServerFromApiFinished(tr("API config reloaded"));
|
||||||
|
|
@ -290,10 +460,13 @@ bool ApiConfigsController::updateServiceFromTelegram(const int serverIndex)
|
||||||
auto installationUuid = m_settings->getInstallationUuid(true);
|
auto installationUuid = m_settings->getInstallationUuid(true);
|
||||||
|
|
||||||
QString serviceProtocol = serverConfig.value(configKey::protocol).toString();
|
QString serviceProtocol = serverConfig.value(configKey::protocol).toString();
|
||||||
ApiPayloadData apiPayloadData = generateApiPayloadData(serviceProtocol);
|
ProtocolData protocolData = generateProtocolData(serviceProtocol);
|
||||||
|
|
||||||
QJsonObject apiPayload = fillApiPayload(serviceProtocol, apiPayloadData);
|
QJsonObject apiPayload;
|
||||||
|
appendProtocolDataToApiPayload(serviceProtocol, protocolData, apiPayload);
|
||||||
apiPayload[configKey::uuid] = installationUuid;
|
apiPayload[configKey::uuid] = installationUuid;
|
||||||
|
apiPayload[configKey::osVersion] = QSysInfo::productType();
|
||||||
|
apiPayload[configKey::appVersion] = QString(APP_VERSION);
|
||||||
apiPayload[configKey::accessToken] = serverConfig.value(configKey::accessToken).toString();
|
apiPayload[configKey::accessToken] = serverConfig.value(configKey::accessToken).toString();
|
||||||
apiPayload[configKey::apiEndpoint] = serverConfig.value(configKey::apiEndpoint).toString();
|
apiPayload[configKey::apiEndpoint] = serverConfig.value(configKey::apiEndpoint).toString();
|
||||||
|
|
||||||
|
|
@ -301,7 +474,11 @@ bool ApiConfigsController::updateServiceFromTelegram(const int serverIndex)
|
||||||
ErrorCode errorCode = gatewayController.post(QString("%1v1/proxy_config"), apiPayload, responseBody);
|
ErrorCode errorCode = gatewayController.post(QString("%1v1/proxy_config"), apiPayload, responseBody);
|
||||||
|
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
fillServerConfig(serviceProtocol, apiPayloadData, responseBody, serverConfig);
|
errorCode = fillServerConfig(serviceProtocol, protocolData, responseBody, serverConfig);
|
||||||
|
if (errorCode != ErrorCode::NoError) {
|
||||||
|
emit errorOccurred(errorCode);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
m_serversModel->editServer(serverConfig, serverIndex);
|
m_serversModel->editServer(serverConfig, serverIndex);
|
||||||
emit updateServerFromApiFinished();
|
emit updateServerFromApiFinished();
|
||||||
|
|
@ -314,9 +491,6 @@ bool ApiConfigsController::updateServiceFromTelegram(const int serverIndex)
|
||||||
|
|
||||||
bool ApiConfigsController::deactivateDevice()
|
bool ApiConfigsController::deactivateDevice()
|
||||||
{
|
{
|
||||||
GatewayController gatewayController(m_settings->getGatewayEndpoint(), m_settings->isDevGatewayEnv(), apiDefs::requestTimeoutMsecs,
|
|
||||||
m_settings->isStrictKillSwitchEnabled());
|
|
||||||
|
|
||||||
auto serverIndex = m_serversModel->getProcessedServerIndex();
|
auto serverIndex = m_serversModel->getProcessedServerIndex();
|
||||||
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
||||||
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
||||||
|
|
@ -325,19 +499,19 @@ bool ApiConfigsController::deactivateDevice()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString protocol = apiConfigObject.value(configKey::serviceProtocol).toString();
|
GatewayRequestData gatewayRequestData { QSysInfo::productType(),
|
||||||
ApiPayloadData apiPayloadData = generateApiPayloadData(protocol);
|
QString(APP_VERSION),
|
||||||
|
m_settings->getInstallationUuid(true),
|
||||||
|
apiConfigObject.value(configKey::userCountryCode).toString(),
|
||||||
|
apiConfigObject.value(configKey::serverCountryCode).toString(),
|
||||||
|
apiConfigObject.value(configKey::serviceType).toString(),
|
||||||
|
"",
|
||||||
|
serverConfigObject.value(configKey::authData).toObject() };
|
||||||
|
|
||||||
QJsonObject apiPayload = fillApiPayload(protocol, apiPayloadData);
|
QJsonObject apiPayload = gatewayRequestData.toJsonObject();
|
||||||
apiPayload[configKey::userCountryCode] = apiConfigObject.value(configKey::userCountryCode);
|
|
||||||
apiPayload[configKey::serverCountryCode] = apiConfigObject.value(configKey::serverCountryCode);
|
|
||||||
apiPayload[configKey::serviceType] = apiConfigObject.value(configKey::serviceType);
|
|
||||||
apiPayload[configKey::authData] = serverConfigObject.value(configKey::authData);
|
|
||||||
apiPayload[configKey::uuid] = m_settings->getInstallationUuid(true);
|
|
||||||
apiPayload[apiDefs::key::cliVersion] = QString(APP_VERSION);
|
|
||||||
|
|
||||||
QByteArray responseBody;
|
QByteArray responseBody;
|
||||||
ErrorCode errorCode = gatewayController.post(QString("%1v1/revoke_config"), apiPayload, responseBody);
|
ErrorCode errorCode = executeRequest(QString("%1v1/revoke_config"), apiPayload, responseBody);
|
||||||
if (errorCode != ErrorCode::NoError && errorCode != ErrorCode::ApiNotFoundError) {
|
if (errorCode != ErrorCode::NoError && errorCode != ErrorCode::ApiNotFoundError) {
|
||||||
emit errorOccurred(errorCode);
|
emit errorOccurred(errorCode);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -351,9 +525,6 @@ bool ApiConfigsController::deactivateDevice()
|
||||||
|
|
||||||
bool ApiConfigsController::deactivateExternalDevice(const QString &uuid, const QString &serverCountryCode)
|
bool ApiConfigsController::deactivateExternalDevice(const QString &uuid, const QString &serverCountryCode)
|
||||||
{
|
{
|
||||||
GatewayController gatewayController(m_settings->getGatewayEndpoint(), m_settings->isDevGatewayEnv(), apiDefs::requestTimeoutMsecs,
|
|
||||||
m_settings->isStrictKillSwitchEnabled());
|
|
||||||
|
|
||||||
auto serverIndex = m_serversModel->getProcessedServerIndex();
|
auto serverIndex = m_serversModel->getProcessedServerIndex();
|
||||||
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
||||||
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
||||||
|
|
@ -362,19 +533,19 @@ bool ApiConfigsController::deactivateExternalDevice(const QString &uuid, const Q
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString protocol = apiConfigObject.value(configKey::serviceProtocol).toString();
|
GatewayRequestData gatewayRequestData { QSysInfo::productType(),
|
||||||
ApiPayloadData apiPayloadData = generateApiPayloadData(protocol);
|
QString(APP_VERSION),
|
||||||
|
uuid,
|
||||||
|
apiConfigObject.value(configKey::userCountryCode).toString(),
|
||||||
|
serverCountryCode,
|
||||||
|
apiConfigObject.value(configKey::serviceType).toString(),
|
||||||
|
"",
|
||||||
|
serverConfigObject.value(configKey::authData).toObject() };
|
||||||
|
|
||||||
QJsonObject apiPayload = fillApiPayload(protocol, apiPayloadData);
|
QJsonObject apiPayload = gatewayRequestData.toJsonObject();
|
||||||
apiPayload[configKey::userCountryCode] = apiConfigObject.value(configKey::userCountryCode);
|
|
||||||
apiPayload[configKey::serverCountryCode] = serverCountryCode;
|
|
||||||
apiPayload[configKey::serviceType] = apiConfigObject.value(configKey::serviceType);
|
|
||||||
apiPayload[configKey::authData] = serverConfigObject.value(configKey::authData);
|
|
||||||
apiPayload[configKey::uuid] = uuid;
|
|
||||||
apiPayload[apiDefs::key::cliVersion] = QString(APP_VERSION);
|
|
||||||
|
|
||||||
QByteArray responseBody;
|
QByteArray responseBody;
|
||||||
ErrorCode errorCode = gatewayController.post(QString("%1v1/revoke_config"), apiPayload, responseBody);
|
ErrorCode errorCode = executeRequest(QString("%1v1/revoke_config"), apiPayload, responseBody);
|
||||||
if (errorCode != ErrorCode::NoError && errorCode != ErrorCode::ApiNotFoundError) {
|
if (errorCode != ErrorCode::NoError && errorCode != ErrorCode::ApiNotFoundError) {
|
||||||
emit errorOccurred(errorCode);
|
emit errorOccurred(errorCode);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -413,119 +584,29 @@ bool ApiConfigsController::isConfigValid()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiConfigsController::ApiPayloadData ApiConfigsController::generateApiPayloadData(const QString &protocol)
|
void ApiConfigsController::setCurrentProtocol(const QString &protocolName)
|
||||||
{
|
{
|
||||||
ApiConfigsController::ApiPayloadData apiPayload;
|
auto serverIndex = m_serversModel->getProcessedServerIndex();
|
||||||
if (protocol == configKey::cloak) {
|
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
||||||
apiPayload.certRequest = OpenVpnConfigurator::createCertRequest();
|
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
||||||
} else if (protocol == configKey::awg) {
|
|
||||||
auto connData = WireguardConfigurator::genClientKeys();
|
apiConfigObject[configKey::serviceProtocol] = protocolName;
|
||||||
apiPayload.wireGuardClientPubKey = connData.clientPubKey;
|
|
||||||
apiPayload.wireGuardClientPrivKey = connData.clientPrivKey;
|
serverConfigObject.insert(configKey::apiConfig, apiConfigObject);
|
||||||
}
|
|
||||||
return apiPayload;
|
m_serversModel->editServer(serverConfigObject, serverIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject ApiConfigsController::fillApiPayload(const QString &protocol, const ApiPayloadData &apiPayloadData)
|
bool ApiConfigsController::isVlessProtocol()
|
||||||
{
|
{
|
||||||
QJsonObject obj;
|
auto serverIndex = m_serversModel->getProcessedServerIndex();
|
||||||
if (protocol == configKey::cloak) {
|
auto serverConfigObject = m_serversModel->getServerConfig(serverIndex);
|
||||||
obj[configKey::certificate] = apiPayloadData.certRequest.request;
|
auto apiConfigObject = serverConfigObject.value(configKey::apiConfig).toObject();
|
||||||
} else if (protocol == configKey::awg) {
|
|
||||||
obj[configKey::publicKey] = apiPayloadData.wireGuardClientPubKey;
|
if (apiConfigObject[configKey::serviceProtocol].toString() == "vless") {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
obj[configKey::osVersion] = QSysInfo::productType();
|
|
||||||
obj[configKey::appVersion] = QString(APP_VERSION);
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ApiConfigsController::fillServerConfig(const QString &protocol, const ApiPayloadData &apiPayloadData,
|
|
||||||
const QByteArray &apiResponseBody, QJsonObject &serverConfig)
|
|
||||||
{
|
|
||||||
QString data = QJsonDocument::fromJson(apiResponseBody).object().value(config_key::config).toString();
|
|
||||||
|
|
||||||
data.replace("vpn://", "");
|
|
||||||
QByteArray ba = QByteArray::fromBase64(data.toUtf8(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
|
||||||
|
|
||||||
if (ba.isEmpty()) {
|
|
||||||
emit errorOccurred(ErrorCode::ApiConfigEmptyError);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray ba_uncompressed = qUncompress(ba);
|
|
||||||
if (!ba_uncompressed.isEmpty()) {
|
|
||||||
ba = ba_uncompressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString configStr = ba;
|
|
||||||
if (protocol == configKey::cloak) {
|
|
||||||
configStr.replace("<key>", "<key>\n");
|
|
||||||
configStr.replace("$OPENVPN_PRIV_KEY", apiPayloadData.certRequest.privKey);
|
|
||||||
} else if (protocol == configKey::awg) {
|
|
||||||
configStr.replace("$WIREGUARD_CLIENT_PRIVATE_KEY", apiPayloadData.wireGuardClientPrivKey);
|
|
||||||
auto newServerConfig = QJsonDocument::fromJson(configStr.toUtf8()).object();
|
|
||||||
auto containers = newServerConfig.value(config_key::containers).toArray();
|
|
||||||
if (containers.isEmpty()) {
|
|
||||||
return; // todo process error
|
|
||||||
}
|
|
||||||
auto container = containers.at(0).toObject();
|
|
||||||
QString containerName = ContainerProps::containerTypeToString(DockerContainer::Awg);
|
|
||||||
auto containerConfig = container.value(containerName).toObject();
|
|
||||||
auto protocolConfig = QJsonDocument::fromJson(containerConfig.value(config_key::last_config).toString().toUtf8()).object();
|
|
||||||
containerConfig[config_key::junkPacketCount] = protocolConfig.value(config_key::junkPacketCount);
|
|
||||||
containerConfig[config_key::junkPacketMinSize] = protocolConfig.value(config_key::junkPacketMinSize);
|
|
||||||
containerConfig[config_key::junkPacketMaxSize] = protocolConfig.value(config_key::junkPacketMaxSize);
|
|
||||||
containerConfig[config_key::initPacketJunkSize] = protocolConfig.value(config_key::initPacketJunkSize);
|
|
||||||
containerConfig[config_key::responsePacketJunkSize] = protocolConfig.value(config_key::responsePacketJunkSize);
|
|
||||||
containerConfig[config_key::cookieReplyPacketJunkSize] = protocolConfig.value(config_key::cookieReplyPacketJunkSize);
|
|
||||||
containerConfig[config_key::transportPacketJunkSize] = protocolConfig.value(config_key::transportPacketJunkSize);
|
|
||||||
containerConfig[config_key::initPacketMagicHeader] = protocolConfig.value(config_key::initPacketMagicHeader);
|
|
||||||
containerConfig[config_key::responsePacketMagicHeader] = protocolConfig.value(config_key::responsePacketMagicHeader);
|
|
||||||
containerConfig[config_key::underloadPacketMagicHeader] = protocolConfig.value(config_key::underloadPacketMagicHeader);
|
|
||||||
containerConfig[config_key::transportPacketMagicHeader] = protocolConfig.value(config_key::transportPacketMagicHeader);
|
|
||||||
containerConfig[config_key::specialJunk1] = protocolConfig.value(config_key::specialJunk1);
|
|
||||||
containerConfig[config_key::specialJunk2] = protocolConfig.value(config_key::specialJunk2);
|
|
||||||
containerConfig[config_key::specialJunk3] = protocolConfig.value(config_key::specialJunk3);
|
|
||||||
containerConfig[config_key::specialJunk4] = protocolConfig.value(config_key::specialJunk4);
|
|
||||||
containerConfig[config_key::specialJunk5] = protocolConfig.value(config_key::specialJunk5);
|
|
||||||
containerConfig[config_key::controlledJunk1] = protocolConfig.value(config_key::controlledJunk1);
|
|
||||||
containerConfig[config_key::controlledJunk2] = protocolConfig.value(config_key::controlledJunk2);
|
|
||||||
containerConfig[config_key::controlledJunk3] = protocolConfig.value(config_key::controlledJunk3);
|
|
||||||
containerConfig[config_key::specialHandshakeTimeout] = protocolConfig.value(config_key::specialHandshakeTimeout);
|
|
||||||
container[containerName] = containerConfig;
|
|
||||||
containers.replace(0, container);
|
|
||||||
newServerConfig[config_key::containers] = containers;
|
|
||||||
configStr = QString(QJsonDocument(newServerConfig).toJson());
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject newServerConfig = QJsonDocument::fromJson(configStr.toUtf8()).object();
|
|
||||||
serverConfig[config_key::dns1] = newServerConfig.value(config_key::dns1);
|
|
||||||
serverConfig[config_key::dns2] = newServerConfig.value(config_key::dns2);
|
|
||||||
serverConfig[config_key::containers] = newServerConfig.value(config_key::containers);
|
|
||||||
serverConfig[config_key::hostName] = newServerConfig.value(config_key::hostName);
|
|
||||||
|
|
||||||
if (newServerConfig.value(config_key::configVersion).toInt() == apiDefs::ConfigSource::AmneziaGateway) {
|
|
||||||
serverConfig[config_key::configVersion] = newServerConfig.value(config_key::configVersion);
|
|
||||||
serverConfig[config_key::description] = newServerConfig.value(config_key::description);
|
|
||||||
serverConfig[config_key::name] = newServerConfig.value(config_key::name);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto defaultContainer = newServerConfig.value(config_key::defaultContainer).toString();
|
|
||||||
serverConfig[config_key::defaultContainer] = defaultContainer;
|
|
||||||
|
|
||||||
QVariantMap map = serverConfig.value(configKey::apiConfig).toObject().toVariantMap();
|
|
||||||
map.insert(newServerConfig.value(configKey::apiConfig).toObject().toVariantMap());
|
|
||||||
auto apiConfig = QJsonObject::fromVariantMap(map);
|
|
||||||
|
|
||||||
if (newServerConfig.value(config_key::configVersion).toInt() == apiDefs::ConfigSource::AmneziaGateway) {
|
|
||||||
apiConfig.insert(configKey::serviceInfo, QJsonDocument::fromJson(apiResponseBody).object().value(configKey::serviceInfo).toObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
serverConfig[configKey::apiConfig] = apiConfig;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> ApiConfigsController::getQrCodes()
|
QList<QString> ApiConfigsController::getQrCodes()
|
||||||
|
|
@ -542,3 +623,10 @@ QString ApiConfigsController::getVpnKey()
|
||||||
{
|
{
|
||||||
return m_vpnKey;
|
return m_vpnKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorCode ApiConfigsController::executeRequest(const QString &endpoint, const QJsonObject &apiPayload, QByteArray &responseBody)
|
||||||
|
{
|
||||||
|
GatewayController gatewayController(m_settings->getGatewayEndpoint(), m_settings->isDevGatewayEnv(), apiDefs::requestTimeoutMsecs,
|
||||||
|
m_settings->isStrictKillSwitchEnabled());
|
||||||
|
return gatewayController.post(endpoint, apiPayload, responseBody);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ public slots:
|
||||||
|
|
||||||
bool isConfigValid();
|
bool isConfigValid();
|
||||||
|
|
||||||
|
void setCurrentProtocol(const QString &protocolName);
|
||||||
|
bool isVlessProtocol();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void errorOccurred(ErrorCode errorCode);
|
void errorOccurred(ErrorCode errorCode);
|
||||||
|
|
||||||
|
|
@ -46,23 +49,12 @@ signals:
|
||||||
void vpnKeyExportReady();
|
void vpnKeyExportReady();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ApiPayloadData
|
|
||||||
{
|
|
||||||
OpenVpnConfigurator::ConnectionData certRequest;
|
|
||||||
|
|
||||||
QString wireGuardClientPrivKey;
|
|
||||||
QString wireGuardClientPubKey;
|
|
||||||
};
|
|
||||||
|
|
||||||
ApiPayloadData generateApiPayloadData(const QString &protocol);
|
|
||||||
QJsonObject fillApiPayload(const QString &protocol, const ApiPayloadData &apiPayloadData);
|
|
||||||
void fillServerConfig(const QString &protocol, const ApiPayloadData &apiPayloadData, const QByteArray &apiResponseBody,
|
|
||||||
QJsonObject &serverConfig);
|
|
||||||
|
|
||||||
QList<QString> getQrCodes();
|
QList<QString> getQrCodes();
|
||||||
int getQrCodesCount();
|
int getQrCodesCount();
|
||||||
QString getVpnKey();
|
QString getVpnKey();
|
||||||
|
|
||||||
|
ErrorCode executeRequest(const QString &endpoint, const QJsonObject &apiPayload, QByteArray &responseBody);
|
||||||
|
|
||||||
QList<QString> m_qrCodes;
|
QList<QString> m_qrCodes;
|
||||||
QString m_vpnKey;
|
QString m_vpnKey;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,12 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case IsProtocolSelectionSupportedRole: {
|
||||||
|
if (m_accountInfoData.supportedProtocols.size() > 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
@ -95,6 +101,10 @@ void ApiAccountInfoModel::updateModel(const QJsonObject &accountInfoObject, cons
|
||||||
|
|
||||||
accountInfoData.configType = apiUtils::getConfigType(serverConfig);
|
accountInfoData.configType = apiUtils::getConfigType(serverConfig);
|
||||||
|
|
||||||
|
for (const auto &protocol : accountInfoObject.value(apiDefs::key::supportedProtocols).toArray()) {
|
||||||
|
accountInfoData.supportedProtocols.push_back(protocol.toString());
|
||||||
|
}
|
||||||
|
|
||||||
m_accountInfoData = accountInfoData;
|
m_accountInfoData = accountInfoData;
|
||||||
|
|
||||||
m_supportInfo = accountInfoObject.value(apiDefs::key::supportInfo).toObject();
|
m_supportInfo = accountInfoObject.value(apiDefs::key::supportInfo).toObject();
|
||||||
|
|
@ -159,6 +169,7 @@ QHash<int, QByteArray> ApiAccountInfoModel::roleNames() const
|
||||||
roles[ServiceDescriptionRole] = "serviceDescription";
|
roles[ServiceDescriptionRole] = "serviceDescription";
|
||||||
roles[IsComponentVisibleRole] = "isComponentVisible";
|
roles[IsComponentVisibleRole] = "isComponentVisible";
|
||||||
roles[HasExpiredWorkerRole] = "hasExpiredWorker";
|
roles[HasExpiredWorkerRole] = "hasExpiredWorker";
|
||||||
|
roles[IsProtocolSelectionSupportedRole] = "isProtocolSelectionSupported";
|
||||||
|
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ public:
|
||||||
ServiceDescriptionRole,
|
ServiceDescriptionRole,
|
||||||
EndDateRole,
|
EndDateRole,
|
||||||
IsComponentVisibleRole,
|
IsComponentVisibleRole,
|
||||||
HasExpiredWorkerRole
|
HasExpiredWorkerRole,
|
||||||
|
IsProtocolSelectionSupportedRole
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit ApiAccountInfoModel(QObject *parent = nullptr);
|
explicit ApiAccountInfoModel(QObject *parent = nullptr);
|
||||||
|
|
@ -51,6 +52,8 @@ private:
|
||||||
int maxDeviceCount;
|
int maxDeviceCount;
|
||||||
|
|
||||||
apiDefs::ConfigType configType;
|
apiDefs::ConfigType configType;
|
||||||
|
|
||||||
|
QStringList supportedProtocols;
|
||||||
};
|
};
|
||||||
|
|
||||||
AccountInfoData m_accountInfoData;
|
AccountInfoData m_accountInfoData;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
#include <AmneziaVPN-Swift.h>
|
#include <AmneziaVPN-Swift.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "core/api/apiUtils.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
namespace configKey
|
namespace configKey
|
||||||
|
|
@ -66,6 +68,7 @@ bool ServersModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
} else {
|
} else {
|
||||||
server.insert(config_key::description, value.toString());
|
server.insert(config_key::description, value.toString());
|
||||||
}
|
}
|
||||||
|
server.insert(config_key::nameOverriddenByUser, true);
|
||||||
m_settings->editServer(index.row(), server);
|
m_settings->editServer(index.row(), server);
|
||||||
m_servers.replace(index.row(), server);
|
m_servers.replace(index.row(), server);
|
||||||
if (index.row() == m_defaultServerIndex) {
|
if (index.row() == m_defaultServerIndex) {
|
||||||
|
|
@ -426,7 +429,7 @@ void ServersModel::updateDefaultServerContainersModel()
|
||||||
emit defaultServerContainersUpdated(containers);
|
emit defaultServerContainersUpdated(containers);
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject ServersModel::getServerConfig(const int serverIndex)
|
QJsonObject ServersModel::getServerConfig(const int serverIndex) const
|
||||||
{
|
{
|
||||||
return m_servers.at(serverIndex).toObject();
|
return m_servers.at(serverIndex).toObject();
|
||||||
}
|
}
|
||||||
|
|
@ -813,3 +816,8 @@ const QString ServersModel::getDefaultServerImagePathCollapsed()
|
||||||
}
|
}
|
||||||
return QString("qrc:/countriesFlags/images/flagKit/%1.svg").arg(countryCode.toUpper());
|
return QString("qrc:/countriesFlags/images/flagKit/%1.svg").arg(countryCode.toUpper());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ServersModel::processedServerIsPremium() const
|
||||||
|
{
|
||||||
|
return apiUtils::isPremiumServer(getServerConfig(m_processedServerIndex));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,9 @@ public:
|
||||||
Q_PROPERTY(bool isDefaultServerFromApi READ isDefaultServerFromApi NOTIFY defaultServerIndexChanged)
|
Q_PROPERTY(bool isDefaultServerFromApi READ isDefaultServerFromApi NOTIFY defaultServerIndexChanged)
|
||||||
|
|
||||||
Q_PROPERTY(int processedIndex READ getProcessedServerIndex WRITE setProcessedServerIndex NOTIFY processedServerIndexChanged)
|
Q_PROPERTY(int processedIndex READ getProcessedServerIndex WRITE setProcessedServerIndex NOTIFY processedServerIndexChanged)
|
||||||
|
Q_PROPERTY(bool processedServerIsPremium READ processedServerIsPremium NOTIFY processedServerChanged)
|
||||||
|
|
||||||
|
bool processedServerIsPremium() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setDefaultServerIndex(const int index);
|
void setDefaultServerIndex(const int index);
|
||||||
|
|
@ -92,7 +95,7 @@ public slots:
|
||||||
void removeServer();
|
void removeServer();
|
||||||
void removeServer(const int serverIndex);
|
void removeServer(const int serverIndex);
|
||||||
|
|
||||||
QJsonObject getServerConfig(const int serverIndex);
|
QJsonObject getServerConfig(const int serverIndex) const;
|
||||||
|
|
||||||
void reloadDefaultServerContainerConfig();
|
void reloadDefaultServerContainerConfig();
|
||||||
void updateContainerConfig(const int containerIndex, const QJsonObject config);
|
void updateContainerConfig(const int containerIndex, const QJsonObject config);
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,13 @@ PageType {
|
||||||
model: CloakConfigModel
|
model: CloakConfigModel
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
implicitWidth: listview.width
|
id: delegateItem
|
||||||
implicitHeight: col.implicitHeight
|
|
||||||
|
|
||||||
property alias trafficFromField: trafficFromField
|
property alias trafficFromField: trafficFromField
|
||||||
|
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
|
||||||
|
|
||||||
|
implicitWidth: listview.width
|
||||||
|
implicitHeight: col.implicitHeight
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: col
|
id: col
|
||||||
|
|
@ -78,7 +81,6 @@ PageType {
|
||||||
|
|
||||||
BaseHeaderType {
|
BaseHeaderType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
headerText: qsTr("Cloak settings")
|
headerText: qsTr("Cloak settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,6 +90,8 @@ PageType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 32
|
Layout.topMargin: 32
|
||||||
|
|
||||||
|
enabled: delegateItem.isEnabled
|
||||||
|
|
||||||
headerText: qsTr("Disguised as traffic from")
|
headerText: qsTr("Disguised as traffic from")
|
||||||
textField.text: site
|
textField.text: site
|
||||||
|
|
||||||
|
|
@ -104,6 +108,8 @@ PageType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkEmptyText: true
|
||||||
}
|
}
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
TextFieldWithHeaderType {
|
||||||
|
|
@ -112,6 +118,8 @@ PageType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
|
enabled: delegateItem.isEnabled
|
||||||
|
|
||||||
headerText: qsTr("Port")
|
headerText: qsTr("Port")
|
||||||
textField.text: port
|
textField.text: port
|
||||||
textField.maximumLength: 5
|
textField.maximumLength: 5
|
||||||
|
|
@ -122,6 +130,8 @@ PageType {
|
||||||
port = textField.text
|
port = textField.text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkEmptyText: true
|
||||||
}
|
}
|
||||||
|
|
||||||
DropDownType {
|
DropDownType {
|
||||||
|
|
@ -129,6 +139,8 @@ PageType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
|
enabled: delegateItem.isEnabled
|
||||||
|
|
||||||
descriptionText: qsTr("Cipher")
|
descriptionText: qsTr("Cipher")
|
||||||
headerText: qsTr("Cipher")
|
headerText: qsTr("Cipher")
|
||||||
|
|
||||||
|
|
@ -166,25 +178,46 @@ PageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicButtonType {
|
BasicButtonType {
|
||||||
id: saveRestartButton
|
id: saveButton
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
Layout.bottomMargin: 24
|
Layout.bottomMargin: 24
|
||||||
|
|
||||||
|
enabled: trafficFromField.errorText === "" &&
|
||||||
|
portTextField.errorText === ""
|
||||||
|
|
||||||
text: qsTr("Save")
|
text: qsTr("Save")
|
||||||
|
|
||||||
clickedFunc: function() {
|
clickedFunc: function() {
|
||||||
forceActiveFocus()
|
forceActiveFocus()
|
||||||
|
|
||||||
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
var headerText = qsTr("Save settings?")
|
||||||
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.")
|
||||||
return
|
var yesButtonText = qsTr("Continue")
|
||||||
|
var noButtonText = qsTr("Cancel")
|
||||||
|
|
||||||
|
var yesButtonFunction = function() {
|
||||||
|
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
||||||
|
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||||
|
InstallController.updateContainer(CloakConfigModel.getConfig())
|
||||||
}
|
}
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
var noButtonFunction = function() {
|
||||||
InstallController.updateContainer(CloakConfigModel.getConfig())
|
if (!GC.isMobile()) {
|
||||||
|
saveButton.forceActiveFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Keys.onEnterPressed: saveButton.clicked()
|
||||||
|
Keys.onReturnPressed: saveButton.clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,13 @@ PageType {
|
||||||
model: OpenVpnConfigModel
|
model: OpenVpnConfigModel
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
implicitWidth: listview.width
|
id: delegateItem
|
||||||
implicitHeight: col.implicitHeight
|
|
||||||
|
|
||||||
property alias vpnAddressSubnetTextField: vpnAddressSubnetTextField
|
property alias vpnAddressSubnetTextField: vpnAddressSubnetTextField
|
||||||
|
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
|
||||||
|
|
||||||
|
implicitWidth: listview.width
|
||||||
|
implicitHeight: col.implicitHeight
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: col
|
id: col
|
||||||
|
|
@ -77,7 +80,6 @@ PageType {
|
||||||
|
|
||||||
BaseHeaderType {
|
BaseHeaderType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
headerText: qsTr("OpenVPN settings")
|
headerText: qsTr("OpenVPN settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,6 +89,8 @@ PageType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 32
|
Layout.topMargin: 32
|
||||||
|
|
||||||
|
enabled: delegateItem.isEnabled
|
||||||
|
|
||||||
headerText: qsTr("VPN address subnet")
|
headerText: qsTr("VPN address subnet")
|
||||||
textField.text: subnetAddress
|
textField.text: subnetAddress
|
||||||
|
|
||||||
|
|
@ -97,6 +101,8 @@ PageType {
|
||||||
subnetAddress = textField.text
|
subnetAddress = textField.text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkEmptyText: true
|
||||||
}
|
}
|
||||||
|
|
||||||
ParagraphTextType {
|
ParagraphTextType {
|
||||||
|
|
@ -134,7 +140,7 @@ PageType {
|
||||||
Layout.topMargin: 40
|
Layout.topMargin: 40
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
enabled: isPortEditable
|
enabled: delegateItem.isEnabled
|
||||||
|
|
||||||
headerText: qsTr("Port")
|
headerText: qsTr("Port")
|
||||||
textField.text: port
|
textField.text: port
|
||||||
|
|
@ -146,6 +152,8 @@ PageType {
|
||||||
port = textField.text
|
port = textField.text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkEmptyText: true
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitcherType {
|
SwitcherType {
|
||||||
|
|
@ -388,26 +396,45 @@ PageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicButtonType {
|
BasicButtonType {
|
||||||
id: saveRestartButton
|
id: saveButton
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
Layout.bottomMargin: 24
|
Layout.bottomMargin: 24
|
||||||
|
|
||||||
|
enabled: vpnAddressSubnetTextField.errorText === "" &&
|
||||||
|
portTextField.errorText === ""
|
||||||
|
|
||||||
text: qsTr("Save")
|
text: qsTr("Save")
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
clickedFunc: function() {
|
onClicked: function() {
|
||||||
forceActiveFocus()
|
forceActiveFocus()
|
||||||
|
|
||||||
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
var headerText = qsTr("Save settings?")
|
||||||
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.")
|
||||||
return
|
var yesButtonText = qsTr("Continue")
|
||||||
}
|
var noButtonText = qsTr("Cancel")
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
var yesButtonFunction = function() {
|
||||||
InstallController.updateContainer(OpenVpnConfigModel.getConfig())
|
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
||||||
|
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||||
|
InstallController.updateContainer(OpenVpnConfigModel.getConfig())
|
||||||
|
}
|
||||||
|
var noButtonFunction = function() {
|
||||||
|
if (!GC.isMobile()) {
|
||||||
|
saveButton.forceActiveFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Keys.onEnterPressed: saveButton.clicked()
|
||||||
|
Keys.onReturnPressed: saveButton.clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,15 +57,13 @@ PageType {
|
||||||
model: ShadowSocksConfigModel
|
model: ShadowSocksConfigModel
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
|
id: delegateItem
|
||||||
|
|
||||||
|
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
|
||||||
|
|
||||||
implicitWidth: listview.width
|
implicitWidth: listview.width
|
||||||
implicitHeight: col.implicitHeight
|
implicitHeight: col.implicitHeight
|
||||||
|
|
||||||
property var focusItemId: portTextField.enabled ?
|
|
||||||
portTextField :
|
|
||||||
cipherDropDown.enabled ?
|
|
||||||
cipherDropDown :
|
|
||||||
saveRestartButton
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: col
|
id: col
|
||||||
|
|
||||||
|
|
@ -80,7 +78,6 @@ PageType {
|
||||||
|
|
||||||
BaseHeaderType {
|
BaseHeaderType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
headerText: qsTr("Shadowsocks settings")
|
headerText: qsTr("Shadowsocks settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +87,7 @@ PageType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 40
|
Layout.topMargin: 40
|
||||||
|
|
||||||
enabled: isPortEditable
|
enabled: delegateItem.isEnabled
|
||||||
|
|
||||||
headerText: qsTr("Port")
|
headerText: qsTr("Port")
|
||||||
textField.text: port
|
textField.text: port
|
||||||
|
|
@ -102,6 +99,8 @@ PageType {
|
||||||
port = textField.text
|
port = textField.text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkEmptyText: true
|
||||||
}
|
}
|
||||||
|
|
||||||
DropDownType {
|
DropDownType {
|
||||||
|
|
@ -109,7 +108,7 @@ PageType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
|
|
||||||
enabled: isCipherEditable
|
enabled: delegateItem.isEnabled
|
||||||
|
|
||||||
descriptionText: qsTr("Cipher")
|
descriptionText: qsTr("Cipher")
|
||||||
headerText: qsTr("Cipher")
|
headerText: qsTr("Cipher")
|
||||||
|
|
@ -149,27 +148,43 @@ PageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicButtonType {
|
BasicButtonType {
|
||||||
id: saveRestartButton
|
id: saveButton
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
Layout.bottomMargin: 24
|
Layout.bottomMargin: 24
|
||||||
|
|
||||||
enabled: isPortEditable | isCipherEditable
|
enabled: portTextField.errorText === ""
|
||||||
|
|
||||||
text: qsTr("Save")
|
text: qsTr("Save")
|
||||||
|
|
||||||
clickedFunc: function() {
|
clickedFunc: function() {
|
||||||
forceActiveFocus()
|
forceActiveFocus()
|
||||||
|
|
||||||
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
var headerText = qsTr("Save settings?")
|
||||||
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.")
|
||||||
return
|
var yesButtonText = qsTr("Continue")
|
||||||
}
|
var noButtonText = qsTr("Cancel")
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
var yesButtonFunction = function() {
|
||||||
InstallController.updateContainer(ShadowSocksConfigModel.getConfig())
|
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
||||||
|
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||||
|
InstallController.updateContainer(ShadowSocksConfigModel.getConfig())
|
||||||
|
}
|
||||||
|
var noButtonFunction = function() {
|
||||||
|
if (!GC.isMobile()) {
|
||||||
|
saveButton.forceActiveFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Keys.onEnterPressed: saveButton.clicked()
|
||||||
|
Keys.onReturnPressed: saveButton.clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ PageType {
|
||||||
}
|
}
|
||||||
var noButtonFunction = function() {
|
var noButtonFunction = function() {
|
||||||
if (!GC.isMobile()) {
|
if (!GC.isMobile()) {
|
||||||
saveRestartButton.forceActiveFocus()
|
saveButton.forceActiveFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,10 @@ PageType {
|
||||||
model: XrayConfigModel
|
model: XrayConfigModel
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
|
id: delegateItem
|
||||||
|
|
||||||
property alias focusItemId: textFieldWithHeaderType.textField
|
property alias focusItemId: textFieldWithHeaderType.textField
|
||||||
|
property bool isEnabled: ServersModel.isProcessedServerHasWriteAccess()
|
||||||
|
|
||||||
implicitWidth: listview.width
|
implicitWidth: listview.width
|
||||||
implicitHeight: col.implicitHeight
|
implicitHeight: col.implicitHeight
|
||||||
|
|
@ -85,6 +88,8 @@ PageType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 32
|
Layout.topMargin: 32
|
||||||
|
|
||||||
|
enabled: delegateItem.isEnabled
|
||||||
|
|
||||||
headerText: qsTr("Disguised as traffic from")
|
headerText: qsTr("Disguised as traffic from")
|
||||||
textField.text: site
|
textField.text: site
|
||||||
|
|
||||||
|
|
@ -101,6 +106,8 @@ PageType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkEmptyText: true
|
||||||
}
|
}
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
TextFieldWithHeaderType {
|
||||||
|
|
@ -130,23 +137,38 @@ PageType {
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
Layout.bottomMargin: 24
|
Layout.bottomMargin: 24
|
||||||
|
|
||||||
|
enabled: portTextField.errorText === ""
|
||||||
|
|
||||||
text: qsTr("Save")
|
text: qsTr("Save")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: function() {
|
||||||
forceActiveFocus()
|
forceActiveFocus()
|
||||||
|
|
||||||
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
var headerText = qsTr("Save settings?")
|
||||||
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
var descriptionText = qsTr("All users with whom you shared a connection with will no longer be able to connect to it.")
|
||||||
return
|
var yesButtonText = qsTr("Continue")
|
||||||
}
|
var noButtonText = qsTr("Cancel")
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
var yesButtonFunction = function() {
|
||||||
InstallController.updateContainer(XrayConfigModel.getConfig())
|
if (ConnectionController.isConnected && ServersModel.getDefaultServerData("defaultContainer") === ContainersModel.getProcessedContainerIndex()) {
|
||||||
focusItem.forceActiveFocus()
|
PageController.showNotificationMessage(qsTr("Unable change settings while there is an active connection"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||||
|
InstallController.updateContainer(XrayConfigModel.getConfig())
|
||||||
|
//focusItem.forceActiveFocus()
|
||||||
|
}
|
||||||
|
var noButtonFunction = function() {
|
||||||
|
if (!GC.isMobile()) {
|
||||||
|
saveButton.forceActiveFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onEnterPressed: basicButton.clicked()
|
Keys.onEnterPressed: saveButton.clicked()
|
||||||
Keys.onReturnPressed: basicButton.clicked()
|
Keys.onReturnPressed: saveButton.clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,32 @@ PageType {
|
||||||
|
|
||||||
readonly property bool isVisibleForAmneziaFree: ApiAccountInfoModel.data("isComponentVisible")
|
readonly property bool isVisibleForAmneziaFree: ApiAccountInfoModel.data("isComponentVisible")
|
||||||
|
|
||||||
|
SwitcherType {
|
||||||
|
id: switcher
|
||||||
|
|
||||||
|
readonly property bool isVlessProtocol: ApiConfigsController.isVlessProtocol()
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 24
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
|
||||||
|
visible: ApiAccountInfoModel.data("isProtocolSelectionSupported")
|
||||||
|
|
||||||
|
text: qsTr("Use VLESS protocol")
|
||||||
|
checked: switcher.isVlessProtocol
|
||||||
|
onToggled: function() {
|
||||||
|
if (ServersModel.isDefaultServerCurrentlyProcessed() && ConnectionController.isConnected) {
|
||||||
|
PageController.showNotificationMessage(qsTr("Cannot change protocol during active connection"))
|
||||||
|
} else {
|
||||||
|
PageController.showBusyIndicator(true)
|
||||||
|
ApiConfigsController.setCurrentProtocol(switcher.isVlessProtocol ? "awg" : "vless")
|
||||||
|
ApiConfigsController.updateServiceFromGateway(ServersModel.processedIndex, "", "", true)
|
||||||
|
PageController.showBusyIndicator(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WarningType {
|
WarningType {
|
||||||
id: warning
|
id: warning
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,7 @@ PageType {
|
||||||
Layout.leftMargin: 16
|
Layout.leftMargin: 16
|
||||||
Layout.rightMargin: 16
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
visible: false
|
enabled: SettingsController.isKillSwitchEnabled && !ConnectionController.isConnected
|
||||||
enabled: false //SettingsController.isKillSwitchEnabled && !ConnectionController.isConnected
|
|
||||||
checked: SettingsController.strictKillSwitchEnabled
|
checked: SettingsController.strictKillSwitchEnabled
|
||||||
|
|
||||||
text: qsTr("Strict KillSwitch")
|
text: qsTr("Strict KillSwitch")
|
||||||
|
|
@ -104,9 +103,7 @@ PageType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DividerType {
|
DividerType {}
|
||||||
visible: false
|
|
||||||
}
|
|
||||||
|
|
||||||
LabelWithButtonType {
|
LabelWithButtonType {
|
||||||
Layout.topMargin: 32
|
Layout.topMargin: 32
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ PageType {
|
||||||
|
|
||||||
LabelWithButtonType {
|
LabelWithButtonType {
|
||||||
id: labelWithButton6
|
id: labelWithButton6
|
||||||
visible: ServersModel.getProcessedServerData("isServerFromTelegramApi")
|
visible: ServersModel.getProcessedServerData("isServerFromTelegramApi") && ServersModel.processedServerIsPremium
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
text: qsTr("Switch to the new Amnezia Premium subscription")
|
text: qsTr("Switch to the new Amnezia Premium subscription")
|
||||||
|
|
@ -273,7 +273,7 @@ PageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
DividerType {
|
DividerType {
|
||||||
visible: ServersModel.getProcessedServerData("isServerFromTelegramApi")
|
visible: ServersModel.getProcessedServerData("isServerFromTelegramApi") && ServersModel.processedServerIsPremium
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -429,6 +429,11 @@ PageType {
|
||||||
|
|
||||||
fillConnectionTypeModel()
|
fillConnectionTypeModel()
|
||||||
|
|
||||||
|
if (exportTypeSelector.currentIndex >= root.connectionTypesModel.length) {
|
||||||
|
exportTypeSelector.currentIndex = 0
|
||||||
|
exportTypeSelector.text = root.connectionTypesModel[0].name
|
||||||
|
}
|
||||||
|
|
||||||
if (accessTypeSelector.currentIndex === 1) {
|
if (accessTypeSelector.currentIndex === 1) {
|
||||||
PageController.showBusyIndicator(true)
|
PageController.showBusyIndicator(true)
|
||||||
ExportController.updateClientManagementModel(ContainersModel.getProcessedContainerIndex(),
|
ExportController.updateClientManagementModel(ContainersModel.getProcessedContainerIndex(),
|
||||||
|
|
|
||||||
BIN
deploy/DeveloperIDG2CA.cer
Normal file
BIN
deploy/DeveloperIDG2CA.cer
Normal file
Binary file not shown.
258
deploy/build_macos.sh
Executable file → Normal file
258
deploy/build_macos.sh
Executable file → Normal file
|
|
@ -1,4 +1,15 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Usage:
|
||||||
|
# Export the required signing credentials before running this script, e.g.:
|
||||||
|
# export MAC_APP_CERT_PW='pw-for-DeveloperID-Application'
|
||||||
|
# export MAC_INSTALL_CERT_PW='pw-for-DeveloperID-Installer'
|
||||||
|
# export MAC_SIGNER_ID='Developer ID Application: Some Company Name (XXXXXXXXXX)'
|
||||||
|
# export MAC_INSTALLER_SIGNER_ID='Developer ID Installer: Some Company Name (XXXXXXXXXX)'
|
||||||
|
# export APPLE_DEV_EMAIL='your@email.com'
|
||||||
|
# export APPLE_DEV_PASSWORD='<your-password>'
|
||||||
|
# bash deploy/build_macos.sh [-n]
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
echo "Build script started ..."
|
echo "Build script started ..."
|
||||||
|
|
||||||
set -o errexit -o nounset
|
set -o errexit -o nounset
|
||||||
|
|
@ -14,10 +25,10 @@ done
|
||||||
PROJECT_DIR=$(pwd)
|
PROJECT_DIR=$(pwd)
|
||||||
DEPLOY_DIR=$PROJECT_DIR/deploy
|
DEPLOY_DIR=$PROJECT_DIR/deploy
|
||||||
|
|
||||||
mkdir -p $DEPLOY_DIR/build
|
mkdir -p "$DEPLOY_DIR/build"
|
||||||
BUILD_DIR=$DEPLOY_DIR/build
|
BUILD_DIR="$DEPLOY_DIR/build"
|
||||||
|
|
||||||
echo "Project dir: ${PROJECT_DIR}"
|
echo "Project dir: ${PROJECT_DIR}"
|
||||||
echo "Build dir: ${BUILD_DIR}"
|
echo "Build dir: ${BUILD_DIR}"
|
||||||
|
|
||||||
APP_NAME=AmneziaVPN
|
APP_NAME=AmneziaVPN
|
||||||
|
|
@ -28,39 +39,45 @@ PLIST_NAME=$APP_NAME.plist
|
||||||
OUT_APP_DIR=$BUILD_DIR/client
|
OUT_APP_DIR=$BUILD_DIR/client
|
||||||
BUNDLE_DIR=$OUT_APP_DIR/$APP_FILENAME
|
BUNDLE_DIR=$OUT_APP_DIR/$APP_FILENAME
|
||||||
|
|
||||||
|
# Prebuilt deployment assets are available via the symlink under deploy/data
|
||||||
PREBUILT_DEPLOY_DATA_DIR=$PROJECT_DIR/deploy/data/deploy-prebuilt/macos
|
PREBUILT_DEPLOY_DATA_DIR=$PROJECT_DIR/deploy/data/deploy-prebuilt/macos
|
||||||
DEPLOY_DATA_DIR=$PROJECT_DIR/deploy/data/macos
|
DEPLOY_DATA_DIR=$PROJECT_DIR/deploy/data/macos
|
||||||
|
|
||||||
INSTALLER_DATA_DIR=$BUILD_DIR/installer/packages/$APP_DOMAIN/data
|
|
||||||
INSTALLER_BUNDLE_DIR=$BUILD_DIR/installer/$APP_FILENAME
|
|
||||||
DMG_FILENAME=$PROJECT_DIR/${APP_NAME}.dmg
|
|
||||||
|
|
||||||
# Search Qt
|
# Search Qt
|
||||||
if [ -z "${QT_VERSION+x}" ]; then
|
if [ -z "${QT_VERSION+x}" ]; then
|
||||||
QT_VERSION=6.4.3;
|
QT_VERSION=6.8.3;
|
||||||
QIF_VERSION=4.6
|
|
||||||
QT_BIN_DIR=$HOME/Qt/$QT_VERSION/macos/bin
|
QT_BIN_DIR=$HOME/Qt/$QT_VERSION/macos/bin
|
||||||
QIF_BIN_DIR=$QT_BIN_DIR/../../../Tools/QtInstallerFramework/$QIF_VERSION/bin
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Using Qt in $QT_BIN_DIR"
|
echo "Using Qt in $QT_BIN_DIR"
|
||||||
echo "Using QIF in $QIF_BIN_DIR"
|
|
||||||
|
|
||||||
|
|
||||||
# Checking env
|
# Checking env
|
||||||
$QT_BIN_DIR/qt-cmake --version
|
"$QT_BIN_DIR/qt-cmake" --version
|
||||||
cmake --version
|
cmake --version
|
||||||
clang -v
|
clang -v
|
||||||
|
|
||||||
# Build App
|
# Build App
|
||||||
echo "Building App..."
|
echo "Building App..."
|
||||||
cd $BUILD_DIR
|
cd "$BUILD_DIR"
|
||||||
|
|
||||||
$QT_BIN_DIR/qt-cmake -S $PROJECT_DIR -B $BUILD_DIR
|
"$QT_BIN_DIR/qt-cmake" -S "$PROJECT_DIR" -B "$BUILD_DIR"
|
||||||
cmake --build . --config release --target all
|
cmake --build . --config release --target all
|
||||||
|
|
||||||
# Build and run tests here
|
# Build and run tests here
|
||||||
|
|
||||||
|
# Create a temporary keychain and import certificates
|
||||||
|
KEYCHAIN_PATH="$PROJECT_DIR/mac_sign.keychain"
|
||||||
|
trap 'echo "Cleaning up mac_sign.keychain..."; security delete-keychain "$KEYCHAIN_PATH" 2>/dev/null || true; rm -f "$KEYCHAIN_PATH" 2>/dev/null || true' EXIT
|
||||||
|
KEYCHAIN=$(security default-keychain -d user | tr -d '"[:space:]"')
|
||||||
|
security list-keychains -d user -s "$KEYCHAIN_PATH" "$KEYCHAIN" "$(security list-keychains -d user | tr '\n' ' ')"
|
||||||
|
security create-keychain -p "" "$KEYCHAIN_PATH"
|
||||||
|
security import "$DEPLOY_DIR/DeveloperIdApplicationCertificate.p12" -k "$KEYCHAIN_PATH" -P "$MAC_APP_CERT_PW" -T /usr/bin/codesign
|
||||||
|
security import "$DEPLOY_DIR/DeveloperIdInstallerCertificate.p12" -k "$KEYCHAIN_PATH" -P "$MAC_INSTALL_CERT_PW" -T /usr/bin/codesign
|
||||||
|
security import "$DEPLOY_DIR/DeveloperIDG2CA.cer" -k "$KEYCHAIN_PATH" -T /usr/bin/codesign
|
||||||
|
security list-keychains -d user -s "$KEYCHAIN_PATH"
|
||||||
|
|
||||||
echo "____________________________________"
|
echo "____________________________________"
|
||||||
echo "............Deploy.................."
|
echo "............Deploy.................."
|
||||||
echo "____________________________________"
|
echo "____________________________________"
|
||||||
|
|
@ -69,102 +86,159 @@ echo "____________________________________"
|
||||||
echo "Packaging ..."
|
echo "Packaging ..."
|
||||||
|
|
||||||
|
|
||||||
cp -Rv $PREBUILT_DEPLOY_DATA_DIR/* $BUNDLE_DIR/Contents/macOS
|
cp -Rv "$PREBUILT_DEPLOY_DATA_DIR"/* "$BUNDLE_DIR/Contents/macOS"
|
||||||
$QT_BIN_DIR/macdeployqt $OUT_APP_DIR/$APP_FILENAME -always-overwrite -qmldir=$PROJECT_DIR
|
"$QT_BIN_DIR/macdeployqt" "$OUT_APP_DIR/$APP_FILENAME" -always-overwrite -qmldir="$PROJECT_DIR"
|
||||||
cp -av $BUILD_DIR/service/server/$APP_NAME-service $BUNDLE_DIR/Contents/macOS
|
cp -av "$BUILD_DIR/service/server/$APP_NAME-service" "$BUNDLE_DIR/Contents/macOS"
|
||||||
cp -Rv $PROJECT_DIR/deploy/data/macos/* $BUNDLE_DIR/Contents/macOS
|
rsync -av --exclude="$PLIST_NAME" --exclude=post_install.sh --exclude=post_uninstall.sh "$DEPLOY_DATA_DIR/" "$BUNDLE_DIR/Contents/macOS/"
|
||||||
rm -f $BUNDLE_DIR/Contents/macOS/post_install.sh $BUNDLE_DIR/Contents/macOS/post_uninstall.sh
|
|
||||||
|
|
||||||
if [ "${MAC_CERT_PW+x}" ]; then
|
if [ "${MAC_APP_CERT_PW+x}" ]; then
|
||||||
|
|
||||||
CERTIFICATE_P12=$DEPLOY_DIR/PrivacyTechAppleCertDeveloperId.p12
|
# Path to the p12 that contains the Developer ID *Application* certificate
|
||||||
WWDRCA=$DEPLOY_DIR/WWDRCA.cer
|
CERTIFICATE_P12=$DEPLOY_DIR/DeveloperIdApplicationCertificate.p12
|
||||||
KEYCHAIN=amnezia.build.macos.keychain
|
|
||||||
TEMP_PASS=tmp_pass
|
|
||||||
|
|
||||||
security create-keychain -p $TEMP_PASS $KEYCHAIN || true
|
# Ensure launchd plist is bundled, but place it inside Resources so that
|
||||||
security default-keychain -s $KEYCHAIN
|
# the bundle keeps a valid structure (nothing but `Contents` at the root).
|
||||||
security unlock-keychain -p $TEMP_PASS $KEYCHAIN
|
mkdir -p "$BUNDLE_DIR/Contents/Resources"
|
||||||
|
cp "$DEPLOY_DATA_DIR/$PLIST_NAME" "$BUNDLE_DIR/Contents/Resources/$PLIST_NAME"
|
||||||
|
|
||||||
security default-keychain
|
# Show available signing identities (useful for debugging)
|
||||||
security list-keychains
|
security find-identity -p codesigning || true
|
||||||
|
|
||||||
security import $WWDRCA -k $KEYCHAIN -T /usr/bin/codesign || true
|
|
||||||
security import $CERTIFICATE_P12 -k $KEYCHAIN -P $MAC_CERT_PW -T /usr/bin/codesign || true
|
|
||||||
|
|
||||||
security set-key-partition-list -S apple-tool:,apple: -k $TEMP_PASS $KEYCHAIN
|
|
||||||
security find-identity -p codesigning
|
|
||||||
|
|
||||||
echo "Signing App bundle..."
|
echo "Signing App bundle..."
|
||||||
/usr/bin/codesign --deep --force --verbose --timestamp -o runtime --sign "$MAC_SIGNER_ID" $BUNDLE_DIR
|
/usr/bin/codesign --deep --force --verbose --timestamp -o runtime --keychain "$KEYCHAIN_PATH" --sign "$MAC_SIGNER_ID" "$BUNDLE_DIR"
|
||||||
/usr/bin/codesign --verify -vvvv $BUNDLE_DIR || true
|
/usr/bin/codesign --verify -vvvv "$BUNDLE_DIR" || true
|
||||||
spctl -a -vvvv $BUNDLE_DIR || true
|
spctl -a -vvvv "$BUNDLE_DIR" || true
|
||||||
|
|
||||||
if [ "${NOTARIZE_APP+x}" ]; then
|
|
||||||
echo "Notarizing App bundle..."
|
|
||||||
/usr/bin/ditto -c -k --keepParent $BUNDLE_DIR $PROJECT_DIR/Bundle_to_notarize.zip
|
|
||||||
xcrun notarytool submit $PROJECT_DIR/Bundle_to_notarize.zip --apple-id $APPLE_DEV_EMAIL --team-id $MAC_TEAM_ID --password $APPLE_DEV_PASSWORD
|
|
||||||
rm $PROJECT_DIR/Bundle_to_notarize.zip
|
|
||||||
sleep 300
|
|
||||||
xcrun stapler staple $BUNDLE_DIR
|
|
||||||
xcrun stapler validate $BUNDLE_DIR
|
|
||||||
spctl -a -vvvv $BUNDLE_DIR || true
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Packaging installer..."
|
echo "Packaging installer..."
|
||||||
mkdir -p $INSTALLER_DATA_DIR
|
PKG_DIR=$BUILD_DIR/pkg
|
||||||
cp -av $PROJECT_DIR/deploy/installer $BUILD_DIR
|
# Remove any stale packaging data from previous runs
|
||||||
cp -av $DEPLOY_DATA_DIR/post_install.sh $INSTALLER_DATA_DIR/post_install.sh
|
rm -rf "$PKG_DIR"
|
||||||
cp -av $DEPLOY_DATA_DIR/post_uninstall.sh $INSTALLER_DATA_DIR/post_uninstall.sh
|
PKG_ROOT=$PKG_DIR/root
|
||||||
cp -av $DEPLOY_DATA_DIR/$PLIST_NAME $INSTALLER_DATA_DIR/$PLIST_NAME
|
SCRIPTS_DIR=$PKG_DIR/scripts
|
||||||
|
RESOURCES_DIR=$PKG_DIR/resources
|
||||||
|
INSTALL_PKG=$PKG_DIR/${APP_NAME}_install.pkg
|
||||||
|
UNINSTALL_PKG=$PKG_DIR/${APP_NAME}_uninstall.pkg
|
||||||
|
FINAL_PKG=$PKG_DIR/${APP_NAME}.pkg
|
||||||
|
UNINSTALL_SCRIPTS_DIR=$PKG_DIR/uninstall_scripts
|
||||||
|
|
||||||
chmod a+x $INSTALLER_DATA_DIR/post_install.sh $INSTALLER_DATA_DIR/post_uninstall.sh
|
mkdir -p "$PKG_ROOT/Applications" "$SCRIPTS_DIR" "$RESOURCES_DIR" "$UNINSTALL_SCRIPTS_DIR"
|
||||||
|
|
||||||
cd $BUNDLE_DIR
|
cp -R "$BUNDLE_DIR" "$PKG_ROOT/Applications"
|
||||||
tar czf $INSTALLER_DATA_DIR/$APP_NAME.tar.gz ./
|
# launchd plist is already inside the bundle; no need to add it again after signing
|
||||||
|
/usr/bin/codesign --deep --force --verbose --timestamp -o runtime --keychain "$KEYCHAIN_PATH" --sign "$MAC_SIGNER_ID" "$PKG_ROOT/Applications/$APP_FILENAME"
|
||||||
|
/usr/bin/codesign --verify --deep --strict --verbose=4 "$PKG_ROOT/Applications/$APP_FILENAME" || true
|
||||||
|
cp "$DEPLOY_DATA_DIR/post_install.sh" "$SCRIPTS_DIR/post_install.sh"
|
||||||
|
cp "$DEPLOY_DATA_DIR/post_uninstall.sh" "$UNINSTALL_SCRIPTS_DIR/postinstall"
|
||||||
|
mkdir -p "$RESOURCES_DIR/scripts"
|
||||||
|
cp "$DEPLOY_DATA_DIR/check_install.sh" "$RESOURCES_DIR/scripts/check_install.sh"
|
||||||
|
cp "$DEPLOY_DATA_DIR/check_uninstall.sh" "$RESOURCES_DIR/scripts/check_uninstall.sh"
|
||||||
|
|
||||||
echo "Building installer..."
|
cat > "$SCRIPTS_DIR/postinstall" <<'EOS'
|
||||||
$QIF_BIN_DIR/binarycreator --offline-only -v -c $BUILD_DIR/installer/config/macos.xml -p $BUILD_DIR/installer/packages -f $INSTALLER_BUNDLE_DIR
|
#!/bin/bash
|
||||||
|
SCRIPT_DIR="$(dirname "$0")"
|
||||||
|
bash "$SCRIPT_DIR/post_install.sh"
|
||||||
|
exit 0
|
||||||
|
EOS
|
||||||
|
|
||||||
if [ "${MAC_CERT_PW+x}" ]; then
|
chmod +x "$SCRIPTS_DIR"/*
|
||||||
echo "Signing installer bundle..."
|
chmod +x "$UNINSTALL_SCRIPTS_DIR"/*
|
||||||
security unlock-keychain -p $TEMP_PASS $KEYCHAIN
|
chmod +x "$RESOURCES_DIR/scripts"/*
|
||||||
/usr/bin/codesign --deep --force --verbose --timestamp -o runtime --sign "$MAC_SIGNER_ID" $INSTALLER_BUNDLE_DIR
|
cp "$PROJECT_DIR/LICENSE" "$RESOURCES_DIR/LICENSE"
|
||||||
/usr/bin/codesign --verify -vvvv $INSTALLER_BUNDLE_DIR || true
|
|
||||||
|
|
||||||
if [ "${NOTARIZE_APP+x}" ]; then
|
APP_VERSION=$(grep -m1 -E 'project\(' "$PROJECT_DIR/CMakeLists.txt" | sed -E 's/.*VERSION ([0-9.]+).*/\1/')
|
||||||
echo "Notarizing installer bundle..."
|
echo "Building component package $INSTALL_PKG ..."
|
||||||
/usr/bin/ditto -c -k --keepParent $INSTALLER_BUNDLE_DIR $PROJECT_DIR/Installer_bundle_to_notarize.zip
|
|
||||||
xcrun notarytool submit $PROJECT_DIR/Installer_bundle_to_notarize.zip --apple-id $APPLE_DEV_EMAIL --team-id $MAC_TEAM_ID --password $APPLE_DEV_PASSWORD
|
# Disable bundle relocation so the app always ends up in /Applications even if
|
||||||
rm $PROJECT_DIR/Installer_bundle_to_notarize.zip
|
# another copy is lying around somewhere. We do this by letting pkgbuild
|
||||||
sleep 300
|
# analyse the contents, flipping the BundleIsRelocatable flag to false for every
|
||||||
xcrun stapler staple $INSTALLER_BUNDLE_DIR
|
# bundle it discovers and then feeding that plist back to pkgbuild.
|
||||||
xcrun stapler validate $INSTALLER_BUNDLE_DIR
|
|
||||||
spctl -a -vvvv $INSTALLER_BUNDLE_DIR || true
|
COMPONENT_PLIST="$PKG_DIR/component.plist"
|
||||||
fi
|
# Create the component description plist first
|
||||||
|
pkgbuild --analyze --root "$PKG_ROOT" "$COMPONENT_PLIST"
|
||||||
|
|
||||||
|
# Turn all `BundleIsRelocatable` keys to false (PlistBuddy is available on all
|
||||||
|
# macOS systems). We first convert to xml1 to ensure predictable formatting.
|
||||||
|
|
||||||
|
# Turn relocation off for every bundle entry in the plist. PlistBuddy cannot
|
||||||
|
# address keys that contain slashes without quoting, so we iterate through the
|
||||||
|
# top-level keys it prints.
|
||||||
|
plutil -convert xml1 "$COMPONENT_PLIST"
|
||||||
|
for bundle_key in $(/usr/libexec/PlistBuddy -c "Print" "$COMPONENT_PLIST" | awk '/^[ \t]*[A-Za-z0-9].*\.app/ {print $1}'); do
|
||||||
|
/usr/libexec/PlistBuddy -c "Set :'${bundle_key}':BundleIsRelocatable false" "$COMPONENT_PLIST" || true
|
||||||
|
done
|
||||||
|
|
||||||
|
# Now build the real payload package with the edited plist so that the final
|
||||||
|
# PackageInfo contains relocatable="false".
|
||||||
|
pkgbuild --root "$PKG_ROOT" \
|
||||||
|
--identifier "$APP_DOMAIN" \
|
||||||
|
--version "$APP_VERSION" \
|
||||||
|
--install-location "/" \
|
||||||
|
--scripts "$SCRIPTS_DIR" \
|
||||||
|
--component-plist "$COMPONENT_PLIST" \
|
||||||
|
--sign "$MAC_INSTALLER_SIGNER_ID" \
|
||||||
|
"$INSTALL_PKG"
|
||||||
|
|
||||||
|
# Build uninstaller component package
|
||||||
|
UNINSTALL_COMPONENT_PKG=$PKG_DIR/${APP_NAME}_uninstall_component.pkg
|
||||||
|
echo "Building uninstaller component package $UNINSTALL_COMPONENT_PKG ..."
|
||||||
|
pkgbuild --nopayload \
|
||||||
|
--identifier "$APP_DOMAIN.uninstall" \
|
||||||
|
--version "$APP_VERSION" \
|
||||||
|
--scripts "$UNINSTALL_SCRIPTS_DIR" \
|
||||||
|
--sign "$MAC_INSTALLER_SIGNER_ID" \
|
||||||
|
"$UNINSTALL_COMPONENT_PKG"
|
||||||
|
|
||||||
|
# Wrap uninstaller component in a distribution package for clearer UI
|
||||||
|
echo "Building uninstaller distribution package $UNINSTALL_PKG ..."
|
||||||
|
UNINSTALL_RESOURCES=$PKG_DIR/uninstall_resources
|
||||||
|
rm -rf "$UNINSTALL_RESOURCES"
|
||||||
|
mkdir -p "$UNINSTALL_RESOURCES"
|
||||||
|
cp "$DEPLOY_DATA_DIR/uninstall_welcome.html" "$UNINSTALL_RESOURCES"
|
||||||
|
cp "$DEPLOY_DATA_DIR/uninstall_conclusion.html" "$UNINSTALL_RESOURCES"
|
||||||
|
productbuild \
|
||||||
|
--distribution "$DEPLOY_DATA_DIR/distribution_uninstall.xml" \
|
||||||
|
--package-path "$PKG_DIR" \
|
||||||
|
--resources "$UNINSTALL_RESOURCES" \
|
||||||
|
--sign "$MAC_INSTALLER_SIGNER_ID" \
|
||||||
|
"$UNINSTALL_PKG"
|
||||||
|
|
||||||
|
cp "$PROJECT_DIR/deploy/data/macos/distribution.xml" "$PKG_DIR/distribution.xml"
|
||||||
|
|
||||||
|
echo "Creating final installer $FINAL_PKG ..."
|
||||||
|
productbuild --distribution "$PKG_DIR/distribution.xml" \
|
||||||
|
--package-path "$PKG_DIR" \
|
||||||
|
--resources "$RESOURCES_DIR" \
|
||||||
|
--sign "$MAC_INSTALLER_SIGNER_ID" \
|
||||||
|
"$FINAL_PKG"
|
||||||
|
|
||||||
|
if [ "${MAC_INSTALL_CERT_PW+x}" ] && [ "${NOTARIZE_APP+x}" ]; then
|
||||||
|
echo "Notarizing installer package..."
|
||||||
|
xcrun notarytool submit "$FINAL_PKG" \
|
||||||
|
--apple-id "$APPLE_DEV_EMAIL" \
|
||||||
|
--team-id "$MAC_TEAM_ID" \
|
||||||
|
--password "$APPLE_DEV_PASSWORD" \
|
||||||
|
--wait
|
||||||
|
|
||||||
|
echo "Stapling ticket..."
|
||||||
|
xcrun stapler staple "$FINAL_PKG"
|
||||||
|
xcrun stapler validate "$FINAL_PKG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Building DMG installer..."
|
if [ "${MAC_INSTALL_CERT_PW+x}" ]; then
|
||||||
# Allow Terminal to make changes in Privacy & Security > App Management
|
/usr/bin/codesign --verify -vvvv "$FINAL_PKG" || true
|
||||||
hdiutil create -size 256mb -volname AmneziaVPN -srcfolder $BUILD_DIR/installer/$APP_NAME.app -ov -format UDZO $DMG_FILENAME
|
spctl -a -vvvv "$FINAL_PKG" || true
|
||||||
|
|
||||||
if [ "${MAC_CERT_PW+x}" ]; then
|
|
||||||
echo "Signing DMG installer..."
|
|
||||||
security unlock-keychain -p $TEMP_PASS $KEYCHAIN
|
|
||||||
/usr/bin/codesign --deep --force --verbose --timestamp -o runtime --sign "$MAC_SIGNER_ID" $DMG_FILENAME
|
|
||||||
/usr/bin/codesign --verify -vvvv $DMG_FILENAME || true
|
|
||||||
|
|
||||||
if [ "${NOTARIZE_APP+x}" ]; then
|
|
||||||
echo "Notarizing DMG installer..."
|
|
||||||
xcrun notarytool submit $DMG_FILENAME --apple-id $APPLE_DEV_EMAIL --team-id $MAC_TEAM_ID --password $APPLE_DEV_PASSWORD
|
|
||||||
sleep 300
|
|
||||||
xcrun stapler staple $DMG_FILENAME
|
|
||||||
xcrun stapler validate $DMG_FILENAME
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Finished, artifact is $DMG_FILENAME"
|
# Sign app bundle
|
||||||
|
/usr/bin/codesign --deep --force --verbose --timestamp -o runtime --keychain "$KEYCHAIN_PATH" --sign "$MAC_SIGNER_ID" "$BUNDLE_DIR"
|
||||||
|
spctl -a -vvvv "$BUNDLE_DIR" || true
|
||||||
|
|
||||||
# restore keychain
|
# Restore login keychain as the only user keychain and delete the temporary keychain
|
||||||
security default-keychain -s login.keychain
|
KEYCHAIN="$HOME/Library/Keychains/login.keychain-db"
|
||||||
|
security list-keychains -d user -s "$KEYCHAIN"
|
||||||
|
security delete-keychain "$KEYCHAIN_PATH"
|
||||||
|
|
||||||
|
echo "Finished, artifact is $FINAL_PKG"
|
||||||
|
|
|
||||||
5
deploy/data/macos/check_install.sh
Executable file
5
deploy/data/macos/check_install.sh
Executable file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
if [ -d "/Applications/AmneziaVPN.app" ] || pgrep -x "AmneziaVPN-service" >/dev/null; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
5
deploy/data/macos/check_uninstall.sh
Executable file
5
deploy/data/macos/check_uninstall.sh
Executable file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
if [ -d "/Applications/AmneziaVPN.app" ] || pgrep -x "AmneziaVPN-service" >/dev/null; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
17
deploy/data/macos/distribution.xml
Normal file
17
deploy/data/macos/distribution.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<installer-gui-script minSpecVersion="1">
|
||||||
|
<title>AmneziaVPN Installer</title>
|
||||||
|
<license file="LICENSE"/>
|
||||||
|
<choices-outline>
|
||||||
|
<line choice="install"/>
|
||||||
|
<line choice="uninstall"/>
|
||||||
|
</choices-outline>
|
||||||
|
<choice id="install" title="Install AmneziaVPN" start_selected="true">
|
||||||
|
<pkg-ref id="org.amneziavpn.package"/>
|
||||||
|
</choice>
|
||||||
|
<choice id="uninstall" title="Uninstall AmneziaVPN" start_selected="false">
|
||||||
|
<pkg-ref id="org.amneziavpn.uninstall"/>
|
||||||
|
</choice>
|
||||||
|
<pkg-ref id="org.amneziavpn.package" auth="Root" install-check="scripts/check_install.sh">AmneziaVPN_install.pkg</pkg-ref>
|
||||||
|
<pkg-ref id="org.amneziavpn.uninstall" auth="Root" install-check="scripts/check_uninstall.sh">AmneziaVPN_uninstall_component.pkg</pkg-ref>
|
||||||
|
</installer-gui-script>
|
||||||
13
deploy/data/macos/distribution_uninstall.xml
Normal file
13
deploy/data/macos/distribution_uninstall.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<installer-gui-script minSpecVersion="1">
|
||||||
|
<title>Uninstall AmneziaVPN</title>
|
||||||
|
<options customize-install-button="always"/>
|
||||||
|
<welcome file="uninstall_welcome.html"/>
|
||||||
|
<conclusion file="uninstall_conclusion.html"/>
|
||||||
|
<choices-outline>
|
||||||
|
<line choice="uninstall"/>
|
||||||
|
</choices-outline>
|
||||||
|
<choice id="uninstall" title="Uninstall AmneziaVPN" start_selected="true">
|
||||||
|
<pkg-ref id="org.amneziavpn.uninstall"/>
|
||||||
|
</choice>
|
||||||
|
<pkg-ref id="org.amneziavpn.uninstall" auth="Root">AmneziaVPN_uninstall_component.pkg</pkg-ref>
|
||||||
|
</installer-gui-script>
|
||||||
|
|
@ -7,29 +7,42 @@ LOG_FOLDER=/var/log/$APP_NAME
|
||||||
LOG_FILE="$LOG_FOLDER/post-install.log"
|
LOG_FILE="$LOG_FOLDER/post-install.log"
|
||||||
APP_PATH=/Applications/$APP_NAME.app
|
APP_PATH=/Applications/$APP_NAME.app
|
||||||
|
|
||||||
if launchctl list "$APP_NAME-service" &> /dev/null; then
|
# Handle new installations unpacked into localized folder
|
||||||
launchctl unload $LAUNCH_DAEMONS_PLIST_NAME
|
if [ -d "/Applications/${APP_NAME}.localized" ]; then
|
||||||
rm -f $LAUNCH_DAEMONS_PLIST_NAME
|
echo "`date` Detected ${APP_NAME}.localized, migrating to standard path" >> $LOG_FILE
|
||||||
|
sudo rm -rf "$APP_PATH"
|
||||||
|
sudo mv "/Applications/${APP_NAME}.localized/${APP_NAME}.app" "$APP_PATH"
|
||||||
|
sudo rm -rf "/Applications/${APP_NAME}.localized"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tar xzf $APP_PATH/$APP_NAME.tar.gz -C $APP_PATH
|
if launchctl list "$APP_NAME-service" &> /dev/null; then
|
||||||
rm -f $APP_PATH/$APP_NAME.tar.gz
|
launchctl unload "$LAUNCH_DAEMONS_PLIST_NAME"
|
||||||
sudo chmod -R a-w $APP_PATH/
|
rm -f "$LAUNCH_DAEMONS_PLIST_NAME"
|
||||||
sudo chown -R root $APP_PATH/
|
fi
|
||||||
sudo chgrp -R wheel $APP_PATH/
|
|
||||||
|
sudo chmod -R a-w "$APP_PATH/"
|
||||||
|
sudo chown -R root "$APP_PATH/"
|
||||||
|
sudo chgrp -R wheel "$APP_PATH/"
|
||||||
|
|
||||||
rm -rf $LOG_FOLDER
|
rm -rf $LOG_FOLDER
|
||||||
mkdir -p $LOG_FOLDER
|
mkdir -p $LOG_FOLDER
|
||||||
|
|
||||||
echo "`date` Script started" > $LOG_FILE
|
echo "`date` Script started" > $LOG_FILE
|
||||||
|
|
||||||
killall -9 $APP_NAME-service 2>> $LOG_FILE
|
echo "Requesting ${APP_NAME} to quit gracefully" >> "$LOG_FILE"
|
||||||
|
osascript -e 'tell application "AmneziaVPN" to quit'
|
||||||
|
|
||||||
mv -f $APP_PATH/$PLIST_NAME $LAUNCH_DAEMONS_PLIST_NAME 2>> $LOG_FILE
|
PLIST_SOURCE="$APP_PATH/Contents/Resources/$PLIST_NAME"
|
||||||
chown root:wheel $LAUNCH_DAEMONS_PLIST_NAME
|
if [ -f "$PLIST_SOURCE" ]; then
|
||||||
launchctl load $LAUNCH_DAEMONS_PLIST_NAME
|
mv -f "$PLIST_SOURCE" "$LAUNCH_DAEMONS_PLIST_NAME" 2>> $LOG_FILE
|
||||||
|
else
|
||||||
|
echo "`date` ERROR: service plist not found at $PLIST_SOURCE" >> $LOG_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
chown root:wheel "$LAUNCH_DAEMONS_PLIST_NAME"
|
||||||
|
launchctl load "$LAUNCH_DAEMONS_PLIST_NAME"
|
||||||
|
echo "`date` Launching ${APP_NAME} application" >> $LOG_FILE
|
||||||
|
open -a "$APP_PATH" 2>> $LOG_FILE || true
|
||||||
|
|
||||||
echo "`date` Service status: $?" >> $LOG_FILE
|
echo "`date` Service status: $?" >> $LOG_FILE
|
||||||
echo "`date` Script finished" >> $LOG_FILE
|
echo "`date` Script finished" >> $LOG_FILE
|
||||||
|
|
||||||
#rm -- "$0"
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,19 @@ SYSTEM_APP_SUPPORT="/Library/Application Support/$APP_NAME"
|
||||||
LOG_FOLDER="/var/log/$APP_NAME"
|
LOG_FOLDER="/var/log/$APP_NAME"
|
||||||
CACHES_FOLDER="$HOME/Library/Caches/$APP_NAME"
|
CACHES_FOLDER="$HOME/Library/Caches/$APP_NAME"
|
||||||
|
|
||||||
|
# Attempt to quit the GUI application if it's currently running
|
||||||
|
if pgrep -x "$APP_NAME" > /dev/null; then
|
||||||
|
echo "Quitting $APP_NAME..."
|
||||||
|
osascript -e 'tell application "'"$APP_NAME"'" to quit' || true
|
||||||
|
# Wait up to 10 seconds for the app to terminate gracefully
|
||||||
|
for i in {1..10}; do
|
||||||
|
if ! pgrep -x "$APP_NAME" > /dev/null; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Stop the running service if it exists
|
# Stop the running service if it exists
|
||||||
if pgrep -x "${APP_NAME}-service" > /dev/null; then
|
if pgrep -x "${APP_NAME}-service" > /dev/null; then
|
||||||
sudo killall -9 "${APP_NAME}-service"
|
sudo killall -9 "${APP_NAME}-service"
|
||||||
|
|
@ -32,3 +45,40 @@ sudo rm -rf "$LOG_FOLDER"
|
||||||
|
|
||||||
# Remove any caches left behind
|
# Remove any caches left behind
|
||||||
rm -rf "$CACHES_FOLDER"
|
rm -rf "$CACHES_FOLDER"
|
||||||
|
|
||||||
|
# Remove PF data directory created by firewall helper, if present
|
||||||
|
sudo rm -rf "/Library/Application Support/${APP_NAME}/pf"
|
||||||
|
|
||||||
|
# ---------------- PF firewall cleanup ----------------------
|
||||||
|
# Rules are loaded under the anchor "amn" (see macosfirewall.cpp)
|
||||||
|
# Flush only that anchor to avoid destroying user/system rules.
|
||||||
|
|
||||||
|
PF_ANCHOR="amn"
|
||||||
|
|
||||||
|
### Flush all PF rules, NATs, and tables under our anchor and sub-anchors ###
|
||||||
|
anchors=$(sudo pfctl -s Anchors 2>/dev/null | awk '/^'"${PF_ANCHOR}"'/ {sub(/\*$/, "", $1); print $1}')
|
||||||
|
for anc in $anchors; do
|
||||||
|
echo "Flushing PF anchor $anc"
|
||||||
|
sudo pfctl -a "$anc" -F all 2>/dev/null || true
|
||||||
|
# flush tables under this anchor
|
||||||
|
tables=$(sudo pfctl -s Tables 2>/dev/null | awk '/^'"$anc"'/ {print}')
|
||||||
|
for tbl in $tables; do
|
||||||
|
echo "Killing PF table $tbl"
|
||||||
|
sudo pfctl -t "$tbl" -T kill 2>/dev/null || true
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
### Reload default PF config to restore system rules ###
|
||||||
|
if [ -f /etc/pf.conf ]; then
|
||||||
|
echo "Restoring system PF config"
|
||||||
|
sudo pfctl -f /etc/pf.conf 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
### Disable PF if no rules remain ###
|
||||||
|
if sudo pfctl -s info 2>/dev/null | grep -q '^Status: Enabled' && \
|
||||||
|
! sudo pfctl -sr 2>/dev/null | grep -q .; then
|
||||||
|
echo "Disabling PF"
|
||||||
|
sudo pfctl -d 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -----------------------------------------------------------
|
||||||
|
|
|
||||||
7
deploy/data/macos/uninstall_conclusion.html
Normal file
7
deploy/data/macos/uninstall_conclusion.html
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<html>
|
||||||
|
<head><title>Uninstall Complete</title></head>
|
||||||
|
<body>
|
||||||
|
<h1>AmneziaVPN has been uninstalled</h1>
|
||||||
|
<p>Thank you for using AmneziaVPN. The application and its components have been removed.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
7
deploy/data/macos/uninstall_welcome.html
Normal file
7
deploy/data/macos/uninstall_welcome.html
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<html>
|
||||||
|
<head><title>Uninstall AmneziaVPN</title></head>
|
||||||
|
<body>
|
||||||
|
<h1>Uninstall AmneziaVPN</h1>
|
||||||
|
<p>This process will remove AmneziaVPN from your system. Click Continue to proceed.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -4,11 +4,6 @@ if(WIN32)
|
||||||
${CMAKE_CURRENT_LIST_DIR}/config/windows.xml.in
|
${CMAKE_CURRENT_LIST_DIR}/config/windows.xml.in
|
||||||
${CMAKE_BINARY_DIR}/installer/config/windows.xml
|
${CMAKE_BINARY_DIR}/installer/config/windows.xml
|
||||||
)
|
)
|
||||||
elseif(APPLE AND NOT IOS)
|
|
||||||
configure_file(
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/config/macos.xml.in
|
|
||||||
${CMAKE_BINARY_DIR}/installer/config/macos.xml
|
|
||||||
)
|
|
||||||
elseif(LINUX)
|
elseif(LINUX)
|
||||||
set(ApplicationsDir "@ApplicationsDir@")
|
set(ApplicationsDir "@ApplicationsDir@")
|
||||||
configure_file(
|
configure_file(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=AmneziaVPN
|
Name=AmneziaVPN
|
||||||
Version=@CMAKE_PROJECT_VERSION@
|
Version=1.0
|
||||||
Comment=Client of your self-hosted VPN
|
Comment=Client of your self-hosted VPN
|
||||||
Exec=AmneziaVPN
|
Exec=AmneziaVPN
|
||||||
Icon=/usr/share/pixmaps/AmneziaVPN.png
|
Icon=/usr/share/pixmaps/AmneziaVPN.png
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Installer>
|
|
||||||
<Name>AmneziaVPN</Name>
|
|
||||||
<Version>@CMAKE_PROJECT_VERSION@</Version>
|
|
||||||
<Title>AmneziaVPN</Title>
|
|
||||||
<Publisher>AmneziaVPN</Publisher>
|
|
||||||
<StartMenuDir>AmneziaVPN</StartMenuDir>
|
|
||||||
<TargetDir>/Applications/AmneziaVPN.app</TargetDir>
|
|
||||||
<WizardDefaultWidth>600</WizardDefaultWidth>
|
|
||||||
<WizardDefaultHeight>380</WizardDefaultHeight>
|
|
||||||
<WizardStyle>Mac</WizardStyle>
|
|
||||||
<RemoveTargetDir>true</RemoveTargetDir>
|
|
||||||
<AllowSpaceInPath>true</AllowSpaceInPath>
|
|
||||||
<AllowNonAsciiCharacters>false</AllowNonAsciiCharacters>
|
|
||||||
<ControlScript>controlscript.js</ControlScript>
|
|
||||||
<RepositorySettingsPageVisible>false</RepositorySettingsPageVisible>
|
|
||||||
<DependsOnLocalInstallerBinary>true</DependsOnLocalInstallerBinary>
|
|
||||||
<SupportsModify>false</SupportsModify>
|
|
||||||
<DisableAuthorizationFallback>true</DisableAuthorizationFallback>
|
|
||||||
<RemoteRepositories>
|
|
||||||
<Repository>
|
|
||||||
<Url>https://amneziavpn.org/updates/macos</Url>
|
|
||||||
<Enabled>true</Enabled>
|
|
||||||
<DisplayName>AmneziaVPN - repository for macOS</DisplayName>
|
|
||||||
</Repository>
|
|
||||||
</RemoteRepositories>
|
|
||||||
</Installer>
|
|
||||||
|
|
@ -192,7 +192,14 @@ bool KillSwitch::addAllowedRange(const QStringList &ranges) {
|
||||||
bool KillSwitch::enablePeerTraffic(const QJsonObject &configStr) {
|
bool KillSwitch::enablePeerTraffic(const QJsonObject &configStr) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
InterfaceConfig config;
|
InterfaceConfig config;
|
||||||
config.m_dnsServer = configStr.value(amnezia::config_key::dns1).toString();
|
|
||||||
|
config.m_primaryDnsServer = configStr.value(amnezia::config_key::dns1).toString();
|
||||||
|
|
||||||
|
// We don't use secondary DNS if primary DNS is AmneziaDNS
|
||||||
|
if (!config.m_primaryDnsServer.contains(amnezia::protocols::dns::amneziaDnsIp)) {
|
||||||
|
config.m_secondaryDnsServer = configStr.value(amnezia::config_key::dns2).toString();
|
||||||
|
}
|
||||||
|
|
||||||
config.m_serverPublicKey = "openvpn";
|
config.m_serverPublicKey = "openvpn";
|
||||||
config.m_serverIpv4Gateway = configStr.value("vpnGateway").toString();
|
config.m_serverIpv4Gateway = configStr.value("vpnGateway").toString();
|
||||||
config.m_serverIpv4AddrIn = configStr.value("vpnServer").toString();
|
config.m_serverIpv4AddrIn = configStr.value("vpnServer").toString();
|
||||||
|
|
@ -255,6 +262,9 @@ bool KillSwitch::enablePeerTraffic(const QJsonObject &configStr) {
|
||||||
|
|
||||||
bool KillSwitch::enableKillSwitch(const QJsonObject &configStr, int vpnAdapterIndex) {
|
bool KillSwitch::enableKillSwitch(const QJsonObject &configStr, int vpnAdapterIndex) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
if (configStr.value("splitTunnelType").toInt() != 0) {
|
||||||
|
WindowsFirewall::create(this)->allowAllTraffic();
|
||||||
|
}
|
||||||
return WindowsFirewall::create(this)->enableInterface(vpnAdapterIndex);
|
return WindowsFirewall::create(this)->enableInterface(vpnAdapterIndex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -304,8 +314,14 @@ bool KillSwitch::enableKillSwitch(const QJsonObject &configStr, int vpnAdapterIn
|
||||||
LinuxFirewall::setAnchorEnabled(LinuxFirewall::Both, QStringLiteral("300.allowLAN"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::Both, QStringLiteral("300.allowLAN"), true);
|
||||||
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv4, QStringLiteral("310.blockDNS"), true);
|
LinuxFirewall::setAnchorEnabled(LinuxFirewall::IPv4, QStringLiteral("310.blockDNS"), true);
|
||||||
QStringList dnsServers;
|
QStringList dnsServers;
|
||||||
|
|
||||||
dnsServers.append(configStr.value(amnezia::config_key::dns1).toString());
|
dnsServers.append(configStr.value(amnezia::config_key::dns1).toString());
|
||||||
dnsServers.append(configStr.value(amnezia::config_key::dns2).toString());
|
|
||||||
|
// We don't use secondary DNS if primary DNS is AmneziaDNS
|
||||||
|
if (!configStr.value(amnezia::config_key::dns1).toString().contains(amnezia::protocols::dns::amneziaDnsIp)) {
|
||||||
|
dnsServers.append(configStr.value(amnezia::config_key::dns2).toString());
|
||||||
|
}
|
||||||
|
|
||||||
dnsServers.append("127.0.0.1");
|
dnsServers.append("127.0.0.1");
|
||||||
dnsServers.append("127.0.0.53");
|
dnsServers.append("127.0.0.53");
|
||||||
|
|
||||||
|
|
@ -342,7 +358,11 @@ bool KillSwitch::enableKillSwitch(const QJsonObject &configStr, int vpnAdapterIn
|
||||||
|
|
||||||
QStringList dnsServers;
|
QStringList dnsServers;
|
||||||
dnsServers.append(configStr.value(amnezia::config_key::dns1).toString());
|
dnsServers.append(configStr.value(amnezia::config_key::dns1).toString());
|
||||||
dnsServers.append(configStr.value(amnezia::config_key::dns2).toString());
|
|
||||||
|
// We don't use secondary DNS if primary DNS is AmneziaDNS
|
||||||
|
if (!configStr.value(amnezia::config_key::dns1).toString().contains(amnezia::protocols::dns::amneziaDnsIp)) {
|
||||||
|
dnsServers.append(configStr.value(amnezia::config_key::dns2).toString());
|
||||||
|
}
|
||||||
|
|
||||||
for (auto dns : configStr.value(amnezia::config_key::allowedDnsServers).toArray()) {
|
for (auto dns : configStr.value(amnezia::config_key::allowedDnsServers).toArray()) {
|
||||||
if (!dns.isString()) {
|
if (!dns.isString()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue