Commit Graph

55 Commits

Author SHA1 Message Date
Stan Grishin f64dd10a41 adblock-fast: update to 1.2.2-18
* Switch Hagezi URL to a more compact higher-level only domains list as we
  prefer it anyways and there's less processing (thanks @dave14305)
* When update_config_sizes is unset, save collected sizes to RAM to improve
  luci app performance (thanks @sshaikh)

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2026-04-24 18:27:12 -07:00
Stan Grishin e958e3f213 adblock-fast: update to 1.2.2-r16
* add: ucode-mod-uloop dependency
* add: parallel downloads using uloop
* fix: explicit allow for domains from allow-lists
* fix: get environment information for getInitStatus RPCD call
* add: update tests

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2026-03-28 13:36:54 -07:00
Stan Grishin 20155a7165 adblock-fast: update to 1.2.2-r14
* fix: ensure output in CLI in status and quick start commands
* fix: ensure relevant directories exist when using a (gzip) cache file on
  first boot
* add: update functional tests

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2026-03-25 14:10:07 -07:00
Stan Grishin cb9813125e adblock-fast: update to 1.2.2-r12
Config:
* update pause_timeout default value to 60
* add config option rpcd_token

Init script:
* add validation for rpcd_token

Ucode script:
* fix: always reload config options on RPCD calls to prevent stale values
* fix: shell_quote curl params
* fix: do not reload is_tty on each call

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2026-03-19 11:44:32 -07:00
Stan Grishin 6799f6bf9b adblock-fast: update to 1.2.2-r10
* bugfix: always print errors/warnings on non-quiet start
* bugfix: return proper enabled status in RPCD
* bugfix: return stupped status in RPCD when procd data is empty
* bugfix: correctly process verbosity=0
* delete LICENSE file and only keep it upstream

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2026-03-08 10:29:44 -07:00
Stan Grishin 4c4f8c303e adblock-fast: update to 1.2.2-r8
* bugfix: support TMP and final block-list destination on different
  partitions
* update pause-related code/defaults/validation

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2026-03-04 12:22:17 -08:00
Stan Grishin d06ee022b5 adblock-fast: update to 1.2.2-r6
Update adblock-fast from 1.2.1-r7 to 1.2.2-r6. This is a major
architectural rewrite that ports the core business logic from a ~2,700-line
monolithic shell script (`/etc/init.d/adblock-fast`) to a ~2,850-line ucode
module (`/lib/adblock-fast/adblock-fast.uc`), reducing the init script to a
thin ~130-line procd wrapper. The rewrite also introduces a comprehensive
test suite and adds the AGPL-3.0-or-later LICENSE file.

---

- **36 files changed**, +5,787 / -2,836 lines (net +2,951)
- **1 commit**: `0263b2b` — `adblock-fast: update to 1.2.2-r6`

---

The previous implementation embedded all business logic (download pipeline,
domain processing, resolver configuration, status reporting, caching)
inside the init.d script as a ~2,700-line POSIX shell script. This made the
code difficult to test, maintain, and extend. Shell limitations (no native
data structures, reliance on subshell `eval`, global namespace pollution)
also introduced fragility and performance overhead from repeated subprocess
spawning for UCI/ubus operations.

```
/etc/init.d/adblock-fast          (131 lines) — Thin procd wrapper
/lib/adblock-fast/adblock-fast.uc (2849 lines) — Core logic (ucode)
/lib/adblock-fast/cli.uc          (95 lines)  — CLI action dispatcher
```

The init script now delegates all operations to the ucode module via:
```sh
readonly _ucode="ucode -S -L /lib/${packageName} /lib/${packageName}/cli.uc --"
```

The CLI dispatcher (`cli.uc`) maps init script actions (start, stop,
status, allow, check, pause, etc.) to the module's exported functions.
The init script retains only procd lifecycle glue (`start_service`,
`stop_service`, `service_triggers`, `service_data`) and UCI validation
schemas.

1. **Native UCI/ubus bindings** — Direct `cursor()` and `connect()` calls
   replace subprocess-heavy `uci get/set` and `jsonfilter` pipelines
2. **Proper data structures** — Objects and arrays for config, status
   tracking, DNS mode definitions; no more string-concatenation state
   management
