luci-app-adblock-fast: update to 1.2.2-r6#8353
luci-app-adblock-fast: update to 1.2.2-r6#8353stangri wants to merge 1 commit intoopenwrt:masterfrom
Conversation
|
|
||
| if (system(sprintf("mv %s %s", shell_quote(tmp_file), shell_quote(cron_file))) != 0) { | ||
| system(sprintf("rm -f %s", shell_quote(tmp_file))); | ||
| return false; |
There was a problem hiding this comment.
| system(sprintf("rm -f %s", shell_quote(tmp_file))); | ||
| return false; | ||
| } | ||
| system(sprintf("chmod 600 %s 2>/dev/null", shell_quote(cron_file))); |
There was a problem hiding this comment.
|
|
||
| writefile(temp_file, join('\n', out_lines) + '\n'); | ||
|
|
||
| if (system(sprintf("mv %s %s", shell_quote(temp_file), shell_quote(cron_file))) == 0) { |
There was a problem hiding this comment.
| writefile(temp_file, join('\n', out_lines) + '\n'); | ||
|
|
||
| if (system(sprintf("mv %s %s", shell_quote(temp_file), shell_quote(cron_file))) == 0) { | ||
| system(sprintf("chmod 600 %s 2>/dev/null", shell_quote(cron_file))); |
There was a problem hiding this comment.
|
|
||
| if (system(sprintf("mv %s %s", shell_quote(temp_file), shell_quote(cron_file))) == 0) { | ||
| system(sprintf("chmod 600 %s 2>/dev/null", shell_quote(cron_file))); | ||
| system('if [ -x /etc/init.d/cron ] && /etc/init.d/cron enabled >/dev/null 2>&1; then /etc/init.d/cron restart >/dev/null 2>&1; elif pidof crond >/dev/null 2>&1; then killall -HUP crond 2>/dev/null; fi'); |
There was a problem hiding this comment.
| system('if [ -x /etc/init.d/cron ] && /etc/init.d/cron enabled >/dev/null 2>&1; then /etc/init.d/cron restart >/dev/null 2>&1; elif pidof crond >/dev/null 2>&1; then killall -HUP crond 2>/dev/null; fi'); | ||
| return { result: true }; | ||
| } | ||
| system(sprintf("rm -f %s", shell_quote(temp_file))); |
There was a problem hiding this comment.
| let cmd; | ||
| switch (action) { | ||
| case 'enable': | ||
| cmd = sprintf("/etc/init.d/%s enable && uci set %s.config.enabled=1 && uci commit %s", |
There was a problem hiding this comment.
There was a problem hiding this comment.
There was a problem hiding this comment.
Just pointing out their availability - the command chaining here seems tidy enough although it generally means a performance hit to invoke the chained external calls.
| let temp_file = cron_file + '.tmp'; | ||
| let found = false, written = false; | ||
|
|
||
| system(sprintf("mkdir -p '%s'", replace(cron_file, /\/[^\/]+$/, ''))); |
There was a problem hiding this comment.
| return false; | ||
| } | ||
| system(sprintf("chmod 600 %s 2>/dev/null", shell_quote(cron_file))); | ||
| system('[ -x /etc/init.d/cron ] && /etc/init.d/cron reload >/dev/null 2>&1'); |
There was a problem hiding this comment.
There was a problem hiding this comment.
Seems like the cron actions can be outsourced to a function, gate them behind necessary checks like an lstat to check for the +x bit, here.
| let mday = uci_ctx.get(packageName, 'config', 'auto_update_monthday') || '1'; | ||
| let ndays = uci_ctx.get(packageName, 'config', 'auto_update_every_ndays') || '3'; | ||
| let nhours = uci_ctx.get(packageName, 'config', 'auto_update_every_nhours') || '6'; | ||
|
|
There was a problem hiding this comment.
Maybe just a single https://ucode.mein.io/module-uci.cursor.html#get_all and pick the various properties after.
There was a problem hiding this comment.
var sets globally so you might have variable bleed. let should be fine.
8abcff3 to
06bbf6b
Compare
|
@systemcrash appreciate the prompt review, your suggestions and linter errors will be addressed shortly. |
06bbf6b to
7b0ee69
Compare
| } | ||
|
|
||
| function uci_has_changes(config) { | ||
| return trim(cmd_output(sprintf("uci changes '%s' 2>/dev/null", config))) != ''; |
There was a problem hiding this comment.
Forgot to mention changes is also available in code.
7b0ee69 to
dddffb4
Compare
Update luci-app-adblock-fast from 1.2.1-r3 to 1.2.2-r6. This rewrites the rpcd backend from a 519-line shell script to a 452-line native ucode module, adds two new RPC methods for cron management, reorganizes the web UI with a dedicated scheduling tab and a collapsible service details section, moves schedule persistence from UCI to crontab, and adds the AGPL-3.0-or-later LICENSE file. Signed-off-by: Stan Grishin <stangri@melmac.ca> --- - **8 files changed**, +1,765 / -851 lines (net +914) - **1 commit**: `a18c61a` — `luci-app-adblock-fast: update to 1.2.2-r6` --- - `+rpcd-mod-ucode` — Native ucode rpcd module loader - `+jsonfilter` — No longer needed; ucode handles JSON natively - Version bumped from `1.2.1-r3` to `1.2.2-r6` - URL updated from `github.com/stangri/...` to `github.com/mossdef-org/...` --- The rpcd script moves from: ``` /usr/libexec/rpcd/luci.adblock-fast (519 lines, shell) ``` to: ``` /usr/share/rpcd/ucode/luci.adblock-fast (452 lines, ucode) ``` | Aspect | Old (Shell) | New (ucode) | |-----------------|-------------------------|--------------------| | Language | POSIX `/bin/sh` | ucode bytecode | | JSON handling | `json_init/add/dump` | Native objects | | UCI access | `config_load/get` subpr | `cursor()` API | | ubus access | `jsonfilter` pipelines | `connect()` API | | Business logic | Duplicated in script | Imports shared lib | | Method decl | `case` switch block | Declarative schema | | Performance | Fork/exec per operation | In-process calls | The new script imports the shared business logic module directly: ```javascript import adb from '/lib/adblock-fast/adblock-fast.uc'; ``` Query methods (`getInitStatus`, `getPlatformSupport`, `getFileUrlFilesizes`, etc.) now delegate to the shared `adb` library rather than re-implementing the logic. **Retained (7 methods, same interface):** | Method | Type | Purpose | |-----------------------|--------|--------------------| | `getFileUrlFilesizes` | Query | URL sizes from cfg | | `getInitList` | Query | Enabled/running | | `getInitStatus` | Query | Full service state | | `getPlatformSupport` | Query | Resolver/tool info | | `setInitAction` | Action | Start/stop/enable | | `getCronStatus` | Query | Cron diagnostics | | `syncCron` | Action | Update cron sched | **Added (2 new methods):** | Method | Type | Purpose | |----------------|--------|----------------------| | `getCronEntry` | Query | Get raw cron line | | `setCronEntry` | Action | Set/replace cron line| The cron subsystem now tracks three entry states: - **`active`** — Enabled and scheduled - **`suspended`** — Disabled but recoverable - **`disabled`** — Fully off `getCronStatus` returns new diagnostic fields: - `cron_line_multi` — Multiple entries detected - `cron_line_parse_ok` — Expression validity - `cron_line_state` — One of: `active`, `suspended`, `disabled`, `multi`, `unsupported`, `missing` - `entry` — Raw matched cron line Bumped from **11** to **13**, reflecting the new methods and enhanced `getCronStatus` response shape. Two new methods added to the rpcd ACL file (`luci-app-adblock-fast.json`): - `getCronEntry` (read section) - `setCronEntry` (write section) --- **LuciCompat** bumped from `11` to `13`. **Data fetching refactored:** - Removed separate `getServiceInfo()` ubus call - `initStatus` response now provides all data (package compat, errors, warnings) in one call - `ubus` object built from `initData` properties instead of separate service instance query **New "Service Details" section:** - Blocking stats, DNS backend info, compressed cache status, force-DNS ports, and donation link moved from inline status text to a separate collapsible `detailsDiv` - Main status area now shows only the essential state label and cache info when stopped **Cron warning logic rewritten:** - Warnings only displayed when service is both enabled and running - New `warningCronEntryMismatch` warning for suspended or unparseable cron entries - Suggests "Resync Cron" action when `cronSyncNeeded` is detected - Pre-existing checks for missing/disabled cron daemon preserved but now gated behind `showCronWarnings` flag **Cron sync flow rewritten:** 1. Fetches current entry via `getCronEntry()` 2. Strips comment markers and suspended/disabled tags from the entry 3. Writes cleaned entry via `setCronEntry()` 4. Reloads page only on success **New exports:** `getCronEntry`, `setCronEntry` **New helper: `parseCronEntry(cronEntry)`** - Parses raw cron line into form field values - Detects schedule mode from cron pattern: - `every_n_hours` — `*/N * * * *` - `every_n_days` — `M H */N * *` - `monthly` — `M H D * *` - `weekly` — `M H * * D` - `daily` — `M H * * *` (default) - Returns config object with: `auto_update_enabled`, `auto_update_mode`, `auto_update_hour`, `auto_update_minute`, `auto_update_weekday`, `auto_update_monthday`, `auto_update_every_ndays`, `auto_update_every_nhours` - Falls back to defaults for unparseable entries **New helper: `generateCronEntry(config)`** - Inverse of `parseCronEntry` - Converts form config object back to cron syntax - Returns empty string when auto-update disabled - Output format: `M H DOM * DOW /etc/init.d/adblock-fast dl` `# adblock-fast-auto` **Data loading consolidated:** - Removed separate `getFileUrlFilesizes()` and `getPlatformSupport()` calls - Now fetches `getInitStatus()` + `getCronStatus()` - Sizes and platform data extracted from the unified `initStatus` response **New "List Updates Schedule" tab:** - All scheduling options moved from `tab_advanced` to dedicated `tab_schedule` - Options: `auto_update_enabled`, `auto_update_mode`, `auto_update_every_ndays`, `auto_update_every_nhours`, `auto_update_weekday`, `auto_update_monthday`, `auto_update_hour`, `auto_update_minute` - Each option's `cfgvalue()` overridden to read from parsed cron config instead of UCI - `config_update_enabled` remains on `tab_advanced` **Schedule persistence moved to crontab:** - Old: scheduling fields saved to UCI config, then `syncCron` called after `uci-applied` event to generate cron entry from config - New: `handleSave()` collects form values, calls `generateCronEntry()`, writes directly via `setCronEntry()`, then removes scheduling fields from UCI before saving remaining config - Result: schedule lives in crontab, survives config resets **`handleSaveApply` simplified:** - Old: chained `handleSave` → listener for `uci-applied` → `syncCron` → page reload - New: `handleSave()` → `ui.changes.apply()` - Cron already updated during save, no separate sync step needed **Instance handling fix:** - `dnsmasq_instance` and `smartdns_instance` write overrides now wrap values in arrays - Ensures instances stored as UCI lists, not scalar strings --- **2 new strings added:** - `"List Updates Schedule"` — New tab header - `"Service Details"` — New status section header **0 strings removed, 0 strings reworded.** All other changes are source line number updates from the JavaScript refactoring. Existing translations remain valid; translators only need to handle the 2 new entries. --- Adds the full AGPL-3.0-or-later license text (661 lines), matching the `PKG_LICENSE` field already declared in the Makefile. --- - `rpcdCompat` bumped from `11` to `13` - `LuciCompat` bumped from `11` to `13` - Requires `rpcd-mod-ucode` (replaces `jsonfilter`) - Requires companion `adblock-fast` package >=1.2.2 (for the shared `/lib/adblock-fast/adblock-fast.uc` library imported by the rpcd ucode module) - All existing RPC methods preserved; 2 new ones added - All existing UI functionality preserved; scheduling options reorganized into dedicated tab Signed-off-by: Stan Grishin <stangri@melmac.ca>
dddffb4 to
6a56df9
Compare
Maintainer: me
Compile tested: x86_64, Dell EMC Edge620, OpenWrt 25.12.0-rc4
Run tested: x86_64, Dell EMC Edge620, OpenWrt 25.12.0-rc4
Description:
Update luci-app-adblock-fast from 1.2.1-r3 to 1.2.2-r6. This rewrites the rpcd backend from a 519-line shell script to a 452-line native ucode module, adds two new RPC methods for cron management, reorganizes the web UI with a dedicated scheduling tab and a collapsible service details section, moves schedule persistence from UCI to crontab, and adds the AGPL-3.0-or-later LICENSE file.
a18c61a—luci-app-adblock-fast: update to 1.2.2-r6+rpcd-mod-ucode— Native ucode rpcd module loader+jsonfilter— No longer needed; ucode handles JSON nativelyVersion bumped from
1.2.1-r3to1.2.2-r6URL updated from
github.com/stangri/...togithub.com/mossdef-org/...The rpcd script moves from:
to:
/bin/shjson_init/add/dumpconfig_load/getsubprcursor()APIjsonfilterpipelinesconnect()APIcaseswitch blockThe new script imports the shared business logic module directly:
Query methods (
getInitStatus,getPlatformSupport,getFileUrlFilesizes, etc.) now delegate to the sharedadblibrary rather than re-implementing the logic.Retained (7 methods, same interface):
getFileUrlFilesizesgetInitListgetInitStatusgetPlatformSupportsetInitActiongetCronStatussyncCronAdded (2 new methods):
getCronEntrysetCronEntryThe cron subsystem now tracks three entry states:
active— Enabled and scheduledsuspended— Disabled but recoverabledisabled— Fully offgetCronStatusreturns new diagnostic fields:cron_line_multi— Multiple entries detectedcron_line_parse_ok— Expression validitycron_line_state— One of:active,suspended,disabled,multi,unsupported,missingentry— Raw matched cron lineBumped from 11 to 13, reflecting the new
methods and enhanced
getCronStatusresponse shape.Two new methods added to the rpcd ACL file
(
luci-app-adblock-fast.json):getCronEntry(read section)setCronEntry(write section)LuciCompat bumped from
11to13.Data fetching refactored:
getServiceInfo()ubus callinitStatusresponse now provides all data (package compat, errors, warnings) in one callubusobject built frominitDataproperties instead of separate service instance queryNew "Service Details" section:
detailsDivCron warning logic rewritten:
warningCronEntryMismatchwarning for suspended or unparseable cron entriescronSyncNeededis detectedshowCronWarningsflagCron sync flow rewritten:
getCronEntry()setCronEntry()New exports:
getCronEntry,setCronEntryNew helper:
parseCronEntry(cronEntry)every_n_hours—*/N * * * *every_n_days—M H */N * *monthly—M H D * *weekly—M H * * Ddaily—M H * * *(default)auto_update_enabled,auto_update_mode,auto_update_hour,auto_update_minute,auto_update_weekday,auto_update_monthday,auto_update_every_ndays,auto_update_every_nhoursNew helper:
generateCronEntry(config)parseCronEntryM H DOM * DOW /etc/init.d/adblock-fast dl# adblock-fast-autoData loading consolidated:
getFileUrlFilesizes()andgetPlatformSupport()callsgetInitStatus()+getCronStatus()initStatusresponseNew "List Updates Schedule" tab:
tab_advancedto dedicatedtab_scheduleauto_update_enabled,auto_update_mode,auto_update_every_ndays,auto_update_every_nhours,auto_update_weekday,auto_update_monthday,auto_update_hour,auto_update_minutecfgvalue()overridden to read from parsed cron config instead of UCIconfig_update_enabledremains ontab_advancedSchedule persistence moved to crontab:
syncCroncalled afteruci-appliedevent to generate cron entry from confighandleSave()collects form values, callsgenerateCronEntry(), writes directly viasetCronEntry(), then removes scheduling fields from UCI before saving remaining confighandleSaveApplysimplified:handleSave→ listener foruci-applied→syncCron→ page reloadhandleSave()→ui.changes.apply()Instance handling fix:
dnsmasq_instanceandsmartdns_instancewrite overrides now wrap values in arrays2 new strings added:
"List Updates Schedule"— New tab header"Service Details"— New status section header0 strings removed, 0 strings reworded.
All other changes are source line number updates
from the JavaScript refactoring. Existing
translations remain valid; translators only need
to handle the 2 new entries.
Adds the full AGPL-3.0-or-later license text
(661 lines), matching the
PKG_LICENSEfieldalready declared in the Makefile.
rpcdCompatbumped from11to13LuciCompatbumped from11to13rpcd-mod-ucode(replacesjsonfilter)adblock-fastpackage >=1.2.2 (for the shared/lib/adblock-fast/adblock-fast.uclibrary imported by the rpcd ucode module)