Commit Graph

2888 Commits

Author SHA1 Message Date
Alexandr Stelnykovych 6d03debc91 Bump version 2.2.0
+ npm audit fix
v2.2.0
2026-05-18 18:00:33 +03:00
Alexandr Stelnykovych 2d4d5bc0e6 Merge branch 'feature/split-tunneling' into release/v2.2.0 2026-05-18 17:52:10 +03:00
Alexandr Stelnykovych 2e3b0e4ede Merge branch 'fix/1997-correct-update-app-fingerprints' into release/v2.2.0 2026-05-18 17:51:44 +03:00
Alexandr Stelnykovych b193aab625 ui: clarify Split Tunnel config tooltips and messaging
https://github.com/safing/portmaster-shadow/issues/45
2026-05-18 17:48:29 +03:00
Alexandr Stelnykovych b5153a3a84 Merge pull request #2168 from safing/fix/s43_LPE_CWE-428
Fix: CWE 428
2026-05-18 14:36:21 +03:00
Alexandr Stelnykovych 353fda0855 feat(profile): re-key profiles when fingerprints change
- Detect fingerprint changes and re-derive the profile ID
- Migrate profile to new ID while preserving all settings and creation time
- Update UI to handle profile navigation after fingerprint-triggered re-keying
- Emit EventMigrated for history DB and connection re-attribution

https://github.com/safing/portmaster/issues/1997
2026-05-14 17:25:33 +03:00
Alexandr Stelnykovych e0507ca85b feat(profile): validate fingerprints on save
Reject saves with unparseable fingerprints (e.g., invalid regex patterns)
to prevent profiles from being saved in an unusable state.

https://github.com/safing/portmaster/issues/1997
2026-05-14 17:22:22 +03:00
Alexandr Stelnykovych 8927874d69 firewall: always fetch entity location in FilterConnection
Proxy split tunnel connections bypassed both filter and tunnel checks,
leaving no code path to trigger the GeoIP lookup, so Country, ASN and
AS Org showed as N/A in the UI.

Add Entity.FetchLocation (GeoIP only, no filter lists) and call it
unconditionally at the start of FilterConnection.
2026-05-14 12:12:20 +03:00
Alexandr Stelnykovych 15e5401734 fix(firewall): skip SPN tunnel check for proxied split-tunnel connections
Proxied egress connections from ownPID were still running through
checkTunneling(), causing them to be routed via SPN if Portmaster's
own profile had SPN enabled. Add a checkTunnel flag that is set to
false for isOwnSplitTunnelProxyConnection to preserve the original
app's routing decision.
2026-05-13 23:56:10 +03:00
Alexandr Stelnykovych d0141c468a feat(service/profile): Add validation and documentation for Split Tunnel options
- Add validation to Network Interface config to reject whitespace-only values
- Improve "Use Split Tunnel" description to clarify default physical interface detection behavior
2026-05-13 15:28:04 +03:00
Alexandr Stelnykovych b51e59a1c1 feat(UI): add Split Tunnel quick-setting to app profile view
Adds a "Split Tunnel" toggle to the app profile quick-settings bar,
mirroring splittun/use per-app setting.

Shows an interference dot when:
- splittun/usagePolicy has Exclude rules (yellow)
- SPN is active and routes all traffic, fully bypassing Split Tunnel (red)
- SPN is active and partially bypasses Split Tunnel (yellow)

Dot and interference checks are suppressed when the Split Tunneling
or SPN module is globally disabled.
2026-05-13 14:50:52 +03:00
Alexandr Stelnykovych 2d5628a309 feat(UI): add Split Tunneling feature card
- Replace "Safing Support" feature with Split Tunneling in features.go,
  using a dedicated config key/scope and free package tier
- Fix feature-card component to prioritize ConfigKey over ConfigScope
  when resolving the config lookup key
