Commit Graph
43 Commits
Author SHA1 Message Date
Alexandr Stelnykovych 3dd55529bf feat(firewall; Linux): Add split-tunneling support to firewall mark handling 2026-05-06 14:42:22 +03:00
Alexandr Stelnykovych 315fc254a5 fix(firewall; Linux): delete unmarked conntrack entries on firewall activation
Add DeleteUnmarkedConnections() to purge conntrack entries with mark=0
when firewall is activated. This forces applications with existing
connections to reconnect, allowing DNAT rules (like SPN) to apply.

Without this, connections established while Portmaster was paused or
stopped would bypass DNAT because netfilter's nat table is only
traversed for new connections.

Loopback connections are excluded from deletion to avoid disconnecting
local services.

https://github.com/safing/portmaster-shadow/issues/42
2026-05-06 14:33:23 +03:00
Alexandr Stelnykovych 8d627bc1bc fix(linux/nfq): use correct protocol family for deleting conntrack elements
Use the selected conntrack family for delete operations
so IPv6 entries are removed correctly too.
2026-05-05 15:09:57 +03:00
Alexandr Stelnykovych 39e523d18e firewall(linux): add MarkRerouteSplitTun (0x6b7) and iptables rules
Introduces mark 1719 for split-tunnel rerouting, mirroring the existing SPN mark (1717).
Adds FILTER RETURN and NAT DNAT rules for both IPv4 and IPv6 targeting port 719.
2026-04-29 17:37:43 +03:00
Alexandr Stelnykovych 933323d5f9 feat: add VerdictRerouteToSplitTun verdict type
Add a new verdict (value 8) for routing connections through the split
tunnel. This prepares the infrastructure for the upcoming split-tunneling
feature without implementing the full feature yet.

Changes:
- Define VerdictRerouteToSplitTun in network/status.go with String() and Verb()
- Add RerouteToSplitTun() to the Packet interface and InfoPacket stub
- Implement RerouteToSplitTun() for windowskext (v1) and windowskext2 (v2) packets
- Map VerdictRerouteToSplitTun to KextVerdict 11 in kextinterface and kext2
- Handle the verdict in packet_handler.go dispatch, connection.go, api.go,
  metrics.go and nameserver.go
- Add VerdictRerouteToSplitTun = 8 to Angular Verdict enum and update
  stats counting, filter queries and verdict CSS class

(WIP) Note: Linux (nfq) implementation not updated yet. Therefore Linux build will fail.
2026-04-17 20:48:48 +03:00
Alexandr Stelnykovych 25ce0e545f firewall/Linux: add MarkAcceptFinal to bypass third-party iptables OUTPUT rules for Portmaster-owned connections
Introduce mark 1709 (MarkAcceptFinal) and a corresponding
PermanentAcceptFinal() method that sets this mark on packets belonging
to Portmaster-owned outbound connections.

Add iptables rules (both IPv4 and IPv6, filter and mangle chains) to
ACCEPT packets/connections carrying mark 1709, so  further OUTPUT rules from
third-party software (e.g. iVPN) cannot override the allow decision.

https://github.com/safing/portmaster-shadow/issues/34
2026-03-27 14:04:45 +02:00
Alexandr Stelnykovych 2252fd17ed ivpn/linux: route SPN hub traffic around VPN tunnel (split tunnel)
Add a synchronous HookMgr[T] that lets callers register pre-connect
hooks before SPN dials a home hub. The IVPN interop layer subscribes
to this hook and uses Linux ip-rule/ip-route to steer SPN hub IPs
through a dedicated routing table (717) pointing to the non-VPN default
gateway, preventing SPN control traffic from being tunnelled into IVPN.

- service/mgr: add generic HookMgr[T] (synchronous, cancellable)
- spn/captain: expose HookSPNConnecting; invoke it in connectToHomeHub
- service/netenv: add GatewayInfo + GatewaysInfo() with interface/mask
- service/interop/ivpn: add ensureSpnHubBypassVpnRoutes managing policy
  routing; call it from the SPN pre-connect hook and on VPN stop/connect
- nfq/packet: add hex comments next to mark constants

