
* Add allowed DNS list for killswitch * Windows killswitch strict mode backend part * Killswitch strict mode for Linux and MacOS * Windows fixes * feature: Add Kill Switch settings page with strict mode option * fix windows build after merge * Refresh killswitch mode when it toggled * Use HLM to store strictMode flag * Some Linux updates * feat: Enhance VerticalRadioButton with improved styling and disabled states * Refresh killSwitch state update * Fix build * refactor: Modularize header components * Change kill switch radio button styling * Fix strict kill switch mode handling * Refactor: Replace HeaderType with new Types for headers in QML pages * Remove deprecated HeaderType QML component * Refresh strict mode killswitch after global toggle change * Implement model, controller and UI for killswitch dns exceptions * Connect backend part and UI * Change label text to DNS exceptions * Remove HeaderType from PageSettingsApiDevices * Some pretty fixes * Fix problem with definition sequence of PageSettingsKillSwitchExceptions.pml elements * Add exclusion method for Windows firewall * Change ubuntu version in deploy script * Update ubuntu version in GH actions * Add confirmation popup for strict killswitch mode * Add qt standard path for build script * Add method to killswitch for expanding strickt mode exceptions list and fix allowTrafficTo() for Windows. Also Added cache in KillSwitch class for exceptions * Add insertion of gateway address to strict killswitch exceptions * Review fixes * buildfix and naming --------- Co-authored-by: aiamnezia <ai@amnezia.org>
215 lines
4.4 KiB
C++
215 lines
4.4 KiB
C++
#include "ipcserver.h"
|
|
|
|
#include <QDateTime>
|
|
#include <QFileInfo>
|
|
#include <QLocalSocket>
|
|
#include <QObject>
|
|
|
|
#include "logger.h"
|
|
#include "router.h"
|
|
|
|
#include "killswitch.h"
|
|
|
|
#ifdef Q_OS_WIN
|
|
#include "tapcontroller_win.h"
|
|
#endif
|
|
|
|
|
|
IpcServer::IpcServer(QObject *parent) : IpcInterfaceSource(parent)
|
|
|
|
{
|
|
}
|
|
|
|
int IpcServer::createPrivilegedProcess()
|
|
{
|
|
#ifdef MZ_DEBUG
|
|
qDebug() << "IpcServer::createPrivilegedProcess";
|
|
#endif
|
|
|
|
m_localpid++;
|
|
|
|
ProcessDescriptor pd(this);
|
|
|
|
pd.localServer->setSocketOptions(QLocalServer::WorldAccessOption);
|
|
|
|
if (!pd.localServer->listen(amnezia::getIpcProcessUrl(m_localpid))) {
|
|
qDebug() << QString("Unable to start the server: %1.").arg(pd.localServer->errorString());
|
|
return -1;
|
|
}
|
|
|
|
// Make sure any connections are handed to QtRO
|
|
QObject::connect(pd.localServer.data(), &QLocalServer::newConnection, this, [pd]() {
|
|
qDebug() << "IpcServer new connection";
|
|
if (pd.serverNode) {
|
|
pd.serverNode->addHostSideConnection(pd.localServer->nextPendingConnection());
|
|
pd.serverNode->enableRemoting(pd.ipcProcess.data());
|
|
}
|
|
});
|
|
|
|
QObject::connect(pd.serverNode.data(), &QRemoteObjectHost::error, this,
|
|
[pd](QRemoteObjectNode::ErrorCode errorCode) { qDebug() << "QRemoteObjectHost::error" << errorCode; });
|
|
|
|
QObject::connect(pd.serverNode.data(), &QRemoteObjectHost::destroyed, this, [pd]() { qDebug() << "QRemoteObjectHost::destroyed"; });
|
|
|
|
m_processes.insert(m_localpid, pd);
|
|
|
|
return m_localpid;
|
|
}
|
|
|
|
int IpcServer::routeAddList(const QString &gw, const QStringList &ips)
|
|
{
|
|
#ifdef MZ_DEBUG
|
|
qDebug() << "IpcServer::routeAddList";
|
|
#endif
|
|
|
|
return Router::routeAddList(gw, ips);
|
|
}
|
|
|
|
bool IpcServer::clearSavedRoutes()
|
|
{
|
|
#ifdef MZ_DEBUG
|
|
qDebug() << "IpcServer::clearSavedRoutes";
|
|
#endif
|
|
|
|
return Router::clearSavedRoutes();
|
|
}
|
|
|
|
bool IpcServer::routeDeleteList(const QString &gw, const QStringList &ips)
|
|
{
|
|
#ifdef MZ_DEBUG
|
|
qDebug() << "IpcServer::routeDeleteList";
|
|
#endif
|
|
|
|
return Router::routeDeleteList(gw, ips);
|
|
}
|
|
|
|
void IpcServer::flushDns()
|
|
{
|
|
#ifdef MZ_DEBUG
|
|
qDebug() << "IpcServer::flushDns";
|
|
#endif
|
|
|
|
return Router::flushDns();
|
|
}
|
|
|
|
void IpcServer::resetIpStack()
|
|
{
|
|
#ifdef MZ_DEBUG
|
|
qDebug() << "IpcServer::resetIpStack";
|
|
#endif
|
|
|
|
Router::resetIpStack();
|
|
}
|
|
|
|
bool IpcServer::checkAndInstallDriver()
|
|
{
|
|
#ifdef MZ_DEBUG
|
|
qDebug() << "IpcServer::checkAndInstallDriver";
|
|
#endif
|
|
|
|
#ifdef Q_OS_WIN
|
|
return TapController::checkAndSetup();
|
|
#else
|
|
return true;
|
|
#endif
|
|
}
|
|
|
|
QStringList IpcServer::getTapList()
|
|
{
|
|
#ifdef MZ_DEBUG
|
|
qDebug() << "IpcServer::getTapList";
|
|
#endif
|
|
|
|
#ifdef Q_OS_WIN
|
|
return TapController::getTapList();
|
|
#else
|
|
return QStringList();
|
|
#endif
|
|
}
|
|
|
|
void IpcServer::cleanUp()
|
|
{
|
|
#ifdef MZ_DEBUG
|
|
qDebug() << "IpcServer::cleanUp";
|
|
#endif
|
|
|
|
Logger::deInit();
|
|
Logger::cleanUp();
|
|
}
|
|
|
|
void IpcServer::clearLogs()
|
|
{
|
|
Logger::clearLogs(true);
|
|
}
|
|
|
|
bool IpcServer::createTun(const QString &dev, const QString &subnet)
|
|
{
|
|
return Router::createTun(dev, subnet);
|
|
}
|
|
|
|
bool IpcServer::deleteTun(const QString &dev)
|
|
{
|
|
return Router::deleteTun(dev);
|
|
}
|
|
|
|
bool IpcServer::updateResolvers(const QString &ifname, const QList<QHostAddress> &resolvers)
|
|
{
|
|
return Router::updateResolvers(ifname, resolvers);
|
|
}
|
|
|
|
void IpcServer::StartRoutingIpv6()
|
|
{
|
|
Router::StartRoutingIpv6();
|
|
}
|
|
void IpcServer::StopRoutingIpv6()
|
|
{
|
|
Router::StopRoutingIpv6();
|
|
}
|
|
|
|
void IpcServer::setLogsEnabled(bool enabled)
|
|
{
|
|
#ifdef MZ_DEBUG
|
|
qDebug() << "IpcServer::setLogsEnabled";
|
|
#endif
|
|
|
|
if (enabled) {
|
|
Logger::init(true);
|
|
} else {
|
|
Logger::deInit();
|
|
}
|
|
}
|
|
|
|
bool IpcServer::resetKillSwitchAllowedRange(QStringList ranges)
|
|
{
|
|
return KillSwitch::instance()->resetAllowedRange(ranges);
|
|
}
|
|
|
|
bool IpcServer::addKillSwitchAllowedRange(QStringList ranges)
|
|
{
|
|
return KillSwitch::instance()->addAllowedRange(ranges);
|
|
}
|
|
|
|
bool IpcServer::disableAllTraffic()
|
|
{
|
|
return KillSwitch::instance()->disableAllTraffic();
|
|
}
|
|
|
|
bool IpcServer::enableKillSwitch(const QJsonObject &configStr, int vpnAdapterIndex)
|
|
{
|
|
return KillSwitch::instance()->enableKillSwitch(configStr, vpnAdapterIndex);
|
|
}
|
|
|
|
bool IpcServer::disableKillSwitch()
|
|
{
|
|
return KillSwitch::instance()->disableKillSwitch();
|
|
}
|
|
|
|
bool IpcServer::enablePeerTraffic(const QJsonObject &configStr)
|
|
{
|
|
return KillSwitch::instance()->enablePeerTraffic(configStr);
|
|
}
|
|
|
|
bool IpcServer::refreshKillSwitch(bool enabled)
|
|
{
|
|
return KillSwitch::instance()->refresh(enabled);
|
|
}
|