2026-05-12 18:00:06 +03:00
Alexandr Stelnykovych ee2e3ef357 UI: Do not show "SPN Tunnel: connection has not been routed through the SPN"
The SPN Tunnel information is visible only when the connection has been routed through it.
2026-05-12 16:35:57 +03:00
Alexandr Stelnykovych dea008886d UI: Do not show username in the main application view
https://github.com/safing/portmaster/issues/2123
2026-05-12 16:27:15 +03:00
Alexandr Stelnykovych 2e4b3e938e Bump version 2.1.19 v2.1.19 2026-05-11 15:13:21 +03:00
Alexandr Stelnykovych f93e5a7d38 fix(windows): mitigate CWE-428 unquoted service path for PortmasterCore
- Update NSIS installer to register service with properly quoted executable path
- Add runtime self-heal in portmaster-core on Windows service startup to protect users who update via in-app updater without re-running the installer

https://github.com/safing/portmaster-shadow/issues/43
2026-05-11 15:09:47 +03:00
Alexandr Stelnykovych 0fd3665ac0 kext: fast-track split-tunnel proxy packets on loopback
Add PM_SPLIT_TUN_PORT (719) to fast_track_pm_packets so that redirected
packets arriving at the local split-tunnel proxy are permitted immediately
by the kext, matching the existing behaviour for the SPN port (717) and
the DNS port (53). This prevents internal proxy connections from being
reported to Portmaster and appearing in the connection monitor UI.

Also simplify fast_track_pm_packets by removing the redundant
match-on-direction branches, which were identical for Outbound and
Inbound.

Bump kext interface patch version to 2.1.1.0.
2026-05-07 13:46:16 +03:00
Alexandr Stelnykovych 485b19f241 firewall: identify and auto-approve own egress split-tunnel connections
Add isOwnSplitTunnelProxyConnection to detect outbound connections
from Portmaster's own split-tunnel proxies. Replace the slice-returning
FindProxiedEgressConnection with a boolean HasProxiedEgressConnection
to avoid unnecessary allocations on each lookup.
2026-05-06 19:06:55 +03:00
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 89ee86890a refactor: simplify IVPN compatibility state reconciliation
Rename ensureSPNCompatibility to reconcileCompatibilityState and extract the
implementation logic to improve code clarity and maintainability across all
platform implementations.
2026-05-05 14:00:26 +03:00
Alexandr Stelnykovych 4e67768927 splittun on Linux: generalize WireGuard compatibility rule for SPN and Split Tunnel
- Rename ensureWgSpnCompatRule to ensureWgCompatRule to reflect that it now
  handles both SPN and Split Tunnel compatibility with WireGuard
- Add split tunnel configuration check alongside SPN check
- Update comments to clarify the rule applies to both SPN and Split Tunnel
- Ensure compatibility rule remains active when either SPN or split tunneling
  is enabled
2026-04-30 18:26:34 +03:00
Alexandr Stelnykovych 192980b757 splittun: add splittun/enable config option with dynamic enable/disable
- New config.go registers the "splittun/enable" boolean option
- subsystems.ts: change ToggleOptionKey from splittun/use to splittun/enable
- Module Start/Stop replaced with enable()/disable() helpers driven by
  the config option; a callback on EventConfigChange toggles state at runtime
2026-04-30 18:18:53 +03:00
Alexandr Stelnykovych 594ab52bc6 splittun/proxy: migrate Logger to structured API and add logPrefix parameter
- Logger interface changes from Debugf/Infof/Warnf/Errorf to
  Debug/Info/Warn/Error with key-value args (slog-compatible)
- NewTCPProxy, NewTCPProxyWithConfig, NewUDPProxy, NewUDPProxyWithConfig
  all gain a logPrefix string parameter
- noopLogger updated; resolveLogPrefix helper added
- README, tests, and benchmarks updated accordingly
- proxies.go: remove proxyLogger wrapper now that mgr.Manager satisfies
  the new structured Logger interface directly
2026-04-30 18:17:16 +03:00
Alexandr Stelnykovych 74d4138c8e log: emit message on log level change and make slog handler level dynamic
- SetLogLevel now writes a log line via writeLogLevelChange() so level
  transitions are always visible regardless of old/new level
- slogLevel is now a shared *slog.LevelVar; all derived loggers pick up
  changes instantly without recreating the handler
- slog.SetDefault is called only once (sync.Once) so handlers are stable
2026-04-30 18:07:26 +03:00
Alexandr Stelnykovych f7e6ea0eb3 splittun/proxy: add LocalBinding with SO_BINDTODEVICE support
Introduces LocalBinding{IP, Interface} to carry both source-address
and device binding in a single DeciderFunc return value. On Linux,
SO_BINDTODEVICE is applied via net.Dialer.Control before connect(2),
forcing traffic through the specified interface regardless of the
routing table. Non-Linux platforms get a no-op stub.

