Merge branch 'dev' into feature/qt6-libssh-support
This commit is contained in:
commit
ad77d74f4b
10 changed files with 64 additions and 26 deletions
|
@ -7,6 +7,10 @@ if(ANDROID)
|
|||
set(QT_ANDROID_BUILD_ALL_ABIS ON)
|
||||
endif()
|
||||
|
||||
if(APPLE AND NOT IOS)
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
endif()
|
||||
|
||||
add_subdirectory(client)
|
||||
|
||||
if(NOT IOS AND NOT ANDROID)
|
||||
|
|
|
@ -664,13 +664,16 @@ ErrorCode ServerController::isServerPortBusy(const ServerCredentials &credential
|
|||
return ErrorCode::NoError;
|
||||
};
|
||||
|
||||
const QString containerString = ProtocolProps::protoToString(ContainerProps::defaultProtocol(container));
|
||||
const Proto protocol = ContainerProps::defaultProtocol(container);
|
||||
const QString containerString = ProtocolProps::protoToString(protocol);
|
||||
const QJsonObject containerConfig = config.value(containerString).toObject();
|
||||
|
||||
QStringList fixedPorts = ContainerProps::fixedPortsForContainer(container);
|
||||
|
||||
QString port = containerConfig.value(config_key::port).toString(protocols::openvpn::defaultPort);
|
||||
QString transportProto = containerConfig.value(config_key::transport_proto).toString(protocols::openvpn::defaultTransportProto);
|
||||
QString defaultPort("%1");
|
||||
QString port = containerConfig.value(config_key::port).toString(defaultPort.arg(ProtocolProps::defaultPort(protocol)));
|
||||
QString defaultTransportProto = ProtocolProps::transportProtoToString(ProtocolProps::defaultTransportProto(protocol), protocol);
|
||||
QString transportProto = containerConfig.value(config_key::transport_proto).toString(defaultTransportProto);
|
||||
|
||||
QString script = QString("sudo lsof -i -P -n | grep -E ':%1 ").arg(port);
|
||||
for (auto &port : fixedPorts) {
|
||||
|
|
|
@ -69,7 +69,7 @@ void AdvancedServerSettingsLogic::onPushButtonScanServerClicked()
|
|||
|
||||
bool isServerCreated;
|
||||
auto containersCount = m_settings->containers(uiLogic()->m_selectedServerIndex).size();
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(false, isServerCreated);
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(isServerCreated);
|
||||
if (errorCode != ErrorCode::NoError) {
|
||||
emit uiLogic()->showWarningMessage(tr("Error occurred while scanning the server.") + "\n" +
|
||||
tr("Error message: ") + errorString(errorCode) + "\n" +
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QStandardPaths>
|
||||
#include <utilities.h>
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
@ -82,8 +83,8 @@ void AppSettingsLogic::onPushButtonBackupAppConfigClicked()
|
|||
|
||||
void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open backup"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
||||
QString fileName = Utils::getOpenFileName(Q_NULLPTR, tr("Open backup"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
||||
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
|
@ -98,6 +99,5 @@ void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
|||
} else {
|
||||
emit uiLogic()->showWarningMessage(tr("Can't import config, file is corrupted."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
#include <QApplication>
|
||||
|
||||
#include "protocols/CloakLogic.h"
|
||||
#include "protocols/OpenVpnLogic.h"
|
||||
#include "protocols/ShadowSocksLogic.h"
|
||||
#include "protocols/PageProtocolLogicBase.h"
|
||||
|
||||
#include "core/servercontroller.h"
|
||||
#include <functional>
|
||||
|
@ -92,7 +90,7 @@ void ServerContainersLogic::onPushButtonContinueClicked(DockerContainer c, int p
|
|||
qApp->processEvents();
|
||||
|
||||
bool isServerCreated = false;
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(false, isServerCreated);
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(isServerCreated);
|
||||
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
if (!uiLogic()->isContainerAlreadyAddedToGui(c)) {
|
||||
|
|
|
@ -184,7 +184,7 @@ void StartPageLogic::onPushButtonImport()
|
|||
|
||||
void StartPageLogic::onPushButtonImportOpenFile()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open config file"),
|
||||
QString fileName = Utils::getOpenFileName(Q_NULLPTR, tr("Open config file"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.vpn *.ovpn *.conf");
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
|
|
|
@ -330,7 +330,7 @@ void UiLogic::installServer(QPair<DockerContainer, QJsonObject> &container)
|
|||
};
|
||||
|
||||
bool isServerCreated = false;
|
||||
ErrorCode errorCode = addAlreadyInstalledContainersGui(true, isServerCreated);
|
||||
ErrorCode errorCode = addAlreadyInstalledContainersGui(isServerCreated);
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
if (!isContainerAlreadyAddedToGui(container.first)) {
|
||||
progressBarFunc.setTextFunc(QString("Installing %1").arg(ContainerProps::containerToString(container.first)));
|
||||
|
@ -519,14 +519,22 @@ void UiLogic::registerPagesLogic()
|
|||
registerPageLogic<AdvancedServerSettingsLogic>();
|
||||
}
|
||||
|
||||
ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool createNewServer, bool &isServerCreated)
|
||||
ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool &isServerCreated)
|
||||
{
|
||||
isServerCreated = false;
|
||||
ServerCredentials credentials;
|
||||
if (createNewServer) {
|
||||
credentials = m_installCredentials;
|
||||
} else {
|
||||
credentials = m_settings->serverCredentials(m_selectedServerIndex);
|
||||
ServerCredentials installCredentials = m_installCredentials;
|
||||
bool createNewServer = true;
|
||||
int serverIndex;
|
||||
|
||||
for (int i = 0; i < m_settings->serversCount(); i++) {
|
||||
const ServerCredentials credentials = m_settings->serverCredentials(i);
|
||||
if (m_installCredentials.hostName == credentials.hostName && m_installCredentials.port == credentials.port) {
|
||||
createNewServer = false;
|
||||
isServerCreated = true;
|
||||
installCredentials = credentials;
|
||||
serverIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QMap<DockerContainer, QJsonObject> installedContainers;
|
||||
|
@ -540,10 +548,10 @@ ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool createNewServer, bool &
|
|||
QJsonObject server;
|
||||
QJsonArray containerConfigs;
|
||||
if (createNewServer) {
|
||||
server.insert(config_key::hostName, credentials.hostName);
|
||||
server.insert(config_key::userName, credentials.userName);
|
||||
server.insert(config_key::password, credentials.password);
|
||||
server.insert(config_key::port, credentials.port);
|
||||
server.insert(config_key::hostName, installCredentials.hostName);
|
||||
server.insert(config_key::userName, installCredentials.userName);
|
||||
server.insert(config_key::password, installCredentials.password);
|
||||
server.insert(config_key::port, installCredentials.port);
|
||||
server.insert(config_key::description, m_settings->nextAvailableServerName());
|
||||
}
|
||||
|
||||
|
@ -556,8 +564,8 @@ ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool createNewServer, bool &
|
|||
containerConfigs.append(container.value());
|
||||
server.insert(config_key::containers, containerConfigs);
|
||||
} else {
|
||||
m_settings->setContainerConfig(m_selectedServerIndex, container.key(), container.value());
|
||||
m_settings->setDefaultContainer(m_selectedServerIndex, installedContainers.firstKey());
|
||||
m_settings->setContainerConfig(serverIndex, container.key(), container.value());
|
||||
m_settings->setDefaultContainer(serverIndex, installedContainers.firstKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ public:
|
|||
Q_INVOKABLE void saveBinaryFile(const QString& desc, QString ext, const QString& data);
|
||||
Q_INVOKABLE void copyToClipboard(const QString& text);
|
||||
|
||||
Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool createNewServer, bool &isServerCreated);
|
||||
Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool &isServerCreated);
|
||||
|
||||
void shareTempFile(const QString &suggestedName, QString ext, const QString& data);
|
||||
|
||||
|
|
|
@ -247,6 +247,23 @@ QString Utils::certUtilPath()
|
|||
#endif
|
||||
}
|
||||
|
||||
QString Utils::getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(parent, caption, dir, filter, selectedFilter, options);
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
// patch for files containing spaces etc
|
||||
const QString sep {"raw%3A%2F"};
|
||||
if (fileName.startsWith("content://") && fileName.contains(sep)) {
|
||||
QString contentUrl = fileName.split(sep).at(0);
|
||||
QString rawUrl = fileName.split(sep).at(1);
|
||||
rawUrl.replace(" ", "%20");
|
||||
fileName = contentUrl + sep + rawUrl;
|
||||
}
|
||||
#endif
|
||||
return fileName;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// Inspired from http://stackoverflow.com/a/15281070/1529139
|
||||
// and http://stackoverflow.com/q/40059902/1529139
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef UTILITIES_H
|
||||
#define UTILITIES_H
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QRegExp>
|
||||
#include <QString>
|
||||
#include <QRegularExpression>
|
||||
|
@ -50,6 +51,13 @@ public:
|
|||
static QString wireguardExecPath();
|
||||
static QString certUtilPath();
|
||||
|
||||
static QString getOpenFileName(QWidget *parent = nullptr,
|
||||
const QString &caption = QString(),
|
||||
const QString &dir = QString(),
|
||||
const QString &filter = QString(),
|
||||
QString *selectedFilter = nullptr,
|
||||
QFileDialog::Options options = QFileDialog::Options());
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static bool signalCtrl(DWORD dwProcessId, DWORD dwCtrlEvent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue