mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-10 04:13:27 +03:00
Compare commits
5 Commits
feat/selfh
...
server_scr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f41b8790e | ||
|
|
6bb3db7684 | ||
|
|
201e4063ed | ||
|
|
211bf51f1d | ||
|
|
7e0c35ba29 |
3
.github/workflows/deploy.yml
vendored
3
.github/workflows/deploy.yml
vendored
@@ -23,9 +23,6 @@ jobs:
|
||||
- 'recipes/**'
|
||||
- 'conanfile.py'
|
||||
- '.github/workflows/deploy.yml'
|
||||
- 'cmake/conan_provider.cmake'
|
||||
- 'cmake/platform_settings.cmake'
|
||||
- 'cmake/recipes_bootstrap.cmake'
|
||||
|
||||
Bake-Prebuilts-Linux:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -18,9 +18,9 @@ project(${PROJECT} VERSION ${AMNEZIAVPN_VERSION}
|
||||
HOMEPAGE_URL "https://amnezia.org/"
|
||||
)
|
||||
|
||||
# trigger conan to kick off `conan install` globally
|
||||
find_package(OpenSSL REQUIRED)
|
||||
if (PREBUILTS_ONLY)
|
||||
# trigger conan to kick off `conan install`
|
||||
find_package(OpenSSL REQUIRED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -212,32 +212,11 @@ endif()
|
||||
|
||||
install(TARGETS ${PROJECT}
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
RUNTIME_DEPENDENCY_SET client_deps
|
||||
COMPONENT AmneziaVPN
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
set(RUNTIME_DEPS_DIR ${CMAKE_INSTALL_BINDIR}/AmneziaVPN.app/Contents/Frameworks)
|
||||
else()
|
||||
set(RUNTIME_DEPS_DIR ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
||||
install(RUNTIME_DEPENDENCY_SET client_deps
|
||||
PRE_EXCLUDE_REGEXES
|
||||
[[api-ms-win-.*]]
|
||||
[[ext-ms-.*]]
|
||||
[[kernel32\.dll]]
|
||||
[[hvsifiletrust\.dll]]
|
||||
[[libc\.so\..*]] [[libgcc_s\.so\..*]] [[libm\.so\..*]] [[libstdc\+\+\.so\..*]]
|
||||
[[.*\.framework]]
|
||||
[[^[Qq]t.*]]
|
||||
POST_EXCLUDE_REGEXES
|
||||
[[^.*[\\/]system32[\\/].*\.dll$]]
|
||||
[[^/lib.*]]
|
||||
[[^/usr/lib.*]]
|
||||
DIRECTORIES ${CONAN_RUNTIME_LIB_DIRS}
|
||||
install(FILES $<TARGET_RUNTIME_DLLS:${PROJECT}>
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT AmneziaVPN
|
||||
DESTINATION "${RUNTIME_DEPS_DIR}"
|
||||
)
|
||||
|
||||
set(deploy_tool_options "")
|
||||
|
||||
@@ -54,6 +54,7 @@ target_include_directories(${PROJECT} PRIVATE ${Qt6Gui_PRIVATE_INCLUDE_DIRS})
|
||||
|
||||
|
||||
set_target_properties(${PROJECT} PROPERTIES
|
||||
XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION
|
||||
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/ios/app/Info.plist.in
|
||||
MACOSX_BUNDLE_ICON_FILE "AppIcon"
|
||||
MACOSX_BUNDLE_INFO_STRING "AmneziaVPN"
|
||||
|
||||
@@ -73,7 +73,7 @@ ErrorCode ConnectionController::prepareConnection(const QString &serverId,
|
||||
if (!cfg.has_value()) return ErrorCode::InternalError;
|
||||
container = cfg->defaultContainer;
|
||||
containerConfigModel = cfg->containerConfig(container);
|
||||
dns = cfg->getDnsPair(primaryDns, secondaryDns);
|
||||
dns = cfg->getDnsPair(m_appSettingsRepository->useAmneziaDns(), primaryDns, secondaryDns);
|
||||
hostName = cfg->hostName;
|
||||
description = cfg->description;
|
||||
break;
|
||||
|
||||
@@ -65,15 +65,13 @@ ExportController::ExportResult ExportController::generateConnectionConfig(const
|
||||
}
|
||||
ContainerConfig containerConfig = adminConfig->containerConfig(container);
|
||||
|
||||
const QPair<QString, QString> dns = adminConfig->getDnsPair(m_appSettingsRepository->primaryDns(), m_appSettingsRepository->secondaryDns());
|
||||
|
||||
if (ContainerUtils::containerService(container) != ServiceType::Other) {
|
||||
SshSession sshSession;
|
||||
Proto protocol = ContainerUtils::defaultProtocol(container);
|
||||
|
||||
DnsSettings dnsSettings = {
|
||||
dns.first,
|
||||
dns.second
|
||||
m_appSettingsRepository->primaryDns(),
|
||||
m_appSettingsRepository->secondaryDns()
|
||||
};
|
||||
|
||||
auto configurator = ConfiguratorBase::create(protocol, &sshSession);
|
||||
@@ -90,6 +88,10 @@ ExportController::ExportResult ExportController::generateConnectionConfig(const
|
||||
}
|
||||
}
|
||||
|
||||
const QPair<QString, QString> dns = adminConfig->getDnsPair(m_appSettingsRepository->useAmneziaDns(),
|
||||
m_appSettingsRepository->primaryDns(),
|
||||
m_appSettingsRepository->secondaryDns());
|
||||
|
||||
adminConfig->containers.clear();
|
||||
adminConfig->containers[container] = containerConfig;
|
||||
adminConfig->defaultContainer = container;
|
||||
@@ -131,14 +133,16 @@ ExportController::NativeConfigResult ExportController::generateNativeConfig(cons
|
||||
result.errorCode = ErrorCode::InternalError;
|
||||
return result;
|
||||
}
|
||||
const QPair<QString, QString> dns = adminConfig->getDnsPair(m_appSettingsRepository->primaryDns(), m_appSettingsRepository->secondaryDns());
|
||||
const QPair<QString, QString> dns = adminConfig->getDnsPair(m_appSettingsRepository->useAmneziaDns(),
|
||||
m_appSettingsRepository->primaryDns(),
|
||||
m_appSettingsRepository->secondaryDns());
|
||||
|
||||
ContainerConfig modifiedContainerConfig = containerConfig;
|
||||
modifiedContainerConfig.container = container;
|
||||
|
||||
DnsSettings dnsSettings = {
|
||||
dns.first,
|
||||
dns.second
|
||||
m_appSettingsRepository->primaryDns(),
|
||||
m_appSettingsRepository->secondaryDns()
|
||||
};
|
||||
|
||||
SshSession sshSession;
|
||||
|
||||
@@ -486,7 +486,7 @@ QJsonObject ImportController::extractOpenVpnConfig(const QString &data) const
|
||||
QJsonObject config;
|
||||
config[configKey::containers] = arr;
|
||||
config[configKey::defaultContainer] = configKey::amneziaOpenvpn;
|
||||
config[configKey::description] = m_serversRepository->nextAvailableServerName();
|
||||
config[configKey::description] = m_appSettingsRepository->nextAvailableServerName();
|
||||
|
||||
const static QRegularExpression dnsRegExp("dhcp-option DNS (\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b)");
|
||||
QRegularExpressionMatchIterator dnsMatch = dnsRegExp.globalMatch(data);
|
||||
@@ -645,7 +645,7 @@ QJsonObject ImportController::extractWireGuardConfig(const QString &data, Config
|
||||
QJsonObject config;
|
||||
config[configKey::containers] = arr;
|
||||
config[configKey::defaultContainer] = containerName;
|
||||
config[configKey::description] = m_serversRepository->nextAvailableServerName();
|
||||
config[configKey::description] = m_appSettingsRepository->nextAvailableServerName();
|
||||
|
||||
const static QRegularExpression dnsRegExp(
|
||||
"DNS = "
|
||||
@@ -699,7 +699,7 @@ QJsonObject ImportController::extractXrayConfig(const QString &data, ConfigTypes
|
||||
? configKey::amneziaSsxray
|
||||
: configKey::amneziaXray;
|
||||
if (description.isEmpty()) {
|
||||
config[configKey::description] = m_serversRepository->nextAvailableServerName();
|
||||
config[configKey::description] = m_appSettingsRepository->nextAvailableServerName();
|
||||
} else {
|
||||
config[configKey::description] = description;
|
||||
}
|
||||
|
||||
@@ -211,8 +211,7 @@ ErrorCode InstallController::updateContainer(const QString &serverId, DockerCont
|
||||
newConfig.getXrayProtocolConfig() && newConfig.getXrayProtocolConfig()->serverConfig.isThirdPartyConfig;
|
||||
|
||||
if (errorCode == ErrorCode::NoError && xrayServerSettingsChanged && !skipXrayInboundSync) {
|
||||
const QPair<QString, QString> dns = adminConfig->getDnsPair(m_appSettingsRepository->primaryDns(), m_appSettingsRepository->secondaryDns());
|
||||
DnsSettings dnsSettings = { dns.first, dns.second };
|
||||
DnsSettings dnsSettings = { m_appSettingsRepository->primaryDns(), m_appSettingsRepository->secondaryDns() };
|
||||
XrayConfigurator xrayConfigurator(&sshSession);
|
||||
qDebug() << "InstallController::updateContainer applying Xray server inbound sync, reinstall="
|
||||
<< reinstallRequired;
|
||||
@@ -359,7 +358,7 @@ void InstallController::addEmptyServer(const ServerCredentials &credentials)
|
||||
serverConfig.userName = credentials.userName;
|
||||
serverConfig.password = credentials.secretData;
|
||||
serverConfig.port = credentials.port;
|
||||
serverConfig.description = m_serversRepository->nextAvailableServerName();
|
||||
serverConfig.description = m_appSettingsRepository->nextAvailableServerName();
|
||||
serverConfig.displayName = serverConfig.description.isEmpty() ? serverConfig.hostName : serverConfig.description;
|
||||
serverConfig.defaultContainer = DockerContainer::None;
|
||||
|
||||
@@ -1171,7 +1170,7 @@ ErrorCode InstallController::installServer(const ServerCredentials &credentials,
|
||||
serverConfig.userName = credentials.userName;
|
||||
serverConfig.password = credentials.secretData;
|
||||
serverConfig.port = credentials.port;
|
||||
serverConfig.description = m_serversRepository->nextAvailableServerName();
|
||||
serverConfig.description = m_appSettingsRepository->nextAvailableServerName();
|
||||
|
||||
for (auto iterator = preparedContainers.begin(); iterator != preparedContainers.end(); iterator++) {
|
||||
serverConfig.containers.insert(iterator.key(), iterator.value());
|
||||
@@ -1241,26 +1240,28 @@ ErrorCode InstallController::installContainer(const QString &serverId, DockerCon
|
||||
return ErrorCode::NoError;
|
||||
}
|
||||
|
||||
ErrorCode InstallController::checkSshConnection(ServerCredentials &credentials, QString &output,
|
||||
ErrorCode InstallController::checkSshConnection(const ServerCredentials &credentials, QString &output,
|
||||
std::function<QString()> passphraseCallback)
|
||||
{
|
||||
SshSession sshSession(this);
|
||||
ErrorCode errorCode = ErrorCode::NoError;
|
||||
|
||||
if (credentials.secretData.contains("BEGIN") && credentials.secretData.contains("PRIVATE KEY")) {
|
||||
ServerCredentials processedCredentials = credentials;
|
||||
|
||||
if (processedCredentials.secretData.contains("BEGIN") && processedCredentials.secretData.contains("PRIVATE KEY")) {
|
||||
if (!passphraseCallback) {
|
||||
return ErrorCode::SshPrivateKeyError;
|
||||
}
|
||||
|
||||
QString decryptedPrivateKey;
|
||||
errorCode = sshSession.getDecryptedPrivateKey(credentials, decryptedPrivateKey, passphraseCallback);
|
||||
errorCode = sshSession.getDecryptedPrivateKey(processedCredentials, decryptedPrivateKey, passphraseCallback);
|
||||
if (errorCode != ErrorCode::NoError) {
|
||||
return errorCode;
|
||||
}
|
||||
credentials.secretData = decryptedPrivateKey;
|
||||
processedCredentials.secretData = decryptedPrivateKey;
|
||||
}
|
||||
|
||||
output = sshSession.checkSshConnection(credentials, errorCode);
|
||||
output = sshSession.checkSshConnection(processedCredentials, errorCode);
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,7 @@ public:
|
||||
|
||||
bool isUpdateDockerContainerRequired(DockerContainer container, const ContainerConfig &oldConfig, const ContainerConfig &newConfig);
|
||||
|
||||
ErrorCode checkSshConnection(ServerCredentials &credentials, QString &output,
|
||||
std::function<QString()> passphraseCallback = nullptr);
|
||||
ErrorCode checkSshConnection(const ServerCredentials &credentials, QString &output, std::function<QString()> passphraseCallback = nullptr);
|
||||
|
||||
bool isServerAlreadyExists(const ServerCredentials &credentials, int &existingServerIndex);
|
||||
|
||||
|
||||
@@ -83,46 +83,6 @@ bool ServersController::renameServer(const QString &serverId, const QString &nam
|
||||
}
|
||||
}
|
||||
|
||||
bool ServersController::changeServerDns(const QString &serverId, const QString &primaryDns, const QString &secondaryDns, const int &dnsMode)
|
||||
{
|
||||
const serverConfigUtils::ConfigType kind = m_serversRepository->serverKind(serverId);
|
||||
if(kind == serverConfigUtils::ConfigType::SelfHostedAdmin) {
|
||||
auto cfg = m_serversRepository->selfHostedAdminConfig(serverId);
|
||||
if (!cfg.has_value()) return false;
|
||||
cfg->dns1 = primaryDns;
|
||||
cfg->dns2 = secondaryDns;
|
||||
cfg->dnsMode = dnsMode;
|
||||
m_serversRepository->editServer(serverId, cfg->toJson(), kind);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QPair<QString, QString> ServersController::getDnsPair(const QString &serverId) const
|
||||
{
|
||||
const serverConfigUtils::ConfigType kind = m_serversRepository->serverKind(serverId);
|
||||
if (kind == serverConfigUtils::ConfigType::SelfHostedAdmin) {
|
||||
const auto cfg = m_serversRepository->selfHostedAdminConfig(serverId);
|
||||
return cfg.has_value()
|
||||
? cfg->getDnsPair(m_appSettingsRepository->primaryDns(), m_appSettingsRepository->primaryDns())
|
||||
: QPair<QString, QString>();
|
||||
} else {
|
||||
return QPair<QString, QString>();
|
||||
}
|
||||
}
|
||||
|
||||
int ServersController::getDnsMode(const QString &serverId) const
|
||||
{
|
||||
const serverConfigUtils::ConfigType kind = m_serversRepository->serverKind(serverId);
|
||||
if (kind == serverConfigUtils::ConfigType::SelfHostedAdmin) {
|
||||
const auto cfg = m_serversRepository->selfHostedAdminConfig(serverId);
|
||||
return cfg.has_value() ? cfg->dnsMode : int();
|
||||
} else {
|
||||
return int();
|
||||
}
|
||||
}
|
||||
|
||||
void ServersController::removeServer(const QString &serverId)
|
||||
{
|
||||
m_serversRepository->removeServer(serverId);
|
||||
|
||||
@@ -37,7 +37,6 @@ public:
|
||||
|
||||
// Server management
|
||||
bool renameServer(const QString &serverId, const QString &name);
|
||||
bool changeServerDns(const QString &serverId, const QString &primaryDns, const QString &secondaryDns, const int &dnsMode);
|
||||
void removeServer(const QString &serverId);
|
||||
void setDefaultServer(const QString &serverId);
|
||||
|
||||
@@ -58,8 +57,6 @@ public:
|
||||
QMap<DockerContainer, ContainerConfig> getServerContainersMap(const QString &serverId) const;
|
||||
DockerContainer getDefaultContainer(const QString &serverId) const;
|
||||
ContainerConfig getContainerConfig(const QString &serverId, DockerContainer container) const;
|
||||
QPair<QString, QString> getDnsPair(const QString &serverId) const;
|
||||
int getDnsMode(const QString &serverId) const;
|
||||
|
||||
// Validation
|
||||
bool isServerFromApiAlreadyExists(const QString &userCountryCode, const QString &serviceType, const QString &serviceProtocol) const;
|
||||
|
||||
@@ -363,6 +363,6 @@ void SettingsController::disablePremV1MigrationReminder()
|
||||
|
||||
QString SettingsController::nextAvailableServerName() const
|
||||
{
|
||||
return m_serversRepository->nextAvailableServerName();
|
||||
return m_appSettingsRepository->nextAvailableServerName();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "version.h"
|
||||
#include "core/controllers/gatewayController.h"
|
||||
#include "core/utils/constants/apiKeys.h"
|
||||
#include "core/utils/errorStrings.h"
|
||||
#include "core/utils/selfhosted/scriptsRegistry.h"
|
||||
|
||||
namespace
|
||||
@@ -108,7 +109,7 @@ void UpdateController::fetchGatewayUrl()
|
||||
.then(this, [this, gatewayController](QPair<ErrorCode, QByteArray> result) {
|
||||
auto [err, gatewayResponse] = result;
|
||||
if (err != ErrorCode::NoError) {
|
||||
logger.error() << "Gateway request failed, error code:" << static_cast<int>(err);
|
||||
logger.error() << errorString(err);
|
||||
finishUpdateCheck();
|
||||
return;
|
||||
}
|
||||
@@ -249,9 +250,17 @@ void UpdateController::runInstaller()
|
||||
runLinuxInstaller(kInstallerLocalPath);
|
||||
#endif
|
||||
} else {
|
||||
logger.error() << "Installer download failed, network error:" << static_cast<int>(reply->error())
|
||||
<< reply->errorString();
|
||||
logger.error() << "HTTP status:" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError
|
||||
|| reply->error() == QNetworkReply::NetworkError::TimeoutError) {
|
||||
logger.error() << errorString(ErrorCode::ApiConfigTimeoutError);
|
||||
} else {
|
||||
QString err = reply->errorString();
|
||||
logger.error() << QString::fromUtf8(reply->readAll());
|
||||
logger.error() << "Network error code:" << QString::number(static_cast<int>(reply->error()));
|
||||
logger.error() << "Error message:" << err;
|
||||
logger.error() << "HTTP status:" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
logger.error() << errorString(ErrorCode::ApiConfigDownloadError);
|
||||
}
|
||||
}
|
||||
reply->deleteLater();
|
||||
});
|
||||
|
||||
@@ -64,14 +64,15 @@ void SelfHostedAdminServerConfig::clearCachedClientProfile(DockerContainer conta
|
||||
containers[container] = cleared;
|
||||
}
|
||||
|
||||
QPair<QString, QString> SelfHostedAdminServerConfig::getDnsPair(const QString &primaryDns, const QString &secondaryDns) const
|
||||
QPair<QString, QString> SelfHostedAdminServerConfig::getDnsPair(bool isAmneziaDnsEnabled, const QString &primaryDns,
|
||||
const QString &secondaryDns) const
|
||||
{
|
||||
QString d1 = dns1;
|
||||
QString d2 = dns2;
|
||||
const bool dnsOnServer = containers.contains(DockerContainer::Dns);
|
||||
|
||||
if (d1.isEmpty() || !NetworkUtilities::checkIPv4Format(d1)) {
|
||||
d1 = ((dnsMode == 1) && dnsOnServer) ? protocols::dns::amneziaDnsIp : primaryDns;
|
||||
d1 = (isAmneziaDnsEnabled && dnsOnServer) ? protocols::dns::amneziaDnsIp : primaryDns;
|
||||
}
|
||||
if (d2.isEmpty() || !NetworkUtilities::checkIPv4Format(d2)) {
|
||||
d2 = secondaryDns;
|
||||
@@ -109,9 +110,6 @@ QJsonObject SelfHostedAdminServerConfig::toJson() const
|
||||
if (!dns2.isEmpty()) {
|
||||
obj[configKey::dns2] = dns2;
|
||||
}
|
||||
if (dnsMode > -1) {
|
||||
obj[configKey::dnsMode] = dnsMode;
|
||||
}
|
||||
|
||||
if (!userName.isEmpty()) {
|
||||
obj[configKey::userName] = userName;
|
||||
@@ -149,11 +147,6 @@ SelfHostedAdminServerConfig SelfHostedAdminServerConfig::fromJson(const QJsonObj
|
||||
|
||||
config.dns1 = json.value(configKey::dns1).toString();
|
||||
config.dns2 = json.value(configKey::dns2).toString();
|
||||
if (json.contains(configKey::dnsMode)) {
|
||||
config.dnsMode = json.value(configKey::dnsMode).toInt();
|
||||
} else {
|
||||
config.dnsMode = 0;
|
||||
}
|
||||
|
||||
config.userName = json.value(configKey::userName).toString();
|
||||
config.password = json.value(configKey::password).toString();
|
||||
|
||||
@@ -26,7 +26,6 @@ struct SelfHostedAdminServerConfig {
|
||||
DockerContainer defaultContainer;
|
||||
QString dns1;
|
||||
QString dns2;
|
||||
int dnsMode = 0;
|
||||
|
||||
QString userName;
|
||||
QString password;
|
||||
@@ -42,7 +41,8 @@ struct SelfHostedAdminServerConfig {
|
||||
|
||||
void clearCachedClientProfile(DockerContainer container);
|
||||
|
||||
QPair<QString, QString> getDnsPair(const QString &primaryDns, const QString &secondaryDns) const;
|
||||
QPair<QString, QString> getDnsPair(bool isAmneziaDnsEnabled, const QString &primaryDns,
|
||||
const QString &secondaryDns) const;
|
||||
|
||||
QJsonObject toJson() const;
|
||||
static SelfHostedAdminServerConfig fromJson(const QJsonObject &json);
|
||||
|
||||
@@ -80,8 +80,8 @@ QString getProtocolName(DockerContainer defaultContainer, const QMap<DockerConta
|
||||
namespace amnezia
|
||||
{
|
||||
|
||||
ServerDescription buildServerDescription(const SelfHostedAdminServerConfig &server, bool /*isAmneziaDnsEnabled*/)
|
||||
{
|
||||
ServerDescription buildServerDescription(const SelfHostedAdminServerConfig &server, bool isAmneziaDnsEnabled)
|
||||
{
|
||||
ServerDescription row = buildBaseDescription(server);
|
||||
row.selfHostedSshCredentials.hostName = server.hostName;
|
||||
row.selfHostedSshCredentials.userName = server.userName;
|
||||
@@ -92,7 +92,7 @@ ServerDescription buildServerDescription(const SelfHostedAdminServerConfig &serv
|
||||
&& !row.selfHostedSshCredentials.secretData.isEmpty();
|
||||
|
||||
row.serverName = server.displayName;
|
||||
row.baseDescription = getBaseDescription(server.containers, server.dnsMode == 1, row.hasWriteAccess, row.primaryDnsIsAmnezia);
|
||||
row.baseDescription = getBaseDescription(server.containers, isAmneziaDnsEnabled, row.hasWriteAccess, row.primaryDnsIsAmnezia);
|
||||
|
||||
const QString protocolName = getProtocolName(server.defaultContainer, server.containers);
|
||||
row.expandedServerDescription = row.baseDescription + row.hostName;
|
||||
|
||||
@@ -426,6 +426,26 @@ void SecureAppSettingsRepository::clearSettings()
|
||||
emit settingsCleared();
|
||||
}
|
||||
|
||||
QString SecureAppSettingsRepository::nextAvailableServerName() const
|
||||
{
|
||||
int i = 0;
|
||||
bool nameExist = false;
|
||||
|
||||
do {
|
||||
i++;
|
||||
nameExist = false;
|
||||
QJsonArray servers = QJsonDocument::fromJson(value("Servers/serversList").toByteArray()).array();
|
||||
for (const QJsonValue &server : servers) {
|
||||
if (server.toObject().value(configKey::description).toString() == QString("Server") + " " + QString::number(i)) {
|
||||
nameExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (nameExist);
|
||||
|
||||
return QString("Server") + " " + QString::number(i);
|
||||
}
|
||||
|
||||
void SecureAppSettingsRepository::setInstallationUuid(const QString &uuid)
|
||||
{
|
||||
m_settings->setValue("Conf/installationUuid", uuid);
|
||||
|
||||
@@ -90,6 +90,8 @@ public:
|
||||
bool restoreAppConfig(const QByteArray &cfg);
|
||||
void clearSettings();
|
||||
|
||||
QString nextAvailableServerName() const;
|
||||
|
||||
QByteArray xraySavedConfigs() const;
|
||||
void setXraySavedConfigs(const QByteArray &data);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonValue>
|
||||
#include <QSet>
|
||||
#include <QUuid>
|
||||
|
||||
#include "core/utils/serverConfigUtils.h"
|
||||
@@ -33,45 +32,6 @@ QJsonObject embedStorageServerId(const QString &serverId, const QJsonObject &pay
|
||||
return o;
|
||||
}
|
||||
|
||||
QString storedServerDisplayName(const SecureServersRepository *repository, const QString &serverId)
|
||||
{
|
||||
using Kind = serverConfigUtils::ConfigType;
|
||||
switch (repository->serverKind(serverId)) {
|
||||
case Kind::SelfHostedAdmin:
|
||||
if (const auto cfg = repository->selfHostedAdminConfig(serverId)) {
|
||||
return cfg->displayName;
|
||||
}
|
||||
break;
|
||||
case Kind::SelfHostedUser:
|
||||
if (const auto cfg = repository->selfHostedUserConfig(serverId)) {
|
||||
return cfg->displayName;
|
||||
}
|
||||
break;
|
||||
case Kind::Native:
|
||||
if (const auto cfg = repository->nativeConfig(serverId)) {
|
||||
return cfg->displayName;
|
||||
}
|
||||
break;
|
||||
case Kind::AmneziaPremiumV2:
|
||||
case Kind::AmneziaFreeV3:
|
||||
case Kind::ExternalPremium:
|
||||
if (const auto cfg = repository->apiV2Config(serverId)) {
|
||||
return cfg->displayName;
|
||||
}
|
||||
break;
|
||||
case Kind::AmneziaPremiumV1:
|
||||
case Kind::AmneziaFreeV2:
|
||||
if (const auto cfg = repository->legacyApiConfig(serverId)) {
|
||||
return cfg->displayName;
|
||||
}
|
||||
break;
|
||||
case Kind::Invalid:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
SecureServersRepository::SecureServersRepository(SecureQSettings *settings, QObject *parent)
|
||||
@@ -193,28 +153,6 @@ void SecureServersRepository::clearServers()
|
||||
syncToStorage();
|
||||
}
|
||||
|
||||
QString SecureServersRepository::nextAvailableServerName() const
|
||||
{
|
||||
QSet<QString> usedNames;
|
||||
usedNames.reserve(m_orderedServerIds.size());
|
||||
|
||||
for (const QString &serverId : m_orderedServerIds) {
|
||||
const QString displayName = storedServerDisplayName(this, serverId);
|
||||
if (!displayName.isEmpty()) {
|
||||
usedNames.insert(displayName);
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
QString candidate;
|
||||
do {
|
||||
i++;
|
||||
candidate = QStringLiteral("Server %1").arg(i);
|
||||
} while (usedNames.contains(candidate));
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
QString SecureServersRepository::addServer(const QString &serverId, const QJsonObject &serverJson, serverConfigUtils::ConfigType kind)
|
||||
{
|
||||
const QString id = normalizedOrGeneratedServerId(serverId);
|
||||
|
||||
@@ -48,8 +48,6 @@ public:
|
||||
|
||||
void clearServers();
|
||||
|
||||
QString nextAvailableServerName() const;
|
||||
|
||||
void invalidateCache();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace amnezia
|
||||
|
||||
constexpr QLatin1String dns1("dns1");
|
||||
constexpr QLatin1String dns2("dns2");
|
||||
constexpr QLatin1String dnsMode("dnsMode");
|
||||
|
||||
constexpr QLatin1String serverIndex("serverIndex");
|
||||
constexpr QLatin1String description("description");
|
||||
|
||||
@@ -26,8 +26,6 @@ set_target_properties(networkextension PROPERTIES
|
||||
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2"
|
||||
|
||||
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../../Frameworks"
|
||||
|
||||
XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION
|
||||
)
|
||||
|
||||
if(DEPLOY)
|
||||
@@ -116,20 +114,10 @@ target_include_directories(networkextension PRIVATE ${CLIENT_ROOT_DIR})
|
||||
target_include_directories(networkextension PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
find_package(openvpnadapter REQUIRED)
|
||||
# FIXME(ygurov): https://github.com/conan-io/conan/issues/20034
|
||||
set_property(TARGET amnezia::openvpnadapter APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_property(TARGET amnezia::openvpnadapter APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
|
||||
set_property(TARGET amnezia::openvpnadapter APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_property(TARGET amnezia::openvpnadapter APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
|
||||
target_link_libraries(networkextension PRIVATE amnezia::openvpnadapter)
|
||||
|
||||
find_package(awg-apple REQUIRED)
|
||||
target_link_libraries(networkextension PRIVATE amnezia::awg-apple)
|
||||
|
||||
find_package(hev-socks5-tunnel REQUIRED)
|
||||
# FIXME(ygurov): https://github.com/conan-io/conan/issues/20034
|
||||
set_property(TARGET heiher::hev-socks5-tunnel APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_property(TARGET heiher::hev-socks5-tunnel APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
|
||||
set_property(TARGET heiher::hev-socks5-tunnel APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_property(TARGET heiher::hev-socks5-tunnel APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
|
||||
target_link_libraries(networkextension PRIVATE heiher::hev-socks5-tunnel)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
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_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_CMD="cat"; LOCK_FILE="/var/run/yum.pid";\
|
||||
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;\
|
||||
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
|
||||
if which apt-get > /dev/null 2>&1 || command -v apt-get > /dev/null 2>&1; then LOCK_CMD="fuser"; LOCK_FILE="/var/lib/dpkg/lock-frontend";\
|
||||
elif which dnf > /dev/null 2>&1 || command -v 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 || command -v yum > /dev/null 2>&1; then LOCK_CMD="cat"; LOCK_FILE="/var/run/yum.pid";\
|
||||
elif which zypper > /dev/null 2>&1 || command -v zypper > /dev/null 2>&1; then LOCK_CMD="cat"; LOCK_FILE="/var/run/zypp.pid";\
|
||||
elif which pacman > /dev/null 2>&1 || command -v 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;\
|
||||
if sudo -n which $LOCK_CMD > /dev/null 2>&1 || 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,8 +1,8 @@
|
||||
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 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";\
|
||||
if pm=$(which apt-get 2>/dev/null || command -v apt-get 2>/dev/null); then opt="--version";\
|
||||
elif pm=$(which dnf 2>/dev/null || command -v dnf 2>/dev/null); then opt="--version";\
|
||||
elif pm=$(which yum 2>/dev/null || command -v yum 2>/dev/null); then opt="--version";\
|
||||
elif pm=$(which zypper 2>/dev/null || command -v zypper 2>/dev/null); then opt="--version";\
|
||||
elif pm=$(which pacman 2>/dev/null || command -v pacman 2>/dev/null); then opt="--version";\
|
||||
else pm="uname"; opt="-a";\
|
||||
fi;\
|
||||
CUR_USER=$(whoami 2>/dev/null || echo $HOME | sed 's/.*\///');\
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
sudo docker ps -a | grep amnezia | awk '{print $1}' | xargs sudo docker stop;\
|
||||
sudo docker ps -a | grep amnezia | awk '{print $1}' | xargs sudo docker rm -fv;\
|
||||
sudo docker images -a --format table | grep amnezia | awk '{print $3, $1 ":" $2}' | xargs sudo docker rmi;\
|
||||
sudo docker volume ls | grep amnezia | awk '{print $2}' | xargs sudo docker volume rm -f;\
|
||||
sudo docker network ls | grep amnezia-dns-net | awk '{print $1}' | xargs sudo docker network rm;\
|
||||
sudo rm -frd /opt/amnezia
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace PageLoader
|
||||
PageSettingsServersList,
|
||||
PageSettings,
|
||||
PageSettingsServerData,
|
||||
PageSettingsServerDns,
|
||||
PageSettingsServerInfo,
|
||||
PageSettingsServerProtocols,
|
||||
PageSettingsServerServices,
|
||||
|
||||
@@ -100,12 +100,6 @@ void ServersUiController::editServerName(const QString &serverId, const QString
|
||||
updateModel();
|
||||
}
|
||||
|
||||
void ServersUiController::editServerDns(const QString &primaryDns, const QString &secondaryDns, const int &dnsMode)
|
||||
{
|
||||
m_serversController->changeServerDns(m_processedServerId, primaryDns, secondaryDns, dnsMode);
|
||||
emit processedServerDnsModeChanged(m_processedServerId);
|
||||
}
|
||||
|
||||
void ServersUiController::setDefaultServer(const QString &serverId)
|
||||
{
|
||||
if (serverId.isEmpty()) {
|
||||
@@ -282,24 +276,6 @@ QString ServersUiController::serverHostName(const QString &serverId) const
|
||||
return serverDescriptionById(serverId).hostName;
|
||||
}
|
||||
|
||||
QVariantMap ServersUiController::getDnsPair(const QString &serverId) const
|
||||
{
|
||||
QVariantMap result;
|
||||
result["first"] = m_serversController->getDnsPair(serverId).first;
|
||||
result["second"] = m_serversController->getDnsPair(serverId).second;
|
||||
return result;
|
||||
}
|
||||
|
||||
int ServersUiController::processedServerDnsMode() const
|
||||
{
|
||||
return serverDnsMode(m_processedServerId);
|
||||
}
|
||||
|
||||
int ServersUiController::serverDnsMode(const QString &serverId) const
|
||||
{
|
||||
return m_serversController->getDnsMode(serverId);
|
||||
}
|
||||
|
||||
int ServersUiController::serverDefaultContainer(const QString &serverId) const
|
||||
{
|
||||
const auto &description = serverDescriptionById(serverId);
|
||||
|
||||
@@ -30,7 +30,6 @@ class ServersUiController : public QObject
|
||||
|
||||
Q_PROPERTY(QString processedServerId READ getProcessedServerId WRITE setProcessedServerId NOTIFY processedServerIdChanged)
|
||||
Q_PROPERTY(int processedContainerIndex READ getProcessedContainerIndex WRITE setProcessedContainerIndex NOTIFY processedContainerIndexChanged)
|
||||
Q_PROPERTY(int processedServerDnsMode READ processedServerDnsMode NOTIFY processedServerDnsModeChanged)
|
||||
Q_PROPERTY(bool processedServerIsPremium READ processedServerIsPremium NOTIFY processedServerIdChanged)
|
||||
|
||||
Q_PROPERTY(bool hasServersFromGatewayApi READ hasServersFromGatewayApi NOTIFY hasServersFromGatewayApiChanged)
|
||||
@@ -52,7 +51,6 @@ public slots:
|
||||
void removeServerAtIndex(int index);
|
||||
|
||||
void editServerName(const QString &serverId, const QString &name);
|
||||
void editServerDns(const QString &primaryDns, const QString &secondaryDns, const int &dnsMode);
|
||||
|
||||
void setDefaultServer(const QString &serverId);
|
||||
void setDefaultServerAtIndex(int index);
|
||||
@@ -76,9 +74,6 @@ public slots:
|
||||
|
||||
QString serverName(const QString &serverId) const;
|
||||
QString serverHostName(const QString &serverId) const;
|
||||
QVariantMap getDnsPair(const QString &serverId) const;
|
||||
int processedServerDnsMode() const;
|
||||
int serverDnsMode(const QString &serverId) const;
|
||||
int serverDefaultContainer(const QString &serverId) const;
|
||||
bool isServerFromApi(const QString &serverId) const;
|
||||
bool isServerCountrySelectionAvailable(const QString &serverId) const;
|
||||
@@ -116,7 +111,6 @@ signals:
|
||||
void defaultServerIdChanged(const QString &serverId);
|
||||
void processedServerIdChanged(const QString &serverId);
|
||||
void processedContainerIndexChanged(int index);
|
||||
void processedServerDnsModeChanged(const QString &serverId);
|
||||
void hasServersFromGatewayApiChanged();
|
||||
void updateApiCountryModel();
|
||||
void updateApiServicesModel();
|
||||
|
||||
@@ -120,11 +120,6 @@ bool ContainersModel::isServiceContainer(const int containerIndex)
|
||||
return qvariant_cast<ServiceType>(data(index(containerIndex), ServiceTypeRole) == ServiceType::Other);
|
||||
}
|
||||
|
||||
bool ContainersModel::isContainerInstalled(const int containerIndex)
|
||||
{
|
||||
return qvariant_cast<bool>(data(index(containerIndex), IsInstalledRole));
|
||||
}
|
||||
|
||||
bool ContainersModel::hasInstalledServices()
|
||||
{
|
||||
for (const auto &container : m_containers.keys()) {
|
||||
|
||||
@@ -71,7 +71,6 @@ public slots:
|
||||
|
||||
bool isSupportedByCurrentPlatform(const int containerIndex);
|
||||
bool isServiceContainer(const int containerIndex);
|
||||
bool isContainerInstalled(const int containerIndex);
|
||||
|
||||
bool hasInstalledServices();
|
||||
bool hasInstalledProtocols();
|
||||
|
||||
@@ -112,7 +112,7 @@ PageType {
|
||||
return
|
||||
}
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
}
|
||||
var noButtonFunction = function () {
|
||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||
|
||||
@@ -279,7 +279,7 @@ PageType {
|
||||
return
|
||||
}
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
}
|
||||
var noButtonFunction = function () {
|
||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||
|
||||
@@ -17,10 +17,6 @@ import "../Components"
|
||||
PageType {
|
||||
id: root
|
||||
|
||||
enableTimer: false
|
||||
|
||||
property bool portDirty: false
|
||||
|
||||
function formatTransport(value) {
|
||||
if (value === "raw") return "RAW (TCP)"
|
||||
if (value === "xhttp") return "XHTTP"
|
||||
@@ -43,8 +39,8 @@ PageType {
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: 20 + PageController.safeAreaTopMargin
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (backButton.enabled && backButton.activeFocus) {
|
||||
onFocusChanged: {
|
||||
if (this.activeFocus) {
|
||||
listView.positionViewAtBeginning()
|
||||
}
|
||||
}
|
||||
@@ -64,6 +60,8 @@ PageType {
|
||||
delegate: ColumnLayout {
|
||||
width: listView.width
|
||||
|
||||
property alias focusItemId: textFieldWithHeaderType.textField
|
||||
|
||||
spacing: 0
|
||||
|
||||
Text {
|
||||
@@ -109,32 +107,13 @@ PageType {
|
||||
Layout.rightMargin: 16
|
||||
enabled: listView.enabled
|
||||
headerText: qsTr("Port")
|
||||
|
||||
Binding {
|
||||
target: textFieldWithHeaderType.textField
|
||||
property: "text"
|
||||
value: port
|
||||
when: !textFieldWithHeaderType.textField.activeFocus
|
||||
restoreMode: Binding.RestoreNone
|
||||
}
|
||||
|
||||
textField.text: port
|
||||
textField.maximumLength: 5
|
||||
textField.validator: IntValidator {
|
||||
bottom: 1; top: 65535
|
||||
}
|
||||
textField.onActiveFocusChanged: {
|
||||
if (textField.activeFocus && textField.text === "" && port !== "") {
|
||||
textField.text = port
|
||||
}
|
||||
}
|
||||
textField.onTextChanged: {
|
||||
root.portDirty = (textField.text !== port)
|
||||
}
|
||||
textField.onEditingFinished: {
|
||||
if (textField.text !== port) {
|
||||
port = textField.text
|
||||
}
|
||||
root.portDirty = false
|
||||
if (textField.text !== port) port = textField.text
|
||||
}
|
||||
checkEmptyText: true
|
||||
}
|
||||
@@ -193,8 +172,9 @@ PageType {
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
visible: listView.enabled
|
||||
&& (XrayConfigModel.hasUnsavedChanges || root.portDirty)
|
||||
enabled: visible && textFieldWithHeaderType.textField.text !== ""
|
||||
&& (XrayConfigModel.hasUnsavedChanges
|
||||
|| textFieldWithHeaderType.textField.text !== port)
|
||||
enabled: visible && textFieldWithHeaderType.errorText === ""
|
||||
text: qsTr("Save")
|
||||
onClicked: function() {
|
||||
forceActiveFocus()
|
||||
|
||||
@@ -742,7 +742,7 @@ PageType {
|
||||
return
|
||||
}
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
}
|
||||
var noButtonFunction = function () {
|
||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||
|
||||
@@ -95,7 +95,7 @@ PageType {
|
||||
return
|
||||
}
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
}
|
||||
var noButtonFunction = function () {
|
||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||
|
||||
@@ -211,7 +211,7 @@ PageType {
|
||||
return
|
||||
}
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
}
|
||||
var noButtonFunction = function () {
|
||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||
|
||||
@@ -208,7 +208,7 @@ PageType {
|
||||
return
|
||||
}
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||
}
|
||||
var noButtonFunction = function () {
|
||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||
|
||||
@@ -96,7 +96,6 @@ PageType {
|
||||
|
||||
property list<QtObject> serverActions: [
|
||||
check,
|
||||
dns,
|
||||
reboot,
|
||||
remove,
|
||||
clear,
|
||||
@@ -117,33 +116,6 @@ PageType {
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: dns
|
||||
|
||||
property bool isVisible: root.isServerWithWriteAccess
|
||||
readonly property string title: qsTr("DNS server")
|
||||
function getDescription() {
|
||||
var dnsMode = ServersUiController.processedServerDnsMode
|
||||
|
||||
if (dnsMode === 0) return qsTr("DNS by default (1.1.1.1 1.0.0.1)")
|
||||
if (dnsMode === 1) return qsTr("AmneziaDNS")
|
||||
if (dnsMode === 2) {
|
||||
var dnsPair = ServersUiController.getDnsPair(ServersUiController.processedServerId)
|
||||
|
||||
return qsTr("Specified DNS (%1 %2)")
|
||||
.arg(dnsPair.first)
|
||||
.arg(dnsPair.second)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
readonly property string description: getDescription()
|
||||
readonly property var tColor: AmneziaStyle.color.paleGray
|
||||
readonly property var clickedHandler: function() {
|
||||
PageController.goToPage(PageEnum.PageSettingsServerDns)
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: reboot
|
||||
|
||||
|
||||
@@ -1,324 +0,0 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import PageEnum 1.0
|
||||
import Style 1.0
|
||||
import ContainerProps 1.0
|
||||
|
||||
import "./"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Components"
|
||||
|
||||
PageType {
|
||||
id: root
|
||||
|
||||
property int amneziaDnsIndex: ContainerProps.containerFromString("amnezia-dns")
|
||||
property int dnsMode: ServersUiController.serverDnsMode(ServersUiController.processedServerId)
|
||||
property int selectedIndex: dnsMode
|
||||
property bool dnsFieldsVisible: false
|
||||
property bool saveButtonVisible: false
|
||||
property string primaryDnsText: ServersUiController.getDnsPair(ServersUiController.processedServerId).first
|
||||
property string secondaryDnsText: ServersUiController.getDnsPair(ServersUiController.processedServerId).second
|
||||
|
||||
BackButtonType {
|
||||
id: backButton
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: 20 + PageController.safeAreaTopMargin
|
||||
|
||||
onFocusChanged: {
|
||||
if (this.activeFocus) {
|
||||
listView.positionViewAtBeginning()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListViewType {
|
||||
id: listView
|
||||
|
||||
anchors.top: backButton.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
|
||||
header: ColumnLayout {
|
||||
width: listView.width
|
||||
spacing: 16
|
||||
|
||||
BaseHeaderType {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
headerText: qsTr("DNS server")
|
||||
}
|
||||
|
||||
ParagraphTextType {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
Layout.bottomMargin: 16
|
||||
|
||||
BasicButtonType {
|
||||
id: privacyPolicyButton
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.bottomMargin: 16
|
||||
Layout.topMargin: -15
|
||||
implicitHeight: 25
|
||||
|
||||
defaultColor: AmneziaStyle.color.transparent
|
||||
hoveredColor: AmneziaStyle.color.translucentWhite
|
||||
pressedColor: AmneziaStyle.color.sheerWhite
|
||||
disabledColor: AmneziaStyle.color.mutedGray
|
||||
textColor: AmneziaStyle.color.goldenApricot
|
||||
|
||||
text: qsTr("Learn more")
|
||||
|
||||
clickedFunc: function() {
|
||||
Qt.openUrlExternally(LanguageUiController.getCurrentSiteUrl("dns"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
model: dnsList
|
||||
|
||||
ButtonGroup {
|
||||
id: dnsChoicesRadioButtonGroup
|
||||
}
|
||||
|
||||
delegate: ColumnLayout {
|
||||
id: content
|
||||
|
||||
width: listView.width
|
||||
height: content.implicitHeight
|
||||
|
||||
RowLayout {
|
||||
VerticalRadioButton {
|
||||
id: dnsChoiceRadioButton
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
|
||||
text: title
|
||||
descriptionText: description
|
||||
imageSource: "qrc:/images/controls/download.svg"
|
||||
|
||||
ButtonGroup.group: dnsChoicesRadioButtonGroup
|
||||
|
||||
checked: index === selectedIndex
|
||||
checkable: !ConnectionController.isConnected
|
||||
|
||||
onClicked: {
|
||||
if (ConnectionController.isConnectionInProgress) {
|
||||
PageController.showNotificationMessage(qsTr("Unable change dns settings while trying to make an active connection"))
|
||||
return
|
||||
}
|
||||
if (ConnectionController.isConnected) {
|
||||
PageController.showNotificationMessage(qsTr("Unable change dns settings while there is an active connection"))
|
||||
return
|
||||
}
|
||||
|
||||
if (index !== selectedIndex) {
|
||||
selectedIndex = index
|
||||
clickedHandler()
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onEnterPressed: {
|
||||
if (checkable) {
|
||||
checked = true
|
||||
}
|
||||
dnsChoiceRadioButton.clicked()
|
||||
}
|
||||
Keys.onReturnPressed: {
|
||||
if (checkable) {
|
||||
checked = true
|
||||
}
|
||||
dnsChoiceRadioButton.clicked()
|
||||
}
|
||||
}
|
||||
|
||||
BasicButtonType {
|
||||
id: removeAmneziaDnsButton
|
||||
|
||||
visible: ContainersModel.isContainerInstalled(amneziaDnsIndex) && title === "AmneziaDNS"
|
||||
|
||||
Layout.rightMargin: 32
|
||||
Layout.alignment: Qt.AlignRight
|
||||
|
||||
defaultColor: AmneziaStyle.color.midnightBlack
|
||||
hoveredColor: AmneziaStyle.color.slateGray
|
||||
pressedColor: AmneziaStyle.color.mutedGray
|
||||
|
||||
leftImageSource: image
|
||||
leftImageColor: AmneziaStyle.color.paleGray
|
||||
|
||||
clickedFunc: function() {
|
||||
ContainersModel.setProcessedContainerIndex(amneziaDnsIndex)
|
||||
|
||||
var headerText = qsTr("Remove %1 from server?").arg(ContainersModel.getProcessedContainerName())
|
||||
var yesButtonText = qsTr("Continue")
|
||||
var noButtonText = qsTr("Cancel")
|
||||
|
||||
var yesButtonFunction = function() {
|
||||
if (ServersUiController.isDefaultServerCurrentlyProcessed() && ConnectionController.isConnected && (root.dnsMode === 1)) {
|
||||
PageController.showNotificationMessage(qsTr("Cannot remove AmneziaDNS from running server"))
|
||||
} else {
|
||||
PageController.goToPage(PageEnum.PageDeinstalling)
|
||||
InstallController.removeContainer(ServersUiController.processedServerId, amneziaDnsIndex)
|
||||
}
|
||||
}
|
||||
var noButtonFunction = function() {}
|
||||
|
||||
showQuestionDrawer(headerText, "", yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DividerType {
|
||||
}
|
||||
}
|
||||
|
||||
footer: ColumnLayout {
|
||||
width: listView.width
|
||||
|
||||
TextFieldWithHeaderType {
|
||||
id: primaryDns
|
||||
|
||||
visible: root.dnsFieldsVisible
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 32
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
headerText: qsTr("Primary DNS")
|
||||
|
||||
textField.text: root.primaryDnsText
|
||||
textField.validator: RegularExpressionValidator {
|
||||
regularExpression: InstallController.ipAddressRegExp()
|
||||
}
|
||||
}
|
||||
|
||||
TextFieldWithHeaderType {
|
||||
id: secondaryDns
|
||||
|
||||
visible: root.dnsFieldsVisible
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
headerText: qsTr("Secondary DNS")
|
||||
|
||||
textField.text: root.secondaryDnsText
|
||||
textField.validator: RegularExpressionValidator {
|
||||
regularExpression: InstallController.ipAddressRegExp()
|
||||
}
|
||||
}
|
||||
|
||||
BasicButtonType {
|
||||
id: saveButton
|
||||
|
||||
visible: root.saveButtonVisible || (root.dnsMode === 1 && !ContainersModel.isContainerInstalled(amneziaDnsIndex))
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: root.dnsFieldsVisible ? 8 : 32
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
Layout.bottomMargin: 8
|
||||
|
||||
text: qsTr("Save")
|
||||
|
||||
clickedFunc: function() {
|
||||
if (!ContainersModel.isContainerInstalled(amneziaDnsIndex)) {
|
||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||
InstallController.install(amneziaDnsIndex, InstallController.getPortForInstall(ContainerProps.defaultProtocol(amneziaDnsIndex)),
|
||||
InstallController.defaultTransportProto(ContainerProps.defaultProtocol(amneziaDnsIndex)), ServersUiController.processedServerId)
|
||||
}
|
||||
|
||||
if (primaryDns.textField.text === "") {
|
||||
primaryDns.errorText = qsTr("Primary DNS cannot be empty")
|
||||
return
|
||||
}
|
||||
|
||||
primaryDns.errorText = ""
|
||||
secondaryDns.errorText = ""
|
||||
|
||||
root.saveButtonVisible = false
|
||||
root.dnsMode = root.selectedIndex
|
||||
|
||||
ServersUiController.editServerDns(primaryDns.textField.text, secondaryDns.textField.text, root.dnsMode)
|
||||
PageController.showNotificationMessage(qsTr("Settings saved"))
|
||||
}
|
||||
}
|
||||
|
||||
CaptionTextType {
|
||||
visible: !ContainersModel.isContainerInstalled(amneziaDnsIndex) && root.selectedIndex === 1
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
|
||||
text: qsTr("The AmneziaDNS service will be installed on the server")
|
||||
color: AmneziaStyle.color.mutedGray
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property list<QtObject> dnsList: [
|
||||
defaultDns,
|
||||
amneziaDns,
|
||||
specifyDns,
|
||||
]
|
||||
|
||||
QtObject {
|
||||
id: defaultDns
|
||||
|
||||
readonly property string title: qsTr("DNS by default")
|
||||
readonly property string description: qsTr("1.1.1.1 1.0.0.1")
|
||||
readonly property var clickedHandler: function() {
|
||||
root.dnsFieldsVisible = false
|
||||
root.saveButtonVisible = true
|
||||
|
||||
root.primaryDnsText = "1.1.1.1"
|
||||
root.secondaryDnsText = "1.0.0.1"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: amneziaDns
|
||||
|
||||
readonly property string title: qsTr("AmneziaDNS")
|
||||
readonly property string description: qsTr("AmneziaDNS on your server")
|
||||
readonly property string image: qsTr("qrc:/images/controls/trash.svg")
|
||||
readonly property var clickedHandler: function() {
|
||||
root.dnsFieldsVisible = false
|
||||
root.saveButtonVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: specifyDns
|
||||
|
||||
readonly property string title: qsTr("Specify DNS server address")
|
||||
readonly property var clickedHandler: function() {
|
||||
root.dnsFieldsVisible = true
|
||||
root.saveButtonVisible = true
|
||||
|
||||
var dnsPair = ServersUiController.getDnsPair(ServersUiController.processedServerId)
|
||||
if (!dnsPair) return
|
||||
|
||||
root.primaryDnsText = dnsPair.first || ""
|
||||
root.secondaryDnsText = dnsPair.second || ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,6 @@
|
||||
<file>Pages2/PageSettingsKillSwitchExceptions.qml</file>
|
||||
<file>Pages2/PageSettingsLogging.qml</file>
|
||||
<file>Pages2/PageSettingsServerData.qml</file>
|
||||
<file>Pages2/PageSettingsServerDns.qml</file>
|
||||
<file>Pages2/PageSettingsServerInfo.qml</file>
|
||||
<file>Pages2/PageSettingsServerProtocol.qml</file>
|
||||
<file>Pages2/PageSettingsServerProtocols.qml</file>
|
||||
|
||||
@@ -20,7 +20,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
set(_CONAN_INSTALL_ARGS
|
||||
"-c=tools.android:cmake_legacy_toolchain=false"
|
||||
"-c=tools.build:sharedlinkflags=['-Wl,-z,max-page-size=16384']"
|
||||
"-c=tools.build:exelinkflags=['-Wl,-z,max-page-size=16384']")
|
||||
"-c=tools.build:exelinkflags=['-Wl,-z,max-page-size=16384']"
|
||||
"-o=openssl/*:shared=True")
|
||||
set(CMAKE_ANDROID_STL_TYPE "c++_shared" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
@@ -28,12 +29,6 @@ if (WIN32 OR APPLE)
|
||||
set(CMAKE_INSTALL_BINDIR ".")
|
||||
endif()
|
||||
|
||||
# Apple NE-based apps do not support any dylibs or variations
|
||||
# So Qt would use the openssl bundled with system, not application
|
||||
if (NOT(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR (APPLE AND MACOS_NE)))
|
||||
list(APPEND _CONAN_INSTALL_ARGS "-o=openssl/*:shared=True")
|
||||
endif()
|
||||
|
||||
list(PREPEND _CONAN_INSTALL_ARGS "--build=missing")
|
||||
list(JOIN _CONAN_INSTALL_ARGS ";" _CONAN_INSTALL_ARGS_JOINED)
|
||||
set(CONAN_INSTALL_ARGS ${_CONAN_INSTALL_ARGS_JOINED} CACHE STRING "" FORCE)
|
||||
|
||||
@@ -5,7 +5,6 @@ from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.scm import Git
|
||||
from conan.internal.model.pkg_type import PackageType
|
||||
from conan.tools.files import chdir
|
||||
from conan.tools.apple import XCRun
|
||||
|
||||
import os
|
||||
import shutil
|
||||
@@ -50,10 +49,7 @@ class OpenVPNAdapter(ConanFile):
|
||||
|
||||
def build(self):
|
||||
with chdir(self, self.source_folder):
|
||||
xcrun = XCRun(self)
|
||||
|
||||
xcodebuild = xcrun.find("xcodebuild")
|
||||
self.run(f"{xcodebuild}"
|
||||
self.run("xcrun xcodebuild"
|
||||
" -project OpenVPNAdapter.xcodeproj"
|
||||
" -scheme OpenVPNAdapter"
|
||||
" -configuration Release"
|
||||
@@ -61,20 +57,10 @@ class OpenVPNAdapter(ConanFile):
|
||||
f" -sdk {self._sdk}"
|
||||
f' "CONFIGURATION_BUILD_DIR={self.build_folder}"'
|
||||
f' "BUILT_PRODUCTS_DIR={self.build_folder}"'
|
||||
" MACH_O_TYPE=staticlib"
|
||||
" BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
|
||||
" CODE_SIGNING_ALLOWED=NO"
|
||||
)
|
||||
|
||||
openvpnadapter = os.path.join(self.build_folder, "OpenVPNAdapter.framework", "OpenVPNAdapter")
|
||||
self.run(f"{xcrun.libtool} -static -o"
|
||||
f" {openvpnadapter}"
|
||||
f" {openvpnadapter}"
|
||||
f' {os.path.join(self.build_folder, "OpenVPNClient.framework", "OpenVPNClient")}'
|
||||
f' {os.path.join(self.build_folder, "LZ4.framework", "LZ4")}'
|
||||
f' {os.path.join(self.build_folder, "mbedTLS.framework", "mbedTLS")}'
|
||||
)
|
||||
|
||||
def package(self):
|
||||
shutil.copytree(os.path.join(self.build_folder, "OpenVPNAdapter.framework"),
|
||||
os.path.join(self.package_folder, "OpenVPNAdapter.framework"))
|
||||
@@ -84,4 +70,3 @@ class OpenVPNAdapter(ConanFile):
|
||||
self.cpp_info.type = PackageType.STATIC
|
||||
self.cpp_info.package_framework = True
|
||||
self.cpp_info.location = os.path.join(self.package_folder, "OpenVPNAdapter.framework")
|
||||
self.cpp_info.frameworks = ["SystemConfiguration"]
|
||||
|
||||
@@ -316,9 +316,12 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(${PROJECT} PROPERTIES
|
||||
INSTALL_RPATH "@executable_path/../Frameworks"
|
||||
)
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set_target_properties(${PROJECT} PROPERTIES
|
||||
INSTALL_RPATH "@executable_path/../Frameworks"
|
||||
BUILD_WITH_INSTALL_RPATH TRUE
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(FW_COREFOUNDATION CoreFoundation)
|
||||
find_library(FW_SYSTEMCONFIG SystemConfiguration)
|
||||
@@ -425,32 +428,11 @@ endif()
|
||||
# install target
|
||||
install(TARGETS ${PROJECT}
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
RUNTIME_DEPENDENCY_SET service_deps
|
||||
COMPONENT AmneziaVPN
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
set(RUNTIME_DEPS_DIR ${CMAKE_INSTALL_BINDIR}/../Frameworks)
|
||||
else()
|
||||
set(RUNTIME_DEPS_DIR ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
||||
install(RUNTIME_DEPENDENCY_SET service_deps
|
||||
PRE_EXCLUDE_REGEXES
|
||||
[[api-ms-win-.*]]
|
||||
[[ext-ms-.*]]
|
||||
[[kernel32\.dll]]
|
||||
[[hvsifiletrust\.dll]]
|
||||
[[libc\.so\..*]] [[libgcc_s\.so\..*]] [[libm\.so\..*]] [[libstdc\+\+\.so\..*]]
|
||||
[[.*\.framework]]
|
||||
[[^[Qq]t.*]]
|
||||
POST_EXCLUDE_REGEXES
|
||||
[[^.*[\\/]system32[\\/].*\.dll$]]
|
||||
[[^/lib.*]]
|
||||
[[^/usr/lib.*]]
|
||||
DIRECTORIES ${CONAN_RUNTIME_LIB_DIRS}
|
||||
install(FILES $<TARGET_RUNTIME_DLLS:${PROJECT}>
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT AmneziaVPN
|
||||
DESTINATION "${RUNTIME_DEPS_DIR}"
|
||||
)
|
||||
|
||||
qt_generate_deploy_app_script(
|
||||
|
||||
Reference in New Issue
Block a user