diff --git a/.vscode/launch.json b/.vscode/launch.json index 80a785ddf07..462a643f7e5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "skipFiles": [ "/**" ], - "program": "${workspaceFolder}/index.js" + "program": "${workspaceFolder}/scripts/compose.js" }, { "type": "pwa-node", diff --git a/README.md b/README.md index 5af0f8999f1..442b95d2945 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ The files `/assets/filters.json` and `/assets/filters-dev.json` must not be edit - `environment` - either `dev` or `prod`. Only `prod` lists are available in AdGuard DNS. - `disabled` - if set to `true`, the blocklist won't be updated. - `tags` — a list of [tags](#tags) + - `trusted` - a flag that allows using `$dnsrewrite` rules for this filter. If the filter is not trusted, `$dnsrewrite` rules will be removed from the compiled filter.
Metadata example @@ -86,7 +87,8 @@ The files `/assets/filters.json` and `/assets/filters-dev.json` must not be edit "expires": "4 days", "displayNumber": 3, "environment": "prod", - "tags": [] + "tags": [], + "trusted": true } ``` diff --git a/filters/general/filter_1_DnsFilter/metadata.json b/filters/general/filter_1_DnsFilter/metadata.json index f19444f8d09..8b419bb9dc0 100644 --- a/filters/general/filter_1_DnsFilter/metadata.json +++ b/filters/general/filter_1_DnsFilter/metadata.json @@ -11,5 +11,6 @@ "environment": "prod", "tags": [ "purpose:general" - ] + ], + "trusted": true } \ No newline at end of file diff --git a/filters/general/filter_59_DnsPopupsFilter/metadata.json b/filters/general/filter_59_DnsPopupsFilter/metadata.json index 7116bd0b273..61eafc86fc8 100644 --- a/filters/general/filter_59_DnsPopupsFilter/metadata.json +++ b/filters/general/filter_59_DnsPopupsFilter/metadata.json @@ -11,5 +11,6 @@ "environment": "prod", "tags": [ "purpose:general" - ] + ], + "trusted": true } \ No newline at end of file diff --git a/hostlists-builder/index.js b/hostlists-builder/index.js index 4892788d9e1..ec746d1901c 100644 --- a/hostlists-builder/index.js +++ b/hostlists-builder/index.js @@ -175,11 +175,18 @@ async function build(filtersDir, tagsDir, localesDir, assetsDir, groupsDir) { revision.setVersionCandidate(); revision.setTimeUpdatedCandidate(); - const hostlistCompiled = await hostlistCompiler({ + let hostlistCompiled = await hostlistCompiler({ ...hostlistConfiguration, version: revision.getVersionCandidate(), }); + if (!metadata.trusted) { + // Remove $dnsrewrite rules if the filter is not trusted. + hostlistCompiled = hostlistCompiled.filter((line) => { + return !line.includes('dnsrewrite='); + }); + } + const hash = calculateRevisionHash(hostlistCompiled); // Rewrites the filter if it's actually changed.