Wires LocalBinding through TCPProxy, UDPProxy, and splittun's
proxyDecider/AwaitRequest so split-tunnelled connections are bound
to the correct physical interface.
2026-04-29 17:37:57 +03:00
Alexandr Stelnykovych 194d903675 netenv: restrict interface address selection to routable unicast IPs
Replaces scattered link-local exclusion checks with the new
isRoutableUnicastIP predicate (site-local or global scope only),
consistently applied in refreshIfaceCache, buildInterfaceInfoDirect,
hasRoutableIPv4, and hasRoutableIPv6. Updates tests accordingly.
2026-04-29 17:37:51 +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 64475f94d0 build(linux): add build_angular.sh dev helper script
Adds a standalone bash script to build the Angular UI project and package it into a distributable zip. Supports --development and --interactive flags.
2026-04-29 17:37:11 +03:00
Alexandr Stelnykovych 7a61a06881 Merge branch 'development' into feature/split-tunneling 2026-04-28 12:53:38 +03:00
Alexandr Stelnykovych c036e41987 Bump version 2.1.18
+ npm audit fix
v2.1.18
2026-04-28 00:01:35 +03:00
Alexandr Stelnykovych f09fd9cc3c fix(interop/ivpn/Linux): improve error handling in spnConnectingHook function
Ignore IVPN compatibility warnings during SPN connection.
2026-04-27 23:51:49 +03:00
Alexandr Stelnykovych afc4a9117b fix(interop/ivpn/Linux): fix SPN hub bypass gateway handling and connect hook flow 2026-04-27 18:28:33 +03:00
Alexandr Stelnykovych 895f102f31 splittun: fix proxy startup leak, pending request memory leak, and nil-manager panic
- proxies: shut down partially-started proxies on startup failure via
  deferred cleanup; avoid nil-manager panic in stopProxies by falling
  back to context.Background(); start UDP4 unconditionally and gate
  TCP6/UDP6 on IPv6Enabled()

- requests: add 30s TTL to pending requests to prevent memory leaks
  when OS drops a redirected connection before it reaches the proxy;
  schedule deferred cleanup via module.mgr.Go so the goroutine only
  runs when entries are registered and exits cleanly on module stop;
  add expiry check in consumeRequest as a safety net; clear map on Stop

- requests: guard against nil LocalIP on public AwaitRequest API
2026-04-24 22:57:31 +03:00
Alexandr Stelnykovych ee8cde31f6 feat: Add Split Tunnel feature (Windows PoC)
Implement initial proof-of-concept for split tunnel functionality on Windows,
allowing applications to route traffic through a designated network interface
while bypassing default system routing.

Features:
- Split tunnel module with TCP/UDP proxy infrastructure
- Firewall integration with split tunnel verdict handling
- SplitTunneling context attached to connections
- Configuration options: enable toggle, interface selection, and policy rules
- UI display of split tunnel connection details in connection info panel
- Subsystem configuration for user-level access

Windows-specific implementation:
- Uses proxy-based interface routing on Windows
- Automatic or manual interface detection and binding
- Support for IPv4 and IPv6 traffic

Note: Linux implementation is under development. SPN takes precedence over
split tunnel when both are enabled, ensuring SPN connections bypass this feature.
2026-04-24 18:04:01 +03:00
Alexandr Stelnykovych 29cc58fecb refactor(proxy): simplify source address binding to use net.IP instead of strings 2026-04-24 17:58:21 +03:00
Alexandr Stelnykovych 52a3b9256a netenv: enhance interface detection with physical adapter selection
- Refactor GetInterface* functions to return InterfaceInfo with IPv4/IPv6
  addresses instead of just net.Interface
- Add pre-caching of first routable IPv4/IPv6 per interface to avoid repeated
  address list scans
- Skip loopback interfaces in cache refresh
- Add GetBestPhysicalDefaultInterfaces() to detect which physical adapters
  carry the default route per IP family, excluding VPNs/tunnels
