fix: per-site config was not working properly

This commit is contained in:
FUFSoB committed 2026-07-02 19:18:55 +05:00
1 parent 459a864478
commit 57a3426c85
7 files changed
+123 -42

No files matched your search

+14 -6
View File
@@ -278,9 +278,10 @@ let
];
zapretDefaultDomainType = types.enum [
"youtube"
"general"
"google"
"discord"
"other"
"youtube"
"instagram"
"soundcloud"
"twitter"
@@ -321,15 +322,22 @@ let
Built-in domain groups copied from zapret-discord-youtube hostlists.
These are expanded and combined with domains.
"youtube" uses the upstream Google/YouTube list. "discord" uses
Discord-related domains from the upstream general list. "other" uses
the non-Discord domains from the upstream general list.
Each value maps directly to the same-named upstream file:
"general" uses list-general.txt, "google" uses list-google.txt,
and the remaining values use their corresponding list-<name>.txt.
"discord" is an alias for "general"; "youtube" is an alias for
"google".
When "general" or "discord" is used together with configName, the
module also clones the selected config's Discord UDP voice rule
(--filter-l7=discord,stun).
When preset is unset, use one defaultDomains entry per rule so the
module can infer a single rule family. Split groups into separate
rules when they need different strategies.
'';
example = [ "youtube" ];
example = [ "google" ];
};
ips = mkOption {
+5 -4
View File
@@ -152,10 +152,11 @@ in
zapret family from the active config, clone it from another configName,
add custom NFQWS rule fragments, or combine these pieces.
defaultDomains provides built-in zapret-discord-youtube domain groups
such as "youtube" and "discord"; defaultIps provides upstream IP/CIDR
groups such as "all". configName is a higher-level
alternative to nfqwsArgs and cannot be used together with nfqwsArgs.
defaultDomains selects same-named upstream zapret-discord-youtube
hostlists such as "general" and "google", with the aliases "discord"
and "youtube" for readability. defaultIps provides upstream IP/CIDR
groups such as "all". configName is a higher-level alternative to
nfqwsArgs and cannot be used together with nfqwsArgs.
'';
example = [
{
+24 -6
View File
@@ -6,7 +6,6 @@
let
trim = lib.strings.trim;
hasPrefix = lib.strings.hasPrefix;
hasInfix = lib.strings.hasInfix;
splitString = lib.strings.splitString;
zapretSrc = if builtins.isAttrs zapret && zapret ? outPath then zapret.outPath else zapret;
@@ -21,21 +20,22 @@ let
upstreamHostlist = file: parseListFile "${zapretSrc}/hostlists/${file}";
generalDomains = upstreamHostlist "list-general.txt";
isDiscordDomain = domain: domain == "dis.gd" || hasInfix "discord" domain;
domainGroups = {
general = generalDomains;
google = upstreamHostlist "list-google.txt";
discord = generalDomains;
youtube = upstreamHostlist "list-google.txt";
discord = builtins.filter isDiscordDomain generalDomains;
other = builtins.filter (domain: !(isDiscordDomain domain)) generalDomains;
instagram = upstreamHostlist "list-instagram.txt";
soundcloud = upstreamHostlist "list-soundcloud.txt";
twitter = upstreamHostlist "list-twitter.txt";
};
groupPresets = {
youtube = "google";
general = "general";
google = "google";
discord = "general";
other = "general";
youtube = "google";
instagram = "instagram";
soundcloud = "soundcloud";
twitter = "twitter";
@@ -45,6 +45,11 @@ let
all = upstreamHostlist "ipset-all.txt";
};
protocolGroups = {
general = [ "discord-voice" ];
discord = [ "discord-voice" ];
};
expandDefaultDomains =
groups:
lib.unique (
@@ -76,12 +81,24 @@ let
effectiveRuleIpsetFamilies =
rule:
lib.optional (effectiveRuleIps rule != [ ]) "all";
effectiveRuleProtocolFamilies =
rule:
lib.optionals (rule.configName != null) (
lib.unique (
lib.concatMap (
group:
if builtins.hasAttr group protocolGroups then protocolGroups.${group} else [ ]
) rule.defaultDomains
)
);
in
{
inherit
domainGroups
groupPresets
ipGroups
protocolGroups
expandDefaultDomains
expandDefaultIps
inferPresets
@@ -89,5 +106,6 @@ in
effectiveRuleIps
effectiveRulePresets
effectiveRuleIpsetFamilies
effectiveRuleProtocolFamilies
;
}
+2
View File
@@ -46,6 +46,7 @@ let
ips = zapretDomainGroups.effectiveRuleIps rule;
presets = zapretDomainGroups.effectiveRulePresets rule;
ipsets = zapretDomainGroups.effectiveRuleIpsetFamilies rule;
protocols = zapretDomainGroups.effectiveRuleProtocolFamilies rule;
}
) zapretCfg.hostlistRules;
@@ -73,6 +74,7 @@ let
nfqwsArgs
ipsets
presets
protocols
;
hasDomains = rule.domains != [ ];
hasIps = rule.ips != [ ];