3. **Streaming I/O** — 64KB chunked file reads for blocklist processing
   instead of loading entire files into memory via pipes
4. **Memoized environment detection** — Platform capabilities (installed
   resolvers, ipset/nftset support, downloader detection) cached on first
   call
5. **Centralized trigger logic** — Config diff comparison
   (`adb_config_cache()`) determines download/restart/skip in one place
6. **Testable** — Module exports enable direct unit testing without mocking
   an entire init system

---

- `+ucode` — ucode interpreter runtime
- `+ucode-mod-fs` — Filesystem operations (readfile, writefile, popen,
  stat, etc.)
- `+ucode-mod-uci` — Native UCI cursor API
- `+ucode-mod-ubus` — Native ubus RPC API

- `+jshn` — No longer needed (was used for JSON parsing in shell)

- URL updated from `github.com/stangri/adblock-fast/` to
  `github.com/mossdef-org/adblock-fast/`
- Install target now installs `/lib/adblock-fast/adblock-fast.uc` and
  `/lib/adblock-fast/cli.uc` alongside the init script
- Version stamp now patches the ucode module
  (`version:` field) instead of init script (`PKG_VERSION` variable)
- `postinst` script removed (service enable handled elsewhere)
- `prerm` script simplified: only purges cache, no longer
  stops service or removes rc.d symlinks (handled by procd)

---

The module supports all existing DNS resolver integrations through a
unified `dns_modes{}` configuration map. Each mode defines output file
paths, gzip cache names, sed format/parse filters, and grep patterns:

| Mode                 | Output Format                                    |
|----------------------|--------------------------------------------------|
| `dnsmasq.addnhosts`  | `127.0.0.1 domain` (+ `:: domain` with IPv6)    |
| `dnsmasq.conf`       | `local=/domain/`                                 |
| `dnsmasq.ipset`      | `ipset=/domain/adb`                              |
| `dnsmasq.nftset`     | `nftset=/domain/4#inet#fw4#adb4[,6#...]`         |
| `dnsmasq.servers`    | `server=/domain/` (block) / `server=/domain/#` (allow) |
| `smartdns.domainset` | Raw domain (with smartdns conf wrapper)          |
| `smartdns.ipset`     | Raw domain (with smartdns ipset conf)            |
| `smartdns.nftset`    | Raw domain (with smartdns nftset conf)           |
| `unbound.adb_list`   | `local-zone: "domain." always_nxdomain`          |

The download pipeline auto-detects blocklist format from content:

| Format       | Detection                           | Example                    |
|--------------|-------------------------------------|----------------------------|
| AdBlock Plus | `[Adblock Plus]` header / `^||`     | `\|\|example.com^`         |
| dnsmasq      | `^server=`                          | `server=/example.com/`     |
| dnsmasq2     | `^local=`                           | `local=/example.com/`      |
| dnsmasq3     | `^address=`                         | `address=/example.com/0.0.0.0` |
| hosts        | `^0.0.0.0\s` or `^127.0.0.1\s`     | `0.0.0.0 example.com`     |
| domains      | (fallback — plain domain list)      | `example.com`              |

```
For each file_url UCI section:
  → Download URL (curl with retries, timeout, optional max-file-size)
  → Auto-detect format → Apply format-specific sed filter → Extract domains
  → Append to accumulator (blocked or allowed)

Merge phase:
  → sort -u (deduplicate)
  → Subdomain optimization (awk label-reverse → sort → dedup → reverse)
  → Remove allowed domains (sed -f generated_script)
  → Inject canary domains (iCloud Private Relay, Mozilla DoH)
  → Inject manually blocked_domain entries from config
  → Format for target DNS resolver
  → Optional validity check (remove malformed entries)
  → Atomic rename to output file

Resolver phase:
  → Update resolver config (UCI: addnhosts, conf-dir, server files)
  → Sanity check (dnsmasq --test)
  → Restart resolver service
  → Heartbeat probe (resolve canary domain to verify blocking)
  → Revert on failure
```

