🐶 Sync 2025-11-02 14:26:26

This commit is contained in:
actions-user
2025-11-02 14:26:26 +08:00
parent 64bcc56c2a
commit ac011db799
1557 changed files with 746465 additions and 0 deletions

69
openwrt-bandix/Makefile Normal file
View File

@@ -0,0 +1,69 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=bandix
PKG_VERSION:=0.6.1
PKG_RELEASE:=1
PKG_LICENSE:=Apache-2.0
PKG_MAINTAINER:=timsaya
include $(INCLUDE_DIR)/package.mk
# 使用OpenWrt的Rust映射机制
include $(TOPDIR)/feeds/packages/lang/rust/rust-values.mk
# 二进制文件的文件名和URL
RUST_BANDIX_VERSION:=0.6.1
RUST_BINARY_FILENAME:=bandix-$(RUST_BANDIX_VERSION)-$(RUSTC_TARGET_ARCH).tar.gz
# 修正下载地址定义方式
PKG_SOURCE:=$(RUST_BINARY_FILENAME)
PKG_SOURCE_URL:=https://github.com/timsaya/bandix/releases/download/v$(RUST_BANDIX_VERSION)
PKG_HASH:=skip
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=Network
TITLE:=Bandix - Network traffic monitoring tool
endef
define Package/$(PKG_NAME)/description
Bandix core service for network traffic monitoring
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)/bin
gzip -dc "$(DL_DIR)/$(PKG_SOURCE)" | tar -C $(PKG_BUILD_DIR)/bin --strip-components=1 -xf -
$(Build/Patch)
endef
define Build/Compile
# nothing to do
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/bandix $(1)/usr/bin/
# 添加启动脚本和配置文件
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_BIN) ./files/bandix.init $(1)/etc/init.d/bandix
$(INSTALL_CONF) ./files/bandix.config $(1)/etc/config/bandix
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
if ! grep -q "^/usr/share/bandix$$" /etc/sysupgrade.conf; then
echo "/usr/share/bandix" >> /etc/sysupgrade.conf
fi
if ! grep -q "^/etc/config/bandix$$" /etc/sysupgrade.conf; then
echo "/etc/config/bandix" >> /etc/sysupgrade.conf
fi
fi
endef
$(eval $(call BuildPackage,bandix))

View File

@@ -0,0 +1,22 @@
config bandix 'general'
option iface 'br-lan'
option port '8686'
option data_dir '/usr/share/bandix'
option language 'auto'
option theme 'auto'
config bandix 'traffic'
option enabled '0'
option speed_unit 'bytes'
option offline_timeout '600'
option traffic_retention_seconds '600'
option traffic_flush_interval_seconds '600'
option traffic_persist_history '0'
config bandix 'connections'
option enabled '0'

View File

@@ -0,0 +1,66 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG=/usr/bin/bandix
service_triggers() {
procd_add_reload_trigger "bandix"
}
reload_service() {
restart
}
start_service() {
local iface
local port
local data_dir
local traffic_enabled
local traffic_retention_seconds
local traffic_flush_interval_seconds
local traffic_persist_history
local connections_enabled
config_load 'bandix'
config_get iface 'general' 'iface'
config_get port 'general' 'port'
config_get data_dir 'general' 'data_dir'
config_get_bool traffic_enabled 'traffic' 'enabled'
config_get traffic_retention_seconds 'traffic' 'traffic_retention_seconds'
config_get traffic_flush_interval_seconds 'traffic' 'traffic_flush_interval_seconds'
config_get_bool traffic_persist_history 'traffic' 'traffic_persist_history'
config_get_bool connections_enabled 'connections' 'enabled'
[ "$connections_enabled" != 1 ] && [ "$traffic_enabled" != 1 ] && return 1
# 构建基础命令行参数
local args="--iface $iface --port $port --data-dir $data_dir"
# 添加流量监控相关参数
if [ "$traffic_enabled" -eq 1 ]; then
args="$args --enable-traffic"
fi
if [ -n "$traffic_retention_seconds" ]; then
args="$args --traffic-retention-seconds $traffic_retention_seconds"
fi
if [ -n "$traffic_flush_interval_seconds" ]; then
args="$args --traffic-flush-interval-seconds $traffic_flush_interval_seconds"
fi
if [ "$traffic_persist_history" -eq 1 ]; then
args="$args --traffic-persist-history"
fi
# 添加连接统计监控参数
if [ "$connections_enabled" -eq 1 ]; then
args="$args --enable-connection"
fi
procd_open_instance bandix
procd_set_param command $PROG $args
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
procd_set_param stderr 1
procd_set_param stdout 1
procd_set_param pidfile /var/run/bandix.pid
procd_close_instance
}