The IPv4 filter was sized for 100 entries while the current base list
contains about 18k IPv4 addresses. The filter was fully saturated, so every
lookup of a global IPv4 address fell through to the cache database. The
domain filter was sized for 1M entries with about 843k domains in use, which
left little head room for additional intel sources.
Raise the capacities with head room for growth:
domain 1M -> 2M, ipv4 100 -> 200k, ipv6 100 -> 20k, asn 1k -> 10k,
country 100 -> 300. This adds about 2 MB of memory for the domain filter
and doubles the size of its record in the cache database.
Count the values added per entity type and log them next to the capacity
after a base list has been processed, so a list outgrowing its filter can be
spotted in the logs.
Filters restored from the cache database keep their stored size. Existing
installations pick up the new capacities with the next base list update.
Pass the cache database version into resolveUpdateOrder so the ordering
logic can be tested without a database, and cover the base/diff
combinations, including a newer base skipping older diffs.
The cleanup after a base update deleted entries older than "now - 1h".
If the import took longer than an hour of wall-clock time (system sleep,
slow disk), entries written by the import itself were deleted too, and
stayed unblocked until the next base update. Use the update start time,
minus a small margin for clock corrections, as the cutoff instead.
The base/intermediate/urgent file variables used to detect the base file
and to compare versions were never assigned after the v2 updater
rewrite. As a result the "is this the base file" check never matched:
processing a new base.dsdl neither rebuilt the bloom filter from scratch
nor triggered the removal of obsolete entries. Entries that were removed
from the lists upstream stayed in the cache database and in the bloom
filter and kept blocking indefinitely, and both grew over time.
Detect the base file by filename, as the updater returns a new Artifact
instance on every GetFile call, so pointer identity could never match.
Drop the unused variables and the IsNewerThan checks: which files need
processing is already decided by comparing against the persisted cache
database version in resolveUpdateOrder.
The geoip reader memory-maps geoipv4/v6.mmdb once and only reopened
them on a new artifact version. The intel updater moves every file in
the intel directory on every update, even when unchanged, and the next
update renames the new copy over the moved one.
On Windows a mapped file without open handles cannot be deleted but can
be replaced by such a rename, after which the mapping has no backing
data: evicted pages come back zero-filled, maxminddb fails with
"invalid node in search tree", and geo rules block with "data not
available". Since the switch to Go 1.26 in v2.2.2 os.RemoveAll no
longer unlinks the mapped file on the first update, which is what kept
earlier releases safe.
- Detect a replaced file by its identity (file ID or inode, size and
mtime), taken from an open handle since os.Stat resolves the Windows
file ID lazily, and reload.
- Do not close the previous reader on reload; a lookup may still use
it. The finalizer set by maxminddb.Open unmaps it later.
- Buffer the worker trigger so an update event during a load is not
dropped, and do not hold the broadcaster lock during file access.
https://github.com/safing/portmaster/issues/2265
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.
https://github.com/safing/portmaster/issues/1988
---
The filterlists database is often updated when the service starts, even if the latest version is already cached in the database.
This does not affect PM’s functionality, but it unnecessarily consumes CPU resources.
**Technical explanation:**
This happens because the filterlists update check sometimes runs before the module is fully initialized.
**Steps to Reproduce:**
1. Start PM and ensure the filterlists are up to date.
2. Fully stop PM.
3. Start PM again.
**Observed result:**
PM reprocesses the filterlists cache database.
**Expected result:**
PM should update only when new data is available. Already processed data should not be reprocessed.
* 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>