fix(adblock): resolve race condition on rapid DNS domain changes#1663
Draft
gsanchietti wants to merge 1 commit into
Draft
fix(adblock): resolve race condition on rapid DNS domain changes#1663gsanchietti wants to merge 1 commit into
gsanchietti wants to merge 1 commit into
Conversation
Store whitelist/blacklist in UCI instead of direct file writes. When multiple rapid API calls add/edit/delete domains, the API now only stages changes to UCI (no restart). The init.d script calls f_write_local_lists() during start_service() and reload_service() to write files from UCI. procd's existing reload trigger (PROCD_RELOAD_DELAY=5s) debounces rapid UCI commits into a single reload_service call. The reload action (not restart) prevents f_rmdns (file clearing) that was causing "running with 0 blocked domains" broken state during concurrent restarts. Changes: - ns.threatshield: dns_get_local_list() reads from UCI; dns_write_local_list() writes to UCI + save (no commit/restart) - adblock.init: f_write_local_lists() writes UCI lists to physical files during service start/reload - 99_adblock_migrate_lists.sh: one-time migration of existing files to UCI - Makefile: install migration script to /etc/uci-defaults/ Closes NethServer#1572 Assisted-by: Copilot:claude-haiku-4.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ssh root@192.168.100.215api-cli ns.threatshield dns-add-allowed --data '{"address":"test1.com","description":""}' &api-cli ns.threatshield dns-list-alloweduci commit && reload_configfrom shell)Files changed