| Function              | Purpose                                              |
|-----------------------|------------------------------------------------------|
| `start(args)`         | Main lifecycle: download, restore from cache, or restart |
| `stop()`              | Disable blocking, flush kernel state, cleanup        |
| `status_service()`    | Report status to syslog/ubus                         |
| `allow(domain)`       | Whitelist domain in live blocklist + UCI config       |
| `check(pattern)`      | Search current blocklist for domain                  |
| `check_tld()`         | Detect TLD entries (sanity check)                    |
| `check_leading_dot()` | Detect leading-dot errors                            |
| `check_lists(domain)` | Search upstream list URLs for domain                 |
| `dl()`                | Force re-download all lists                          |
| `killcache()`         | Purge all cached files                               |
| `pause(seconds)`      | Temporarily disable blocking                         |
| `show_blocklist()`    | Output parsed blocklist to stdout                    |
| `sizes()`             | Fetch/display configured blocklist file sizes        |
| `get_init_status()`   | Full service state for UI/RPC clients                |
| `get_init_list()`     | Enabled/disabled status                              |
| `get_platform_support()` | Detect installed resolvers and features           |
| `get_file_url_filesizes()` | Return cached/live URL metadata                |

- 40+ localized message codes (e.g., `errorDownloadingList`,
  `errorConfigValidationFail`, `warningSanityCheckTLD`)
- Errors/warnings accumulated in `status_data{}` arrays
- Synced atomically to ubus service data for UI consumption
- Status states: `statusSuccess`, `statusFail`, `statusDownloading`,
  `statusProcessing`, `statusRestarting`, `statusPaused`

---

The init script (`/etc/init.d/adblock-fast`) is reduced from ~2,700 to ~130
lines. It now serves exclusively as a procd service wrapper:

- **procd lifecycle**: `start_service()` calls ucode `start`, captures
  shell output for `service_data()`; `stop_service()` calls ucode `stop`
- **Service triggers**: WAN interface triggers, config change triggers, UCI
  validation (unchanged from previous version)
- **Extra commands**: `allow`, `check`, `check_tld`, `check_leading_dot`,
  `check_lists`, `dl`, `killcache`, `pause`, `show_blocklist`, `sizes`,
  `version` — all delegate directly to ucode CLI dispatcher
- **procd data bridge**: `emit_procd_shell()` in ucode generates shell
  statements that the init script `eval`s for `service_data()` and
  `service_stopped()`/`service_started()` hooks (firewall restart flag)

---

The `90-adblock-fast` uci-defaults script is simplified from 181 to 65
lines:

- **Removed**: Entire `simple-adblock` migration path (config, cache files,
  URL lists). This migration was for the initial transition from
  simple-adblock to adblock-fast and is no longer needed.
- **Retained**: List name migration (adds `name` option to `file_url`
  sections that lack one, using pristine default config as reference),
  config key renames (`debug` → `debug_init_script`, `proc_debug` →
  `debug_performance`, `sanity_check` → `dnsmasq_sanity_check`)
- **Simplified**: Uses direct `uci` commands instead of sourcing the init
  script for `uci_get`/`uci_set` helpers. Pristine config lookup now
  supports both apk (`.apk-new`) and opkg (`-opkg`) package manager
  conventions.

---

A full test suite is added in `net/adblock-fast/tests/` (16 new files,
~1,800 lines) mock-and-expect pattern.

- **Module patching**: Converts ES6 imports to CommonJS requires, redirects
  hardcoded system paths to temp directories for isolation
- **Resolver stubs**: Mock binaries for dnsmasq (v2.89), smartdns, unbound,
  ipset, nft, resolveip
- **Test case format**: Markup-based (`-- Testcase --`,
  `-- Environment --`, `-- Expect stdout --`, `-- File path --`) with
  support for inline test data and per-test environment overrides
- **Assertion model**: Compares stdout, stderr, and exit code against
  expected values using `diff -u`
- **Shell validation**: Syntax-checks init.d and uci-defaults scripts via
  `sh -n`
- **Automatic cleanup**: Trap-based temp directory removal

**UCI Mock** (`tests/lib/mocklib/uci.uc`):
- Full `cursor()` interface: `load`, `get`, `get_all`, `foreach`, `set`,
  `delete`, `list_add`, `list_remove`, `commit`, `changes`
- Loads JSON fixtures from `tests/mocks/uci/` (adblock-fast, dhcp, network,
  smartdns, unbound configs)
- Supports `@type[index]` extended section addressing