https://github.com/safing/portmaster-shadow/issues/34
2026-03-26 23:20:34 +02:00
Alexandr Stelnykovych 15c495f5c9 feat(interception; Linux): ensure iptables jump rules remain at top of chains on startup
Add ensureJumpRulesAtTop and reinsertDisplacedRules to detect and fix
iptables jump rules that have been displaced by other services during
boot. A background worker runs checks at 5s, 15s, and 45s after nfqueue
interception starts, reinserting any out-of-position rules.
2026-03-17 12:08:42 +02:00
Alexandr Stelnykovych 93fb39825d fix(interception): streamline rule insertion logic in activateIPTables 2026-03-17 10:48:55 +02:00
Alexandr Stelnykovych 8396300b05 feat(interoperability/ivpn): disable custom DNS when Portmaster interception is paused
Add EventStartStopState event  manager and IsStarted() method
to the Interception module so other modules can react to start/stop state changes.

Update IVPN interop to subscribe to interception start/stop events
and skip applying custom DNS settings when interception is inactive,
ensuring correct behavior when Portmaster is in the Paused state.
2026-02-28 14:34:51 +02:00
Alexandr Stelnykovych 063fa7f115 fix(interception): ensure metrics are stopped on failed module start 2025-11-12 14:24:24 +02:00
Alexandr Stelnykovych 83fb71b4bc Merge branch 'development' into feature/2050-pause 2025-11-11 17:33:28 +02:00
Alexandr Stelnykovych 2009dcf9c8 fix: DNSMonitor module crash on stop
Add traceEnded channel to ETWSession for better session management

https://github.com/safing/portmaster/issues/2065
2025-11-11 17:32:56 +02:00
Alexandr Stelnykovych 4d2d91972b feat: refactor interception modules into pausable group
- Add GroupModule to wrap interception, dnsmonitor, and compat modules
- Simplify pause/resume operations by grouping related modules
- Update worker info collection to handle nested module groups
- Remove deprecated flags and improve module lifecycle management
- Add proper atomic state tracking for nfqueue interception