- Implement platform-specific physical interface detection:
  * Linux: reads /proc/net/route and /proc/net/ipv6_route, uses
    /sys/class/net/*/device to identify real hardware
  * Windows: uses GetAdaptersAddresses with IfType filtering
  * Other platforms: returns not-supported error
- Add helper functions: buildInterfaceInfo, interfaceToInfo, buildInterfaceInfoDirect,
  hasRoutableIPv4, hasRoutableIPv6
- Update tests to work with new InterfaceInfo return type and add coverage
  for new features
2026-04-24 17:55:32 +03:00
Alexandr Stelnykovych fdd04e1dd0 netenv: add cached network interface lookup
Add interfaces.go with GetInterface, GetInterfaceByIP, GetInterfaceByMAC
and GetInterfaceByName for resolving local network interfaces by IP, MAC,
or name.

- Lazy init: no work until first call
- sync.RWMutex with double-checked locking for concurrent read throughput
- Refresh throttled to once per second to absorb rapid interface churn
  (same NetworkChangedFlag pattern used across netenv)
- Only live, routable interfaces cached: FlagUp required; link-local and
  address-less interfaces excluded as unsuitable for TCP/UDP tunneling
2026-04-23 17:32:31 +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 52bfe1750f service/splittun/proxy: refactor DeciderFunc API and extract session cache
- Change DeciderFunc signature to return (remoteIP net.IP,
  remotePort uint16, localAddr string, extraInfo any, err error)
  instead of a single "host:port" dest string
- Extract ConnContext, Metrics, sessionCache, and idCounter into
  a new cache.go file
- Add a secondary destKey index to sessionCache for O(1)
  FindProxiedEgressConnection lookups by upstream destination
- Attach per-session extraInfo and atomic byte/packet counters
  to ConnContext
- Update TCP and UDP proxies, tests, and README accordingly
2026-04-17 20:30:36 +03:00
Alexandr Stelnykovych f5bad230fc Merge branch 'development' into feature/split-tunneling 2026-04-14 12:22:48 +03:00
Alexandr Stelnykovych 7fca633cd8 test(resolver): TestResolveIPAndValidate fix 2026-04-13 18:17:20 +03:00
Alexandr Stelnykovych 0c83c5c1b9 test(resolver): refresh public suffix expectations after x/net PSL update 2026-04-13 17:22:14 +03:00
Alexandr Stelnykovych e54f2a23fe Merge pull request #2155 from safing/feature/s40-restart_ui_on_upgrade
(feat) Restart the UI process after automatic update

The Tauri (UI) process now automatically restarts after a successful update.
2026-04-10 16:54:30 +03:00
Alexandr Stelnykovych ce67af81e3 fix(tauri): harden UI process restart path resolution and avoid exit on relaunch failure
This fixes Linux-related issue when UI process do not start automatically after upgrade.

- replace direct current_exe relaunch usage with verified launch program resolution
- consider both current_exe and argv0, but only accept verified launchable file paths
- fail relaunch with explicit error when no safe executable path is available
- in reconnect flow, exit current UI only if relaunch spawn succeeds
- if relaunch request fails, keep current UI process running and continue normal startup

https://github.com/safing/portmaster-shadow/issues/40
2026-04-10 16:01:13 +03:00
Alexandr Stelnykovych fab4d3e68b fix: fix variable shadowing in copyAndCheckSHA256Sum
Separate variable declaration from assignment in the SHA256 validation
logic to prevent variable shadowing and ensure proper error handling
scope.
2026-04-10 13:30:22 +03:00
Alexandr Stelnykovych 14a8df4b11 Restart UI process (Tauri) after automatic update
https://github.com/safing/portmaster-shadow/issues/40
2026-04-10 13:12:04 +03:00
Alexandr Stelnykovych 67802f5cfb vscode config: Use consistent debug binary output path in VS Code launch configuration
- Add fixed output path for portmaster-core debug configurations
- Prevents creation of temporary debug binaries with random suffixes
- Reuses same binary across debug sessions
2026-04-08 15:30:04 +03:00
Alexandr Stelnykovych b298265c46 fix(updates): prevent downgrade due to CDN caching issues for recent index updates
https://github.com/safing/portmaster-shadow/issues/39
2026-04-03 13:26:51 +03:00