- metablogizer: Add HTTP health checks for backend (uhttpd) and frontend (HAProxy) - metablogizer: Fix BusyBox-compatible certificate expiry detection using openssl checkend - secubox-portal: Add speed test widget with ping/download/upload measurement - tor-shield: Fix settings save ensuring UCI sections exist - cdn-cache: UI improvements and restructure - streamlit: Fix port conflict (sappix now uses 8503) - secubox-core: Add proxy mode detection - security-threats: Dashboard improvements - haproxy: Init.d and Makefile updates PKG_RELEASE bumps: - luci-app-cdn-cache: 3 - luci-app-metablogizer: 2 - luci-app-secubox-portal: 2 - luci-app-secubox-security-threats: 2 - luci-app-secubox: 4 - luci-app-streamlit: 9 - luci-app-tor-shield: 2 - secubox-app-haproxy: 23 - secubox-core: 6 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
4.1 KiB
4.1 KiB
Claude Instructions for SecuBox OpenWrt
OpenWrt Shell Scripting Guidelines
Process Detection
- Use
pgrep crowdsecinstead ofpgrep -x crowdsec- The
-xflag requires an exact process name match which doesn't work reliably on OpenWrt/BusyBox - Same applies to other daemons: use
pgrep <name>without-x
- The
Command Availability
timeoutcommand is NOT available on OpenWrt by default - use alternatives or check withcommand -v timeoutsscommand may not be available - usenetstator/proc/net/tcpas fallbackssqlite3may not be installed - provide fallback methods (e.g., delete database file instead of running SQL)
JSON Parsing
- Use
jsonfilterinstead ofjq- jsonfilter is native to OpenWrt (part of libubox), jq is often not installed - Syntax examples:
# Get a field value jsonfilter -i /path/to/file.json -e '@.field_name' # Get nested field jsonfilter -i /path/to/file.json -e '@.parent.child' # Get array length (count elements) jsonfilter -i /path/to/file.json -e '@[*]' | wc -l # Get array element jsonfilter -i /path/to/file.json -e '@[0]' - Always check for empty results:
[ -z "$result" ] && result=0
Port Detection
When checking if a port is listening, use this order of fallbacks:
/proc/net/tcp(always available) - ports are in hex (e.g., 8080 = 1F90)netstat -tln(usually available)ss -tln(may not be available)
Logging
- OpenWrt uses
logreadinstead of traditional log files - Use
logread -l Nto get last N lines - CrowdSec writes to
/var/log/crowdsec.log
Build & Sync Workflow
CRITICAL: Sync Local Feed Before Building
- ALWAYS sync the local-feed before building packages from edited source trees
- The build system uses
secubox-tools/local-feed/NOTpackage/secubox/directly - If you edit files in
package/secubox/<pkg>/, those changes won't be built unless synced
Before building after edits:
# Option 1: Sync specific package to local-feed
rsync -av --delete package/secubox/<package-name>/ secubox-tools/local-feed/<package-name>/
# Option 2: Sync all SecuBox packages
for pkg in package/secubox/*/; do
name=$(basename "$pkg")
rsync -av --delete "$pkg" "secubox-tools/local-feed/$name/"
done
# Then build
./secubox-tools/local-build.sh build <package-name>
Quick deploy without rebuild (for RPCD/shell scripts):
# Copy script directly to router for testing
scp package/secubox/<pkg>/root/usr/libexec/rpcd/<script> root@192.168.255.1:/usr/libexec/rpcd/
ssh root@192.168.255.1 '/etc/init.d/rpcd restart'
Local Feeds Hygiene
- Clean and resync local feeds before build iterations when dependency drift is suspected
- Prefer the repo helpers; avoid ad-hoc
rmunless explicitly needed
Local Build Flow
- Use
./secubox-tools/local-build.sh build <module>for cached SDK builds - If CI parity is required, use
make package/<module>/compile V=s
Sync Build Artifacts
- After building, synchronize results into the build output folder used by local-build.sh
- Use the repo sync helper scripts where available to avoid missing
root/vshtdocs/payloads
Toolchain Usage
-
CRITICAL: Non-LuCI SecuBox apps MUST be built with the full OpenWrt toolchain, NOT the SDK
- Go packages (crowdsec, crowdsec-firewall-bouncer) require the full toolchain due to CGO and ARM64 compatibility
- Native C/C++ binaries (netifyd, nodogsplash) require the full toolchain
- The SDK produces binaries with LSE atomic instructions that crash on some ARM64 CPUs (like MochaBin's Cortex-A72)
-
Packages requiring full toolchain build (in
secubox-tools/openwrt):crowdsec- Go binary with CGOcrowdsec-firewall-bouncer- Go binary with CGOnetifyd- C++ native binarynodogsplash- C native binary
-
To build with full toolchain:
cd secubox-tools/openwrt make package/<package-name>/compile V=s -
LuCI apps and pure shell/Lua packages can use the SDK:
cd secubox-tools/sdk make package/<package-name>/compile V=s # Or use local-build.sh for LuCI apps -
If unsure, check
OPENWRT_ONLY_PACKAGESinsecubox-tools/local-build.sh