**ubus Mock** (`tests/lib/mocklib/ubus.uc`):
- `connect()` → `call(object, method, args)` with signature-based fixture
  lookup
- Fixtures in `tests/mocks/ubus/` (system info, network interface
  dump/status, dnsmasq service list)

**System Call Interception** (`tests/lib/mocklib.uc`):
- Blocks service operations: `/etc/init.d/*`, `logger`, `sleep`,
  `dnsmasq --test`
- Passes through data processing: `sed`, `sort`, `grep`, `awk`
- Fixed timestamp (`1615382640`) for reproducible output
- Null `getenv()` for environment isolation

**01_pipeline** — Data processing pipeline (9 tests):
1. `01_all_dns_modes` — Verifies all 9 DNS output modes produce valid,
   deduplicated output (~162-165 domains from 2 input lists)
2. `02_input_format_detection` — Validates auto-detection of domains,
   hosts, AdBlock Plus, and dnsmasq input formats
3. `03_subdomain_dedup` — Confirms parent domains retained, child
   subdomains removed (e.g., blocks `example.com`, skips `sub.example.com`)
4. `04_allowed_domains` — Verifies `allowed_domain` config removes domains
   from output while preserving others
5. `05_canary_domains` — Confirms iCloud Private Relay and Mozilla DoH
   canary domain injection when enabled
6. `06_servers_mode_allow` — Validates dnsmasq.servers mode prepends
   explicit allow entries (`server=/domain/#` format)
7. `07_ipv6_addnhosts` — Verifies dual-stack output (both `127.0.0.1` and
   `::` entries) in addnhosts mode with IPv6 enabled
8. `08_ipv6_nftset` — Confirms nftset mode includes IPv6 set references
   (`4#inet#fw4#adb4,6#inet#fw4#adb6`) when IPv6 enabled
9. `09_unbound_header` — Validates `server:` header line prepended in
   unbound output mode

**02_config** — Configuration handling (1 test):
1. `01_blocked_domain_injection` — Verifies `blocked_domain` config entries
   appear in output

**03_functional** — CLI command tests (2 tests):
1. `01_check_domain` — Tests `check()` correctly identifies blocked vs.
   unblocked domains with appropriate output messages
2. `02_show_blocklist` — Tests `show_blocklist()` outputs parsed domain
   list (162 domains, correct format)

5 curated test data files with ~160+ unique test domains across multiple
formats (plain domains, hosts, AdBlock Plus, dnsmasq), including:
- Valid tracking/ad domains for positive matching
- Overlapping domains across files for deduplication testing
- Parent/child domain pairs for subdomain optimization testing
- Invalid entries (IPs, malformed, special chars) for filter robustness
- Mock UCI/ubus fixtures simulating a standard OpenWrt environment
  (512MB RAM, WAN interface up, dnsmasq running)

---

Adds the full AGPL-3.0-or-later license text (661 lines), matching the
`PKG_LICENSE` field already declared in the Makefile.

---

- Package compat bumped from `11` to `13` (in the ucode module's
  `pkg.compat` constant), reflecting the architectural change
- All existing UCI configuration options preserved (same validation schema)
- All existing extra_commands preserved (same CLI interface)
- All existing DNS resolver modes preserved (same output formats)
- procd service triggers and config triggers unchanged
- `simple-adblock` migration path removed from uci-defaults (obsolete)

---

```sh
cd net/adblock-fast/tests && sh run_tests.sh
```

Requires: `ucode`, `ucode-mod-fs`, `ucode-mod-uci`, `ucode-mod-ubus`,
`sed`, `sort`, `grep`, `awk` (standard OpenWrt buildroot tools).

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2026-02-26 17:00:05 -08:00
Stan Grishin 7fd0a6e15c adblock-fast: update to 1.2.1-r7
* switch from nslookup to resolveip and add dependencey
* fix/use new OutputFormatFilter names for all resolvers

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2026-02-04 20:04:15 -08:00
Stan Grishin e1f891ca9f adblock-fast: update to 1.2.1-3
* add an option dnsmasq_validity_check to enable removal of invalid
  domains from the final dnsmasq files
* renamed option sanity_check to dnsmasq_sanity_check
* better names for Format Filters and Parse Filters variables

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2026-01-29 10:36:22 -08:00
Stan Grishin e367c1d739 adblock-fast: update to 1.2.0-26
Makefile:
* nicer DEPENDS

