From aa5428fc9be8982e6925d0b95160bf0f3f887070 Mon Sep 17 00:00:00 2001 From: FUFSoB Date: Sun, 12 Apr 2026 16:42:26 +0500 Subject: [PATCH] make includeExtraUpstreamLists opt-in --- README.md | 4 ++-- modules/proxy-suite/options.nix | 2 +- nix/checks.nix | 27 +++++++++++++++++++++++---- scripts/patch-zapret-config.py | 2 +- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a559d54..fc1da81 100644 --- a/README.md +++ b/README.md @@ -270,11 +270,11 @@ zapret = { }; ``` -When `syncDirectRouting = true`, the module always reuses zapret's upstream `hostlists/list-general.txt` and `list-google.txt`, adds your `listGeneral`, and subtracts both upstream and user domain exclusions before generating sing-box direct rules. If `zapret.includeExtraUpstreamLists = true` (default), it also includes upstream `list-instagram.txt`, `list-soundcloud.txt`, and `list-twitter.txt` in both zapret handling and sing-box direct sync. +When `syncDirectRouting = true`, the module always reuses zapret's upstream `hostlists/list-general.txt` and `list-google.txt`, adds your `listGeneral`, and subtracts both upstream and user domain exclusions before generating sing-box direct rules. If `zapret.includeExtraUpstreamLists = true`, it also includes upstream `list-instagram.txt`, `list-soundcloud.txt`, and `list-twitter.txt` in both zapret handling and sing-box direct sync. Custom `zapret.hostlistRules` domains also join this direct-domain sync by default. Set `enableDirectSync = false` on a custom hostlist if you want zapret to handle it but do not want sing-box direct-routing rules generated from it. -The generated zapret config also auto-activates upstream `list-instagram.txt`, `list-soundcloud.txt`, and `list-twitter.txt` when the selected upstream preset does not already reference them. They are attached using the active config's `general` rule family so those hostlists are actually handled by zapret instead of just existing on disk. Set `zapret.includeExtraUpstreamLists = false;` to opt out. +The generated zapret config can also auto-activate upstream `list-instagram.txt`, `list-soundcloud.txt`, and `list-twitter.txt` when the selected upstream preset does not already reference them. They are attached using the active config's `general` rule family so those hostlists are actually handled by zapret instead of just existing on disk. This is disabled by default; set `zapret.includeExtraUpstreamLists = true;` to opt in. When `syncDirectRoutingUpstreamIps = true`, the module also mirrors zapret's upstream `ipset-all.txt`. This is disabled by default because the upstream IP set is intentionally broad. diff --git a/modules/proxy-suite/options.nix b/modules/proxy-suite/options.nix index a67e295..baf968d 100644 --- a/modules/proxy-suite/options.nix +++ b/modules/proxy-suite/options.nix @@ -444,7 +444,7 @@ in includeExtraUpstreamLists = mkOption { type = types.bool; - default = true; + default = false; description = '' Automatically activate upstream list-instagram.txt, list-soundcloud.txt, and list-twitter.txt in the generated zapret config when the selected diff --git a/nix/checks.nix b/nix/checks.nix index 896beff..1f854a7 100644 --- a/nix/checks.nix +++ b/nix/checks.nix @@ -245,6 +245,18 @@ let zapretSyncNoExtraListsBase = mkZapretBase zapretSyncNoExtraListsFixture; zapretSyncNoExtraListsRules = mkRoutingRules zapretSyncNoExtraListsFixture; + zapretSyncExtraListsFixture = evalProxySuite [ + baseModule + { + services.proxy-suite.zapret = { + enable = true; + includeExtraUpstreamLists = true; + }; + } + ]; + zapretSyncExtraListsBase = mkZapretBase zapretSyncExtraListsFixture; + zapretSyncExtraListsRules = mkRoutingRules zapretSyncExtraListsFixture; + zapretSyncIpsFixture = evalProxySuite [ baseModule { @@ -575,7 +587,7 @@ let true ) ( - assert hasDirectDomain zapretSyncRules "twitter.com"; + assert !(hasDirectDomain zapretSyncRules "twitter.com"); true ) ( @@ -598,6 +610,10 @@ let assert !(hasDirectDomain zapretSyncNoExtraListsRules "twitter.com"); true ) + ( + assert hasDirectDomain zapretSyncExtraListsRules "twitter.com"; + true + ) ( assert !(hasDirectIP zapretSyncUserIpsDisabledRules "203.0.113.0/24"); true @@ -687,9 +703,12 @@ in proxy-suite-module = builtins.seq validated (pkgs.writeText "proxy-suite-module-check" "ok"); zapret-hostlist-rules = pkgs.runCommand "proxy-suite-zapret-hostlist-rules-check" { } '' - grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-twitter.txt"' "${zapretSyncBase}/config" - grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-instagram.txt"' "${zapretSyncBase}/config" - grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-soundcloud.txt"' "${zapretSyncBase}/config" + grep -F -- '--hostlist="${zapretSyncExtraListsBase}/hostlists/list-twitter.txt"' "${zapretSyncExtraListsBase}/config" + grep -F -- '--hostlist="${zapretSyncExtraListsBase}/hostlists/list-instagram.txt"' "${zapretSyncExtraListsBase}/config" + grep -F -- '--hostlist="${zapretSyncExtraListsBase}/hostlists/list-soundcloud.txt"' "${zapretSyncExtraListsBase}/config" + ! grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-twitter.txt"' "${zapretSyncBase}/config" + ! grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-instagram.txt"' "${zapretSyncBase}/config" + ! grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-soundcloud.txt"' "${zapretSyncBase}/config" ! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-twitter.txt"' "${zapretSyncNoExtraListsBase}/config" ! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-instagram.txt"' "${zapretSyncNoExtraListsBase}/config" ! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-soundcloud.txt"' "${zapretSyncNoExtraListsBase}/config" diff --git a/scripts/patch-zapret-config.py b/scripts/patch-zapret-config.py index 620d3b9..1dc6c29 100644 --- a/scripts/patch-zapret-config.py +++ b/scripts/patch-zapret-config.py @@ -162,7 +162,7 @@ def main() -> int: lines = config_path.read_text(encoding="utf-8").splitlines() spec = json.loads(spec_path.read_text(encoding="utf-8")) entries = spec.get("entries", []) - include_extra_upstream_lists = spec.get("includeExtraUpstreamLists", True) + include_extra_upstream_lists = spec.get("includeExtraUpstreamLists", False) start, end = locate_nfqws_block(lines) nfqws_lines = lines[start + 1 : end]