update 2026-10-27 02:06:14

This commit is contained in:
action committed 2026-10-27 02:06:14 +08:00
1 parent 8de6b6ed73
commit 197c60d843
716 files changed
+1093 -461399

No files matched your search

@@ -225,6 +225,48 @@ delete_device() {
echo "$response"
}
# Batch deletion receives a JSON-encoded MAC array, matching the string RPC
# parameters used by other structured requests in this plugin.
delete_devices() {
local macs="$1" type keys count=0 key mac validated="" payload response http_code
[ "${#macs}" -le 65536 ] || { make_error "Too many MAC addresses"; return; }
json_init
json_load "{\"macs\":$macs}" 2>/dev/null || { make_error "Invalid MAC array"; return; }
json_get_type type macs
[ "$type" = array ] || { make_error "Invalid MAC array"; return; }
json_select macs
json_get_keys keys
for key in $keys; do
count=$((count + 1))
[ "$count" -le 1000 ] || { make_error "macs must contain between 1 and 1000 MAC addresses"; return; }
json_get_type type "$key"
[ "$type" = string ] || { make_error "Invalid MAC address"; return; }
json_get_var mac "$key"
case "$mac" in
[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]) ;;
*) make_error "Invalid MAC address"; return ;;
esac
validated="$validated $mac"
done
[ "$count" -gt 0 ] || { make_error "macs must contain between 1 and 1000 MAC addresses"; return; }
json_init
json_add_array macs
for mac in $validated; do json_add_string "" "$mac"; done
json_close_array
payload=$(json_dump)
json_cleanup
response=$(curl -s --connect-timeout 3 --max-time 15 -w '\n%{http_code}' -X DELETE -H 'Content-Type: application/json' --data-binary "$payload" "$BANDIX_DEVICES_API/batch" 2>/dev/null)
if [ $? -ne 0 ] || [ -z "$response" ]; then
make_error "Failed to connect to Bandix service"
return
fi
http_code=$(printf '%s\n' "$response" | tail -n 1)
case "$http_code" in
404|405) make_error "Batch deletion is unavailable. Update the Bandix service." ;;
*) printf '%s\n' "$response" | sed '$d' ;;
esac
}
# 获取设备状态
# GET /api/traffic/devices -> $.data
# {
@@ -236,6 +278,7 @@ delete_device() {
# conn, # 接入类型 (wifi/wired/router)
# uplink, # 接入接口名 (eth1/lan2/phy0-ap0),无则空串
# w_ch, # WiFi 频道号 (1/36/149),非 WiFi 为 0
# w_freq, # WiFi 主信道频率 (MHz),不可用时为 0
# last, # 最后在线时间戳(ms)
# t_rx_b, t_tx_b, # 总下/上行字节
# t_rx_r, t_tx_r, # 总下/上行速率
@@ -1356,6 +1399,9 @@ case "$1" in
json_add_object "deleteDevice"
json_add_string "mac"
json_close_object
json_add_object "deleteDevices"
json_add_string "macs"
json_close_object
json_add_object "getGeoipStatus"
json_close_object
@@ -1579,6 +1625,13 @@ case "$1" in
fi
delete_device "$mac"
;;
deleteDevices)
input=""
read -r input
macs="$(printf '%s' "$input" | jsonfilter -e '$.macs' 2>/dev/null)"
[ -z "$macs" ] && macs="$(printf '%s' "$input" | jsonfilter -e '$[0]' 2>/dev/null)"
delete_devices "$macs"
;;
getGeoipStatus)
get_geoip_status
;;