Skip to content

fix(adblock): resolve race condition on rapid DNS domain changes#1663

Closed
gsanchietti wants to merge 35 commits into
NethServer:mainfrom
gsanchietti:issue1572
Closed

fix(adblock): resolve race condition on rapid DNS domain changes#1663
gsanchietti wants to merge 35 commits into
NethServer:mainfrom
gsanchietti:issue1572

Conversation

@gsanchietti
Copy link
Copy Markdown
Member

Summary

Store whitelist/blacklist in UCI instead of direct file writes. When multiple rapid API calls add/edit/delete domains, changes are staged to UCI (no restart). The init.d script reads UCI during start/reload and writes physical files.

procd's reload trigger (5s debounce) coalesces rapid UCI commits into a single reload_service call. Using reload (not restart) prevents file clearing that caused 'running with 0 blocked domains' broken state.

Related issue

#1572

How to test

  1. ssh root@192.168.100.215
  2. Add multiple domains rapidly: api-cli ns.threatshield dns-add-allowed --data '{"address":"test1.com","description":""}' &
  3. Check UCI staged (should show all entries): api-cli ns.threatshield dns-list-allowed
  4. Apply from UI (or uci commit && reload_config from shell)
  5. Wait 5-6s for procd reload
  6. Verify whitelist file written and adblock status shows enabled (not broken 'running/0')

Files changed

  • ns.threatshield: dns_get_local_list() reads from UCI; dns_write_local_list() writes to UCI + save
  • adblock.init: f_write_local_lists() writes UCI lists to physical files during start/reload
  • 99_adblock_migrate_lists.sh: one-time migration of existing files to UCI (new)
  • Makefile: install migration script

@gsanchietti gsanchietti self-assigned this May 13, 2026
Tbaile and others added 6 commits May 14, 2026 15:29
Sync the local adblock fork to upstream 4.5.5-3 while keeping the
NethSecurity-specific ts-dns hooks, bypass migration, and nft bypass
rules intact.

Assisted-by: Copilot:gpt-5.4
Normalize dns bypass values from UCI and restart adblock after dns
settings, blocklist, and bypass API changes so nft rules follow the
requested state immediately.

Assisted-by: Copilot:gpt-5.4
Changes:
- add a new `nft-reload` action inside adbblock.sh
- trigger reload when the configuration has been updated
- call nft-reload on reload

The above changes will recreated the nft chain
when the bypass configuration has been changed.
Store Threat Shield DNS local allow and block list edits in UCI
so rapid API calls no longer rewrite adblock files or restart the
service immediately.

Write the physical adblock list files during the next reload, add a
one-shot migration for existing list files, and document the staged
workflow for the affected API methods.

Refs NethServer#1572
Assisted-by: Copilot:gpt-5.4
@gsanchietti
Copy link
Copy Markdown
Member Author

Closing this draft so the same issue1572 branch can be reopened against adblock-update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants