feat(luci-app-secubox-netifyd): add flow sink controls

This commit is contained in:
CyberMind-FR 2026-01-07 08:40:29 +01:00
parent ad2e89fd47
commit f701f8b20d
3 changed files with 74 additions and 1 deletions

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-secubox-netifyd
PKG_VERSION:=1.0.2
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_LICENSE:=MIT
PKG_MAINTAINER:=CyberMind <contact@cybermind.fr>
PKG_ARCH:=all
@ -20,6 +20,8 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DATA) ./README-FLOW-DATA.md $(1)/usr/share/doc/$(PKG_NAME)/
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) ./root/usr/sbin/secubox-netifyd-configure $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./root/usr/bin/netifyd-collector-setup $(1)/usr/bin/
endef
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -310,3 +310,21 @@ MIT License - Copyright (C) 2025 CyberMind.fr
- **Netify by eGloo**: Deep packet inspection engine
- **SecuBox Team**: LuCI integration and interface design
- **OpenWrt Community**: Platform and package ecosystem
## Collector Setup Script
Use `/usr/bin/netifyd-collector-setup` to enable the flow exporter and install the cron job
that runs `/usr/bin/netifyd-collector` every minute. The script accepts:
```
/usr/bin/netifyd-collector-setup [unix|tcp] [path_or_host[:port]]
```
Examples:
```
/usr/bin/netifyd-collector-setup unix /tmp/netifyd-flows.json
/usr/bin/netifyd-collector-setup tcp 127.0.0.1:9501
```
Each invocation updates `/etc/config/secubox-netifyd`, writes `/etc/netifyd.d/secubox-sink.conf`,
creates the cron entry (`* * * * * /usr/bin/netifyd-collector`), and restarts `netifyd`.

View File

@ -0,0 +1,53 @@
#!/bin/sh
set -e
# Usage: netifyd-collector-setup [unix|tcp] [path_or_host:port]
# Example:
# netifyd-collector-setup unix /tmp/netifyd-flows.json
# netifyd-collector-setup tcp 127.0.0.1:9501
SINK_MODE="${1:-unix}"
TARGET="${2:-/tmp/netifyd-flows.json}"
configure_sink() {
local mode="$1"
local target="$2"
uci set secubox-netifyd.sink.enabled=1
if [ "$mode" = "tcp" ]; then
local addr="${target%:*}"
local port="${target##*:}"
uci set secubox-netifyd.sink.type="tcp"
uci set secubox-netifyd.sink.tcp_address="$addr"
uci set secubox-netifyd.sink.tcp_port="$port"
else
uci set secubox-netifyd.sink.type="unix"
uci set secubox-netifyd.sink.unix_path="$target"
fi
uci commit secubox-netifyd
}
ensure_collector_cron() {
local entry="* * * * * /usr/bin/netifyd-collector >/dev/null 2>&1"
local existing
existing=$(crontab -l 2>/dev/null || true)
if ! printf '%s\n' "$existing" | grep -Fxq "$entry"; then
local tempfile
tempfile=$(mktemp)
printf '%s\n' "$existing" | grep -v '^$' >"$tempfile"
printf '%s\n' "$entry" >>"$tempfile"
crontab "$tempfile"
rm -f "$tempfile"
fi
}
log() {
printf '%s\n' "$*"
}
log "Configuring Netifyd flow sink ($SINK_MODE -> $TARGET)"
configure_sink "$SINK_MODE" "$TARGET"
ensure_collector_cron
/etc/init.d/netifyd restart >/dev/null 2>&1 || true
log "Collector cron enabled and netifyd restarted."