Init Script:
* ensure resolver config is reverted and resolver is restarted on
  service fail

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2026-01-05 11:03:07 -08:00
Stan Grishin cb37034add adblock-fast: bugfixes
* bugfix: remove IPKG_INSTROOT check
* bugfix: do not attempt to download config update if package is disabled

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-10-10 17:41:35 -07:00
Stan Grishin 3b9bbcf40a adblock-fast: update to 1.2.0-r20
Config file:
* add debug_init_script and debug_performance options
* remove led (default should be empty) option
* remove procd_boot_delay (obsolete) option

Init Script:
* reinstate IPKG_INSTROOT check
* change capitalization in status messages
* unset default value for led option on load_package_config
* bugfix: unset bool options which are later checked for non-empty
* bugfix: create compressed cache only if block-file exists
* adjust errors output/storing errors for later display in multuple cases
* produce information about cache/compressed cache files in service
  status output when service is stopped
* attempt to create compressed cache in service_started only if block-
  file exists
* bugfix: run service_started from the dl command (to create compressed
  cache file)
* rename StripToDomains variables for readability
* improve open port detection

Uci-Defaults:
* improve readability of debug options migration

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-10-08 12:09:55 -07:00
Stan Grishin 17ca12ae5a adblock-fast: update to 1.2.0
Makefile:
* update version/release
Init Script:
* boot up reliability improvements:
  - change START from 50 to 20 to ensure procd_add_raw_trigger works on boot
  - better logic of checking/using the cache/compressed cache on boot
* new dnsmasq handling/integration logic:
  - new logic for checking dnsmasq functionality (similar to dnsmasq init script)
  - instead of copying/duplicating adblock-fast files per specified dnsmasq instance, create one file
    and add softlinks to it for specified dnsmasq instances and make sure it's in the instance's addnmounts
  - update dnsmasqConfFile, dnsmasqIpsetFile and dnsmasqNftsetFile to point to the same filename as the
    logic for integrating with dnsmasq is the same for those options
  - get the confdir for specified dnsmasq instances via ubus info/config file since the config_get is broken
    between releases by https://github.com/openwrt/openwrt/pull/14975
  - update clean-up procedures for other dns backend settings to properly clean up when switching away from
    dnsmasq.conf, dnsmasq.ipset, dnsmasq.nftset where the new logic is used
  - remove obsolete outputDnsmasqFileList variable and logic of building and using it
  - only create compressed cache in service_started after successful resolver restart with the block-file
* new package config / environment loading logic
  - switch away from using `load_validate_config` to start functions to loading package config "manually"
  - unset boolean variables which are non-true on package config load
  - switch checking values of such variables from `-eq 0` to empty/non-empty
* debugging improvements:
  - rename debug option to debug_init_script and proc_debug to debug_performance
  - output performance debug info to log only when debug_performance is set
* miscellaneous changes:
  - move best dl tool detection into its own function for reuse in adb_config_update
  - change uci_changes function to return 0/1 instead of the text of changes
  - improve mktemp calls reliability by creating the file and not using `-u` anymore
  - add remove_cache/remove_gzip calls to adb_file function
  - better readability of the start_serice logic determining the action
  - change flock value from 207 to 209 to avoid collisions with pbr
  - temporarily switch namespaces when using jshn functions to avoid collisions with PROCD
  - move from using spaces to tabs in indentation in code
  - prevent Command Not Found message on uninstall
  - remove unneeded IPKG_INSTROOT check in the init script
  - update all sourcing instructions to include IPKG_INSTROOT in the path
Uci-defaults script:
* transition old debug and proc_debug options to debug_init_script/debug_performance

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-09-28 11:37:23 -07:00
Stan Grishin 02644ad1e4 adblock-fast: bugfix: dl command
* only test gzip existence and reset action/param on boot

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-09-17 15:06:08 -07:00
Stan Grishin 9022d3f53f adblock-fast: update to 1.1.4-r12
README:
* update header

Init-script:
* set an earlier start to get triggers to work
* better str_contains
* improve readability of json() by getting rid of cascading case statements
* add new errors/status messages to get_text()
* prepare get_text() for localization by switching to inline printf
* adjust shellcheck disable comments where needed
* parse unbound config for DNS hijack ports
* test if the archived cache exists on boot and proceed to use it if it does
* add trigger waiting status so that luci app can display correct status
* do not run adb_config_update on boot, speeding up trigger setup

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-08-27 17:33:30 -07:00
Stan Grishin b8fa681098 adblock-fast: bugfixes: status & TLD check with unbound
fixes: https://github.com/openwrt/packages/issues/27146
supercedes: https://github.com/openwrt/packages/pull/27159

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-08-05 09:16:33 -07:00
Stan Grishin a94c5fac4b adblock-fast: update to 1.1.4-4
Makefile:
  - bugfix: change references to melmac.net to melmac.ca

README:
  - add basic README with the link to full documentation

Config:
  - add heartbeat_domain
  - add heartbeat_sleep_timeout
  - add sanity_check
  - add update_config_sizes

Init Script:
  - a lot of visual output improvements, especially with verbosity=2
  - better output separation for different verbosity levels
  - removed unneeded runningErrorFile
  - bugfix: updated runningConfigFile
  - updated runningStatusFile and added runningStatusFileLock
  - moved append_url() higher up for better visibility
  - refactor force-redownload/restart on some config changes functionality
  - improve count_blocked_domains
  - add internal debug_log() for debugging functions where output is captured
  - unified all json add/get calls in the same formatting
  - major rework on json() to allow storing of error/warning messages as json objects
  - added some error/warning messages
  - renamed `cache()` function to `adb_file()` to better reflect functionality
  - added functionality to test the dnsmasq config before restarting dnsmasq with ad-blocking
  - added functionality to throw warnings if TLDs or leading-dot domains are discovered
    in the final block-list file (can be disabled by `sanity_check` option)
  - added functionality to test DNS resolution after resolver restart with `heartbeat_domain`
    for `heartbeat_sleep_timeout` seconds
  - added functionality to revert the resolver's config/ad-blocking if heartbeat domain cannot
    be resolved after resolver restart
  - added `ALLOWED_TMP` variable/file for better processing of external allow-lists
  - added debug output to log with the elapsed time for each step of processing
  - drastically improved final block-list optimization with the new awk script
  - minor other performance improvements
  - added check_tld/check_leading_dot CLI commands to show domains breaking sanity checks
  - added validate functions to triggers

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-08-01 13:31:40 -05:00
Stan Grishin 73821b26e5 adblock-fast: update to 1.1.3-13
* update to SPDX license identified in Makefile
* bugfix: correct HELP line description for sizes command (thanks @justops1337)
* performance fix: updated domains filter (thanks @justops1337)
* bugfix/improvement: more reliable get_url_filesize code with fall-back to
  uclient-fetch (thanks @justops1337)

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-06-02 20:56:47 -07:00
Nikolay Manev 34c02108ce adblock-fast: improve the processing of combined list
Signed-off-by: Nikolay Manev <just.ops@proton.me>

adblock-fast: modify gawk statement

Signed-off-by: Nikolay Manev <just.ops@proton.me>
2025-05-13 09:42:43 -07:00
Nikolay Manev 3d9eb08f8e adblock-fast: Fixed non-printable characters and bump PKG_VERSION
Signed-off-by: Nikolay Manev <just.ops@proton.me>
2025-05-11 10:04:26 -07:00
Stan Grishin 71f596840b adblock-fast: bugfixes: empty allow-lists, support for swap
* do not produce an error on empty allow-lists, fixes https://github.com/openwrt/packages/issues/26228
* do not produce an error when swap is available, fixes https://github.com/openwrt/packages/issues/26313

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-04-15 21:35:58 -07:00
Stan Grishin f19bf22b3c adblock-fast: bugfix: detect_file_type()
* Properly detect domain lists, fixes https://github.com/openwrt/packages/issues/25973
  Thanks @timfeierabend
* Better output when setting triggers
* No wait for ubus network.interface on boot

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-03-01 09:57:10 -08:00
Stan Grishin 2e764368cc adblock-fast: bugfixes: boot-up, StevenBlack list, new CERT.pl source
* bugfix: more robust boot-up start
* bugfix: processing of StevenBlack lists
* new remote block-list: CERT.pl

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-01-29 11:07:14 -08:00
Stan Grishin 92a37ebdf1 adblock-fast: Makefile bugfixes and hijack rework
* remove indentation in postinst/prerm/postrm scripts to fix issues with APK
* rework hijack logic to redirect port 53 to the port of active/selected dnsmasq instances

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2025-01-04 12:12:19 -08:00
Stan Grishin beebdba29e adblock-fast: bugfix: dnsmasq instances confdir hack
* temporary hack until https://github.com/openwrt/openwrt/pull/16806 is merged

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-12-06 17:50:38 -08:00
Stan Grishin 87edf8cb19 adblock-fast: bugfixes
* properly process dnsmasq instances' confdirs
* working str_replace()
* updated output()
* bugfixes and updates for error messages
* sanitize StevenBlack's hosts file

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-11-23 10:05:14 -08:00
Stan Grishin 0cb1b9d12e adblock-fast: update to 1.1.2-10
* bump compat version to accommodate new strings
* improve the output() function (thanks @bigsmile74)
* implement support for user-configurable per-instance dnsmasq confdirs
  for dnsmasq.conf|dnsmasq.ipset|dnsmasq.nftset options

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-11-01 17:46:58 -07:00
Stan Grishin d1e8694625 adblock-fast: bugfix: fix allowed domains for dnsmasq.servers
Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-10-28 17:11:47 -07:00
Stan Grishin 02ab49c33f adblock-fast: explicitly allowing domains for dnsmasq.servers
New features:
* explicitly add allowed domains on download/allow to the dnsmasq.servers
  config file

Cleanup:
* remove unneeded EXTRA_COMMANDS
* remove unneeded EXTRA_HELP
* remove unnecessary `\n` escapes
* remove unnecessary line breaks from output on download

Optimization:
* simplify is_integer()
* replace long if with case
* more verbose output on download

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-10-24 09:29:23 -07:00
Stan Grishin 4d3155d1ed adblock-fast: bugfixes and shellcheck update
* BUGFIX: correctly identify available RAM
* BUGFIX: properly store remote list filesize in config
* shellcheck updates

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-09-20 13:22:14 -07:00
Stan Grishin 50e85ed27f adblock-fast: update to 1.1.2-3
This version brings two significant updates:
* support for text labels/names for the external lists
* better processing of the config update files, which cleans up
  entries with missing URLs

Also:
* new config file contains names for all lists
* it tries to match existing URLs with the names from the new config file
  and update user config as part of uci-defaults script
* contains minor updates to copyright/license/upstream URL/README
* updates the config update script to remove sysctl.org list as it's outdated
* adds two new remote lists: Hagezi and 1Hosts

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-08-03 23:26:26 +00:00
Stan Grishin fb151d5b82 adblock-fast: update to 1.1.2-1
* move extra_command and EXTRA_HELP to the top of the init file
* add packageCompat variable for compatibility check with WebUI
* add OutputFilter variables for supported resolvers
* simplify adb_check with the use of OutputFilter variables
* add show_blocklist command to display currently blocked domains

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-05-13 04:33:42 +00:00
Stan Grishin 474587a1f4 adblock-fast: bugfix: unbound-related fixes
* include `server:` directive at the top of unbound file
* update unbound-related outputGzip variable to include full path
* return always_nxdomain for blocked domains
* also update copyright stamp/license

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-04-21 14:06:58 +00:00
Stan Grishin 9eb61fe02d adblock-fast: improve Makefile's prerm
* improve output of Makefile's prerm routines

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-04-10 23:57:03 +00:00
Stan Grishin 706592edcc adblock-fast: prepare migration to APK
Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-03-23 01:02:05 +00:00
Stan Grishin eafdd63d67 adblock-fast: add force_dns_interface setting
* allow users to specify list of interfaces/networks to force the
  DNS Hijacking on

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-02-14 04:41:10 +00:00
Stan Grishin 0f059b6523 adblock-fast: update to 1.1.1-3
* allow top-level domains in the blocked-domains options fixes
  https://github.com/openwrt/packages/issues/23125

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-01-19 00:05:18 +00:00
Stan Grishin dfeeabbebf adblock-fast: bugfix: pause command
* the pause command used to incorrectly cause block-lists reload, this
  has been fixed in this version

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2024-01-07 23:07:42 +00:00
Stan Grishin bab17f480c adblock-fast: update to 1.1.1-1
* move reload/restart logic from json() to config_cache()
* improve fw4 restart decision logic
* no longer store reload/restart info in ubus/status json file
* rename variables pointing to run-time information
* create dns_set_output_values to reuse code in principal all and luci app
* improve append_url to store collected URLs in an alternative variable

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-12-15 02:42:13 +00:00
Stan Grishin 693287e961 adblock-fast: better allow-listing
* improve allow-listing reliability by running sed from the script-file
  instead of the command-line
