
* 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>
85 lines
3.2 KiB
C++
85 lines
3.2 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef WINDOWSFIREWALL_H
|
|
#define WINDOWSFIREWALL_H
|
|
|
|
#pragma comment(lib, "Fwpuclnt")
|
|
|
|
// Note: The windows.h import needs to come before the fwpmu.h import.
|
|
// clang-format off
|
|
#include <windows.h>
|
|
#include <fwpmu.h>
|
|
// clang-format on
|
|
|
|
#include <QByteArray>
|
|
#include <QHostAddress>
|
|
#include <QObject>
|
|
#include <QString>
|
|
|
|
#include "../client/daemon/interfaceconfig.h"
|
|
|
|
class IpAdressRange;
|
|
struct FWP_VALUE0_;
|
|
struct FWP_CONDITION_VALUE0_;
|
|
|
|
class WindowsFirewall final : public QObject {
|
|
public:
|
|
/**
|
|
* @brief Opens the Windows Filtering Platform, initializes the session,
|
|
* sublayer. Returns a WindowsFirewall object if successful, otherwise
|
|
* nullptr. If there is already a WindowsFirewall object, it will be returned.
|
|
*
|
|
* @param parent - parent QObject
|
|
* @return WindowsFirewall* - nullptr if failed to open the Windows Filtering
|
|
* Platform.
|
|
*/
|
|
static WindowsFirewall* create(QObject* parent);
|
|
~WindowsFirewall() override;
|
|
|
|
bool enableInterface(int vpnAdapterIndex);
|
|
bool enableLanBypass(const QList<IPAddress>& ranges);
|
|
bool enablePeerTraffic(const InterfaceConfig& config);
|
|
bool disablePeerTraffic(const QString& pubkey);
|
|
bool disableKillSwitch();
|
|
bool allowAllTraffic();
|
|
bool allowTrafficRange(const QStringList& ranges);
|
|
|
|
private:
|
|
static bool initSublayer();
|
|
WindowsFirewall(HANDLE session, QObject* parent);
|
|
HANDLE m_sessionHandle;
|
|
bool m_init = false;
|
|
QList<uint64_t> m_activeRules;
|
|
QMultiMap<QString, uint64_t> m_peerRules;
|
|
|
|
bool allowTrafficForAppOnAll(const QString& exePath, int weight,
|
|
const QString& title);
|
|
bool blockTrafficTo(const QList<IPAddress>& range, uint8_t weight,
|
|
const QString& title, const QString& peer = QString());
|
|
bool blockTrafficTo(const IPAddress& addr, uint8_t weight,
|
|
const QString& title, const QString& peer = QString());
|
|
bool blockTrafficOnPort(uint port, uint8_t weight, const QString& title);
|
|
bool allowTrafficTo(const IPAddress& addr, int weight, const QString& title,
|
|
const QString& peer = QString());
|
|
bool allowTrafficTo(const QHostAddress& targetIP, uint port, int weight,
|
|
const QString& title, const QString& peer = QString());
|
|
bool allowTrafficOfAdapter(int networkAdapter, uint8_t weight,
|
|
const QString& title);
|
|
bool allowDHCPTraffic(uint8_t weight, const QString& title);
|
|
bool allowHyperVTraffic(uint8_t weight, const QString& title);
|
|
bool allowLoopbackTraffic(uint8_t weight, const QString& title);
|
|
|
|
// Utils
|
|
QString getCurrentPath();
|
|
void importAddress(const QHostAddress& addr, OUT FWP_VALUE0_& value,
|
|
OUT QByteArray* v6DataBuffer);
|
|
void importAddress(const QHostAddress& addr, OUT FWP_CONDITION_VALUE0_& value,
|
|
OUT QByteArray* v6DataBuffer);
|
|
bool enableFilter(FWPM_FILTER0* filter, const QString& title,
|
|
const QString& description,
|
|
const QString& peer = QString());
|
|
};
|
|
|
|
#endif // WINDOWSFIREWALL_H
|