Fix formatting
This commit is contained in:
parent
9e7cf7fa1f
commit
6a21994736
4 changed files with 50 additions and 56 deletions
|
|
@ -9,7 +9,8 @@
|
||||||
#include "core/errorstrings.h"
|
#include "core/errorstrings.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
const QString installerPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN.dmg";
|
const QString installerPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/AmneziaVPN.dmg";
|
||||||
#elif defined Q_OS_WINDOWS
|
#elif defined Q_OS_WINDOWS
|
||||||
|
|
@ -19,7 +20,8 @@ namespace {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateController::UpdateController(const std::shared_ptr<Settings> &settings, QObject *parent) : QObject(parent), m_settings(settings)
|
UpdateController::UpdateController(const std::shared_ptr<Settings> &settings, QObject *parent)
|
||||||
|
: QObject(parent), m_settings(settings)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,19 +64,19 @@ void UpdateController::checkForUpdates()
|
||||||
|
|
||||||
for (auto asset : assets) {
|
for (auto asset : assets) {
|
||||||
QJsonObject assetObject = asset.toObject();
|
QJsonObject assetObject = asset.toObject();
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
if (assetObject.value("name").toString().endsWith(".exe")) {
|
if (assetObject.value("name").toString().endsWith(".exe")) {
|
||||||
m_downloadUrl = assetObject.value("browser_download_url").toString();
|
m_downloadUrl = assetObject.value("browser_download_url").toString();
|
||||||
}
|
}
|
||||||
#elif defined(Q_OS_MACOS)
|
#elif defined(Q_OS_MACOS)
|
||||||
if (assetObject.value("name").toString().endsWith(".dmg")) {
|
if (assetObject.value("name").toString().endsWith(".dmg")) {
|
||||||
m_downloadUrl = assetObject.value("browser_download_url").toString();
|
m_downloadUrl = assetObject.value("browser_download_url").toString();
|
||||||
}
|
}
|
||||||
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||||
if (assetObject.value("name").toString().contains(".tar.zip")) {
|
if (assetObject.value("name").toString().contains(".tar.zip")) {
|
||||||
m_downloadUrl = assetObject.value("browser_download_url").toString();
|
m_downloadUrl = assetObject.value("browser_download_url").toString();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
emit updateFound();
|
emit updateFound();
|
||||||
|
|
@ -141,5 +143,4 @@ void UpdateController::runInstaller()
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ public slots:
|
||||||
signals:
|
signals:
|
||||||
void updateFound();
|
void updateFound();
|
||||||
void errorOccured(const QString &errorMessage);
|
void errorOccured(const QString &errorMessage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Settings> m_settings;
|
std::shared_ptr<Settings> m_settings;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "router.h"
|
#include "router.h"
|
||||||
|
|
||||||
#include "../core/networkUtilities.h"
|
|
||||||
#include "../client/protocols/protocols_defs.h"
|
#include "../client/protocols/protocols_defs.h"
|
||||||
|
#include "../core/networkUtilities.h"
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include "../client/platforms/windows/daemon/windowsdaemon.h"
|
#include "../client/platforms/windows/daemon/windowsdaemon.h"
|
||||||
#include "../client/platforms/windows/daemon/windowsfirewall.h"
|
#include "../client/platforms/windows/daemon/windowsfirewall.h"
|
||||||
|
|
@ -60,12 +60,15 @@ int IpcServer::createPrivilegedProcess()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(pd.serverNode.data(), &QRemoteObjectHost::error, this,
|
QObject::connect(pd.serverNode.data(), &QRemoteObjectHost::error, this, [pd](QRemoteObjectNode::ErrorCode errorCode) {
|
||||||
[pd](QRemoteObjectNode::ErrorCode errorCode) { qDebug() << "QRemoteObjectHost::error" << errorCode; });
|
qDebug() << "QRemoteObjectHost::error" << errorCode;
|
||||||
|
});
|
||||||
|
|
||||||
QObject::connect(pd.serverNode.data(), &QRemoteObjectHost::destroyed, this, [pd]() { qDebug() << "QRemoteObjectHost::destroyed"; });
|
QObject::connect(pd.serverNode.data(), &QRemoteObjectHost::destroyed, this,
|
||||||
|
[pd]() { qDebug() << "QRemoteObjectHost::destroyed"; });
|
||||||
|
|
||||||
// connect(pd.ipcProcess.data(), &IpcServerProcess::finished, this, [this, pid=m_localpid](int exitCode, QProcess::ExitStatus exitStatus){
|
// connect(pd.ipcProcess.data(), &IpcServerProcess::finished, this, [this, pid=m_localpid](int exitCode,
|
||||||
|
// QProcess::ExitStatus exitStatus){
|
||||||
// qDebug() << "IpcServerProcess finished" << exitCode << exitStatus;
|
// qDebug() << "IpcServerProcess finished" << exitCode << exitStatus;
|
||||||
//// if (m_processes.contains(pid)) {
|
//// if (m_processes.contains(pid)) {
|
||||||
//// m_processes[pid].ipcProcess.reset();
|
//// m_processes[pid].ipcProcess.reset();
|
||||||
|
|
@ -386,12 +389,9 @@ int IpcServer::installApp(const QString &path)
|
||||||
// On Windows, simply run the .exe file with administrator privileges
|
// On Windows, simply run the .exe file with administrator privileges
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.setProgram("powershell.exe");
|
process.setProgram("powershell.exe");
|
||||||
process.setArguments(QStringList()
|
process.setArguments(QStringList() << "Start-Process" << path << "-Verb"
|
||||||
<< "Start-Process"
|
<< "RunAs"
|
||||||
<< path
|
<< "-Wait");
|
||||||
<< "-Verb"
|
|
||||||
<< "RunAs"
|
|
||||||
<< "-Wait");
|
|
||||||
|
|
||||||
qDebug() << "Launching installer with elevated privileges...";
|
qDebug() << "Launching installer with elevated privileges...";
|
||||||
process.start();
|
process.start();
|
||||||
|
|
@ -417,12 +417,7 @@ int IpcServer::installApp(const QString &path)
|
||||||
|
|
||||||
// Mount DMG image
|
// Mount DMG image
|
||||||
qDebug() << "Mounting DMG image...";
|
qDebug() << "Mounting DMG image...";
|
||||||
process.start("hdiutil", QStringList()
|
process.start("hdiutil", QStringList() << "attach" << path << "-mountpoint" << mountPoint << "-nobrowse");
|
||||||
<< "attach"
|
|
||||||
<< path
|
|
||||||
<< "-mountpoint"
|
|
||||||
<< mountPoint
|
|
||||||
<< "-nobrowse");
|
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
|
|
||||||
if (process.exitCode() != 0) {
|
if (process.exitCode() != 0) {
|
||||||
|
|
@ -442,17 +437,12 @@ int IpcServer::installApp(const QString &path)
|
||||||
|
|
||||||
// Copy application to /Applications
|
// Copy application to /Applications
|
||||||
qDebug() << "Copying app to Applications folder...";
|
qDebug() << "Copying app to Applications folder...";
|
||||||
process.start("cp", QStringList()
|
process.start("cp", QStringList() << "-R" << appPath << targetPath);
|
||||||
<< "-R"
|
|
||||||
<< appPath
|
|
||||||
<< targetPath);
|
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
|
|
||||||
// Unmount DMG
|
// Unmount DMG
|
||||||
qDebug() << "Unmounting DMG...";
|
qDebug() << "Unmounting DMG...";
|
||||||
process.start("hdiutil", QStringList()
|
process.start("hdiutil", QStringList() << "detach" << mountPoint);
|
||||||
<< "detach"
|
|
||||||
<< mountPoint);
|
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
|
|
||||||
if (process.exitCode() != 0) {
|
if (process.exitCode() != 0) {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef IPCSERVER_H
|
#ifndef IPCSERVER_H
|
||||||
#define IPCSERVER_H
|
#define IPCSERVER_H
|
||||||
|
|
||||||
|
#include "../client/daemon/interfaceconfig.h"
|
||||||
|
#include <QJsonObject>
|
||||||
#include <QLocalServer>
|
#include <QLocalServer>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QRemoteObjectNode>
|
#include <QRemoteObjectNode>
|
||||||
#include <QJsonObject>
|
|
||||||
#include "../client/daemon/interfaceconfig.h"
|
|
||||||
|
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
#include "ipcserverprocess.h"
|
#include "ipcserverprocess.h"
|
||||||
|
|
@ -37,15 +37,17 @@ public:
|
||||||
virtual bool enablePeerTraffic(const QJsonObject &configStr) override;
|
virtual bool enablePeerTraffic(const QJsonObject &configStr) override;
|
||||||
virtual bool enableKillSwitch(const QJsonObject &excludeAddr, int vpnAdapterIndex) override;
|
virtual bool enableKillSwitch(const QJsonObject &excludeAddr, int vpnAdapterIndex) override;
|
||||||
virtual bool disableKillSwitch() override;
|
virtual bool disableKillSwitch() override;
|
||||||
virtual bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers) override;
|
virtual bool updateResolvers(const QString &ifname, const QList<QHostAddress> &resolvers) override;
|
||||||
virtual int mountDmg(const QString &path, bool mount) override;
|
virtual int mountDmg(const QString &path, bool mount) override;
|
||||||
virtual int installApp(const QString &path) override;
|
virtual int installApp(const QString &path) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_localpid = 0;
|
int m_localpid = 0;
|
||||||
|
|
||||||
struct ProcessDescriptor {
|
struct ProcessDescriptor
|
||||||
ProcessDescriptor (QObject *parent = nullptr) {
|
{
|
||||||
|
ProcessDescriptor(QObject *parent = nullptr)
|
||||||
|
{
|
||||||
serverNode = QSharedPointer<QRemoteObjectHost>(new QRemoteObjectHost(parent));
|
serverNode = QSharedPointer<QRemoteObjectHost>(new QRemoteObjectHost(parent));
|
||||||
ipcProcess = QSharedPointer<IpcServerProcess>(new IpcServerProcess(parent));
|
ipcProcess = QSharedPointer<IpcServerProcess>(new IpcServerProcess(parent));
|
||||||
tun2socksProcess = QSharedPointer<IpcProcessTun2Socks>(new IpcProcessTun2Socks(parent));
|
tun2socksProcess = QSharedPointer<IpcProcessTun2Socks>(new IpcProcessTun2Socks(parent));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue