mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-24 02:00:24 +07:00
feat: per-tunnel Windows firewall for seamless WG switch
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QHostAddress>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
@@ -38,38 +39,42 @@ class WindowsFirewall final : public QObject {
|
||||
static WindowsFirewall* create(QObject* parent);
|
||||
~WindowsFirewall() override;
|
||||
|
||||
bool enableInterface(int vpnAdapterIndex);
|
||||
bool enableInterface(int vpnAdapterIndex, const QString& ifname = QString());
|
||||
bool enableLanBypass(const QList<IPAddress>& ranges);
|
||||
bool enablePeerTraffic(const InterfaceConfig& config);
|
||||
bool disablePeerTraffic(const QString& pubkey);
|
||||
bool disableKillSwitch();
|
||||
bool disableKillSwitchForTunnel(const QString& ifname);
|
||||
bool allowAllTraffic();
|
||||
bool allowTrafficRange(const QStringList& ranges);
|
||||
bool allowTrafficRange(const QStringList& ranges, const QString& ifname = QString());
|
||||
|
||||
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;
|
||||
QList<uint64_t> m_globalRules;
|
||||
QMap<QString, QList<uint64_t>> m_tunnelRules;
|
||||
|
||||
bool allowTrafficForAppOnAll(const QString& exePath, int weight,
|
||||
const QString& title);
|
||||
const QString& title, QList<uint64_t>& target);
|
||||
bool blockTrafficTo(const QList<IPAddress>& range, uint8_t weight,
|
||||
const QString& title, const QString& peer = QString());
|
||||
const QString& title, QList<uint64_t>& target);
|
||||
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);
|
||||
const QString& title, QList<uint64_t>& target);
|
||||
bool blockTrafficOnPort(uint port, uint8_t weight, const QString& title,
|
||||
QList<uint64_t>& target);
|
||||
bool allowTrafficTo(const IPAddress& addr, int weight, const QString& title,
|
||||
const QString& peer = QString());
|
||||
QList<uint64_t>& target);
|
||||
bool allowTrafficTo(const QHostAddress& targetIP, uint port, int weight,
|
||||
const QString& title, const QString& peer = QString());
|
||||
const QString& title, QList<uint64_t>& target);
|
||||
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);
|
||||
const QString& title, QList<uint64_t>& target);
|
||||
bool allowDHCPTraffic(uint8_t weight, const QString& title,
|
||||
QList<uint64_t>& target);
|
||||
bool allowHyperVTraffic(uint8_t weight, const QString& title,
|
||||
QList<uint64_t>& target);
|
||||
bool allowLoopbackTraffic(uint8_t weight, const QString& title,
|
||||
QList<uint64_t>& target);
|
||||
|
||||
// Utils
|
||||
QString getCurrentPath();
|
||||
@@ -78,8 +83,7 @@ class WindowsFirewall final : public QObject {
|
||||
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());
|
||||
const QString& description, QList<uint64_t>& target);
|
||||
};
|
||||
|
||||
#endif // WINDOWSFIREWALL_H
|
||||
|
||||
Reference in New Issue
Block a user