* fix user for smartdns files ownership

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-12-11 00:55:46 +00:00
Stan Grishin 1914114ed3 adblock-fast: bugfix: block domains from config when not using block-lists
* remove empty lines from the combined list to allo optimization code
  to work properly

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-12-10 02:50:03 +00:00
Stan Grishin 496d9b71ab adblock-fast: bugfixes: getsize/resolver
* do not use standalone grep-package dependent syntax to get the remote
  file size
* various bugfixes to prevent attempts to change/commit if dnsmasq/smartdns
  are not installed

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-12-08 02:41:53 +00:00
Stan Grishin 28cd5ecf6e adblock-fast: add smartdns ipset/nftset support
* bugfix: correct URL to config-update file
* bugfix: check if uci configs exist before chacking for changes
* add support for smartdns ipset-based blocking
* add support for smartfns nftset-based blocking
* disallow non-ascii symbols for smartdns blocking
* add check wherever fw4 restart is needed before calling
  procd_set_config_changed firewall
* improve clean-up code in resolver()
* improve case code for different resolver settings
* modify load_validate_config to allow smartdns.ipset and smartdns.nftset

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-12-06 10:22:18 +00:00
Stan Grishin 575af322b5 adblock-fast: add support for smartdns
* add support for smartdns
* switch from using `uci` commands to `uci_` functions
* rename `_resolver_config` to `_dnsmasq_instance_config`
* introduce `_smartdns_instance_config`
* improve resolvers restart code on changes
* update load_validate_config to allow for smartdns option

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-12-05 08:16:35 +00:00
Stan Grishin ffb396bca9 adblock-fast: bugfix: call to missing function
* fix call to is_number to is_integer
* improve boot()

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-11-25 20:54:17 +00:00
Stan Grishin 96ad0ab6fd adblock-fast: bufgix: fix boot()
* fix boot()
* reintroduce procd_boot_delay variable to control delay of service
  start on boot
* introduce `check_lists` command to check enabled block-lists for
  domain(s)
* use config_get_bool instead of config_get for boolean options

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-11-23 22:44:52 +00:00
Stan Grishin 3787b41355 adblock-fast: bugfix: ensure downloaded block-lists end with newline
* ensure downloaded block-lists end with newline
* turn free/total RAM checks into functions calls

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-11-13 10:08:54 +00:00
Stan Grishin 11df396a18 adblock-fast: update to 1.0.1-1
* update Makefile copyright info
* organize functions shared between the init script, uci-defaults and
  luci app in alphabetical order
* update error, warning and status messaging
* use single quotes instead double quotes for static text labels
* better warning for missing recommended packages
* rename dns function to resolver to better reflect its purpose
* improve resolver cleanup code
* move _resolver_config function inside resolver function to improve code readlibity
* rename _process_file_url to process_file_url_wrapper to better reflect its purpose
* add preflight check for available RAM vs total size of block lists
* move _config_add_url_size function inside adb_sizes function to improve code readlibity
* remove uci validation from status_service function to improve performance
* source init script from uci-defaults to include shared functions

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-11-08 09:57:32 +00:00
Stan Grishin 42cc50eec8 adblock-fast: bugfix: allow command
* fix sed to properly purge allowed domains from block-lists
* ensure resolver is restarted on allow command
* reduce pause default/max in attempt to make it work with luci

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-10-21 02:27:54 +00:00
Stan Grishin 13a88d0b79 adblock-fast: bugfix: properly identify hosts-files
* escape dots in grep command to properly identify hosts files

Signed-off-by: Stan Grishin <stangri@melmac.ca>
2023-10-05 14:52:28 +00:00