mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-24 02:00:24 +07:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b96cfec8c | |||
| 657b0fd60c | |||
| 1be22a3051 | |||
| 594635e5cf | |||
| f9b106cf5b | |||
| a9861d18b7 | |||
| c14138f031 | |||
| 60686fde24 | |||
| bd0747296e | |||
| ba61019a50 | |||
| 113f967006 |
@@ -23,6 +23,9 @@ jobs:
|
|||||||
- 'recipes/**'
|
- 'recipes/**'
|
||||||
- 'conanfile.py'
|
- 'conanfile.py'
|
||||||
- '.github/workflows/deploy.yml'
|
- '.github/workflows/deploy.yml'
|
||||||
|
- 'cmake/conan_provider.cmake'
|
||||||
|
- 'cmake/platform_settings.cmake'
|
||||||
|
- 'cmake/recipes_bootstrap.cmake'
|
||||||
|
|
||||||
Bake-Prebuilts-Linux:
|
Bake-Prebuilts-Linux:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
+4
-4
@@ -4,7 +4,7 @@ set(CMAKE_CXX_STANDARD 17)
|
|||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
set(PROJECT AmneziaVPN)
|
set(PROJECT AmneziaVPN)
|
||||||
set(AMNEZIAVPN_VERSION 4.9.0.1)
|
set(AMNEZIAVPN_VERSION 4.9.0.2)
|
||||||
|
|
||||||
set(QT_CREATOR_SKIP_PACKAGE_MANAGER_SETUP ON CACHE BOOL "" FORCE)
|
set(QT_CREATOR_SKIP_PACKAGE_MANAGER_SETUP ON CACHE BOOL "" FORCE)
|
||||||
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES
|
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES
|
||||||
@@ -18,9 +18,9 @@ project(${PROJECT} VERSION ${AMNEZIAVPN_VERSION}
|
|||||||
HOMEPAGE_URL "https://amnezia.org/"
|
HOMEPAGE_URL "https://amnezia.org/"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# trigger conan to kick off `conan install` globally
|
||||||
|
find_package(OpenSSL REQUIRED)
|
||||||
if (PREBUILTS_ONLY)
|
if (PREBUILTS_ONLY)
|
||||||
# trigger conan to kick off `conan install`
|
|
||||||
find_package(OpenSSL REQUIRED)
|
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
|
|||||||
set(RELEASE_DATE "${CURRENT_DATE}")
|
set(RELEASE_DATE "${CURRENT_DATE}")
|
||||||
|
|
||||||
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
|
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
|
||||||
set(APP_ANDROID_VERSION_CODE 2122)
|
set(APP_ANDROID_VERSION_CODE 2123)
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||||
set(MZ_PLATFORM_NAME "linux")
|
set(MZ_PLATFORM_NAME "linux")
|
||||||
|
|||||||
+23
-2
@@ -212,11 +212,32 @@ endif()
|
|||||||
|
|
||||||
install(TARGETS ${PROJECT}
|
install(TARGETS ${PROJECT}
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
RUNTIME_DEPENDENCY_SET client_deps
|
||||||
COMPONENT AmneziaVPN
|
COMPONENT AmneziaVPN
|
||||||
)
|
)
|
||||||
install(FILES $<TARGET_RUNTIME_DLLS:${PROJECT}>
|
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
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}
|
||||||
COMPONENT AmneziaVPN
|
COMPONENT AmneziaVPN
|
||||||
|
DESTINATION "${RUNTIME_DEPS_DIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
set(deploy_tool_options "")
|
set(deploy_tool_options "")
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ target_include_directories(${PROJECT} PRIVATE ${Qt6Gui_PRIVATE_INCLUDE_DIRS})
|
|||||||
|
|
||||||
|
|
||||||
set_target_properties(${PROJECT} PROPERTIES
|
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_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/ios/app/Info.plist.in
|
||||||
MACOSX_BUNDLE_ICON_FILE "AppIcon"
|
MACOSX_BUNDLE_ICON_FILE "AppIcon"
|
||||||
MACOSX_BUNDLE_INFO_STRING "AmneziaVPN"
|
MACOSX_BUNDLE_INFO_STRING "AmneziaVPN"
|
||||||
|
|||||||
@@ -49,14 +49,92 @@ void ConnectionController::setConnectionState(Vpn::ConnectionState state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode ConnectionController::prepareConnection(const QString &serverId,
|
ErrorCode ConnectionController::defaultContainerForServer(const QString &serverId, DockerContainer &container) const
|
||||||
QJsonObject& vpnConfiguration,
|
|
||||||
DockerContainer& container)
|
|
||||||
{
|
{
|
||||||
|
const auto kind = m_serversRepository->serverKind(serverId);
|
||||||
|
switch (kind) {
|
||||||
|
case serverConfigUtils::ConfigType::SelfHostedAdmin: {
|
||||||
|
const auto cfg = m_serversRepository->selfHostedAdminConfig(serverId);
|
||||||
|
if (!cfg.has_value()) {
|
||||||
|
return ErrorCode::InternalError;
|
||||||
|
}
|
||||||
|
container = cfg->defaultContainer;
|
||||||
|
return ErrorCode::NoError;
|
||||||
|
}
|
||||||
|
case serverConfigUtils::ConfigType::SelfHostedUser: {
|
||||||
|
const auto cfg = m_serversRepository->selfHostedUserConfig(serverId);
|
||||||
|
if (!cfg.has_value()) {
|
||||||
|
return ErrorCode::InternalError;
|
||||||
|
}
|
||||||
|
container = cfg->defaultContainer;
|
||||||
|
return ErrorCode::NoError;
|
||||||
|
}
|
||||||
|
case serverConfigUtils::ConfigType::Native: {
|
||||||
|
const auto cfg = m_serversRepository->nativeConfig(serverId);
|
||||||
|
if (!cfg.has_value()) {
|
||||||
|
return ErrorCode::InternalError;
|
||||||
|
}
|
||||||
|
container = cfg->defaultContainer;
|
||||||
|
return ErrorCode::NoError;
|
||||||
|
}
|
||||||
|
case serverConfigUtils::ConfigType::AmneziaPremiumV2:
|
||||||
|
case serverConfigUtils::ConfigType::AmneziaFreeV3:
|
||||||
|
case serverConfigUtils::ConfigType::ExternalPremium: {
|
||||||
|
const auto cfg = m_serversRepository->apiV2Config(serverId);
|
||||||
|
if (!cfg.has_value()) {
|
||||||
|
return ErrorCode::InternalError;
|
||||||
|
}
|
||||||
|
container = cfg->defaultContainer;
|
||||||
|
return ErrorCode::NoError;
|
||||||
|
}
|
||||||
|
case serverConfigUtils::ConfigType::AmneziaPremiumV1:
|
||||||
|
case serverConfigUtils::ConfigType::AmneziaFreeV2:
|
||||||
|
return ErrorCode::LegacyApiV1NotSupportedError;
|
||||||
|
case serverConfigUtils::ConfigType::Invalid:
|
||||||
|
default:
|
||||||
|
return ErrorCode::InternalError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode ConnectionController::isConnectionSupported(const QString &serverId) const
|
||||||
|
{
|
||||||
|
if (serverId.isEmpty()) {
|
||||||
|
return ErrorCode::InternalError;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isServiceReady()) {
|
if (!isServiceReady()) {
|
||||||
return ErrorCode::AmneziaServiceNotRunning;
|
return ErrorCode::AmneziaServiceNotRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serverConfigUtils::isLegacyApiSubscription(m_serversRepository->serverKind(serverId))) {
|
||||||
|
return ErrorCode::LegacyApiV1NotSupportedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
DockerContainer container = DockerContainer::None;
|
||||||
|
const ErrorCode errorCode = defaultContainerForServer(serverId, container);
|
||||||
|
if (errorCode != ErrorCode::NoError) {
|
||||||
|
return errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (container == DockerContainer::None) {
|
||||||
|
return ErrorCode::NoInstalledContainersError;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ContainerUtils::isUnsupportedContainer(container)) {
|
||||||
|
return ErrorCode::LegacyContainerNotSupportedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isContainerSupported(container)) {
|
||||||
|
return ErrorCode::NotSupportedOnThisPlatform;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrorCode::NoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode ConnectionController::prepareConnection(const QString &serverId,
|
||||||
|
QJsonObject& vpnConfiguration,
|
||||||
|
DockerContainer& container)
|
||||||
|
{
|
||||||
ContainerConfig containerConfigModel;
|
ContainerConfig containerConfigModel;
|
||||||
QPair<QString, QString> dns;
|
QPair<QString, QString> dns;
|
||||||
QString hostName;
|
QString hostName;
|
||||||
@@ -120,10 +198,6 @@ ErrorCode ConnectionController::prepareConnection(const QString &serverId,
|
|||||||
return ErrorCode::InternalError;
|
return ErrorCode::InternalError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isContainerSupported(container)) {
|
|
||||||
return ErrorCode::NotSupportedOnThisPlatform;
|
|
||||||
}
|
|
||||||
|
|
||||||
vpnConfiguration = createConnectionConfiguration(dns, isApiConfig, hostName, description, configVersion,
|
vpnConfiguration = createConnectionConfiguration(dns, isApiConfig, hostName, description, configVersion,
|
||||||
containerConfigModel, container);
|
containerConfigModel, container);
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ public:
|
|||||||
QJsonObject& vpnConfiguration,
|
QJsonObject& vpnConfiguration,
|
||||||
DockerContainer& container);
|
DockerContainer& container);
|
||||||
|
|
||||||
|
ErrorCode isConnectionSupported(const QString &serverId) const;
|
||||||
|
|
||||||
ErrorCode openConnection(const QString &serverId);
|
ErrorCode openConnection(const QString &serverId);
|
||||||
|
|
||||||
void closeConnection();
|
void closeConnection();
|
||||||
@@ -73,6 +75,8 @@ signals:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ErrorCode defaultContainerForServer(const QString &serverId, DockerContainer &container) const;
|
||||||
|
|
||||||
SecureServersRepository* m_serversRepository;
|
SecureServersRepository* m_serversRepository;
|
||||||
SecureAppSettingsRepository* m_appSettingsRepository;
|
SecureAppSettingsRepository* m_appSettingsRepository;
|
||||||
VpnConnection* m_vpnConnection;
|
VpnConnection* m_vpnConnection;
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ void CoreController::initControllers()
|
|||||||
m_languageUiController = new LanguageUiController(m_settingsController, m_languageModel, this);
|
m_languageUiController = new LanguageUiController(m_settingsController, m_languageModel, this);
|
||||||
setQmlContextProperty("LanguageUiController", m_languageUiController);
|
setQmlContextProperty("LanguageUiController", m_languageUiController);
|
||||||
|
|
||||||
m_settingsUiController = new SettingsUiController(m_settingsController, m_serversController, m_languageUiController, this);
|
m_settingsUiController = new SettingsUiController(m_settingsController, m_serversController, this);
|
||||||
setQmlContextProperty("SettingsController", m_settingsUiController);
|
setQmlContextProperty("SettingsController", m_settingsUiController);
|
||||||
|
|
||||||
m_pageController = new PageController(m_serversController, m_settingsController, this);
|
m_pageController = new PageController(m_serversController, m_settingsController, this);
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "core/controllers/connectionController.h"
|
#include "core/controllers/connectionController.h"
|
||||||
#include "ui/models/clientManagementModel.h"
|
#include "ui/models/clientManagementModel.h"
|
||||||
#include "ui/controllers/api/apiNewsUiController.h"
|
#include "ui/controllers/api/apiNewsUiController.h"
|
||||||
#include "ui/models/api/apiCountryModel.h"
|
|
||||||
#include "ui/models/containersModel.h"
|
#include "ui/models/containersModel.h"
|
||||||
#include "core/utils/containerEnum.h"
|
#include "core/utils/containerEnum.h"
|
||||||
|
|
||||||
@@ -156,8 +155,11 @@ void CoreSignalHandlers::initExportControllerHandler()
|
|||||||
void CoreSignalHandlers::initImportControllerHandler()
|
void CoreSignalHandlers::initImportControllerHandler()
|
||||||
{
|
{
|
||||||
connect(m_coreController->m_importCoreController, &ImportController::importFinished, this, [this]() {
|
connect(m_coreController->m_importCoreController, &ImportController::importFinished, this, [this]() {
|
||||||
if (!m_coreController->m_connectionController->isConnected()) {
|
if (m_coreController->m_connectionUiController->isConnected()) {
|
||||||
int newServerIndex = m_coreController->m_serversController->getServersCount() - 1;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int newServerIndex = m_coreController->m_serversController->getServersCount() - 1;
|
||||||
const QString serverId = m_coreController->m_serversController->getServerId(newServerIndex);
|
const QString serverId = m_coreController->m_serversController->getServerId(newServerIndex);
|
||||||
if (!serverId.isEmpty()) {
|
if (!serverId.isEmpty()) {
|
||||||
m_coreController->m_serversController->setDefaultServer(serverId);
|
m_coreController->m_serversController->setDefaultServer(serverId);
|
||||||
@@ -165,7 +167,6 @@ void CoreSignalHandlers::initImportControllerHandler()
|
|||||||
if (m_coreController->m_serversUiController) {
|
if (m_coreController->m_serversUiController) {
|
||||||
m_coreController->m_serversUiController->setProcessedServerId(serverId);
|
m_coreController->m_serversUiController->setProcessedServerId(serverId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,16 +178,13 @@ void CoreSignalHandlers::initApiCountryModelUpdateHandler()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray availableCountries;
|
|
||||||
QString serverCountryCode;
|
|
||||||
|
|
||||||
const auto apiV2 = m_coreController->m_serversRepository->apiV2Config(processedServerId);
|
const auto apiV2 = m_coreController->m_serversRepository->apiV2Config(processedServerId);
|
||||||
if (apiV2.has_value()) {
|
if (!apiV2.has_value()) {
|
||||||
availableCountries = apiV2->apiConfig.availableCountries;
|
return;
|
||||||
serverCountryCode = apiV2->apiConfig.serverCountryCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_coreController->m_apiCountryModel->updateModel(availableCountries, serverCountryCode);
|
m_coreController->m_apiCountryModel->updateModel(apiV2->apiConfig.availableCountries,
|
||||||
|
apiV2->apiConfig.serverCountryCode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,13 +235,16 @@ void CoreSignalHandlers::initLanguageHandler()
|
|||||||
connect(m_coreController->m_settingsUiController, &SettingsUiController::resetLanguageToSystem, m_coreController->m_languageUiController, [this]() {
|
connect(m_coreController->m_settingsUiController, &SettingsUiController::resetLanguageToSystem, m_coreController->m_languageUiController, [this]() {
|
||||||
m_coreController->m_languageUiController->changeLanguage(m_coreController->m_languageUiController->getSystemLanguageEnum());
|
m_coreController->m_languageUiController->changeLanguage(m_coreController->m_languageUiController->getSystemLanguageEnum());
|
||||||
});
|
});
|
||||||
|
connect(m_coreController->m_settingsUiController, &SettingsUiController::appLanguageChanged, m_coreController->m_languageUiController, [this]() {
|
||||||
|
m_coreController->m_languageUiController->onAppLanguageChanged(m_coreController->m_settingsController->getAppLanguage());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreSignalHandlers::initAutoConnectHandler()
|
void CoreSignalHandlers::initAutoConnectHandler()
|
||||||
{
|
{
|
||||||
if (m_coreController->m_settingsUiController->isAutoConnectEnabled()
|
if (m_coreController->m_settingsUiController->isAutoConnectEnabled()
|
||||||
&& !m_coreController->m_serversController->getDefaultServerId().isEmpty()) {
|
&& !m_coreController->m_serversController->getDefaultServerId().isEmpty()) {
|
||||||
QTimer::singleShot(1000, this, [this]() { m_coreController->m_connectionUiController->openConnection(); });
|
QTimer::singleShot(1000, this, [this]() { m_coreController->m_connectionUiController->toggleConnection(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,6 +349,9 @@ void CoreSignalHandlers::initUnsupportedConnectDrawerHandler()
|
|||||||
{
|
{
|
||||||
connect(m_coreController->m_subscriptionUiController, &SubscriptionUiController::unsupportedConnectDrawerRequested,
|
connect(m_coreController->m_subscriptionUiController, &SubscriptionUiController::unsupportedConnectDrawerRequested,
|
||||||
m_coreController->m_pageController, &PageController::unsupportedConnectDrawerRequested);
|
m_coreController->m_pageController, &PageController::unsupportedConnectDrawerRequested);
|
||||||
|
|
||||||
|
connect(m_coreController->m_connectionUiController, &ConnectionUiController::unsupportedConnectDrawerRequested,
|
||||||
|
m_coreController->m_pageController, &PageController::unsupportedConnectDrawerRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreSignalHandlers::initStrictKillSwitchHandler()
|
void CoreSignalHandlers::initStrictKillSwitchHandler()
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ QJsonObject ImportController::extractOpenVpnConfig(const QString &data) const
|
|||||||
QJsonObject config;
|
QJsonObject config;
|
||||||
config[configKey::containers] = arr;
|
config[configKey::containers] = arr;
|
||||||
config[configKey::defaultContainer] = configKey::amneziaOpenvpn;
|
config[configKey::defaultContainer] = configKey::amneziaOpenvpn;
|
||||||
config[configKey::description] = m_appSettingsRepository->nextAvailableServerName();
|
config[configKey::description] = m_serversRepository->nextAvailableServerName();
|
||||||
|
|
||||||
const static QRegularExpression dnsRegExp("dhcp-option DNS (\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b)");
|
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);
|
QRegularExpressionMatchIterator dnsMatch = dnsRegExp.globalMatch(data);
|
||||||
@@ -645,7 +645,7 @@ QJsonObject ImportController::extractWireGuardConfig(const QString &data, Config
|
|||||||
QJsonObject config;
|
QJsonObject config;
|
||||||
config[configKey::containers] = arr;
|
config[configKey::containers] = arr;
|
||||||
config[configKey::defaultContainer] = containerName;
|
config[configKey::defaultContainer] = containerName;
|
||||||
config[configKey::description] = m_appSettingsRepository->nextAvailableServerName();
|
config[configKey::description] = m_serversRepository->nextAvailableServerName();
|
||||||
|
|
||||||
const static QRegularExpression dnsRegExp(
|
const static QRegularExpression dnsRegExp(
|
||||||
"DNS = "
|
"DNS = "
|
||||||
@@ -699,7 +699,7 @@ QJsonObject ImportController::extractXrayConfig(const QString &data, ConfigTypes
|
|||||||
? configKey::amneziaSsxray
|
? configKey::amneziaSsxray
|
||||||
: configKey::amneziaXray;
|
: configKey::amneziaXray;
|
||||||
if (description.isEmpty()) {
|
if (description.isEmpty()) {
|
||||||
config[configKey::description] = m_appSettingsRepository->nextAvailableServerName();
|
config[configKey::description] = m_serversRepository->nextAvailableServerName();
|
||||||
} else {
|
} else {
|
||||||
config[configKey::description] = description;
|
config[configKey::description] = description;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,16 @@ namespace
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString buildRemoveContainerScript(const amnezia::ScriptVars &vars, bool removeDataVolume)
|
||||||
|
{
|
||||||
|
QString script = SshSession::replaceVars(amnezia::scriptData(SharedScriptType::remove_container), vars);
|
||||||
|
if (removeDataVolume) {
|
||||||
|
script += QLatin1String("\nsudo docker volume rm -f $CONTAINER_NAME-data 2>/dev/null || true");
|
||||||
|
script = SshSession::replaceVars(script, vars);
|
||||||
|
}
|
||||||
|
return script;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallController::InstallController(SecureServersRepository *serversRepository,
|
InstallController::InstallController(SecureServersRepository *serversRepository,
|
||||||
@@ -120,14 +130,10 @@ ErrorCode InstallController::setupContainer(const ServerCredentials &credentials
|
|||||||
return e;
|
return e;
|
||||||
qDebug().noquote() << "InstallController::setupContainer prepareHostWorker finished";
|
qDebug().noquote() << "InstallController::setupContainer prepareHostWorker finished";
|
||||||
|
|
||||||
amnezia::ScriptVars removeContainerVars =
|
const amnezia::ScriptVars removeContainerVars =
|
||||||
amnezia::genBaseVars(credentials, container, QString(), QString());
|
amnezia::genBaseVars(credentials, container, QString(), QString());
|
||||||
if (!isUpdate) {
|
const bool removeDataVolume = !isUpdate && (container == DockerContainer::MtProxy || container == DockerContainer::Telemt);
|
||||||
removeContainerVars.append({ { "$REMOVE_CONTAINER_DATA", QStringLiteral("1") } });
|
sshSession.runScript(credentials, buildRemoveContainerScript(removeContainerVars, removeDataVolume));
|
||||||
}
|
|
||||||
sshSession.runScript(credentials,
|
|
||||||
sshSession.replaceVars(amnezia::scriptData(SharedScriptType::remove_container),
|
|
||||||
removeContainerVars));
|
|
||||||
qDebug().noquote() << "InstallController::setupContainer removeContainer finished";
|
qDebug().noquote() << "InstallController::setupContainer removeContainer finished";
|
||||||
|
|
||||||
qDebug().noquote() << "buildContainerWorker start";
|
qDebug().noquote() << "buildContainerWorker start";
|
||||||
@@ -152,7 +158,7 @@ ErrorCode InstallController::setupContainer(const ServerCredentials &credentials
|
|||||||
return startupContainerWorker(credentials, container, config, sshSession);
|
return startupContainerWorker(credentials, container, config, sshSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode InstallController::updateContainer(const QString &serverId, DockerContainer container, const ContainerConfig &oldConfig,
|
ErrorCode InstallController::updateServerConfig(const QString &serverId, DockerContainer container, const ContainerConfig &oldConfig,
|
||||||
ContainerConfig &newConfig)
|
ContainerConfig &newConfig)
|
||||||
{
|
{
|
||||||
if (!isUpdateDockerContainerRequired(container, oldConfig, newConfig)) {
|
if (!isUpdateDockerContainerRequired(container, oldConfig, newConfig)) {
|
||||||
@@ -185,7 +191,7 @@ ErrorCode InstallController::updateContainer(const QString &serverId, DockerCont
|
|||||||
SshSession sshSession(this);
|
SshSession sshSession(this);
|
||||||
|
|
||||||
bool reinstallRequired = isReinstallContainerRequired(container, oldConfig, newConfig);
|
bool reinstallRequired = isReinstallContainerRequired(container, oldConfig, newConfig);
|
||||||
qDebug() << "InstallController::updateContainer for container" << container << "reinstall required is" << reinstallRequired;
|
qDebug() << "InstallController::updateServerConfig for container" << container << "reinstall required is" << reinstallRequired;
|
||||||
|
|
||||||
bool xrayServerSettingsChanged = false;
|
bool xrayServerSettingsChanged = false;
|
||||||
if (container == DockerContainer::Xray || container == DockerContainer::SSXray) {
|
if (container == DockerContainer::Xray || container == DockerContainer::SSXray) {
|
||||||
@@ -213,11 +219,11 @@ ErrorCode InstallController::updateContainer(const QString &serverId, DockerCont
|
|||||||
if (errorCode == ErrorCode::NoError && xrayServerSettingsChanged && !skipXrayInboundSync) {
|
if (errorCode == ErrorCode::NoError && xrayServerSettingsChanged && !skipXrayInboundSync) {
|
||||||
DnsSettings dnsSettings = { m_appSettingsRepository->primaryDns(), m_appSettingsRepository->secondaryDns() };
|
DnsSettings dnsSettings = { m_appSettingsRepository->primaryDns(), m_appSettingsRepository->secondaryDns() };
|
||||||
XrayConfigurator xrayConfigurator(&sshSession);
|
XrayConfigurator xrayConfigurator(&sshSession);
|
||||||
qDebug() << "InstallController::updateContainer applying Xray server inbound sync, reinstall="
|
qDebug() << "InstallController::updateServerConfig applying Xray server inbound sync, reinstall="
|
||||||
<< reinstallRequired;
|
<< reinstallRequired;
|
||||||
errorCode = xrayConfigurator.applyServerSettingsToRemote(credentials, container, newConfig, dnsSettings, false);
|
errorCode = xrayConfigurator.applyServerSettingsToRemote(credentials, container, newConfig, dnsSettings, false);
|
||||||
if (errorCode != ErrorCode::NoError) {
|
if (errorCode != ErrorCode::NoError) {
|
||||||
qDebug() << "InstallController::updateContainer Xray inbound sync failed, error="
|
qDebug() << "InstallController::updateServerConfig Xray inbound sync failed, error="
|
||||||
<< static_cast<int>(errorCode);
|
<< static_cast<int>(errorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,6 +242,41 @@ ErrorCode InstallController::updateContainer(const QString &serverId, DockerCont
|
|||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorCode InstallController::updateClientConfig(const QString &serverId, DockerContainer container, ContainerConfig &newConfig)
|
||||||
|
{
|
||||||
|
switch (m_serversRepository->serverKind(serverId)) {
|
||||||
|
case serverConfigUtils::ConfigType::SelfHostedAdmin: {
|
||||||
|
auto config = m_serversRepository->selfHostedAdminConfig(serverId);
|
||||||
|
if (!config.has_value()) {
|
||||||
|
return ErrorCode::InternalError;
|
||||||
|
}
|
||||||
|
config->updateContainerConfig(container, newConfig);
|
||||||
|
m_serversRepository->editServer(serverId, config->toJson(), serverConfigUtils::ConfigType::SelfHostedAdmin);
|
||||||
|
return ErrorCode::NoError;
|
||||||
|
}
|
||||||
|
case serverConfigUtils::ConfigType::SelfHostedUser: {
|
||||||
|
auto config = m_serversRepository->selfHostedUserConfig(serverId);
|
||||||
|
if (!config.has_value()) {
|
||||||
|
return ErrorCode::InternalError;
|
||||||
|
}
|
||||||
|
config->updateContainerConfig(container, newConfig);
|
||||||
|
m_serversRepository->editServer(serverId, config->toJson(), serverConfigUtils::ConfigType::SelfHostedUser);
|
||||||
|
return ErrorCode::NoError;
|
||||||
|
}
|
||||||
|
case serverConfigUtils::ConfigType::Native: {
|
||||||
|
auto config = m_serversRepository->nativeConfig(serverId);
|
||||||
|
if (!config.has_value()) {
|
||||||
|
return ErrorCode::InternalError;
|
||||||
|
}
|
||||||
|
config->updateContainerConfig(container, newConfig);
|
||||||
|
m_serversRepository->editServer(serverId, config->toJson(), serverConfigUtils::ConfigType::Native);
|
||||||
|
return ErrorCode::NoError;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return ErrorCode::InternalError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InstallController::clearCachedProfile(const QString &serverId, DockerContainer container)
|
void InstallController::clearCachedProfile(const QString &serverId, DockerContainer container)
|
||||||
{
|
{
|
||||||
if (ContainerUtils::containerService(container) == ServiceType::Other) {
|
if (ContainerUtils::containerService(container) == ServiceType::Other) {
|
||||||
@@ -358,7 +399,7 @@ void InstallController::addEmptyServer(const ServerCredentials &credentials)
|
|||||||
serverConfig.userName = credentials.userName;
|
serverConfig.userName = credentials.userName;
|
||||||
serverConfig.password = credentials.secretData;
|
serverConfig.password = credentials.secretData;
|
||||||
serverConfig.port = credentials.port;
|
serverConfig.port = credentials.port;
|
||||||
serverConfig.description = m_appSettingsRepository->nextAvailableServerName();
|
serverConfig.description = m_serversRepository->nextAvailableServerName();
|
||||||
serverConfig.displayName = serverConfig.description.isEmpty() ? serverConfig.hostName : serverConfig.description;
|
serverConfig.displayName = serverConfig.description.isEmpty() ? serverConfig.hostName : serverConfig.description;
|
||||||
serverConfig.defaultContainer = DockerContainer::None;
|
serverConfig.defaultContainer = DockerContainer::None;
|
||||||
|
|
||||||
@@ -980,12 +1021,11 @@ ErrorCode InstallController::removeContainer(const QString &serverId, DockerCont
|
|||||||
return ErrorCode::InternalError;
|
return ErrorCode::InternalError;
|
||||||
}
|
}
|
||||||
SshSession sshSession(this);
|
SshSession sshSession(this);
|
||||||
amnezia::ScriptVars removeContainerVars =
|
const amnezia::ScriptVars removeContainerVars =
|
||||||
amnezia::genBaseVars(credentials, container, QString(), QString());
|
amnezia::genBaseVars(credentials, container, QString(), QString());
|
||||||
removeContainerVars.append({ { "$REMOVE_CONTAINER_DATA", QStringLiteral("1") } });
|
const bool removeDataVolume = (container == DockerContainer::MtProxy || container == DockerContainer::Telemt);
|
||||||
ErrorCode errorCode = sshSession.runScript(
|
ErrorCode errorCode =
|
||||||
credentials,
|
sshSession.runScript(credentials, buildRemoveContainerScript(removeContainerVars, removeDataVolume));
|
||||||
sshSession.replaceVars(amnezia::scriptData(SharedScriptType::remove_container), removeContainerVars));
|
|
||||||
|
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
QMap<DockerContainer, ContainerConfig> containers = adminConfig->containers;
|
QMap<DockerContainer, ContainerConfig> containers = adminConfig->containers;
|
||||||
@@ -1170,7 +1210,7 @@ ErrorCode InstallController::installServer(const ServerCredentials &credentials,
|
|||||||
serverConfig.userName = credentials.userName;
|
serverConfig.userName = credentials.userName;
|
||||||
serverConfig.password = credentials.secretData;
|
serverConfig.password = credentials.secretData;
|
||||||
serverConfig.port = credentials.port;
|
serverConfig.port = credentials.port;
|
||||||
serverConfig.description = m_appSettingsRepository->nextAvailableServerName();
|
serverConfig.description = m_serversRepository->nextAvailableServerName();
|
||||||
|
|
||||||
for (auto iterator = preparedContainers.begin(); iterator != preparedContainers.end(); iterator++) {
|
for (auto iterator = preparedContainers.begin(); iterator != preparedContainers.end(); iterator++) {
|
||||||
serverConfig.containers.insert(iterator.key(), iterator.value());
|
serverConfig.containers.insert(iterator.key(), iterator.value());
|
||||||
@@ -1240,28 +1280,26 @@ ErrorCode InstallController::installContainer(const QString &serverId, DockerCon
|
|||||||
return ErrorCode::NoError;
|
return ErrorCode::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode InstallController::checkSshConnection(const ServerCredentials &credentials, QString &output,
|
ErrorCode InstallController::checkSshConnection(ServerCredentials &credentials, QString &output,
|
||||||
std::function<QString()> passphraseCallback)
|
std::function<QString()> passphraseCallback)
|
||||||
{
|
{
|
||||||
SshSession sshSession(this);
|
SshSession sshSession(this);
|
||||||
ErrorCode errorCode = ErrorCode::NoError;
|
ErrorCode errorCode = ErrorCode::NoError;
|
||||||
|
|
||||||
ServerCredentials processedCredentials = credentials;
|
if (credentials.secretData.contains("BEGIN") && credentials.secretData.contains("PRIVATE KEY")) {
|
||||||
|
|
||||||
if (processedCredentials.secretData.contains("BEGIN") && processedCredentials.secretData.contains("PRIVATE KEY")) {
|
|
||||||
if (!passphraseCallback) {
|
if (!passphraseCallback) {
|
||||||
return ErrorCode::SshPrivateKeyError;
|
return ErrorCode::SshPrivateKeyError;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString decryptedPrivateKey;
|
QString decryptedPrivateKey;
|
||||||
errorCode = sshSession.getDecryptedPrivateKey(processedCredentials, decryptedPrivateKey, passphraseCallback);
|
errorCode = sshSession.getDecryptedPrivateKey(credentials, decryptedPrivateKey, passphraseCallback);
|
||||||
if (errorCode != ErrorCode::NoError) {
|
if (errorCode != ErrorCode::NoError) {
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
processedCredentials.secretData = decryptedPrivateKey;
|
credentials.secretData = decryptedPrivateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
output = sshSession.checkSshConnection(processedCredentials, errorCode);
|
output = sshSession.checkSshConnection(credentials, errorCode);
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1465,7 +1503,7 @@ ErrorCode InstallController::getAlreadyInstalledContainers(const ServerCredentia
|
|||||||
QString transportProtoStr = containerAndPortMatch.captured(3);
|
QString transportProtoStr = containerAndPortMatch.captured(3);
|
||||||
DockerContainer container = ContainerUtils::containerFromString(name);
|
DockerContainer container = ContainerUtils::containerFromString(name);
|
||||||
|
|
||||||
if (container == DockerContainer::None) {
|
if (container == DockerContainer::None || ContainerUtils::isUnsupportedContainer(container)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1490,7 +1528,7 @@ ErrorCode InstallController::getAlreadyInstalledContainers(const ServerCredentia
|
|||||||
QString transportProtoStr = torOrDnsRegMatch.captured(3);
|
QString transportProtoStr = torOrDnsRegMatch.captured(3);
|
||||||
DockerContainer container = ContainerUtils::containerFromString(name);
|
DockerContainer container = ContainerUtils::containerFromString(name);
|
||||||
|
|
||||||
if (container == DockerContainer::None) {
|
if (container == DockerContainer::None || ContainerUtils::isUnsupportedContainer(container)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,12 @@ public:
|
|||||||
~InstallController();
|
~InstallController();
|
||||||
|
|
||||||
ErrorCode setupContainer(const ServerCredentials &credentials, DockerContainer container, ContainerConfig &config, bool isUpdate = false);
|
ErrorCode setupContainer(const ServerCredentials &credentials, DockerContainer container, ContainerConfig &config, bool isUpdate = false);
|
||||||
ErrorCode updateContainer(const QString &serverId, DockerContainer container, const ContainerConfig &oldConfig, ContainerConfig &newConfig);
|
|
||||||
|
// Updates server-side container settings (admin self-hosted only): reconfigures the container over SSH.
|
||||||
|
ErrorCode updateServerConfig(const QString &serverId, DockerContainer container, const ContainerConfig &oldConfig, ContainerConfig &newConfig);
|
||||||
|
|
||||||
|
// Updates client-local settings only: rewrites the stored container config for any self-hosted/native server. No SSH.
|
||||||
|
ErrorCode updateClientConfig(const QString &serverId, DockerContainer container, ContainerConfig &newConfig);
|
||||||
|
|
||||||
ErrorCode rebootServer(const QString &serverId);
|
ErrorCode rebootServer(const QString &serverId);
|
||||||
ErrorCode removeAllContainers(const QString &serverId);
|
ErrorCode removeAllContainers(const QString &serverId);
|
||||||
@@ -64,7 +69,8 @@ public:
|
|||||||
|
|
||||||
bool isUpdateDockerContainerRequired(DockerContainer container, const ContainerConfig &oldConfig, const ContainerConfig &newConfig);
|
bool isUpdateDockerContainerRequired(DockerContainer container, const ContainerConfig &oldConfig, const ContainerConfig &newConfig);
|
||||||
|
|
||||||
ErrorCode checkSshConnection(const ServerCredentials &credentials, QString &output, std::function<QString()> passphraseCallback = nullptr);
|
ErrorCode checkSshConnection(ServerCredentials &credentials, QString &output,
|
||||||
|
std::function<QString()> passphraseCallback = nullptr);
|
||||||
|
|
||||||
bool isServerAlreadyExists(const ServerCredentials &credentials, int &existingServerIndex);
|
bool isServerAlreadyExists(const ServerCredentials &credentials, int &existingServerIndex);
|
||||||
|
|
||||||
|
|||||||
@@ -363,6 +363,6 @@ void SettingsController::disablePremV1MigrationReminder()
|
|||||||
|
|
||||||
QString SettingsController::nextAvailableServerName() const
|
QString SettingsController::nextAvailableServerName() const
|
||||||
{
|
{
|
||||||
return m_appSettingsRepository->nextAvailableServerName();
|
return m_serversRepository->nextAvailableServerName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "core/controllers/gatewayController.h"
|
#include "core/controllers/gatewayController.h"
|
||||||
#include "core/utils/constants/apiKeys.h"
|
#include "core/utils/constants/apiKeys.h"
|
||||||
#include "core/utils/errorStrings.h"
|
|
||||||
#include "core/utils/selfhosted/scriptsRegistry.h"
|
#include "core/utils/selfhosted/scriptsRegistry.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -109,7 +108,7 @@ void UpdateController::fetchGatewayUrl()
|
|||||||
.then(this, [this, gatewayController](QPair<ErrorCode, QByteArray> result) {
|
.then(this, [this, gatewayController](QPair<ErrorCode, QByteArray> result) {
|
||||||
auto [err, gatewayResponse] = result;
|
auto [err, gatewayResponse] = result;
|
||||||
if (err != ErrorCode::NoError) {
|
if (err != ErrorCode::NoError) {
|
||||||
logger.error() << errorString(err);
|
logger.error() << "Gateway request failed, error code:" << static_cast<int>(err);
|
||||||
finishUpdateCheck();
|
finishUpdateCheck();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -250,17 +249,9 @@ void UpdateController::runInstaller()
|
|||||||
runLinuxInstaller(kInstallerLocalPath);
|
runLinuxInstaller(kInstallerLocalPath);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError
|
logger.error() << "Installer download failed, network error:" << static_cast<int>(reply->error())
|
||||||
|| reply->error() == QNetworkReply::NetworkError::TimeoutError) {
|
<< reply->errorString();
|
||||||
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() << "HTTP status:" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
logger.error() << errorString(ErrorCode::ApiConfigDownloadError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ ContainerConfig NativeServerConfig::containerConfig(DockerContainer container) c
|
|||||||
return containers.value(container);
|
return containers.value(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeServerConfig::updateContainerConfig(DockerContainer container, const ContainerConfig &config)
|
||||||
|
{
|
||||||
|
containers[container] = config;
|
||||||
|
}
|
||||||
|
|
||||||
QPair<QString, QString> NativeServerConfig::getDnsPair(const QString &primaryDns, const QString &secondaryDns) const
|
QPair<QString, QString> NativeServerConfig::getDnsPair(const QString &primaryDns, const QString &secondaryDns) const
|
||||||
{
|
{
|
||||||
QString d1 = dns1;
|
QString d1 = dns1;
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ struct NativeServerConfig {
|
|||||||
bool hasContainers() const;
|
bool hasContainers() const;
|
||||||
ContainerConfig containerConfig(DockerContainer container) const;
|
ContainerConfig containerConfig(DockerContainer container) const;
|
||||||
|
|
||||||
|
void updateContainerConfig(DockerContainer container, const ContainerConfig &config);
|
||||||
|
|
||||||
QPair<QString, QString> getDnsPair(const QString &primaryDns, const QString &secondaryDns) const;
|
QPair<QString, QString> getDnsPair(const QString &primaryDns, const QString &secondaryDns) const;
|
||||||
|
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ ContainerConfig SelfHostedUserServerConfig::containerConfig(DockerContainer cont
|
|||||||
return containers.value(container);
|
return containers.value(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelfHostedUserServerConfig::updateContainerConfig(DockerContainer container, const ContainerConfig &config)
|
||||||
|
{
|
||||||
|
containers[container] = config;
|
||||||
|
}
|
||||||
|
|
||||||
QPair<QString, QString> SelfHostedUserServerConfig::getDnsPair(const QString &primaryDns,
|
QPair<QString, QString> SelfHostedUserServerConfig::getDnsPair(const QString &primaryDns,
|
||||||
const QString &secondaryDns) const
|
const QString &secondaryDns) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ struct SelfHostedUserServerConfig {
|
|||||||
bool hasContainers() const;
|
bool hasContainers() const;
|
||||||
ContainerConfig containerConfig(DockerContainer container) const;
|
ContainerConfig containerConfig(DockerContainer container) const;
|
||||||
|
|
||||||
|
void updateContainerConfig(DockerContainer container, const ContainerConfig &config);
|
||||||
|
|
||||||
QPair<QString, QString> getDnsPair(const QString &primaryDns, const QString &secondaryDns) const;
|
QPair<QString, QString> getDnsPair(const QString &primaryDns, const QString &secondaryDns) const;
|
||||||
|
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
|
|||||||
@@ -39,33 +39,44 @@ QString OpenVpnProtocol::defaultConfigPath()
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenVpnProtocol::stop()
|
void OpenVpnProtocol::cleanupResources()
|
||||||
{
|
{
|
||||||
qDebug() << "OpenVpnProtocol::stop()";
|
if (m_openVpnProcess || openVpnProcessIsRunning()) {
|
||||||
setConnectionState(Vpn::ConnectionState::Disconnecting);
|
|
||||||
|
|
||||||
// TODO: need refactoring
|
|
||||||
// sendTermSignal() will even return true while server connected ???
|
|
||||||
if ((m_connectionState == Vpn::ConnectionState::Preparing) || (m_connectionState == Vpn::ConnectionState::Connecting)
|
|
||||||
|| (m_connectionState == Vpn::ConnectionState::Connected)
|
|
||||||
|| (m_connectionState == Vpn::ConnectionState::Reconnecting)) {
|
|
||||||
if (!sendTermSignal()) {
|
if (!sendTermSignal()) {
|
||||||
killOpenVpnProcess();
|
killOpenVpnProcess();
|
||||||
}
|
}
|
||||||
QThread::msleep(10);
|
QThread::msleep(10);
|
||||||
m_managementServer.stop();
|
|
||||||
}
|
}
|
||||||
|
m_managementServer.stop();
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
||||||
IpcClient::withInterface([](QSharedPointer<IpcInterfaceReplica> iface) {
|
IpcClient::withInterface([](QSharedPointer<IpcInterfaceReplica> iface) {
|
||||||
QRemoteObjectPendingReply<bool> reply = iface->disableKillSwitch();
|
QRemoteObjectPendingReply<bool> reply = iface->disableKillSwitch();
|
||||||
if (!reply.waitForFinished(1000) && !reply.returnValue()) {
|
if (!reply.waitForFinished(1000) && !reply.returnValue()) {
|
||||||
qWarning() << "OpenVpnProtocol::stop(): Failed to disable killswitch";
|
qWarning() << "OpenVpnProtocol::cleanupResources(): Failed to disable killswitch";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenVpnProtocol::stop()
|
||||||
|
{
|
||||||
|
qDebug() << "OpenVpnProtocol::stop()";
|
||||||
|
|
||||||
|
const bool wasActive = m_connectionState == Vpn::ConnectionState::Preparing
|
||||||
|
|| m_connectionState == Vpn::ConnectionState::Connecting
|
||||||
|
|| m_connectionState == Vpn::ConnectionState::Connected
|
||||||
|
|| m_connectionState == Vpn::ConnectionState::Reconnecting;
|
||||||
|
|
||||||
|
if (wasActive) {
|
||||||
|
setConnectionState(Vpn::ConnectionState::Disconnecting);
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanupResources();
|
||||||
|
|
||||||
|
if (wasActive || m_connectionState == Vpn::ConnectionState::Disconnecting) {
|
||||||
setConnectionState(Vpn::ConnectionState::Disconnected);
|
setConnectionState(Vpn::ConnectionState::Disconnected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode OpenVpnProtocol::prepare()
|
ErrorCode OpenVpnProtocol::prepare()
|
||||||
@@ -168,7 +179,7 @@ void OpenVpnProtocol::updateRouteGateway(QString line)
|
|||||||
|
|
||||||
ErrorCode OpenVpnProtocol::start()
|
ErrorCode OpenVpnProtocol::start()
|
||||||
{
|
{
|
||||||
OpenVpnProtocol::stop();
|
cleanupResources();
|
||||||
|
|
||||||
if (!QFileInfo::exists(configPath())) {
|
if (!QFileInfo::exists(configPath())) {
|
||||||
setLastError(ErrorCode::OpenVpnConfigMissing);
|
setLastError(ErrorCode::OpenVpnConfigMissing);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ protected slots:
|
|||||||
void onReadyReadDataFromManagementServer();
|
void onReadyReadDataFromManagementServer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void cleanupResources();
|
||||||
QString configPath() const;
|
QString configPath() const;
|
||||||
bool openVpnProcessIsRunning() const;
|
bool openVpnProcessIsRunning() const;
|
||||||
bool sendTermSignal();
|
bool sendTermSignal();
|
||||||
|
|||||||
@@ -9,10 +9,13 @@
|
|||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
|
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
|
#include <QNetworkProxy>
|
||||||
|
#include <QTcpSocket>
|
||||||
#include <QtCore/qlogging.h>
|
#include <QtCore/qlogging.h>
|
||||||
#include <QtCore/qobjectdefs.h>
|
#include <QtCore/qobjectdefs.h>
|
||||||
#include <QtCore/qprocess.h>
|
#include <QtCore/qprocess.h>
|
||||||
@@ -56,6 +59,28 @@ XrayProtocol::XrayProtocol(const QJsonObject &configuration, QObject *parent) :
|
|||||||
qWarning() << "Xray config string is not a valid JSON object";
|
qWarning() << "Xray config string is not a valid JSON object";
|
||||||
m_xrayConfig = {};
|
m_xrayConfig = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_serverPort = extractServerPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
int XrayProtocol::extractServerPort() const
|
||||||
|
{
|
||||||
|
const QJsonArray outbounds = m_xrayConfig.value(amnezia::protocols::xray::outbounds).toArray();
|
||||||
|
if (outbounds.isEmpty())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
const QJsonObject settings = outbounds.first().toObject().value(amnezia::protocols::xray::settings).toObject();
|
||||||
|
|
||||||
|
QJsonArray servers;
|
||||||
|
if (settings.contains(amnezia::protocols::xray::vnext))
|
||||||
|
servers = settings.value(amnezia::protocols::xray::vnext).toArray();
|
||||||
|
else if (settings.contains(amnezia::protocols::xray::servers))
|
||||||
|
servers = settings.value(amnezia::protocols::xray::servers).toArray();
|
||||||
|
|
||||||
|
if (servers.isEmpty())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return servers.first().toObject().value(amnezia::protocols::xray::port).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
XrayProtocol::~XrayProtocol()
|
XrayProtocol::~XrayProtocol()
|
||||||
@@ -68,6 +93,13 @@ ErrorCode XrayProtocol::start()
|
|||||||
{
|
{
|
||||||
qDebug() << "XrayProtocol::start()";
|
qDebug() << "XrayProtocol::start()";
|
||||||
|
|
||||||
|
m_connectivityProbeStarted = false;
|
||||||
|
|
||||||
|
if (!probeServerReachable()) {
|
||||||
|
qCritical() << "XrayProtocol: VPN server" << m_remoteAddress << "is unreachable";
|
||||||
|
return ErrorCode::XrayServerUnreachable;
|
||||||
|
}
|
||||||
|
|
||||||
// Inject SOCKS5 auth into the inbound before starting xray.
|
// Inject SOCKS5 auth into the inbound before starting xray.
|
||||||
// Re-uses existing credentials if the config already has them (e.g. imported config).
|
// Re-uses existing credentials if the config already has them (e.g. imported config).
|
||||||
amnezia::serialization::inbounds::InboundCredentials creds;
|
amnezia::serialization::inbounds::InboundCredentials creds;
|
||||||
@@ -104,22 +136,50 @@ ErrorCode XrayProtocol::start()
|
|||||||
qDebug() << "XrayProtocol: patched legacy inbound listen address to 127.0.0.1";
|
qDebug() << "XrayProtocol: patched legacy inbound listen address to 127.0.0.1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startTimeoutTimer();
|
||||||
|
|
||||||
return IpcClient::withInterface(
|
return IpcClient::withInterface(
|
||||||
[&](QSharedPointer<IpcInterfaceReplica> iface) {
|
[&](QSharedPointer<IpcInterfaceReplica> iface) {
|
||||||
auto xrayStart = iface->xrayStart(xrayConfigStr);
|
auto xrayStart = iface->xrayStart(xrayConfigStr);
|
||||||
if (!xrayStart.waitForFinished() || !xrayStart.returnValue()) {
|
if (!xrayStart.waitForFinished() || !xrayStart.returnValue()) {
|
||||||
qCritical() << "Failed to start xray";
|
qCritical() << "Failed to start xray";
|
||||||
|
stopTimeoutTimer();
|
||||||
return ErrorCode::XrayExecutableCrashed;
|
return ErrorCode::XrayExecutableCrashed;
|
||||||
}
|
}
|
||||||
return startTun2Socks();
|
return startTun2Socks();
|
||||||
},
|
},
|
||||||
[]() { return ErrorCode::AmneziaServiceConnectionFailed; });
|
[this]() {
|
||||||
|
stopTimeoutTimer();
|
||||||
|
return ErrorCode::AmneziaServiceConnectionFailed;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void XrayProtocol::stop()
|
void XrayProtocol::stop()
|
||||||
{
|
{
|
||||||
qDebug() << "XrayProtocol::stop()";
|
qDebug() << "XrayProtocol::stop()";
|
||||||
|
|
||||||
|
stopTimeoutTimer();
|
||||||
|
stopLivenessMonitor();
|
||||||
|
|
||||||
|
if (m_tun2socksProcess) {
|
||||||
|
m_tun2socksProcess->blockSignals(true);
|
||||||
|
|
||||||
|
#ifndef Q_OS_WIN
|
||||||
|
m_tun2socksProcess->terminate();
|
||||||
|
auto waitForFinished = m_tun2socksProcess->waitForFinished(1000);
|
||||||
|
if (!waitForFinished.waitForFinished() || !waitForFinished.returnValue()) {
|
||||||
|
qWarning() << "Failed to terminate tun2socks. Killing the process...";
|
||||||
|
m_tun2socksProcess->kill();
|
||||||
|
m_tun2socksProcess->waitForFinished(1000);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
m_tun2socksProcess->kill();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_tun2socksProcess->close();
|
||||||
|
m_tun2socksProcess.reset();
|
||||||
|
}
|
||||||
|
|
||||||
IpcClient::withInterface([](QSharedPointer<IpcInterfaceReplica> iface) {
|
IpcClient::withInterface([](QSharedPointer<IpcInterfaceReplica> iface) {
|
||||||
auto disableKillSwitch = iface->disableKillSwitch();
|
auto disableKillSwitch = iface->disableKillSwitch();
|
||||||
if (!disableKillSwitch.waitForFinished() || !disableKillSwitch.returnValue())
|
if (!disableKillSwitch.waitForFinished() || !disableKillSwitch.returnValue())
|
||||||
@@ -142,31 +202,13 @@ void XrayProtocol::stop()
|
|||||||
qWarning() << "Failed to stop xray";
|
qWarning() << "Failed to stop xray";
|
||||||
});
|
});
|
||||||
|
|
||||||
if (m_tun2socksProcess) {
|
|
||||||
m_tun2socksProcess->blockSignals(true);
|
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
|
||||||
m_tun2socksProcess->terminate();
|
|
||||||
auto waitForFinished = m_tun2socksProcess->waitForFinished(1000);
|
|
||||||
if (!waitForFinished.waitForFinished() || !waitForFinished.returnValue()) {
|
|
||||||
qWarning() << "Failed to terminate tun2socks. Killing the process...";
|
|
||||||
m_tun2socksProcess->kill();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// terminate does not do anything useful on Windows
|
|
||||||
// so just kill the process
|
|
||||||
m_tun2socksProcess->kill();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_tun2socksProcess->close();
|
|
||||||
m_tun2socksProcess.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
setConnectionState(Vpn::ConnectionState::Disconnected);
|
setConnectionState(Vpn::ConnectionState::Disconnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode XrayProtocol::startTun2Socks()
|
ErrorCode XrayProtocol::startTun2Socks()
|
||||||
{
|
{
|
||||||
|
m_tunResourceBusy = false;
|
||||||
|
|
||||||
m_tun2socksProcess = IpcClient::CreatePrivilegedProcess();
|
m_tun2socksProcess = IpcClient::CreatePrivilegedProcess();
|
||||||
if (!m_tun2socksProcess->waitForSource()) {
|
if (!m_tun2socksProcess->waitForSource()) {
|
||||||
return ErrorCode::AmneziaServiceConnectionFailed;
|
return ErrorCode::AmneziaServiceConnectionFailed;
|
||||||
@@ -191,15 +233,31 @@ ErrorCode XrayProtocol::startTun2Socks()
|
|||||||
if (!line.contains("[TCP]") && !line.contains("[UDP]"))
|
if (!line.contains("[TCP]") && !line.contains("[UDP]"))
|
||||||
qDebug() << "[tun2socks]:" << line;
|
qDebug() << "[tun2socks]:" << line;
|
||||||
|
|
||||||
if (line.contains("[STACK] tun://") && line.contains("<-> socks5://")) {
|
if (line.contains("resource busy"))
|
||||||
|
m_tunResourceBusy = true;
|
||||||
|
|
||||||
|
if (line.contains("[STACK] tun://") && line.contains("<-> socks5://") && !m_connectivityProbeStarted) {
|
||||||
|
m_connectivityProbeStarted = true;
|
||||||
disconnect(m_tun2socksProcess.data(), &IpcProcessInterfaceReplica::readyReadStandardOutput, this, nullptr);
|
disconnect(m_tun2socksProcess.data(), &IpcProcessInterfaceReplica::readyReadStandardOutput, this, nullptr);
|
||||||
|
disconnect(m_tun2socksProcess.data(), &IpcProcessInterfaceReplica::readyReadStandardError, this, nullptr);
|
||||||
|
|
||||||
|
runConnectivityProbe([this](bool ok) {
|
||||||
|
if (!ok) {
|
||||||
|
qCritical() << "Xray connectivity probe failed: no traffic flows through the tunnel";
|
||||||
|
stop();
|
||||||
|
setLastError(ErrorCode::XrayConnectivityCheckFailed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ErrorCode res = setupRouting(); res != ErrorCode::NoError) {
|
if (ErrorCode res = setupRouting(); res != ErrorCode::NoError) {
|
||||||
stop();
|
stop();
|
||||||
setLastError(res);
|
setLastError(res);
|
||||||
} else {
|
} else {
|
||||||
|
stopTimeoutTimer();
|
||||||
setConnectionState(Vpn::ConnectionState::Connected);
|
setConnectionState(Vpn::ConnectionState::Connected);
|
||||||
|
startLivenessMonitor();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
@@ -207,15 +265,7 @@ ErrorCode XrayProtocol::startTun2Socks()
|
|||||||
connect(
|
connect(
|
||||||
m_tun2socksProcess.data(), &IpcProcessInterfaceReplica::finished, this,
|
m_tun2socksProcess.data(), &IpcProcessInterfaceReplica::finished, this,
|
||||||
[this](int exitCode, QProcess::ExitStatus exitStatus) {
|
[this](int exitCode, QProcess::ExitStatus exitStatus) {
|
||||||
// Check stdout for "resource busy" — the TUN device was not yet released
|
const bool resourceBusy = m_tunResourceBusy;
|
||||||
// by the previous tun2socks instance. Retry after a short delay.
|
|
||||||
bool resourceBusy = false;
|
|
||||||
if (m_tun2socksProcess) {
|
|
||||||
auto readOut = m_tun2socksProcess->readAllStandardOutput();
|
|
||||||
if (readOut.waitForFinished()) {
|
|
||||||
resourceBusy = readOut.returnValue().contains("resource busy");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resourceBusy && m_tun2socksRetryCount < maxTun2SocksRetries) {
|
if (resourceBusy && m_tun2socksRetryCount < maxTun2SocksRetries) {
|
||||||
m_tun2socksRetryCount++;
|
m_tun2socksRetryCount++;
|
||||||
@@ -331,3 +381,98 @@ ErrorCode XrayProtocol::setupRouting()
|
|||||||
},
|
},
|
||||||
[]() { return ErrorCode::AmneziaServiceConnectionFailed; });
|
[]() { return ErrorCode::AmneziaServiceConnectionFailed; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool XrayProtocol::probeServerReachable()
|
||||||
|
{
|
||||||
|
if (m_remoteAddress.isEmpty() || m_serverPort <= 0) {
|
||||||
|
qWarning() << "XrayProtocol: skipping server reachability probe (address/port unknown)";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTcpSocket sock;
|
||||||
|
sock.connectToHost(m_remoteAddress, static_cast<quint16>(m_serverPort));
|
||||||
|
const bool ok = sock.waitForConnected(m_serverProbeTimeoutMs);
|
||||||
|
if (!ok) {
|
||||||
|
qWarning() << "XrayProtocol: server" << m_remoteAddress << ":" << m_serverPort
|
||||||
|
<< "unreachable:" << sock.errorString();
|
||||||
|
}
|
||||||
|
sock.abort();
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XrayProtocol::runConnectivityProbe(std::function<void(bool)> onResult)
|
||||||
|
{
|
||||||
|
if (m_remoteAddress.isEmpty() || m_serverPort <= 0) {
|
||||||
|
qWarning() << "XrayProtocol: connectivity probe skipped (server address/port unknown)";
|
||||||
|
onResult(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto *sock = new QTcpSocket(this);
|
||||||
|
|
||||||
|
QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, QStringLiteral("127.0.0.1"),
|
||||||
|
static_cast<quint16>(m_socksPort), m_socksUser, m_socksPassword);
|
||||||
|
proxy.setCapabilities(QNetworkProxy::TunnelingCapability | QNetworkProxy::HostNameLookupCapability);
|
||||||
|
sock->setProxy(proxy);
|
||||||
|
|
||||||
|
auto *timeout = new QTimer(this);
|
||||||
|
timeout->setSingleShot(true);
|
||||||
|
|
||||||
|
auto done = QSharedPointer<bool>::create(false);
|
||||||
|
|
||||||
|
auto finish = [=](bool ok) {
|
||||||
|
if (*done)
|
||||||
|
return;
|
||||||
|
*done = true;
|
||||||
|
timeout->stop();
|
||||||
|
timeout->deleteLater();
|
||||||
|
sock->abort();
|
||||||
|
sock->deleteLater();
|
||||||
|
onResult(ok);
|
||||||
|
};
|
||||||
|
|
||||||
|
connect(sock, &QTcpSocket::connected, this, [=]() { finish(true); });
|
||||||
|
connect(sock, &QAbstractSocket::errorOccurred, this, [=](QAbstractSocket::SocketError) { finish(false); });
|
||||||
|
connect(timeout, &QTimer::timeout, this, [=]() { finish(false); });
|
||||||
|
|
||||||
|
timeout->start(m_connectivityProbeTimeoutMs);
|
||||||
|
sock->connectToHost(m_remoteAddress, static_cast<quint16>(m_serverPort));
|
||||||
|
}
|
||||||
|
|
||||||
|
void XrayProtocol::startLivenessMonitor()
|
||||||
|
{
|
||||||
|
if (!m_livenessTimer) {
|
||||||
|
m_livenessTimer = new QTimer(this);
|
||||||
|
connect(m_livenessTimer, &QTimer::timeout, this, [this]() {
|
||||||
|
if (connectionState() != Vpn::ConnectionState::Connected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
runConnectivityProbe([this](bool ok) {
|
||||||
|
if (connectionState() != Vpn::ConnectionState::Connected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
m_livenessFailures = 0;
|
||||||
|
} else if (++m_livenessFailures >= m_maxLivenessFailures) {
|
||||||
|
qCritical() << "XrayProtocol: liveness check failed" << m_livenessFailures
|
||||||
|
<< "times in a row, the tunnel is dead";
|
||||||
|
stop();
|
||||||
|
setLastError(ErrorCode::XrayConnectionLost);
|
||||||
|
} else {
|
||||||
|
qWarning() << "XrayProtocol: liveness check failed (" << m_livenessFailures << "/"
|
||||||
|
<< m_maxLivenessFailures << ")";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
m_livenessFailures = 0;
|
||||||
|
m_livenessTimer->start(m_livenessIntervalMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void XrayProtocol::stopLivenessMonitor()
|
||||||
|
{
|
||||||
|
if (m_livenessTimer)
|
||||||
|
m_livenessTimer->stop();
|
||||||
|
m_livenessFailures = 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,12 +6,16 @@
|
|||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#include "core/utils/errorCodes.h"
|
#include "core/utils/errorCodes.h"
|
||||||
#include "core/utils/routeModes.h"
|
#include "core/utils/routeModes.h"
|
||||||
#include "core/utils/commonStructs.h"
|
#include "core/utils/commonStructs.h"
|
||||||
#include "core/utils/ipcClient.h"
|
#include "core/utils/ipcClient.h"
|
||||||
#include "vpnProtocol.h"
|
#include "vpnProtocol.h"
|
||||||
|
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
class XrayProtocol : public VpnProtocol
|
class XrayProtocol : public VpnProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -25,10 +29,17 @@ private:
|
|||||||
ErrorCode setupRouting();
|
ErrorCode setupRouting();
|
||||||
ErrorCode startTun2Socks();
|
ErrorCode startTun2Socks();
|
||||||
|
|
||||||
|
bool probeServerReachable();
|
||||||
|
void runConnectivityProbe(std::function<void(bool)> onResult);
|
||||||
|
void startLivenessMonitor();
|
||||||
|
void stopLivenessMonitor();
|
||||||
|
int extractServerPort() const;
|
||||||
|
|
||||||
QJsonObject m_xrayConfig;
|
QJsonObject m_xrayConfig;
|
||||||
amnezia::RouteMode m_routeMode;
|
amnezia::RouteMode m_routeMode;
|
||||||
QList<QHostAddress> m_dnsServers;
|
QList<QHostAddress> m_dnsServers;
|
||||||
QString m_remoteAddress;
|
QString m_remoteAddress;
|
||||||
|
int m_serverPort = 0;
|
||||||
|
|
||||||
QString m_socksUser;
|
QString m_socksUser;
|
||||||
QString m_socksPassword;
|
QString m_socksPassword;
|
||||||
@@ -38,6 +49,22 @@ private:
|
|||||||
int m_tun2socksRetryCount = 0;
|
int m_tun2socksRetryCount = 0;
|
||||||
static constexpr int maxTun2SocksRetries = 5;
|
static constexpr int maxTun2SocksRetries = 5;
|
||||||
static constexpr int tun2socksRetryDelayMs = 400;
|
static constexpr int tun2socksRetryDelayMs = 400;
|
||||||
|
|
||||||
|
bool m_connectivityProbeStarted = false;
|
||||||
|
bool m_tunResourceBusy = false;
|
||||||
|
|
||||||
|
QTimer *m_livenessTimer = nullptr;
|
||||||
|
int m_livenessFailures = 0;
|
||||||
|
|
||||||
|
static constexpr int defaultServerProbeTimeoutMs = 5000;
|
||||||
|
static constexpr int defaultConnectivityProbeTimeoutMs = 7000;
|
||||||
|
static constexpr int defaultLivenessIntervalMs = 15000;
|
||||||
|
static constexpr int defaultMaxLivenessFailures = 3;
|
||||||
|
|
||||||
|
int m_serverProbeTimeoutMs = defaultServerProbeTimeoutMs;
|
||||||
|
int m_connectivityProbeTimeoutMs = defaultConnectivityProbeTimeoutMs;
|
||||||
|
int m_livenessIntervalMs = defaultLivenessIntervalMs;
|
||||||
|
int m_maxLivenessFailures = defaultMaxLivenessFailures;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // XRAYPROTOCOL_H
|
#endif // XRAYPROTOCOL_H
|
||||||
|
|||||||
@@ -426,26 +426,6 @@ void SecureAppSettingsRepository::clearSettings()
|
|||||||
emit settingsCleared();
|
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)
|
void SecureAppSettingsRepository::setInstallationUuid(const QString &uuid)
|
||||||
{
|
{
|
||||||
m_settings->setValue("Conf/installationUuid", uuid);
|
m_settings->setValue("Conf/installationUuid", uuid);
|
||||||
|
|||||||
@@ -90,8 +90,6 @@ public:
|
|||||||
bool restoreAppConfig(const QByteArray &cfg);
|
bool restoreAppConfig(const QByteArray &cfg);
|
||||||
void clearSettings();
|
void clearSettings();
|
||||||
|
|
||||||
QString nextAvailableServerName() const;
|
|
||||||
|
|
||||||
QByteArray xraySavedConfigs() const;
|
QByteArray xraySavedConfigs() const;
|
||||||
void setXraySavedConfigs(const QByteArray &data);
|
void setXraySavedConfigs(const QByteArray &data);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
#include <QSet>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
#include "core/utils/serverConfigUtils.h"
|
#include "core/utils/serverConfigUtils.h"
|
||||||
@@ -32,6 +33,45 @@ QJsonObject embedStorageServerId(const QString &serverId, const QJsonObject &pay
|
|||||||
return o;
|
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
|
} // namespace
|
||||||
|
|
||||||
SecureServersRepository::SecureServersRepository(SecureQSettings *settings, QObject *parent)
|
SecureServersRepository::SecureServersRepository(SecureQSettings *settings, QObject *parent)
|
||||||
@@ -153,6 +193,28 @@ void SecureServersRepository::clearServers()
|
|||||||
syncToStorage();
|
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)
|
QString SecureServersRepository::addServer(const QString &serverId, const QJsonObject &serverJson, serverConfigUtils::ConfigType kind)
|
||||||
{
|
{
|
||||||
const QString id = normalizedOrGeneratedServerId(serverId);
|
const QString id = normalizedOrGeneratedServerId(serverId);
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ public:
|
|||||||
|
|
||||||
void clearServers();
|
void clearServers();
|
||||||
|
|
||||||
|
QString nextAvailableServerName() const;
|
||||||
|
|
||||||
void invalidateCache();
|
void invalidateCache();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace amnezia
|
|||||||
Awg2,
|
Awg2,
|
||||||
WireGuard,
|
WireGuard,
|
||||||
OpenVpn,
|
OpenVpn,
|
||||||
|
Cloak,
|
||||||
|
ShadowSocks,
|
||||||
Ipsec,
|
Ipsec,
|
||||||
Xray,
|
Xray,
|
||||||
SSXray,
|
SSXray,
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ QString ContainerUtils::containerToString(DockerContainer c)
|
|||||||
{
|
{
|
||||||
if (c == DockerContainer::None)
|
if (c == DockerContainer::None)
|
||||||
return "none";
|
return "none";
|
||||||
|
if (c == DockerContainer::Cloak)
|
||||||
|
return "amnezia-openvpn-cloak";
|
||||||
if (c == DockerContainer::Awg)
|
if (c == DockerContainer::Awg)
|
||||||
return "amnezia-awg";
|
return "amnezia-awg";
|
||||||
if (c == DockerContainer::Awg2)
|
if (c == DockerContainer::Awg2)
|
||||||
@@ -62,6 +64,8 @@ QMap<DockerContainer, QString> ContainerUtils::containerHumanNames()
|
|||||||
{
|
{
|
||||||
return { { DockerContainer::None, "Not installed" },
|
return { { DockerContainer::None, "Not installed" },
|
||||||
{ DockerContainer::OpenVpn, "OpenVPN" },
|
{ DockerContainer::OpenVpn, "OpenVPN" },
|
||||||
|
{ DockerContainer::ShadowSocks, "OpenVPN over SS" },
|
||||||
|
{ DockerContainer::Cloak, "OpenVPN over Cloak" },
|
||||||
{ DockerContainer::WireGuard, "WireGuard" },
|
{ DockerContainer::WireGuard, "WireGuard" },
|
||||||
{ DockerContainer::Awg, "AmneziaWG" },
|
{ DockerContainer::Awg, "AmneziaWG" },
|
||||||
{ DockerContainer::Awg2, "AmneziaWG" },
|
{ DockerContainer::Awg2, "AmneziaWG" },
|
||||||
@@ -83,6 +87,10 @@ QMap<DockerContainer, QString> ContainerUtils::containerDescriptions()
|
|||||||
return { { DockerContainer::OpenVpn,
|
return { { DockerContainer::OpenVpn,
|
||||||
QObject::tr("OpenVPN is the most popular VPN protocol, with flexible configuration options. It uses its "
|
QObject::tr("OpenVPN is the most popular VPN protocol, with flexible configuration options. It uses its "
|
||||||
"own security protocol with SSL/TLS for key exchange.") },
|
"own security protocol with SSL/TLS for key exchange.") },
|
||||||
|
{ DockerContainer::ShadowSocks,
|
||||||
|
QObject::tr("This protocol is no longer supported.") },
|
||||||
|
{ DockerContainer::Cloak,
|
||||||
|
QObject::tr("This protocol is no longer supported.") },
|
||||||
{ DockerContainer::WireGuard,
|
{ DockerContainer::WireGuard,
|
||||||
QObject::tr("WireGuard - popular VPN protocol with high performance, high speed and low power "
|
QObject::tr("WireGuard - popular VPN protocol with high performance, high speed and low power "
|
||||||
"consumption.") },
|
"consumption.") },
|
||||||
@@ -194,6 +202,9 @@ QMap<DockerContainer, QString> ContainerUtils::containerDetailedDescriptions()
|
|||||||
|
|
||||||
ServiceType ContainerUtils::containerService(DockerContainer c)
|
ServiceType ContainerUtils::containerService(DockerContainer c)
|
||||||
{
|
{
|
||||||
|
if (isUnsupportedContainer(c)) {
|
||||||
|
return ServiceType::Vpn;
|
||||||
|
}
|
||||||
return ProtocolUtils::protocolService(defaultProtocol(c));
|
return ProtocolUtils::protocolService(defaultProtocol(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,6 +213,8 @@ Proto ContainerUtils::defaultProtocol(DockerContainer c)
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case DockerContainer::None: return Proto::Unknown;
|
case DockerContainer::None: return Proto::Unknown;
|
||||||
case DockerContainer::OpenVpn: return Proto::OpenVpn;
|
case DockerContainer::OpenVpn: return Proto::OpenVpn;
|
||||||
|
case DockerContainer::Cloak:
|
||||||
|
case DockerContainer::ShadowSocks: return Proto::Unknown;
|
||||||
case DockerContainer::WireGuard: return Proto::WireGuard;
|
case DockerContainer::WireGuard: return Proto::WireGuard;
|
||||||
case DockerContainer::Awg2: return Proto::Awg;
|
case DockerContainer::Awg2: return Proto::Awg;
|
||||||
case DockerContainer::Awg: return Proto::Awg;
|
case DockerContainer::Awg: return Proto::Awg;
|
||||||
@@ -252,6 +265,8 @@ bool ContainerUtils::isSupportedByCurrentPlatform(DockerContainer c)
|
|||||||
// macOS build using Network Extension – allow OpenVPN for parity with iOS.
|
// macOS build using Network Extension – allow OpenVPN for parity with iOS.
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case DockerContainer::OpenVpn: return true;
|
case DockerContainer::OpenVpn: return true;
|
||||||
|
case DockerContainer::Cloak: return false;
|
||||||
|
case DockerContainer::ShadowSocks: return false;
|
||||||
case DockerContainer::WireGuard: return true;
|
case DockerContainer::WireGuard: return true;
|
||||||
case DockerContainer::Awg2: return true;
|
case DockerContainer::Awg2: return true;
|
||||||
case DockerContainer::Awg: return true;
|
case DockerContainer::Awg: return true;
|
||||||
@@ -336,6 +351,10 @@ int ContainerUtils::easySetupOrder(DockerContainer container)
|
|||||||
|
|
||||||
bool ContainerUtils::isShareable(DockerContainer container)
|
bool ContainerUtils::isShareable(DockerContainer container)
|
||||||
{
|
{
|
||||||
|
if (isUnsupportedContainer(container)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (container) {
|
switch (container) {
|
||||||
case DockerContainer::TorWebSite: return false;
|
case DockerContainer::TorWebSite: return false;
|
||||||
case DockerContainer::Dns: return false;
|
case DockerContainer::Dns: return false;
|
||||||
@@ -352,6 +371,11 @@ bool ContainerUtils::isAwgContainer(DockerContainer container)
|
|||||||
return container == DockerContainer::Awg || container == DockerContainer::Awg2;
|
return container == DockerContainer::Awg || container == DockerContainer::Awg2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ContainerUtils::isUnsupportedContainer(DockerContainer container)
|
||||||
|
{
|
||||||
|
return container == DockerContainer::Cloak || container == DockerContainer::ShadowSocks;
|
||||||
|
}
|
||||||
|
|
||||||
QJsonObject ContainerUtils::getProtocolConfigFromContainer(const Proto protocol, const QJsonObject &containerConfig)
|
QJsonObject ContainerUtils::getProtocolConfigFromContainer(const Proto protocol, const QJsonObject &containerConfig)
|
||||||
{
|
{
|
||||||
QString protocolConfigString = containerConfig.value(ProtocolUtils::protoToString(protocol))
|
QString protocolConfigString = containerConfig.value(ProtocolUtils::protoToString(protocol))
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ namespace amnezia
|
|||||||
|
|
||||||
bool isAwgContainer(DockerContainer container);
|
bool isAwgContainer(DockerContainer container);
|
||||||
|
|
||||||
|
bool isUnsupportedContainer(DockerContainer container);
|
||||||
|
|
||||||
QJsonObject getProtocolConfigFromContainer(const Proto protocol, const QJsonObject &containerConfig);
|
QJsonObject getProtocolConfigFromContainer(const Proto protocol, const QJsonObject &containerConfig);
|
||||||
|
|
||||||
int installPageOrder(DockerContainer container);
|
int installPageOrder(DockerContainer container);
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ namespace amnezia
|
|||||||
OpenSslFailed = 800,
|
OpenSslFailed = 800,
|
||||||
XrayExecutableCrashed = 803,
|
XrayExecutableCrashed = 803,
|
||||||
Tun2SockExecutableCrashed = 804,
|
Tun2SockExecutableCrashed = 804,
|
||||||
|
XrayServerUnreachable = 805,
|
||||||
|
XrayConnectivityCheckFailed = 806,
|
||||||
|
XrayConnectionLost = 807,
|
||||||
|
|
||||||
// import and install errors
|
// import and install errors
|
||||||
ImportInvalidConfigError = 900,
|
ImportInvalidConfigError = 900,
|
||||||
@@ -79,6 +82,7 @@ namespace amnezia
|
|||||||
ImportBackupFileUseRestoreInstead = 903,
|
ImportBackupFileUseRestoreInstead = 903,
|
||||||
RestoreBackupInvalidError = 904,
|
RestoreBackupInvalidError = 904,
|
||||||
LegacyApiV1NotSupportedError = 905,
|
LegacyApiV1NotSupportedError = 905,
|
||||||
|
LegacyContainerNotSupportedError = 906,
|
||||||
|
|
||||||
// Android errors
|
// Android errors
|
||||||
AndroidError = 1000,
|
AndroidError = 1000,
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ QString errorString(ErrorCode code) {
|
|||||||
case (ErrorCode::OpenVpnExecutableMissing): errorMessage = QObject::tr("OpenVPN executable missing"); break;
|
case (ErrorCode::OpenVpnExecutableMissing): errorMessage = QObject::tr("OpenVPN executable missing"); break;
|
||||||
case (ErrorCode::AmneziaServiceConnectionFailed): errorMessage = QObject::tr("Amnezia helper service error"); break;
|
case (ErrorCode::AmneziaServiceConnectionFailed): errorMessage = QObject::tr("Amnezia helper service error"); break;
|
||||||
case (ErrorCode::OpenSslFailed): errorMessage = QObject::tr("OpenSSL failed"); break;
|
case (ErrorCode::OpenSslFailed): errorMessage = QObject::tr("OpenSSL failed"); break;
|
||||||
|
case (ErrorCode::XrayServerUnreachable): errorMessage = QObject::tr("Can't connect: the VPN server is unreachable"); break;
|
||||||
|
case (ErrorCode::XrayConnectivityCheckFailed): errorMessage = QObject::tr("Can't connect: no internet traffic flows through the tunnel"); break;
|
||||||
|
case (ErrorCode::XrayConnectionLost): errorMessage = QObject::tr("Connection lost: traffic stopped flowing through the tunnel"); break;
|
||||||
|
|
||||||
// VPN errors
|
// VPN errors
|
||||||
case (ErrorCode::OpenVpnAdaptersInUseError): errorMessage = QObject::tr("Can't connect: another VPN connection is active"); break;
|
case (ErrorCode::OpenVpnAdaptersInUseError): errorMessage = QObject::tr("Can't connect: another VPN connection is active"); break;
|
||||||
@@ -69,6 +72,7 @@ QString errorString(ErrorCode code) {
|
|||||||
case (ErrorCode::ImportBackupFileUseRestoreInstead): errorMessage = QObject::tr("Backup files cannot be imported here. Use 'Restore from backup' instead."); break;
|
case (ErrorCode::ImportBackupFileUseRestoreInstead): errorMessage = QObject::tr("Backup files cannot be imported here. Use 'Restore from backup' instead."); break;
|
||||||
case (ErrorCode::RestoreBackupInvalidError): errorMessage = QObject::tr("Backup file is corrupted or has invalid format"); break;
|
case (ErrorCode::RestoreBackupInvalidError): errorMessage = QObject::tr("Backup file is corrupted or has invalid format"); break;
|
||||||
case (ErrorCode::LegacyApiV1NotSupportedError): errorMessage = QObject::tr("This legacy Amnezia subscription format is no longer supported"); break;
|
case (ErrorCode::LegacyApiV1NotSupportedError): errorMessage = QObject::tr("This legacy Amnezia subscription format is no longer supported"); break;
|
||||||
|
case (ErrorCode::LegacyContainerNotSupportedError): errorMessage = QObject::tr("This protocol is no longer supported. Please select another protocol or remove this container from the server settings."); break;
|
||||||
case (ErrorCode::ImportOpenConfigError): errorMessage = QObject::tr("Unable to open config file"); break;
|
case (ErrorCode::ImportOpenConfigError): errorMessage = QObject::tr("Unable to open config file"); break;
|
||||||
case (ErrorCode::NoInstalledContainersError): errorMessage = QObject::tr("VPN Protocols is not installed.\n Please install VPN container at first"); break;
|
case (ErrorCode::NoInstalledContainersError): errorMessage = QObject::tr("VPN Protocols is not installed.\n Please install VPN container at first"); break;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
|
|
||||||
|
#include "daemon.h"
|
||||||
#include "daemonlocalserverconnection.h"
|
#include "daemonlocalserverconnection.h"
|
||||||
#include "leakdetector.h"
|
#include "leakdetector.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
@@ -58,8 +59,11 @@ bool DaemonLocalServer::initialize() {
|
|||||||
|
|
||||||
DaemonLocalServerConnection* connection =
|
DaemonLocalServerConnection* connection =
|
||||||
new DaemonLocalServerConnection(&m_server, socket);
|
new DaemonLocalServerConnection(&m_server, socket);
|
||||||
connect(socket, &QLocalSocket::disconnected, connection,
|
connect(socket, &QLocalSocket::disconnected, connection, [connection]() {
|
||||||
&DaemonLocalServerConnection::deleteLater);
|
logger.debug() << "Client connection dropped, deactivating daemon";
|
||||||
|
Daemon::instance()->deactivate(true);
|
||||||
|
connection->deleteLater();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ set_target_properties(networkextension PROPERTIES
|
|||||||
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2"
|
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2"
|
||||||
|
|
||||||
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../../Frameworks"
|
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../../Frameworks"
|
||||||
|
|
||||||
|
XCODE_LINK_BUILD_PHASE_MODE KNOWN_LOCATION
|
||||||
)
|
)
|
||||||
|
|
||||||
if(DEPLOY)
|
if(DEPLOY)
|
||||||
@@ -114,10 +116,20 @@ target_include_directories(networkextension PRIVATE ${CLIENT_ROOT_DIR})
|
|||||||
target_include_directories(networkextension PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
target_include_directories(networkextension PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
find_package(openvpnadapter REQUIRED)
|
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)
|
target_link_libraries(networkextension PRIVATE amnezia::openvpnadapter)
|
||||||
|
|
||||||
find_package(awg-apple REQUIRED)
|
find_package(awg-apple REQUIRED)
|
||||||
target_link_libraries(networkextension PRIVATE amnezia::awg-apple)
|
target_link_libraries(networkextension PRIVATE amnezia::awg-apple)
|
||||||
|
|
||||||
find_package(hev-socks5-tunnel REQUIRED)
|
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)
|
target_link_libraries(networkextension PRIVATE heiher::hev-socks5-tunnel)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
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 stop;\
|
||||||
sudo docker ps -a | grep amnezia | awk '{print $1}' | xargs sudo docker rm -fv;\
|
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 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 docker network ls | grep amnezia-dns-net | awk '{print $1}' | xargs sudo docker network rm;\
|
||||||
sudo rm -frd /opt/amnezia
|
sudo rm -frd /opt/amnezia
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
sudo docker stop $CONTAINER_NAME;\
|
sudo docker stop $CONTAINER_NAME;\
|
||||||
sudo docker rm -fv $CONTAINER_NAME;\
|
sudo docker rm -fv $CONTAINER_NAME;\
|
||||||
sudo docker rmi $CONTAINER_NAME;\
|
sudo docker rmi $CONTAINER_NAME;
|
||||||
test "$REMOVE_CONTAINER_DATA" = "1" && sudo docker volume rm -f ${CONTAINER_NAME}-data 2>/dev/null || true
|
|
||||||
|
|||||||
@@ -475,8 +475,7 @@ bool SubscriptionUiController::deactivateExternalDevice(const QString &serverId,
|
|||||||
void SubscriptionUiController::validateConfig()
|
void SubscriptionUiController::validateConfig()
|
||||||
{
|
{
|
||||||
const QString serverId = m_serversController->getDefaultServerId();
|
const QString serverId = m_serversController->getDefaultServerId();
|
||||||
if (!serverId.isEmpty() && m_serversController->isLegacyApiV1Server(serverId)) {
|
if (serverId.isEmpty()) {
|
||||||
emit unsupportedConnectDrawerRequested();
|
|
||||||
emit configValidated(false);
|
emit configValidated(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "amneziaApplication.h"
|
#include "amneziaApplication.h"
|
||||||
#include "core/controllers/serversController.h"
|
#include "core/controllers/serversController.h"
|
||||||
|
#include "core/models/containerConfig.h"
|
||||||
|
#include "core/utils/containerEnum.h"
|
||||||
|
|
||||||
ConnectionUiController::ConnectionUiController(ConnectionController* connectionController,
|
ConnectionUiController::ConnectionUiController(ConnectionController* connectionController,
|
||||||
ServersController* serversController,
|
ServersController* serversController,
|
||||||
@@ -33,7 +35,7 @@ void ConnectionUiController::openConnection()
|
|||||||
ErrorCode errorCode = m_connectionController->openConnection(serverId);
|
ErrorCode errorCode = m_connectionController->openConnection(serverId);
|
||||||
|
|
||||||
if (errorCode != ErrorCode::NoError) {
|
if (errorCode != ErrorCode::NoError) {
|
||||||
emit connectionErrorOccurred(errorCode);
|
notifyConnectionBlocked(errorCode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,10 +132,36 @@ void ConnectionUiController::toggleConnection()
|
|||||||
} else if (isConnected()) {
|
} else if (isConnected()) {
|
||||||
closeConnection();
|
closeConnection();
|
||||||
} else {
|
} else {
|
||||||
|
const QString serverId = m_serversController->getDefaultServerId();
|
||||||
|
if (serverId.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ErrorCode errorCode = m_connectionController->isConnectionSupported(serverId);
|
||||||
|
if (errorCode != ErrorCode::NoError) {
|
||||||
|
notifyConnectionBlocked(errorCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
emit prepareConfig();
|
emit prepareConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectionUiController::notifyConnectionBlocked(ErrorCode errorCode)
|
||||||
|
{
|
||||||
|
if (errorCode == ErrorCode::LegacyApiV1NotSupportedError) {
|
||||||
|
emit unsupportedConnectDrawerRequested();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorCode == ErrorCode::NoInstalledContainersError) {
|
||||||
|
emit noInstalledContainers();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit connectionErrorOccurred(errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
bool ConnectionUiController::isConnectionInProgress() const
|
bool ConnectionUiController::isConnectionInProgress() const
|
||||||
{
|
{
|
||||||
return m_isConnectionInProgress;
|
return m_isConnectionInProgress;
|
||||||
@@ -143,3 +171,32 @@ bool ConnectionUiController::isConnected() const
|
|||||||
{
|
{
|
||||||
return m_isConnected;
|
return m_isConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConnectionUiController::isRevokeBlockedDuringActiveConnection(const QString &serverId, int containerIndex,
|
||||||
|
const QString &clientId) const
|
||||||
|
{
|
||||||
|
if (clientId.isEmpty() || (!isConnected() && !isConnectionInProgress())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_serversController->getDefaultServerId() != serverId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (static_cast<int>(m_serversController->getDefaultContainer(serverId)) != containerIndex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto adminConfig = m_serversController->selfHostedAdminConfig(serverId);
|
||||||
|
if (!adminConfig.has_value()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString connectionClientId =
|
||||||
|
adminConfig->containerConfig(static_cast<DockerContainer>(containerIndex)).protocolConfig.clientId();
|
||||||
|
if (connectionClientId.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return connectionClientId == clientId || connectionClientId.contains(clientId);
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public slots:
|
|||||||
void openConnection();
|
void openConnection();
|
||||||
void closeConnection();
|
void closeConnection();
|
||||||
|
|
||||||
|
bool isRevokeBlockedDuringActiveConnection(const QString &serverId, int containerIndex, const QString &clientId) const;
|
||||||
|
|
||||||
ErrorCode getLastConnectionError();
|
ErrorCode getLastConnectionError();
|
||||||
void onConnectionStateChanged(Vpn::ConnectionState state);
|
void onConnectionStateChanged(Vpn::ConnectionState state);
|
||||||
|
|
||||||
@@ -48,9 +50,12 @@ signals:
|
|||||||
void connectButtonClicked();
|
void connectButtonClicked();
|
||||||
void preparingConfig();
|
void preparingConfig();
|
||||||
void prepareConfig();
|
void prepareConfig();
|
||||||
|
void unsupportedConnectDrawerRequested();
|
||||||
|
void noInstalledContainers();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vpn::ConnectionState getCurrentConnectionState();
|
Vpn::ConnectionState getCurrentConnectionState();
|
||||||
|
void notifyConnectionBlocked(ErrorCode errorCode);
|
||||||
|
|
||||||
ConnectionController* m_connectionController;
|
ConnectionController* m_connectionController;
|
||||||
ServersController* m_serversController;
|
ServersController* m_serversController;
|
||||||
|
|||||||
@@ -75,13 +75,7 @@ InstallUiController::InstallUiController(InstallController *installController,
|
|||||||
m_connectionController(connectionController)
|
m_connectionController(connectionController)
|
||||||
{
|
{
|
||||||
connect(m_installController, &InstallController::configValidated, this, &InstallUiController::configValidated);
|
connect(m_installController, &InstallController::configValidated, this, &InstallUiController::configValidated);
|
||||||
connect(m_installController, &InstallController::validationErrorOccurred, this, [this](ErrorCode errorCode) {
|
connect(m_installController, &InstallController::validationErrorOccurred, this, &InstallUiController::installationErrorOccurred);
|
||||||
if (errorCode == ErrorCode::NoInstalledContainersError) {
|
|
||||||
emit noInstalledContainers();
|
|
||||||
} else {
|
|
||||||
emit installationErrorOccurred(errorCode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallUiController::~InstallUiController()
|
InstallUiController::~InstallUiController()
|
||||||
@@ -217,13 +211,11 @@ void InstallUiController::scanServerForInstalledContainers(const QString &server
|
|||||||
emit installationErrorOccurred(errorCode);
|
emit installationErrorOccurred(errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallUiController::updateContainer(const QString &serverId, int containerIndex, int protocolIndex, bool closePage)
|
bool InstallUiController::buildContainerConfigFromModel(int containerIndex, int protocolIndex, ContainerConfig &containerConfig)
|
||||||
{
|
{
|
||||||
DockerContainer container = static_cast<DockerContainer>(containerIndex);
|
DockerContainer container = static_cast<DockerContainer>(containerIndex);
|
||||||
|
|
||||||
Proto protocolType = static_cast<Proto>(protocolIndex);
|
Proto protocolType = static_cast<Proto>(protocolIndex);
|
||||||
|
|
||||||
ContainerConfig containerConfig;
|
|
||||||
containerConfig.container = container;
|
containerConfig.container = container;
|
||||||
|
|
||||||
switch (protocolType) {
|
switch (protocolType) {
|
||||||
@@ -271,6 +263,41 @@ void InstallUiController::updateContainer(const QString &serverId, int container
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstallUiController::updateClientConfig(const QString &serverId, int containerIndex, int protocolIndex, bool closePage)
|
||||||
|
{
|
||||||
|
DockerContainer container = static_cast<DockerContainer>(containerIndex);
|
||||||
|
Proto protocolType = static_cast<Proto>(protocolIndex);
|
||||||
|
|
||||||
|
ContainerConfig containerConfig;
|
||||||
|
if (!buildContainerConfigFromModel(containerIndex, protocolIndex, containerConfig)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode errorCode = m_installController->updateClientConfig(serverId, container, containerConfig);
|
||||||
|
|
||||||
|
if (errorCode == ErrorCode::NoError) {
|
||||||
|
ContainerConfig updatedConfig = m_serversController->getContainerConfig(serverId, container);
|
||||||
|
m_protocolModel->updateModel(updatedConfig);
|
||||||
|
updateProtocolConfigModel(serverId, static_cast<int>(container), static_cast<int>(protocolType));
|
||||||
|
emit updateContainerFinished(tr("Settings updated successfully"), closePage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit installationErrorOccurred(errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstallUiController::updateServerConfig(const QString &serverId, int containerIndex, int protocolIndex, bool closePage)
|
||||||
|
{
|
||||||
|
DockerContainer container = static_cast<DockerContainer>(containerIndex);
|
||||||
|
Proto protocolType = static_cast<Proto>(protocolIndex);
|
||||||
|
|
||||||
|
ContainerConfig containerConfig;
|
||||||
|
if (!buildContainerConfigFromModel(containerIndex, protocolIndex, containerConfig)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ContainerConfig oldContainerConfig = m_serversController->getContainerConfig(serverId, container);
|
ContainerConfig oldContainerConfig = m_serversController->getContainerConfig(serverId, container);
|
||||||
@@ -305,13 +332,13 @@ void InstallUiController::updateContainer(const QString &serverId, int container
|
|||||||
QFuture<ErrorCode> future =
|
QFuture<ErrorCode> future =
|
||||||
QtConcurrent::run([installController, serverId, container, oldConfigCopy,
|
QtConcurrent::run([installController, serverId, container, oldConfigCopy,
|
||||||
newConfigCopy]() mutable -> ErrorCode {
|
newConfigCopy]() mutable -> ErrorCode {
|
||||||
return installController->updateContainer(serverId, container, oldConfigCopy, newConfigCopy);
|
return installController->updateServerConfig(serverId, container, oldConfigCopy, newConfigCopy);
|
||||||
});
|
});
|
||||||
watcher->setFuture(future);
|
watcher->setFuture(future);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode errorCode = m_installController->updateContainer(serverId, container, oldContainerConfig, containerConfig);
|
ErrorCode errorCode = m_installController->updateServerConfig(serverId, container, oldContainerConfig, containerConfig);
|
||||||
|
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
ContainerConfig updatedConfig = m_serversController->getContainerConfig(serverId, container);
|
ContainerConfig updatedConfig = m_serversController->getContainerConfig(serverId, container);
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ public slots:
|
|||||||
|
|
||||||
void scanServerForInstalledContainers(const QString &serverId);
|
void scanServerForInstalledContainers(const QString &serverId);
|
||||||
|
|
||||||
void updateContainer(const QString &serverId, int containerIndex, int protocolIndex, bool closePage = true);
|
void updateServerConfig(const QString &serverId, int containerIndex, int protocolIndex, bool closePage = true);
|
||||||
|
void updateClientConfig(const QString &serverId, int containerIndex, int protocolIndex, bool closePage = true);
|
||||||
|
|
||||||
void removeServer(const QString &serverId);
|
void removeServer(const QString &serverId);
|
||||||
void rebootServer(const QString &serverId);
|
void rebootServer(const QString &serverId);
|
||||||
@@ -132,7 +133,6 @@ signals:
|
|||||||
void cachedProfileCleared(const QString &message);
|
void cachedProfileCleared(const QString &message);
|
||||||
void apiConfigRemoved(const QString &message);
|
void apiConfigRemoved(const QString &message);
|
||||||
|
|
||||||
void noInstalledContainers();
|
|
||||||
void configValidated(bool isValid);
|
void configValidated(bool isValid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -162,6 +162,8 @@ private:
|
|||||||
QString m_privateKeyPassphrase;
|
QString m_privateKeyPassphrase;
|
||||||
|
|
||||||
void updateProtocolConfigModel(const QString &serverId, int containerIndex, int protocolIndex);
|
void updateProtocolConfigModel(const QString &serverId, int containerIndex, int protocolIndex);
|
||||||
|
|
||||||
|
bool buildContainerConfigFromModel(int containerIndex, int protocolIndex, ContainerConfig &containerConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INSTALLUICONTROLLER_H
|
#endif // INSTALLUICONTROLLER_H
|
||||||
|
|||||||
@@ -156,7 +156,17 @@ void ServersUiController::updateModel()
|
|||||||
|
|
||||||
m_serversModel->updateModel(m_orderedServerDescriptions, defaultServerId);
|
m_serversModel->updateModel(m_orderedServerDescriptions, defaultServerId);
|
||||||
|
|
||||||
|
if (!m_processedServerId.isEmpty()) {
|
||||||
|
if (isServerFromApi(m_processedServerId)) {
|
||||||
|
const auto &description = serverDescriptionById(m_processedServerId);
|
||||||
|
if (description.isApiV2 && description.isCountrySelectionAvailable
|
||||||
|
&& !description.apiAvailableCountries.isEmpty()) {
|
||||||
|
emit updateApiCountryModel();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
updateContainersModel();
|
updateContainersModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
updateDefaultServerContainersModel();
|
updateDefaultServerContainersModel();
|
||||||
|
|
||||||
if (hadServersFromGatewayBefore != hasServersFromGatewayNow) {
|
if (hadServersFromGatewayBefore != hasServersFromGatewayNow) {
|
||||||
@@ -350,19 +360,14 @@ void ServersUiController::setProcessedServerId(const QString &serverId)
|
|||||||
m_processedServerId = normalizedServerId;
|
m_processedServerId = normalizedServerId;
|
||||||
|
|
||||||
if (newIndex >= 0) {
|
if (newIndex >= 0) {
|
||||||
updateContainersModel();
|
if (isServerFromApi(m_processedServerId)) {
|
||||||
|
const auto &description = serverDescriptionById(m_processedServerId);
|
||||||
for (const auto &description : m_orderedServerDescriptions) {
|
if (description.isApiV2 && description.isCountrySelectionAvailable
|
||||||
if (description.serverId != normalizedServerId) {
|
&& !description.apiAvailableCountries.isEmpty()) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (description.isApiV2) {
|
|
||||||
if (description.isCountrySelectionAvailable && !description.apiAvailableCountries.isEmpty()) {
|
|
||||||
emit updateApiCountryModel();
|
emit updateApiCountryModel();
|
||||||
}
|
}
|
||||||
emit updateApiServicesModel();
|
} else {
|
||||||
}
|
updateContainersModel();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ signals:
|
|||||||
void processedContainerIndexChanged(int index);
|
void processedContainerIndexChanged(int index);
|
||||||
void hasServersFromGatewayApiChanged();
|
void hasServersFromGatewayApiChanged();
|
||||||
void updateApiCountryModel();
|
void updateApiCountryModel();
|
||||||
void updateApiServicesModel();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void updateModel();
|
void updateModel();
|
||||||
|
|||||||
@@ -22,12 +22,10 @@
|
|||||||
|
|
||||||
SettingsUiController::SettingsUiController(SettingsController* settingsController,
|
SettingsUiController::SettingsUiController(SettingsController* settingsController,
|
||||||
ServersController* serversController,
|
ServersController* serversController,
|
||||||
LanguageUiController* languageUiController,
|
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_settingsController(settingsController),
|
m_settingsController(settingsController),
|
||||||
m_serversController(serversController),
|
m_serversController(serversController)
|
||||||
m_languageUiController(languageUiController)
|
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
connect(AndroidController::instance(), &AndroidController::notificationStateChanged, this, &SettingsUiController::onNotificationStateChanged);
|
connect(AndroidController::instance(), &AndroidController::notificationStateChanged, this, &SettingsUiController::onNotificationStateChanged);
|
||||||
@@ -157,13 +155,13 @@ void SettingsUiController::restoreAppConfigFromData(const QByteArray &data)
|
|||||||
{
|
{
|
||||||
ErrorCode errorCode = m_settingsController->restoreAppConfigFromData(data);
|
ErrorCode errorCode = m_settingsController->restoreAppConfigFromData(data);
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
emit appLanguageChanged(
|
emit appLanguageChanged();
|
||||||
static_cast<LanguageSettings::AvailableLanguageEnum>(m_languageUiController->getCurrentLanguageIndex()));
|
|
||||||
|
|
||||||
bool amneziaDnsEnabled = m_settingsController->isAmneziaDnsEnabled();
|
bool amneziaDnsEnabled = m_settingsController->isAmneziaDnsEnabled();
|
||||||
emit amneziaDnsToggled(amneziaDnsEnabled);
|
emit amneziaDnsToggled(amneziaDnsEnabled);
|
||||||
|
|
||||||
emit restoreBackupFinished();
|
emit restoreBackupFinished();
|
||||||
|
emit autoStartChanged();
|
||||||
emit startMinimizedChanged();
|
emit startMinimizedChanged();
|
||||||
} else {
|
} else {
|
||||||
emit errorOccurred(errorCode);
|
emit errorOccurred(errorCode);
|
||||||
@@ -178,6 +176,7 @@ QString SettingsUiController::getAppVersion()
|
|||||||
void SettingsUiController::clearSettings()
|
void SettingsUiController::clearSettings()
|
||||||
{
|
{
|
||||||
m_settingsController->clearSettings();
|
m_settingsController->clearSettings();
|
||||||
|
emit autoStartChanged();
|
||||||
emit startMinimizedChanged();
|
emit startMinimizedChanged();
|
||||||
emit resetLanguageToSystem();
|
emit resetLanguageToSystem();
|
||||||
|
|
||||||
@@ -206,9 +205,8 @@ bool SettingsUiController::isAutoStartEnabled()
|
|||||||
void SettingsUiController::toggleAutoStart(bool enable)
|
void SettingsUiController::toggleAutoStart(bool enable)
|
||||||
{
|
{
|
||||||
m_settingsController->toggleAutoStart(enable);
|
m_settingsController->toggleAutoStart(enable);
|
||||||
if (!enable) {
|
emit autoStartChanged();
|
||||||
emit startMinimizedChanged();
|
emit startMinimizedChanged();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingsUiController::isStartMinimizedEnabled()
|
bool SettingsUiController::isStartMinimizedEnabled()
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
#include "core/controllers/settingsController.h"
|
#include "core/controllers/settingsController.h"
|
||||||
#include "core/controllers/serversController.h"
|
#include "core/controllers/serversController.h"
|
||||||
#include "ui/controllers/languageUiController.h"
|
|
||||||
#include "ui/models/languageModel.h"
|
|
||||||
#include "core/utils/errorCodes.h"
|
#include "core/utils/errorCodes.h"
|
||||||
#include "core/utils/routeModes.h"
|
#include "core/utils/routeModes.h"
|
||||||
#include "core/utils/commonStructs.h"
|
#include "core/utils/commonStructs.h"
|
||||||
@@ -17,7 +15,6 @@ class SettingsUiController : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit SettingsUiController(SettingsController* settingsController,
|
explicit SettingsUiController(SettingsController* settingsController,
|
||||||
ServersController* serversController,
|
ServersController* serversController,
|
||||||
LanguageUiController* languageUiController,
|
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
Q_PROPERTY(QString primaryDns READ getPrimaryDns WRITE setPrimaryDns NOTIFY primaryDnsChanged)
|
Q_PROPERTY(QString primaryDns READ getPrimaryDns WRITE setPrimaryDns NOTIFY primaryDnsChanged)
|
||||||
@@ -32,6 +29,7 @@ public:
|
|||||||
Q_PROPERTY(bool isDevGatewayEnv READ isDevGatewayEnv WRITE toggleDevGatewayEnv NOTIFY devGatewayEnvChanged)
|
Q_PROPERTY(bool isDevGatewayEnv READ isDevGatewayEnv WRITE toggleDevGatewayEnv NOTIFY devGatewayEnvChanged)
|
||||||
|
|
||||||
Q_PROPERTY(bool isHomeAdLabelVisible READ isHomeAdLabelVisible NOTIFY isHomeAdLabelVisibleChanged)
|
Q_PROPERTY(bool isHomeAdLabelVisible READ isHomeAdLabelVisible NOTIFY isHomeAdLabelVisibleChanged)
|
||||||
|
Q_PROPERTY(bool autoStartEnabled READ isAutoStartEnabled NOTIFY autoStartChanged)
|
||||||
Q_PROPERTY(bool startMinimized READ isStartMinimizedEnabled NOTIFY startMinimizedChanged)
|
Q_PROPERTY(bool startMinimized READ isStartMinimizedEnabled NOTIFY startMinimizedChanged)
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -122,7 +120,7 @@ signals:
|
|||||||
|
|
||||||
void loggingDisableByWatcher();
|
void loggingDisableByWatcher();
|
||||||
|
|
||||||
void appLanguageChanged(const LanguageSettings::AvailableLanguageEnum language);
|
void appLanguageChanged();
|
||||||
void resetLanguageToSystem();
|
void resetLanguageToSystem();
|
||||||
|
|
||||||
void onNotificationStateChanged();
|
void onNotificationStateChanged();
|
||||||
@@ -135,12 +133,12 @@ signals:
|
|||||||
void activityResumed();
|
void activityResumed();
|
||||||
|
|
||||||
void isHomeAdLabelVisibleChanged(bool visible);
|
void isHomeAdLabelVisibleChanged(bool visible);
|
||||||
|
void autoStartChanged();
|
||||||
void startMinimizedChanged();
|
void startMinimizedChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SettingsController* m_settingsController;
|
SettingsController* m_settingsController;
|
||||||
ServersController* m_serversController;
|
ServersController* m_serversController;
|
||||||
LanguageUiController* m_languageUiController;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ QVariant ApiAccountInfoModel::data(const QModelIndex &index, int role) const
|
|||||||
switch (role) {
|
switch (role) {
|
||||||
case SubscriptionStatusRole: {
|
case SubscriptionStatusRole: {
|
||||||
if (m_accountInfoData.configType == serverConfigUtils::ConfigType::AmneziaFreeV3) {
|
if (m_accountInfoData.configType == serverConfigUtils::ConfigType::AmneziaFreeV3) {
|
||||||
return tr("Active");
|
return QStringLiteral("<p><a style=\"color: #28c840;\">%1</a>").arg(tr("Active"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiUtils::isSubscriptionExpired(m_accountInfoData.subscriptionEndDate)
|
return apiUtils::isSubscriptionExpired(m_accountInfoData.subscriptionEndDate)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ QVariant ClientManagementModel::data(const QModelIndex &index, int role) const
|
|||||||
auto userData = client.value(configKey::userData).toObject();
|
auto userData = client.value(configKey::userData).toObject();
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
case ClientIdRole: return client.value(configKey::clientId).toString();
|
||||||
case ClientNameRole: return userData.value(configKey::clientName).toString();
|
case ClientNameRole: return userData.value(configKey::clientName).toString();
|
||||||
case CreationDateRole: return userData.value(configKey::creationDate).toString();
|
case CreationDateRole: return userData.value(configKey::creationDate).toString();
|
||||||
case LatestHandshakeRole: return userData.value(configKey::latestHandshake).toString();
|
case LatestHandshakeRole: return userData.value(configKey::latestHandshake).toString();
|
||||||
@@ -62,6 +63,7 @@ void ClientManagementModel::updateClientName(int row, const QString &newName)
|
|||||||
QHash<int, QByteArray> ClientManagementModel::roleNames() const
|
QHash<int, QByteArray> ClientManagementModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
roles[ClientIdRole] = "clientId";
|
||||||
roles[ClientNameRole] = "clientName";
|
roles[ClientNameRole] = "clientName";
|
||||||
roles[CreationDateRole] = "creationDate";
|
roles[CreationDateRole] = "creationDate";
|
||||||
roles[LatestHandshakeRole] = "latestHandshake";
|
roles[LatestHandshakeRole] = "latestHandshake";
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ class ClientManagementModel : public QAbstractListModel
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
enum Roles {
|
enum Roles {
|
||||||
ClientNameRole = Qt::UserRole + 1,
|
ClientIdRole = Qt::UserRole + 1,
|
||||||
|
ClientNameRole,
|
||||||
CreationDateRole,
|
CreationDateRole,
|
||||||
LatestHandshakeRole,
|
LatestHandshakeRole,
|
||||||
DataReceivedRole,
|
DataReceivedRole,
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ public:
|
|||||||
Q_INVOKABLE int containerFromString(const QString &container) const {
|
Q_INVOKABLE int containerFromString(const QString &container) const {
|
||||||
return static_cast<int>(amnezia::ContainerUtils::containerFromString(container));
|
return static_cast<int>(amnezia::ContainerUtils::containerFromString(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_INVOKABLE bool isUnsupportedContainer(int containerIndex) const {
|
||||||
|
return amnezia::ContainerUtils::isUnsupportedContainer(static_cast<amnezia::DockerContainer>(containerIndex));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTAINERPROPS_H
|
#endif // CONTAINERPROPS_H
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
|||||||
case IsCurrentlyProcessedRole: return container == static_cast<DockerContainer>(m_processedContainerIndex);
|
case IsCurrentlyProcessedRole: return container == static_cast<DockerContainer>(m_processedContainerIndex);
|
||||||
case IsSupportedRole: return ContainerUtils::isSupportedByCurrentPlatform(container);
|
case IsSupportedRole: return ContainerUtils::isSupportedByCurrentPlatform(container);
|
||||||
case IsShareableRole: return ContainerUtils::isShareable(container);
|
case IsShareableRole: return ContainerUtils::isShareable(container);
|
||||||
|
case IsUnsupportedContainerRole: return ContainerUtils::isUnsupportedContainer(container);
|
||||||
case IsVpnContainerRole: return ContainerUtils::containerService(container) == ServiceType::Vpn;
|
case IsVpnContainerRole: return ContainerUtils::containerService(container) == ServiceType::Vpn;
|
||||||
case IsServiceContainerRole: return ContainerUtils::containerService(container) == ServiceType::Other;
|
case IsServiceContainerRole: return ContainerUtils::containerService(container) == ServiceType::Other;
|
||||||
case IsIpsecRole: return container == DockerContainer::Ipsec;
|
case IsIpsecRole: return container == DockerContainer::Ipsec;
|
||||||
@@ -142,7 +143,8 @@ bool ContainersModel::hasInstalledProtocols()
|
|||||||
|
|
||||||
bool ContainersModel::isInstallationAllowed(DockerContainer container)
|
bool ContainersModel::isInstallationAllowed(DockerContainer container)
|
||||||
{
|
{
|
||||||
return container != DockerContainer::Awg;
|
return container != DockerContainer::Awg
|
||||||
|
&& !ContainerUtils::isUnsupportedContainer(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainersModel::openContainerSettings(int containerIndex)
|
void ContainersModel::openContainerSettings(int containerIndex)
|
||||||
@@ -176,6 +178,7 @@ QHash<int, QByteArray> ContainersModel::roleNames() const
|
|||||||
roles[IsCurrentlyProcessedRole] = "isCurrentlyProcessed";
|
roles[IsCurrentlyProcessedRole] = "isCurrentlyProcessed";
|
||||||
roles[IsSupportedRole] = "isSupported";
|
roles[IsSupportedRole] = "isSupported";
|
||||||
roles[IsShareableRole] = "isShareable";
|
roles[IsShareableRole] = "isShareable";
|
||||||
|
roles[IsUnsupportedContainerRole] = "isUnsupportedContainer";
|
||||||
roles[IsInstallationAllowedRole] = "isInstallationAllowed";
|
roles[IsInstallationAllowedRole] = "isInstallationAllowed";
|
||||||
roles[InstallPageOrderRole] = "installPageOrder";
|
roles[InstallPageOrderRole] = "installPageOrder";
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ public:
|
|||||||
IsSupportedRole,
|
IsSupportedRole,
|
||||||
IsShareableRole,
|
IsShareableRole,
|
||||||
|
|
||||||
|
IsUnsupportedContainerRole,
|
||||||
|
|
||||||
InstallPageOrderRole,
|
InstallPageOrderRole,
|
||||||
|
|
||||||
// Container type check roles
|
// Container type check roles
|
||||||
|
|||||||
@@ -56,14 +56,17 @@ ListViewType {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checked) {
|
var containerIndex = proxyDefaultServerContainersModel.mapToSource(index)
|
||||||
containersDropDown.closeTriggered()
|
|
||||||
ServersUiController.setDefaultContainer(ServersUiController.defaultServerId, proxyDefaultServerContainersModel.mapToSource(index))
|
if (!isInstalled) {
|
||||||
} else {
|
ServersUiController.processedContainerIndex = containerIndex
|
||||||
ServersUiController.processedContainerIndex = proxyDefaultServerContainersModel.mapToSource(index)
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
|
PageController.goToPage(PageEnum.PageSetupWizardProtocolSettings)
|
||||||
containersDropDown.closeTriggered()
|
containersDropDown.closeTriggered()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
containersDropDown.closeTriggered()
|
||||||
|
ServersUiController.setDefaultContainer(ServersUiController.defaultServerId, containerIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import QtQuick.Layouts
|
|||||||
import SortFilterProxyModel 0.2
|
import SortFilterProxyModel 0.2
|
||||||
|
|
||||||
import PageEnum 1.0
|
import PageEnum 1.0
|
||||||
import ContainerProps 1.0
|
|
||||||
|
|
||||||
import "../Controls2"
|
import "../Controls2"
|
||||||
import "../Controls2/TextTypes"
|
import "../Controls2/TextTypes"
|
||||||
|
|||||||
@@ -6,8 +6,36 @@ Menu {
|
|||||||
|
|
||||||
popupType: Popup.Native
|
popupType: Popup.Native
|
||||||
|
|
||||||
onAboutToShow: blocker.enabled = true
|
property Item inputBlocker: null
|
||||||
onClosed: blocker.enabled = false
|
|
||||||
|
Component {
|
||||||
|
id: inputBlockerComponent
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
preventStealing: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onAboutToShow: {
|
||||||
|
if (!textObj || !textObj.window) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const contentItem = textObj.window.contentItem
|
||||||
|
if (!inputBlocker) {
|
||||||
|
inputBlocker = inputBlockerComponent.createObject(contentItem)
|
||||||
|
} else {
|
||||||
|
inputBlocker.parent = contentItem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClosed: {
|
||||||
|
if (inputBlocker) {
|
||||||
|
inputBlocker.destroy()
|
||||||
|
inputBlocker = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: qsTr("C&ut")
|
text: qsTr("C&ut")
|
||||||
@@ -31,11 +59,4 @@ Menu {
|
|||||||
enabled: textObj.length > 0
|
enabled: textObj.length > 0
|
||||||
onTriggered: textObj.selectAll()
|
onTriggered: textObj.selectAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: blocker
|
|
||||||
z: 2
|
|
||||||
enabled: false
|
|
||||||
preventStealing: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ PageType {
|
|||||||
|
|
||||||
filters: [
|
filters: [
|
||||||
ValueFilter {
|
ValueFilter {
|
||||||
roleName: "isCurrentlyProcessed"
|
roleName: "serverId"
|
||||||
value: true
|
value: ServersUiController.processedServerId
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -440,8 +440,7 @@ PageType {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
InstallController.updateClientConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Awg)
|
||||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Awg)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var noButtonFunction = function() {}
|
var noButtonFunction = function() {}
|
||||||
|
|||||||
@@ -561,7 +561,7 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Awg)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Awg)
|
||||||
}
|
}
|
||||||
|
|
||||||
var noButtonFunction = function() {}
|
var noButtonFunction = function() {}
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.OpenVpn)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.OpenVpn)
|
||||||
}
|
}
|
||||||
var noButtonFunction = function() {
|
var noButtonFunction = function() {
|
||||||
if (!GC.isMobile()) {
|
if (!GC.isMobile()) {
|
||||||
|
|||||||
@@ -128,8 +128,7 @@ PageType {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
InstallController.updateClientConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.WireGuard)
|
||||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.WireGuard)
|
|
||||||
}
|
}
|
||||||
var noButtonFunction = function() {}
|
var noButtonFunction = function() {}
|
||||||
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.WireGuard)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.WireGuard)
|
||||||
}
|
}
|
||||||
var noButtonFunction = function() {
|
var noButtonFunction = function() {
|
||||||
if (!GC.isMobile()) {
|
if (!GC.isMobile()) {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ PageType {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||||
}
|
}
|
||||||
var noButtonFunction = function () {
|
var noButtonFunction = function () {
|
||||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ PageType {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||||
}
|
}
|
||||||
var noButtonFunction = function () {
|
var noButtonFunction = function () {
|
||||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ import "../Components"
|
|||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
enableTimer: false
|
||||||
|
|
||||||
|
property bool portDirty: false
|
||||||
|
|
||||||
function formatTransport(value) {
|
function formatTransport(value) {
|
||||||
if (value === "raw") return "RAW (TCP)"
|
if (value === "raw") return "RAW (TCP)"
|
||||||
if (value === "xhttp") return "XHTTP"
|
if (value === "xhttp") return "XHTTP"
|
||||||
@@ -39,8 +43,8 @@ PageType {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.topMargin: 20 + PageController.safeAreaTopMargin
|
anchors.topMargin: 20 + PageController.safeAreaTopMargin
|
||||||
|
|
||||||
onFocusChanged: {
|
onActiveFocusChanged: {
|
||||||
if (this.activeFocus) {
|
if (backButton.enabled && backButton.activeFocus) {
|
||||||
listView.positionViewAtBeginning()
|
listView.positionViewAtBeginning()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,8 +64,6 @@ PageType {
|
|||||||
delegate: ColumnLayout {
|
delegate: ColumnLayout {
|
||||||
width: listView.width
|
width: listView.width
|
||||||
|
|
||||||
property alias focusItemId: textFieldWithHeaderType.textField
|
|
||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@@ -107,13 +109,32 @@ PageType {
|
|||||||
Layout.rightMargin: 16
|
Layout.rightMargin: 16
|
||||||
enabled: listView.enabled
|
enabled: listView.enabled
|
||||||
headerText: qsTr("Port")
|
headerText: qsTr("Port")
|
||||||
textField.text: port
|
|
||||||
|
Binding {
|
||||||
|
target: textFieldWithHeaderType.textField
|
||||||
|
property: "text"
|
||||||
|
value: port
|
||||||
|
when: !textFieldWithHeaderType.textField.activeFocus
|
||||||
|
restoreMode: Binding.RestoreNone
|
||||||
|
}
|
||||||
|
|
||||||
textField.maximumLength: 5
|
textField.maximumLength: 5
|
||||||
textField.validator: IntValidator {
|
textField.validator: IntValidator {
|
||||||
bottom: 1; top: 65535
|
bottom: 1; top: 65535
|
||||||
}
|
}
|
||||||
|
textField.onActiveFocusChanged: {
|
||||||
|
if (textField.activeFocus && textField.text === "" && port !== "") {
|
||||||
|
textField.text = port
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textField.onTextChanged: {
|
||||||
|
root.portDirty = (textField.text !== port)
|
||||||
|
}
|
||||||
textField.onEditingFinished: {
|
textField.onEditingFinished: {
|
||||||
if (textField.text !== port) port = textField.text
|
if (textField.text !== port) {
|
||||||
|
port = textField.text
|
||||||
|
}
|
||||||
|
root.portDirty = false
|
||||||
}
|
}
|
||||||
checkEmptyText: true
|
checkEmptyText: true
|
||||||
}
|
}
|
||||||
@@ -172,9 +193,8 @@ PageType {
|
|||||||
Layout.leftMargin: 16
|
Layout.leftMargin: 16
|
||||||
Layout.rightMargin: 16
|
Layout.rightMargin: 16
|
||||||
visible: listView.enabled
|
visible: listView.enabled
|
||||||
&& (XrayConfigModel.hasUnsavedChanges
|
&& (XrayConfigModel.hasUnsavedChanges || root.portDirty)
|
||||||
|| textFieldWithHeaderType.textField.text !== port)
|
enabled: visible && textFieldWithHeaderType.textField.text !== ""
|
||||||
enabled: visible && textFieldWithHeaderType.errorText === ""
|
|
||||||
text: qsTr("Save")
|
text: qsTr("Save")
|
||||||
onClicked: function() {
|
onClicked: function() {
|
||||||
forceActiveFocus()
|
forceActiveFocus()
|
||||||
@@ -193,7 +213,7 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling);
|
||||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||||
}
|
}
|
||||||
var noButtonFunction = function() {
|
var noButtonFunction = function() {
|
||||||
if (!GC.isMobile()) saveButton.forceActiveFocus()
|
if (!GC.isMobile()) saveButton.forceActiveFocus()
|
||||||
|
|||||||
@@ -742,7 +742,7 @@ PageType {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||||
}
|
}
|
||||||
var noButtonFunction = function () {
|
var noButtonFunction = function () {
|
||||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ PageType {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||||
}
|
}
|
||||||
var noButtonFunction = function () {
|
var noButtonFunction = function () {
|
||||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ PageType {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||||
}
|
}
|
||||||
var noButtonFunction = function () {
|
var noButtonFunction = function () {
|
||||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ PageType {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||||
InstallController.updateContainer(ServersUiController.processedIndex, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Xray)
|
||||||
}
|
}
|
||||||
var noButtonFunction = function () {
|
var noButtonFunction = function () {
|
||||||
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
if (typeof GC !== "undefined" && !GC.isMobile()) {
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ PageType {
|
|||||||
function mtProxyScheduleUpdate(closePage) {
|
function mtProxyScheduleUpdate(closePage) {
|
||||||
var cp = closePage === undefined ? false : closePage
|
var cp = closePage === undefined ? false : closePage
|
||||||
Qt.callLater(function () {
|
Qt.callLater(function () {
|
||||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.MtProxy, cp)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.MtProxy, cp)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
PageController.goToPage(PageEnum.PageSetupWizardInstalling)
|
||||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Socks5Proxy)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Socks5Proxy)
|
||||||
tempPort = portTextField.textField.text
|
tempPort = portTextField.textField.text
|
||||||
tempUsername = usernameTextField.textField.text
|
tempUsername = usernameTextField.textField.text
|
||||||
tempPassword = passwordTextField.textField.text
|
tempPassword = passwordTextField.textField.text
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ PageType {
|
|||||||
function telemtScheduleUpdate(closePage) {
|
function telemtScheduleUpdate(closePage) {
|
||||||
var cp = closePage === undefined ? false : closePage
|
var cp = closePage === undefined ? false : closePage
|
||||||
Qt.callLater(function () {
|
Qt.callLater(function () {
|
||||||
InstallController.updateContainer(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Telemt, cp)
|
InstallController.updateServerConfig(ServersUiController.processedServerId, ServersUiController.processedContainerIndex, ProtocolEnum.Telemt, cp)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,12 @@ PageType {
|
|||||||
onLinkActivated: Qt.openUrlExternally(link)
|
onLinkActivated: Qt.openUrlExternally(link)
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: qsTr("Use <a href=\"https://www.torproject.org/download/\" style=\"color: #FBB26A;\">Tor Browser</a> to open this URL.")
|
text: qsTr("Use <a href=\"https://www.torproject.org/download/\" style=\"color: #FBB26A;\">Tor Browser</a> to open this URL.")
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.NoButton
|
||||||
|
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParagraphTextType {
|
ParagraphTextType {
|
||||||
|
|||||||
@@ -30,6 +30,16 @@ PageType {
|
|||||||
root.isInAppPurchase = ApiAccountInfoModel.data("isInAppPurchase")
|
root.isInAppPurchase = ApiAccountInfoModel.data("isInAppPurchase")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectConnectionCountry(countryIndex, countryCode, countryName) {
|
||||||
|
if (countryIndex === ApiCountryModel.currentIndex) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
PageController.showBusyIndicator(true)
|
||||||
|
SubscriptionUiController.updateServiceFromGateway(ServersUiController.processedServerId, countryCode, countryName)
|
||||||
|
PageController.showBusyIndicator(false)
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
root.updateSubscriptionState()
|
root.updateSubscriptionState()
|
||||||
}
|
}
|
||||||
@@ -83,7 +93,7 @@ PageType {
|
|||||||
|
|
||||||
model: ApiCountryModel
|
model: ApiCountryModel
|
||||||
|
|
||||||
currentIndex: 0
|
currentIndex: ApiCountryModel.currentIndex
|
||||||
|
|
||||||
ButtonGroup {
|
ButtonGroup {
|
||||||
id: containersRadioButtonGroup
|
id: containersRadioButtonGroup
|
||||||
@@ -204,15 +214,7 @@ PageType {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index !== ApiCountryModel.currentIndex) {
|
root.selectConnectionCountry(index, countryCode, countryName)
|
||||||
PageController.showBusyIndicator(true)
|
|
||||||
var prevIndex = ApiCountryModel.currentIndex
|
|
||||||
ApiCountryModel.currentIndex = index
|
|
||||||
if (!SubscriptionUiController.updateServiceFromGateway(ServersUiController.processedServerId, countryCode, countryName)) {
|
|
||||||
ApiCountryModel.currentIndex = prevIndex
|
|
||||||
}
|
|
||||||
PageController.showBusyIndicator(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onEnterPressed: {
|
Keys.onEnterPressed: {
|
||||||
|
|||||||
@@ -108,9 +108,9 @@ PageType {
|
|||||||
text: qsTr("Auto start")
|
text: qsTr("Auto start")
|
||||||
descriptionText: qsTr("Launch the application every time the device is starts")
|
descriptionText: qsTr("Launch the application every time the device is starts")
|
||||||
|
|
||||||
checked: SettingsController.isAutoStartEnabled()
|
checked: SettingsController.autoStartEnabled
|
||||||
onToggled: function() {
|
onToggled: function() {
|
||||||
if (checked !== SettingsController.isAutoStartEnabled()) {
|
if (checked !== SettingsController.autoStartEnabled) {
|
||||||
SettingsController.toggleAutoStart(checked)
|
SettingsController.toggleAutoStart(checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,10 +154,10 @@ PageType {
|
|||||||
text: qsTr("Start minimized")
|
text: qsTr("Start minimized")
|
||||||
descriptionText: qsTr("Launch application minimized (works with autostart option turned on)")
|
descriptionText: qsTr("Launch application minimized (works with autostart option turned on)")
|
||||||
|
|
||||||
enabled: SettingsController.isAutoStartEnabled()
|
enabled: SettingsController.autoStartEnabled
|
||||||
opacity: enabled ? 1.0 : 0.5
|
opacity: enabled ? 1.0 : 0.5
|
||||||
|
|
||||||
checked: SettingsController.isAutoStartEnabled() && SettingsController.startMinimized
|
checked: SettingsController.autoStartEnabled && SettingsController.startMinimized
|
||||||
onToggled: function() {
|
onToggled: function() {
|
||||||
if (checked !== SettingsController.startMinimized) {
|
if (checked !== SettingsController.startMinimized) {
|
||||||
SettingsController.toggleStartMinimized(checked)
|
SettingsController.toggleStartMinimized(checked)
|
||||||
@@ -166,7 +166,7 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DividerType {
|
DividerType {
|
||||||
visible: !GC.isMobile()
|
visible: !GC.isMobile() && ServersUiController.hasServersFromGatewayApi
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitcherType {
|
SwitcherType {
|
||||||
|
|||||||
@@ -36,17 +36,6 @@ PageType {
|
|||||||
function onRebootServerFinished(finishedMessage) {
|
function onRebootServerFinished(finishedMessage) {
|
||||||
PageController.showNotificationMessage(finishedMessage)
|
PageController.showNotificationMessage(finishedMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRemoveAllContainersFinished(finishedMessage) {
|
|
||||||
PageController.closePage() // close deInstalling page
|
|
||||||
PageController.showNotificationMessage(finishedMessage)
|
|
||||||
}
|
|
||||||
|
|
||||||
function onRemoveContainerFinished(finishedMessage) {
|
|
||||||
PageController.closePage() // close deInstalling page
|
|
||||||
PageController.closePage() // close page with remove button
|
|
||||||
PageController.showNotificationMessage(finishedMessage)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ import "../Components"
|
|||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property bool isClearCacheVisible: ServersUiController.isProcessedServerHasWriteAccess() && !ContainersModel.isServiceContainer(ServersUiController.processedContainerIndex)
|
property bool isUnsupportedContainer: ContainerProps.isUnsupportedContainer(ServersUiController.processedContainerIndex)
|
||||||
|
property bool isClearCacheVisible: !isUnsupportedContainer && ServersUiController.isProcessedServerHasWriteAccess() && !ContainersModel.isServiceContainer(ServersUiController.processedContainerIndex)
|
||||||
|
|
||||||
BackButtonType {
|
BackButtonType {
|
||||||
id: backButton
|
id: backButton
|
||||||
@@ -52,10 +53,11 @@ PageType {
|
|||||||
Layout.bottomMargin: 32
|
Layout.bottomMargin: 32
|
||||||
|
|
||||||
headerText: ContainersModel.getProcessedContainerName() + qsTr(" settings")
|
headerText: ContainersModel.getProcessedContainerName() + qsTr(" settings")
|
||||||
|
descriptionText: root.isUnsupportedContainer ? qsTr("This protocol is no longer supported.") : ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model: ProtocolsModel
|
model: root.isUnsupportedContainer ? null : ProtocolsModel
|
||||||
|
|
||||||
delegate: ColumnLayout {
|
delegate: ColumnLayout {
|
||||||
id: delegateContent
|
id: delegateContent
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ PageType {
|
|||||||
ValueFilter {
|
ValueFilter {
|
||||||
roleName: "isInstallationAllowed"
|
roleName: "isInstallationAllowed"
|
||||||
value: true
|
value: true
|
||||||
|
},
|
||||||
|
ValueFilter {
|
||||||
|
roleName: "isUnsupportedContainer"
|
||||||
|
value: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
sorters: RoleSorter {
|
sorters: RoleSorter {
|
||||||
|
|||||||
@@ -382,6 +382,10 @@ PageType {
|
|||||||
ValueFilter {
|
ValueFilter {
|
||||||
roleName: "isShareable"
|
roleName: "isShareable"
|
||||||
value: true
|
value: true
|
||||||
|
},
|
||||||
|
ValueFilter {
|
||||||
|
roleName: "isUnsupportedContainer"
|
||||||
|
value: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -396,9 +400,19 @@ PageType {
|
|||||||
target: serverSelector
|
target: serverSelector
|
||||||
|
|
||||||
function onServerSelectorIndexChanged() {
|
function onServerSelectorIndexChanged() {
|
||||||
var defaultContainer = proxyContainersModel.mapFromSource(ServersUiController.serverDefaultContainer(ServersUiController.processedServerId))
|
if (!proxyContainersModel.count) {
|
||||||
|
root.shareButtonEnabled = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var defaultContainer = proxyContainersModel.mapFromSource(
|
||||||
|
ServersUiController.serverDefaultContainer(ServersUiController.processedServerId))
|
||||||
|
if (defaultContainer < 0) {
|
||||||
|
defaultContainer = 0
|
||||||
|
}
|
||||||
|
|
||||||
containerSelectorListView.selectedIndex = defaultContainer
|
containerSelectorListView.selectedIndex = defaultContainer
|
||||||
containerSelectorListView.positionViewAtIndex(selectedIndex, ListView.Beginning)
|
containerSelectorListView.positionViewAtIndex(defaultContainer, ListView.Beginning)
|
||||||
containerSelectorListView.triggerCurrentItem()
|
containerSelectorListView.triggerCurrentItem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -837,11 +851,10 @@ PageType {
|
|||||||
var noButtonFunction = function() {
|
var noButtonFunction = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var isActiveConfigForCurrentClient = ServersUiController.isDefaultServerCurrentlyProcessed()
|
if (ConnectionController.isRevokeBlockedDuringActiveConnection(
|
||||||
&& ServersUiController.serverDefaultContainer(ServersUiController.defaultServerId) === ServersUiController.processedContainerIndex
|
ServersUiController.processedServerId,
|
||||||
|
ServersUiController.processedContainerIndex,
|
||||||
if ((ConnectionController.isConnectionInProgress || ConnectionController.isConnected)
|
clientId)) {
|
||||||
&& isActiveConfigForCurrentClient) {
|
|
||||||
PageController.showNotificationMessage("Unable to revoke current config during active connection")
|
PageController.showNotificationMessage("Unable to revoke current config during active connection")
|
||||||
} else {
|
} else {
|
||||||
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
||||||
|
|||||||
@@ -105,6 +105,19 @@ PageType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
objectName: "connectionControllerConnections"
|
||||||
|
|
||||||
|
target: ConnectionController
|
||||||
|
|
||||||
|
function onNoInstalledContainers() {
|
||||||
|
PageController.setTriggeredByConnectButton(true)
|
||||||
|
|
||||||
|
ServersUiController.setProcessedServerId(ServersUiController.defaultServerId)
|
||||||
|
PageController.goToPage(PageEnum.PageSetupWizardEasy)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
objectName: "installControllerConnections"
|
objectName: "installControllerConnections"
|
||||||
|
|
||||||
@@ -153,11 +166,19 @@ PageType {
|
|||||||
PageController.showNotificationMessage(finishedMessage)
|
PageController.showNotificationMessage(finishedMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onNoInstalledContainers() {
|
function onRemoveAllContainersFinished(finishedMessage) {
|
||||||
PageController.setTriggeredByConnectButton(true)
|
if (tabBarStackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageDeinstalling)) {
|
||||||
|
PageController.closePage()
|
||||||
|
}
|
||||||
|
PageController.showNotificationMessage(finishedMessage)
|
||||||
|
}
|
||||||
|
|
||||||
ServersUiController.setProcessedServerId(ServersUiController.defaultServerId)
|
function onRemoveContainerFinished(finishedMessage) {
|
||||||
PageController.goToPage(PageEnum.PageSetupWizardEasy)
|
if (tabBarStackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageDeinstalling)) {
|
||||||
|
PageController.closePage()
|
||||||
|
}
|
||||||
|
PageController.closePage()
|
||||||
|
PageController.showNotificationMessage(finishedMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -234,6 +234,8 @@ Window {
|
|||||||
DrawerType2 {
|
DrawerType2 {
|
||||||
id: privateKeyPassphraseDrawer
|
id: privateKeyPassphraseDrawer
|
||||||
|
|
||||||
|
property bool isCloseByUser: false
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
expandedHeight: root.height * 0.35 + PageController.safeAreaBottomMargin + PageController.imeHeight
|
expandedHeight: root.height * 0.35 + PageController.safeAreaBottomMargin + PageController.imeHeight
|
||||||
|
|
||||||
@@ -253,6 +255,11 @@ Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onAboutToHide() {
|
function onAboutToHide() {
|
||||||
|
if (privateKeyPassphraseDrawer.isCloseByUser === false) {
|
||||||
|
privateKeyPassphraseDrawer.isCloseByUser = true
|
||||||
|
PageController.passphraseRequestDrawerClosed("")
|
||||||
|
}
|
||||||
|
|
||||||
if (passphrase.textField.text !== "") {
|
if (passphrase.textField.text !== "") {
|
||||||
PageController.showBusyIndicator(true)
|
PageController.showBusyIndicator(true)
|
||||||
}
|
}
|
||||||
@@ -293,6 +300,7 @@ Window {
|
|||||||
text: qsTr("Save")
|
text: qsTr("Save")
|
||||||
|
|
||||||
clickedFunc: function() {
|
clickedFunc: function() {
|
||||||
|
privateKeyPassphraseDrawer.isCloseByUser = true
|
||||||
privateKeyPassphraseDrawer.closeTriggered()
|
privateKeyPassphraseDrawer.closeTriggered()
|
||||||
PageController.passphraseRequestDrawerClosed(passphrase.textField.text)
|
PageController.passphraseRequestDrawerClosed(passphrase.textField.text)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|||||||
set(_CONAN_INSTALL_ARGS
|
set(_CONAN_INSTALL_ARGS
|
||||||
"-c=tools.android:cmake_legacy_toolchain=false"
|
"-c=tools.android:cmake_legacy_toolchain=false"
|
||||||
"-c=tools.build:sharedlinkflags=['-Wl,-z,max-page-size=16384']"
|
"-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 "")
|
set(CMAKE_ANDROID_STL_TYPE "c++_shared" CACHE STRING "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -29,6 +28,12 @@ if (WIN32 OR APPLE)
|
|||||||
set(CMAKE_INSTALL_BINDIR ".")
|
set(CMAKE_INSTALL_BINDIR ".")
|
||||||
endif()
|
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(PREPEND _CONAN_INSTALL_ARGS "--build=missing")
|
||||||
list(JOIN _CONAN_INSTALL_ARGS ";" _CONAN_INSTALL_ARGS_JOINED)
|
list(JOIN _CONAN_INSTALL_ARGS ";" _CONAN_INSTALL_ARGS_JOINED)
|
||||||
set(CONAN_INSTALL_ARGS ${_CONAN_INSTALL_ARGS_JOINED} CACHE STRING "" FORCE)
|
set(CONAN_INSTALL_ARGS ${_CONAN_INSTALL_ARGS_JOINED} CACHE STRING "" FORCE)
|
||||||
|
|||||||
@@ -28,6 +28,42 @@ IpcServer::IpcServer(QObject *parent) : IpcInterfaceSource(parent)
|
|||||||
connect(&m_pingHelper, &PingHelper::connectionLose, this, &IpcServer::connectionLose);
|
connect(&m_pingHelper, &PingHelper::connectionLose, this, &IpcServer::connectionLose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IpcServer::~IpcServer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServer::resetServiceState()
|
||||||
|
{
|
||||||
|
qDebug() << "IpcServer::resetServiceState — tearing down active VPN state";
|
||||||
|
|
||||||
|
Xray::getInstance().stopXray();
|
||||||
|
|
||||||
|
for (auto it = m_processes.cbegin(); it != m_processes.cend(); ++it) {
|
||||||
|
const ProcessDescriptor &pd = it.value();
|
||||||
|
if (!pd.ipcProcess)
|
||||||
|
continue;
|
||||||
|
pd.ipcProcess->terminate();
|
||||||
|
if (!pd.ipcProcess->waitForFinished(1000)) {
|
||||||
|
pd.ipcProcess->kill();
|
||||||
|
pd.ipcProcess->waitForFinished(1000);
|
||||||
|
}
|
||||||
|
pd.ipcProcess->close();
|
||||||
|
}
|
||||||
|
m_processes.clear();
|
||||||
|
|
||||||
|
Utils::killProcessByName(Utils::tun2socksPath());
|
||||||
|
Utils::killProcessByName(Utils::openVpnExecPath());
|
||||||
|
|
||||||
|
KillSwitch::instance()->disableKillSwitch();
|
||||||
|
|
||||||
|
Router::restoreResolvers();
|
||||||
|
Router::clearSavedRoutes();
|
||||||
|
Router::StartRoutingIpv6();
|
||||||
|
Router::flushDns();
|
||||||
|
|
||||||
|
m_pingHelper.stop();
|
||||||
|
}
|
||||||
|
|
||||||
int IpcServer::createPrivilegedProcess()
|
int IpcServer::createPrivilegedProcess()
|
||||||
{
|
{
|
||||||
#ifdef MZ_DEBUG
|
#ifdef MZ_DEBUG
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ class IpcServer : public IpcInterfaceSource
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit IpcServer(QObject *parent = nullptr);
|
explicit IpcServer(QObject *parent = nullptr);
|
||||||
|
virtual ~IpcServer();
|
||||||
|
|
||||||
|
void resetServiceState();
|
||||||
|
|
||||||
virtual int createPrivilegedProcess() override;
|
virtual int createPrivilegedProcess() override;
|
||||||
|
|
||||||
virtual int routeAddList(const QString &gw, const QStringList &ips) override;
|
virtual int routeAddList(const QString &gw, const QStringList &ips) override;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from conan.errors import ConanInvalidConfiguration
|
|||||||
from conan.tools.scm import Git
|
from conan.tools.scm import Git
|
||||||
from conan.internal.model.pkg_type import PackageType
|
from conan.internal.model.pkg_type import PackageType
|
||||||
from conan.tools.files import chdir
|
from conan.tools.files import chdir
|
||||||
|
from conan.tools.apple import XCRun
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@@ -49,7 +50,10 @@ class OpenVPNAdapter(ConanFile):
|
|||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
with chdir(self, self.source_folder):
|
with chdir(self, self.source_folder):
|
||||||
self.run("xcrun xcodebuild"
|
xcrun = XCRun(self)
|
||||||
|
|
||||||
|
xcodebuild = xcrun.find("xcodebuild")
|
||||||
|
self.run(f"{xcodebuild}"
|
||||||
" -project OpenVPNAdapter.xcodeproj"
|
" -project OpenVPNAdapter.xcodeproj"
|
||||||
" -scheme OpenVPNAdapter"
|
" -scheme OpenVPNAdapter"
|
||||||
" -configuration Release"
|
" -configuration Release"
|
||||||
@@ -57,10 +61,20 @@ class OpenVPNAdapter(ConanFile):
|
|||||||
f" -sdk {self._sdk}"
|
f" -sdk {self._sdk}"
|
||||||
f' "CONFIGURATION_BUILD_DIR={self.build_folder}"'
|
f' "CONFIGURATION_BUILD_DIR={self.build_folder}"'
|
||||||
f' "BUILT_PRODUCTS_DIR={self.build_folder}"'
|
f' "BUILT_PRODUCTS_DIR={self.build_folder}"'
|
||||||
|
" MACH_O_TYPE=staticlib"
|
||||||
" BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
|
" BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
|
||||||
" CODE_SIGNING_ALLOWED=NO"
|
" 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):
|
def package(self):
|
||||||
shutil.copytree(os.path.join(self.build_folder, "OpenVPNAdapter.framework"),
|
shutil.copytree(os.path.join(self.build_folder, "OpenVPNAdapter.framework"),
|
||||||
os.path.join(self.package_folder, "OpenVPNAdapter.framework"))
|
os.path.join(self.package_folder, "OpenVPNAdapter.framework"))
|
||||||
@@ -70,3 +84,4 @@ class OpenVPNAdapter(ConanFile):
|
|||||||
self.cpp_info.type = PackageType.STATIC
|
self.cpp_info.type = PackageType.STATIC
|
||||||
self.cpp_info.package_framework = True
|
self.cpp_info.package_framework = True
|
||||||
self.cpp_info.location = os.path.join(self.package_folder, "OpenVPNAdapter.framework")
|
self.cpp_info.location = os.path.join(self.package_folder, "OpenVPNAdapter.framework")
|
||||||
|
self.cpp_info.frameworks = ["SystemConfiguration"]
|
||||||
|
|||||||
@@ -316,12 +316,9 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
set_target_properties(${PROJECT} PROPERTIES
|
set_target_properties(${PROJECT} PROPERTIES
|
||||||
INSTALL_RPATH "@executable_path/../Frameworks"
|
INSTALL_RPATH "@executable_path/../Frameworks"
|
||||||
BUILD_WITH_INSTALL_RPATH TRUE
|
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
find_library(FW_COREFOUNDATION CoreFoundation)
|
find_library(FW_COREFOUNDATION CoreFoundation)
|
||||||
find_library(FW_SYSTEMCONFIG SystemConfiguration)
|
find_library(FW_SYSTEMCONFIG SystemConfiguration)
|
||||||
@@ -428,11 +425,32 @@ endif()
|
|||||||
# install target
|
# install target
|
||||||
install(TARGETS ${PROJECT}
|
install(TARGETS ${PROJECT}
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
RUNTIME_DEPENDENCY_SET service_deps
|
||||||
COMPONENT AmneziaVPN
|
COMPONENT AmneziaVPN
|
||||||
)
|
)
|
||||||
install(FILES $<TARGET_RUNTIME_DLLS:${PROJECT}>
|
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
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}
|
||||||
COMPONENT AmneziaVPN
|
COMPONENT AmneziaVPN
|
||||||
|
DESTINATION "${RUNTIME_DEPS_DIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
qt_generate_deploy_app_script(
|
qt_generate_deploy_app_script(
|
||||||
|
|||||||
@@ -35,7 +35,20 @@ LocalServer::LocalServer(QObject *parent) : QObject(parent),
|
|||||||
|
|
||||||
QObject::connect(m_server.data(), &QLocalServer::newConnection, this, [this]() {
|
QObject::connect(m_server.data(), &QLocalServer::newConnection, this, [this]() {
|
||||||
qDebug() << "LocalServer new connection";
|
qDebug() << "LocalServer new connection";
|
||||||
m_serverNode.addHostSideConnection(m_server->nextPendingConnection());
|
|
||||||
|
QLocalSocket *socket = m_server->nextPendingConnection();
|
||||||
|
if (!socket)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_activeClientSocket = socket;
|
||||||
|
|
||||||
|
QObject::connect(socket, &QLocalSocket::disconnected, this, [this, socket]() {
|
||||||
|
qDebug() << "LocalServer: client disconnected";
|
||||||
|
if (m_activeClientSocket == socket)
|
||||||
|
m_ipcServer.resetServiceState();
|
||||||
|
});
|
||||||
|
|
||||||
|
m_serverNode.addHostSideConnection(socket);
|
||||||
|
|
||||||
if (!m_isRemotingEnabled) {
|
if (!m_isRemotingEnabled) {
|
||||||
m_isRemotingEnabled = true;
|
m_isRemotingEnabled = true;
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public:
|
|||||||
QRemoteObjectHost m_serverNode;
|
QRemoteObjectHost m_serverNode;
|
||||||
bool m_isRemotingEnabled = false;
|
bool m_isRemotingEnabled = false;
|
||||||
|
|
||||||
|
QPointer<QLocalSocket> m_activeClientSocket;
|
||||||
|
|
||||||
NetworkWatcher m_networkWatcher;
|
NetworkWatcher m_networkWatcher;
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
DaemonLocalServer server{qApp};
|
DaemonLocalServer server{qApp};
|
||||||
|
|||||||
Reference in New Issue
Block a user