https://github.com/safing/portmaster/issues/2050
2025-11-06 17:28:38 +02:00
Alexandr Stelnykovych c063bda700 feat(WIP): add pause and resume functionality for Portmaster/SPN
https://github.com/safing/portmaster/issues/2050
2025-10-24 18:15:27 +03:00
Alexandr Stelnykovych 10589dc725 (interception) Linux: respect original packet marks (#1993)
(WireGuard/wg-quick compatibility)
2025-09-03 13:32:07 +03:00
Alexandr Stelnykovych 1b76004a63 Minor cleanup in code comments 2025-07-11 19:47:28 +03:00
Alexandr Stelnykovych d5698270e9 improvement(ebpf-Linux): enhance eBPF object loading for kernel compatibility and update attach points 2025-07-11 19:03:13 +03:00
Alexandr Stelnykovych ec2d4ca9eb Merge branch 'master' into merge/master-into-v2-with-history (v1 into v2)
# Conflicts:
#	Earthfile
#	base/config/main.go
#	base/database/dbmodule/db.go
#	base/database/main.go
#	go.mod
#	go.sum
#	service/core/base/global.go
2025-05-28 11:52:15 +03:00
Vladimir Stoilov 40b443282f [service] Fix IPv6 payload layer set 2025-02-11 13:55:29 +02:00
Vladimir Stoilov 59a106b9f2 Merge branch 'develop' into feature/new-installer 2025-01-27 17:26:00 +02:00
Vladimir Stoilov 0f28af66cd Add PID in ETW DNS event in the integration dll (#1768)
* [service] Add reading of PID in ETW DNS event

* [service] Use PID of the ETW DNS events

* [service] Fix use of nil pointer

* [service] Fix compiler error
2025-01-27 17:21:54 +02:00
Vladimir Stoilov 5039e9efca Merge branch 'develop' into feature/new-installer 2025-01-14 16:59:21 +02:00
Vladimir Stoilov ed2338fdb9 [service] Fix error on unitilized dns monitor 2024-12-02 15:25:58 +02:00
Vladimir Stoilov 2a9d75433f [service] Fix module failure when dll is missing 2024-12-02 14:02:49 +02:00
Vladimir Stoilov 374c1c2748 Merge branch 'develop' into feature/new-installer 2024-11-28 13:23:13 +02:00
Daniel 614d8972a2 Improve logging 2024-11-27 16:37:59 +01:00
Vladimir Stoilov 1a1bc14804 Feature/systemd query events (#1728)
* [service] Subscribe to systemd-resolver events

* [service] Add disabled state to the resolver

* [service] Add ETW DNS event listener

* [service] DNS listener refactoring

* [service] Add windows core dll project

* [service] DNSListener refactoring, small bugfixes

* [service] Change dns bypass rule

* [service] Update gitignore

* [service] Remove shim from integration module

* [service] Add DNS packet analyzer

* [service] Add self-check in dns monitor

* [service] Fix go linter errors

* [CI] Add github workflow for the windows core dll

* [service] Minor fixes to the dns monitor
2024-11-27 17:10:47 +02:00
Daniel 0f3f3c360f [WIP] Simplify update system 2024-10-31 16:38:12 +01:00
Vladimir Stoilov 83ec18f552 [WIP] Updater support for windows 2024-09-11 18:52:36 +03:00
Daniel HååviandVladimir Stoilov 80664d1a27 Restructure modules (#1572)
* Move portbase into monorepo

* Add new simple module mgr

* [WIP] Switch to new simple module mgr

* Add StateMgr and more worker variants

* [WIP] Switch more modules

* [WIP] Switch more modules

* [WIP] swtich more modules

* [WIP] switch all SPN modules

* [WIP] switch all service modules

* [WIP] Convert all workers to the new module system

* [WIP] add new task system to module manager

* [WIP] Add second take for scheduling workers

* [WIP] Add FIXME for bugs in new scheduler

* [WIP] Add minor improvements to scheduler

* [WIP] Add new worker scheduler

* [WIP] Fix more bug related to new module system

* [WIP] Fix start handing of the new module system

* [WIP] Improve startup process

* [WIP] Fix minor issues

* [WIP] Fix missing subsystem in settings

* [WIP] Initialize managers in constructor

* [WIP] Move module event initialization to constrictors

* [WIP] Fix setting for enabling and disabling the SPN module

* [WIP] Move API registeration into module construction

* [WIP] Update states mgr for all modules

* [WIP] Add CmdLine operation support

* Add state helper methods to module group and instance

* Add notification and module status handling to status package

* Fix starting issues

* Remove pilot widget and update security lock to new status data

* Remove debug logs

* Improve http server shutdown

* Add workaround for cleanly shutting down firewall+netquery

* Improve logging

* Add syncing states with notifications for new module system

* Improve starting, stopping, shutdown; resolve FIXMEs/TODOs

* [WIP] Fix most unit tests

* Review new module system and fix minor issues

* Push shutdown and restart events again via API

* Set sleep mode via interface

* Update example/template module

* [WIP] Fix spn/cabin unit test

* Remove deprecated UI elements

* Make log output more similar for the logging transition phase

* Switch spn hub and observer cmds to new module system

* Fix log sources

* Make worker mgr less error prone

* Fix tests and minor issues

* Fix observation hub

* Improve shutdown and restart handling

* Split up big connection.go source file

* Move varint and dsd packages to structures repo

* Improve expansion test

* Fix linter warnings

* Fix interception module on windows

* Fix linter errors

---------

Co-authored-by: Vladimir Stoilov <vladimir@safing.io>
2024-08-09 18:15:48 +03:00
Vladimir Stoilov 2e3304809f [windows_kext] Fix minor problems 2024-07-01 15:06:54 +03:00
Vladimir Stoilov b1d168e06d [service] Improve kext verdict translation 2024-06-28 13:29:35 +03:00
Vladimir Stoilov 4bf1736a83 [service] Add check for kext command size 2024-06-28 13:20:18 +03:00
Vladimir Stoilov 176494550e [service] Fix kext verdict of update command 2024-06-27 16:39:31 +03:00
Vladimir Stoilov 1d6228ea7b [windows_kext] fix all linter error 2024-05-16 16:21:27 +03:00
Vladimir Stoilov 6f9b0a8249 [service] Minor windows kext improvments 2024-05-15 18:04:49 +03:00
Vladimir Stoilov b0f664047b Add rust kext to the mono repo 2024-04-29 17:04:08 +03:00
Vladimir Stoilov cd135331ad Move kext files to proper path 2024-04-18 10:39:20 +03:00
Vladimir Stoilov 24f6678ad0 Merge branch 'develop' into feature/new-kext 2024-04-18 10:14:49 +03:00
Alexandr Stelnykovych 76c8425452 fix: Inacessible code due to wrong comparison operation 2024-04-10 14:35:11 +03:00
Patrick Pacher 61176af14e Fix linting errors 2024-03-27 16:17:58 +01:00
Patrick Pacher 8579430db9 wip: migrate to mono-repo. SPN has already been moved to spn/ 2024-03-20 09:45:32 +01:00