Conversation
|
完全没有必要,ssp因为没有分流规则才弄了去广告的选项,psw完全可以自己设置一个去广告的规则就行,geo中就有现成的广告屏蔽分类。 |
|
为了方便维护,在保证正常使用的前提下pws已经开始做减法,而不是继续往里面堆一些实际上并没什么用处的功能。特别是dns去广告,在https普及的当今,基本没什么卵用。 |
这个前置的广告过滤可以不用进核心啊,不进核心的直连流量可以消费 |
这不是重点,重点是我第二个回复。psw是代理插件,去广告有更专业的插件在做,我们不想投入精力去维护代理功能以外的东西。 |
你才多少人玩得转adg和会配置过滤规则,多一个简单的选择不是挺好的么,照顾普通人 |
a68dd8c to
d680663
Compare
|
不进核心的广告过滤我支持一票,带开关不会影响主要功能使用,又可以减少应用安装和设备空间,值得加入 |
15e83c7 to
e3443fa
Compare
SwrodKing
left a comment
There was a problem hiding this comment.
我收回之前说的话,确实无用,并且属于功能重复,我重新分析源码,psw2是可以在全局进行广告过滤的,通过规则管理新建Block规则,添加geosite:category-ads,并将规则排到第一位,最后在基础设置的分流规则中启用就可以实现dns在分流解析前的全局拦截,在https的大环境下geosite:category-ads确实够用了,想要更精细的去广告只能在电脑端进行,另外在分析过程中,发现一个bug:当全局配置中 远程 DNS 出口 设置为 直连(remote_dns_detour='direct')时,所有出口为 "黑洞" 的分流规则(如 geosite:category-ads → blackhole)在 DNS 层不会被正确拦截。这对我造成严重影响,因为我的自建远程dns是直连的,后续我会提交PR来修复它。
Reverse-rebuilt from the 2.9 side-router authoritative deployment. Core adblock logic (from 2.9, superior to the 406b rebuild): - rule_update.lua: content-aware format detection (dnsmasq/AdGuard), AAAA blocking, source-quality gate, auto-update switch protection - helper_dnsmasq.lua: inject adblock.conf into dnsmasq 002-address.conf - app.sh: detect adblock state, pass ADBLOCK to dnsmasq - shunt_options.lua / rule.lua / rule_version.htm: adblock URL UI + update flag - po/* + docs png: i18n strings and UI preview Drops all unrelated changes swept in by the 8/30 upstream merge (DNS/proxy refactors, PKG_VERSION downgrade, parseDNS removal, etc.).
Per deployment on 2.9, the two adblock controls are split across pages: - enable_adblock (rule source dropdown, Chinese '广告过滤') now lives on the Shunt Rules tab (shunt_options.lua), reading/writing the global @global_rules[0]. - adblock_update (timed-update checkbox) stays in 规则更新页 (rule.lua). This keeps the global DNS-stage adblock switch out of the per-node scope and matches the actual UI layout shipped on the router.
Revert the adblock label/description to English source strings so the existing
po translations are reused instead of being orphaned:
- shunt_options.lua: translate("Adblock") + English description (reuses fa/ru/zh-tw
'Adblock' entries already present in the PR)
- rule_version.htm: <%:adblock%> for the manual-update checkbox (reuses the
lowercase 'adblock' po entries)
- po/zh-cn: add 'Adblock' -> 广告过滤, 'adblock' -> 广告过滤规则, and the
description, so zh-cn (the 2.9 deployment language) shows Chinese while all
four languages stay correctly translated with no orphaned entries.
…atrix) Copied from Openwrt-Passwall/openwrt-passwall2 'Auto compile with openwrt sdk.yml', genericized via github.repository / github.ref_name so it builds our fork's branch. Trigger is repository_dispatch / workflow_dispatch only (gated by version check), so pushing this file does NOT auto-fire builds.
…logs - translate the 5 new adblock i18n source strings introduced by the DNS-stage adblock feature (zh-cn newly translated; zh-tw/ru/fa updated to the new wording) - remove 5 orphaned legacy adblock msgids no longer referenced by the code (old wording superseded by the new strings)
6af5de0 to
c69bad3
Compare
Harden the rule source handling and drop fork-only files from the PR. rule_update.lua: - Add is_rule_line() and a rule-syntax ratio to the quality gate, so an HTML error page or JSON response returned with HTTP 200 is rejected instead of being mined for domain lookalikes (which produced address=/github.com/# style entries and broke unrelated sites). - Record the URL that produced adblock.conf (adblock.url) so switching the source invalidates the stale rules immediately. - Make adblock_update default to 1 consistently; the saved value still defaulted to 0 and silently turned auto update off after a manual run. helper_dnsmasq.lua: - nil-check the adblock source handle and close it. A nil handle aborted dnsmasq config generation (breaking DNS) and leaked an fd on every call. app.sh: - detect_adblock() now compares the recorded URL instead of only checking that the rule file exists, so a source switch takes effect. shunt_options.lua: - o.remove is a no-op: removing a node must not delete the global setting. rule.lua / rule_version.htm: - Adblock auto update follows the geoip/geosite pattern (hidden Flag driven by the custom checkbox in Update Options) and defaults to enabled. po/fa, po/ru: - Remove the UTF-8 BOM that invalidated the first msgid. Also remove the fork-only files (build workflow, README rewrite, preview png) and revert unrelated whitespace changes in rule_version.htm. Verified with luaparse (4/4), sh -n, and by executing the real is_rule_line() in a Lua VM against three real rule sources (100% pass) plus HTML/JSON payloads (rejected).
Public lists reach ~220k generated lines and dnsmasq keeps every entry in memory, so an oversized/malicious source could exhaust RAM on low memory devices. Bound the output to MAX_ADBLOCK_RULES (300000) and stop parsing as soon as the cap is hit instead of building the full table first. The cap sits above the largest stock list so normal sources are untouched. Also log a notice when truncation occurs and add the new msgid to the zh-cn/zh-tw/ru/fa catalogs.
Mirror helloworld's behavior: when a rule source is configured but the cached rule file was produced by a different source (or is missing), trigger a background `rule_update.lua log adblock` at startup so a source switch or first enable takes effect without a manual click. The background download records the source URL (adblock.url) and, on a real content change, sets flush_set=1 which restarts the service and reloads the rules via the existing detect_adblock() / helper_dnsmasq path. When the URL already matches and the file is present, no download is triggered, so the periodic cron remains the only updater for refresh.
What
Add a DNS-stage adblock feature to PassWall2,. A single Adblock dropdown (default: Close) in the node Shunt Options, located right below "Enable GeoIP Data Parsing". Selecting a rule source enables ad blocking at the DNS stage; both domestic and foreign ad domains are blocked by returning 0.0.0.0, which also covers the blind spot where domestic ads are directly connected at the firewall layer and never reach the core.
Interaction
luci-app-passwall2/luasrc/model/cbi/passwall2/client/include/shunt_options.lua: newListValueenable_adblock, values: Close (default, empty), NEO DEV HOST, anti-AD, AdGuard Home Filter. Custom rule source URLs are allowed (ListValue is an editable combobox).luci-app-passwall2/luasrc/view/passwall2/rule/rule_version.htm+rule.lua: add an "adblock" checkbox in the rule status page, hidden native flagadblock_update, collected by "Manually update" asupdate=geoip,geosite,adblock.luci-app-passwall2/root/usr/share/passwall2/rule_update.lua:fetch_adblock()downloads the selected rule source, writes dnsmasq-format rules directly or extracts domains (AdGuardHome format) into/usr/share/passwall2/adblock.conf.luci-app-passwall2/root/usr/share/passwall2/app.sh+helper_dnsmasq.lua:ADBLOCKis passed through toadd_rule; when enabled andadblock.confexists, its content is copied into the dnsmasq cache dir as002-address.conf(loaded via conf-dir). The cache fingerprintnew_textincludesADBLOCK+ rule file md5 so the cache is rebuilt on toggle/update.Files changed
luci-app-passwall2/luasrc/model/cbi/passwall2/client/include/shunt_options.lualuci-app-passwall2/luasrc/model/cbi/passwall2/client/rule.lualuci-app-passwall2/luasrc/view/passwall2/rule/rule_version.htmluci-app-passwall2/root/usr/share/passwall2/rule_update.lualuci-app-passwall2/root/usr/share/passwall2/app.shluci-app-passwall2/root/usr/share/passwall2/helper_dnsmasq.lualuci-app-passwall2/po/{zh-cn,zh-tw,ru,fa}/passwall2.po(translations)Notes
conf-dirinclude; no new dependencies.UI Preview
Screenshot of the adblock UI in the node Shunt Options (dropdown right below "Enable GeoIP Data Parsing") and the rule status page (adblock checkbox in Update Options):