🍕 Sync 2025-11-10 00:09:51
This commit is contained in:
@@ -10,7 +10,7 @@ LUCI_DEPENDS:=+luci-base +luci-lib-jsonc +curl +bandix
|
||||
|
||||
PKG_MAINTAINER:=timsaya
|
||||
|
||||
PKG_VERSION:=0.6.3
|
||||
PKG_VERSION:=0.8.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
1524
luci-app-bandix/htdocs/luci-static/resources/view/bandix/dns.js
Normal file
1524
luci-app-bandix/htdocs/luci-static/resources/view/bandix/dns.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,12 +10,15 @@ const translations = {
|
||||
'基本设置': '基本设置',
|
||||
'流量监控设置': '流量监控设置',
|
||||
'连接监控设置': '连接监控设置',
|
||||
'DNS监控设置': 'DNS监控设置',
|
||||
'Bandix 基本配置': 'Bandix 基本配置',
|
||||
'配置 Bandix 服务的基本参数': '配置 Bandix 服务的基本参数',
|
||||
'Bandix 流量监控配置': 'Bandix 流量监控配置',
|
||||
'配置流量监控相关参数': '配置流量监控相关参数',
|
||||
'Bandix 连接监控配置': 'Bandix 连接监控配置',
|
||||
'配置连接监控相关参数': '配置连接监控相关参数',
|
||||
'Bandix DNS监控配置': 'Bandix DNS监控配置',
|
||||
'配置DNS监控相关参数': '配置DNS监控相关参数',
|
||||
'启用': '启用',
|
||||
'启用 Bandix 流量监控服务': '启用 Bandix 流量监控服务',
|
||||
'启用流量监控': '启用流量监控',
|
||||
@@ -56,6 +59,9 @@ const translations = {
|
||||
'数据目录': '数据目录',
|
||||
'Bandix 数据存储目录': 'Bandix 数据存储目录',
|
||||
'启用 Bandix 连接监控功能': '启用 Bandix 连接监控功能',
|
||||
'启用 Bandix DNS监控功能': '启用 Bandix DNS监控功能',
|
||||
'DNS最大记录数': 'DNS最大记录数',
|
||||
'设置DNS查询记录的最大保存数量': '设置DNS查询记录的最大保存数量,超过此数量将删除最旧的记录',
|
||||
'持久化历史数据': '持久化历史数据',
|
||||
'启用数据持久化功能': '启用数据持久化功能,只有启用此选项后才会持久化到磁盘'
|
||||
},
|
||||
@@ -63,12 +69,15 @@ const translations = {
|
||||
'基本设置': '基本設置',
|
||||
'流量监控设置': '流量監控設置',
|
||||
'连接监控设置': '連接監控設置',
|
||||
'DNS监控设置': 'DNS監控設置',
|
||||
'Bandix 基本配置': 'Bandix 基本配置',
|
||||
'配置 Bandix 服务的基本参数': '配置 Bandix 服務的基本參數',
|
||||
'Bandix 流量监控配置': 'Bandix 流量監控配置',
|
||||
'配置流量监控相关参数': '配置流量監控相關參數',
|
||||
'Bandix 连接监控配置': 'Bandix 連接監控配置',
|
||||
'配置连接监控相关参数': '配置連接監控相關參數',
|
||||
'Bandix DNS监控配置': 'Bandix DNS監控配置',
|
||||
'配置DNS监控相关参数': '配置DNS監控相關參數',
|
||||
'启用': '啟用',
|
||||
'启用 Bandix 流量监控服务': '啟用 Bandix 流量監控服務',
|
||||
'启用流量监控': '啟用流量監控',
|
||||
@@ -109,6 +118,9 @@ const translations = {
|
||||
'数据目录': '數據目錄',
|
||||
'Bandix 数据存储目录': 'Bandix 數據存儲目錄',
|
||||
'启用 Bandix 连接监控功能': '啟用 Bandix 連接監控功能',
|
||||
'启用 Bandix DNS监控功能': '啟用 Bandix DNS監控功能',
|
||||
'DNS最大记录数': 'DNS最大記錄數',
|
||||
'设置DNS查询记录的最大保存数量': '設定DNS查詢記錄的最大保存數量,超過此數量將刪除最舊的記錄',
|
||||
'持久化历史数据': '持久化歷史數據',
|
||||
'启用数据持久化功能': '啟用數據持久化功能,只有啟用此選項後才會持久化到磁碟'
|
||||
},
|
||||
@@ -116,16 +128,20 @@ const translations = {
|
||||
'基本设置': 'Basic Settings',
|
||||
'流量监控设置': 'Traffic Monitor Settings',
|
||||
'连接监控设置': 'Connection Monitor Settings',
|
||||
'DNS监控设置': 'DNS Monitor Settings',
|
||||
'Bandix 基本配置': 'Bandix Basic Configuration',
|
||||
'配置 Bandix 服务的基本参数': 'Configure basic parameters for Bandix service',
|
||||
'Bandix 流量监控配置': 'Bandix Traffic Monitor Configuration',
|
||||
'配置流量监控相关参数': 'Configure traffic monitoring related parameters',
|
||||
'Bandix 连接监控配置': 'Bandix Connection Monitor Configuration',
|
||||
'配置连接监控相关参数': 'Configure connection monitoring related parameters',
|
||||
'Bandix DNS监控配置': 'Bandix DNS Monitor Configuration',
|
||||
'配置DNS监控相关参数': 'Configure DNS monitoring related parameters',
|
||||
'启用': 'Enable',
|
||||
'启用 Bandix 流量监控服务': 'Enable Bandix Traffic Monitor Service',
|
||||
'启用流量监控': 'Enable Traffic Monitoring',
|
||||
'启用连接监控': 'Enable Connection Monitoring',
|
||||
'启用DNS监控': 'Enable DNS Monitoring',
|
||||
'界面语言': 'Interface Language',
|
||||
'选择 Bandix 流量监控的显示语言': 'Select the display language for Bandix Traffic Monitor',
|
||||
'简体中文': 'Simplified Chinese',
|
||||
@@ -162,6 +178,9 @@ const translations = {
|
||||
'数据目录': 'Data Directory',
|
||||
'Bandix 数据存储目录': 'Bandix data storage directory',
|
||||
'启用 Bandix 连接监控功能': 'Enable Bandix connection monitoring',
|
||||
'启用 Bandix DNS监控功能': 'Enable Bandix DNS monitoring',
|
||||
'DNS最大记录数': 'DNS Max Records',
|
||||
'设置DNS查询记录的最大保存数量': 'Set the maximum number of DNS query records to keep. Older records will be deleted when this limit is exceeded',
|
||||
'持久化历史数据': 'Persist History Data',
|
||||
'启用数据持久化功能': 'Enable data persistence functionality, data will only be persisted to disk when this option is enabled'
|
||||
},
|
||||
@@ -169,16 +188,20 @@ const translations = {
|
||||
'基本设置': 'Paramètres de Base',
|
||||
'流量监控设置': 'Paramètres de Surveillance du Trafic',
|
||||
'连接监控设置': 'Paramètres de Surveillance des Connexions',
|
||||
'DNS监控设置': 'Paramètres de Surveillance DNS',
|
||||
'Bandix 基本配置': 'Configuration de Base Bandix',
|
||||
'配置 Bandix 服务的基本参数': 'Configurer les paramètres de base du service Bandix',
|
||||
'Bandix 流量监控配置': 'Configuration de Surveillance du Trafic Bandix',
|
||||
'配置流量监控相关参数': 'Configurer les paramètres liés à la surveillance du trafic',
|
||||
'Bandix 连接监控配置': 'Configuration de Surveillance des Connexions Bandix',
|
||||
'配置连接监控相关参数': 'Configurer les paramètres liés à la surveillance des connexions',
|
||||
'Bandix DNS监控配置': 'Configuration de Surveillance DNS Bandix',
|
||||
'配置DNS监控相关参数': 'Configurer les paramètres liés à la surveillance DNS',
|
||||
'启用': 'Activer',
|
||||
'启用 Bandix 流量监控服务': 'Activer le Service de Surveillance du Trafic Bandix',
|
||||
'启用流量监控': 'Activer la Surveillance du Trafic',
|
||||
'启用连接监控': 'Activer la Surveillance des Connexions',
|
||||
'启用DNS监控': 'Activer la Surveillance DNS',
|
||||
'界面语言': 'Langue de l\'Interface',
|
||||
'选择 Bandix 流量监控的显示语言': 'Sélectionner la langue d\'affichage pour le Moniteur de Trafic Bandix',
|
||||
'简体中文': 'Chinois Simplifié',
|
||||
@@ -215,6 +238,9 @@ const translations = {
|
||||
'数据目录': 'Répertoire de Données',
|
||||
'Bandix 数据存储目录': 'Répertoire de stockage de données Bandix',
|
||||
'启用 Bandix 连接监控功能': 'Activer la surveillance des connexions Bandix',
|
||||
'启用 Bandix DNS监控功能': 'Activer la surveillance DNS Bandix',
|
||||
'DNS最大记录数': 'Nombre Maximum d\'Enregistrements DNS',
|
||||
'设置DNS查询记录的最大保存数量': 'Définir le nombre maximum d\'enregistrements de requêtes DNS à conserver. Les enregistrements plus anciens seront supprimés lorsque cette limite est dépassée',
|
||||
'持久化历史数据': 'Persister les Données Historiques',
|
||||
'启用数据持久化功能': 'Activer la fonctionnalité de persistance des données, les données ne seront persistées sur le disque que lorsque cette option est activée'
|
||||
},
|
||||
@@ -222,16 +248,20 @@ const translations = {
|
||||
'基本设置': '基本設定',
|
||||
'流量监控设置': 'トラフィック監視設定',
|
||||
'连接监控设置': '接続監視設定',
|
||||
'DNS监控设置': 'DNS監視設定',
|
||||
'Bandix 基本配置': 'Bandix 基本設定',
|
||||
'配置 Bandix 服务的基本参数': 'Bandix サービスの基本パラメータを設定',
|
||||
'Bandix 流量监控配置': 'Bandix トラフィック監視設定',
|
||||
'配置流量监控相关参数': 'トラフィック監視関連パラメータを設定',
|
||||
'Bandix 连接监控配置': 'Bandix 接続監視設定',
|
||||
'配置连接监控相关参数': '接続監視関連パラメータを設定',
|
||||
'Bandix DNS监控配置': 'Bandix DNS監視設定',
|
||||
'配置DNS监控相关参数': 'DNS監視関連パラメータを設定',
|
||||
'启用': '有効',
|
||||
'启用 Bandix 流量监控服务': 'Bandix トラフィックモニターサービスを有効にする',
|
||||
'启用流量监控': 'トラフィック監視を有効にする',
|
||||
'启用连接监控': '接続監視を有効にする',
|
||||
'启用DNS监控': 'DNS監視を有効にする',
|
||||
'界面语言': 'インターフェース言語',
|
||||
'选择 Bandix 流量监控的显示语言': 'Bandix トラフィックモニターの表示言語を選択',
|
||||
'简体中文': '簡体字中国語',
|
||||
@@ -268,6 +298,9 @@ const translations = {
|
||||
'数据目录': 'データディレクトリ',
|
||||
'Bandix 数据存储目录': 'Bandix データ保存ディレクトリ',
|
||||
'启用 Bandix 连接监控功能': 'Bandix 接続監視機能を有効にする',
|
||||
'启用 Bandix DNS监控功能': 'Bandix DNS監視機能を有効にする',
|
||||
'DNS最大记录数': 'DNS最大記録数',
|
||||
'设置DNS查询记录的最大保存数量': 'DNSクエリ記録の最大保存数を設定。この数を超えると、最も古い記録が削除されます',
|
||||
'持久化历史数据': '履歴データの永続化',
|
||||
'启用数据持久化功能': 'データ永続化機能を有効にする。このオプションが有効な場合のみ、データがディスクに永続化されます'
|
||||
},
|
||||
@@ -275,16 +308,20 @@ const translations = {
|
||||
'基本设置': 'Основные Настройки',
|
||||
'流量监控设置': 'Настройки Мониторинга Трафика',
|
||||
'连接监控设置': 'Настройки Мониторинга Соединений',
|
||||
'DNS监控设置': 'Настройки Мониторинга DNS',
|
||||
'Bandix 基本配置': 'Базовая Конфигурация Bandix',
|
||||
'配置 Bandix 服务的基本参数': 'Настроить основные параметры службы Bandix',
|
||||
'Bandix 流量监控配置': 'Конфигурация Мониторинга Трафика Bandix',
|
||||
'配置流量监控相关参数': 'Настроить параметры, связанные с мониторингом трафика',
|
||||
'Bandix 连接监控配置': 'Конфигурация Мониторинга Соединений Bandix',
|
||||
'配置连接监控相关参数': 'Настроить параметры, связанные с мониторингом соединений',
|
||||
'Bandix DNS监控配置': 'Конфигурация Мониторинга DNS Bandix',
|
||||
'配置DNS监控相关参数': 'Настроить параметры, связанные с мониторингом DNS',
|
||||
'启用': 'Включить',
|
||||
'启用 Bandix 流量监控服务': 'Включить Службу Мониторинга Трафика Bandix',
|
||||
'启用流量监控': 'Включить Мониторинг Трафика',
|
||||
'启用连接监控': 'Включить Мониторинг Соединений',
|
||||
'启用DNS监控': 'Включить Мониторинг DNS',
|
||||
'界面语言': 'Язык Интерфейса',
|
||||
'选择 Bandix 流量监控的显示语言': 'Выберите язык отображения для Монитора Трафика Bandix',
|
||||
'简体中文': 'Упрощенный Китайский',
|
||||
@@ -321,6 +358,9 @@ const translations = {
|
||||
'数据目录': 'Каталог Данных',
|
||||
'Bandix 数据存储目录': 'Каталог хранения данных Bandix',
|
||||
'启用 Bandix 连接监控功能': 'Включить мониторинг соединений Bandix',
|
||||
'启用 Bandix DNS监控功能': 'Включить мониторинг DNS Bandix',
|
||||
'DNS最大记录数': 'Максимальное Количество Записей DNS',
|
||||
'设置DNS查询记录的最大保存数量': 'Установить максимальное количество записей DNS-запросов для хранения. Более старые записи будут удалены при превышении этого лимита',
|
||||
'持久化历史数据': 'Персистентность Исторических Данных',
|
||||
'启用数据持久化功能': 'Включить функциональность персистентности данных, данные будут сохраняться на диск только при включении этой опции'
|
||||
}
|
||||
@@ -408,6 +448,9 @@ return view.extend({
|
||||
if (!uci.get('bandix', 'connections')) {
|
||||
uci.add('bandix', 'connections', 'connections');
|
||||
}
|
||||
if (!uci.get('bandix', 'dns')) {
|
||||
uci.add('bandix', 'dns', 'dns');
|
||||
}
|
||||
|
||||
var language = uci.get('bandix', 'general', 'language');
|
||||
if (!language || language === 'auto') {
|
||||
@@ -676,6 +719,24 @@ return view.extend({
|
||||
o.default = '0';
|
||||
o.rmempty = false;
|
||||
|
||||
// 4. DNS监控设置部分 (dns)
|
||||
s = m.section(form.NamedSection, 'dns', 'dns', getTranslation('DNS监控设置', language));
|
||||
s.description = getTranslation('配置DNS监控相关参数', language);
|
||||
s.addremove = false;
|
||||
|
||||
o = s.option(form.Flag, 'enabled', getTranslation('启用DNS监控', language),
|
||||
getTranslation('启用 Bandix DNS监控功能', language));
|
||||
o.default = '0';
|
||||
o.rmempty = false;
|
||||
|
||||
// 添加DNS最大记录数选项
|
||||
o = s.option(form.Value, 'dns_max_records', getTranslation('DNS最大记录数', language),
|
||||
getTranslation('设置DNS查询记录的最大保存数量', language));
|
||||
o.datatype = 'uinteger';
|
||||
o.placeholder = '10000';
|
||||
o.default = '10000';
|
||||
o.rmempty = false;
|
||||
|
||||
return m.render();
|
||||
}
|
||||
});
|
||||
@@ -10,6 +10,8 @@ readonly BANDIX_DEVICES_API="$BANDIX_API_BASE/api/traffic/devices"
|
||||
readonly BANDIX_LIMITS_API="$BANDIX_API_BASE/api/traffic/limits"
|
||||
readonly BANDIX_METRICS_API="$BANDIX_API_BASE/api/traffic/metrics"
|
||||
readonly BANDIX_CONNECTION_API="$BANDIX_API_BASE/api/connection/devices"
|
||||
readonly BANDIX_DNS_QUERIES_API="$BANDIX_API_BASE/api/dns/queries"
|
||||
readonly BANDIX_DNS_STATS_API="$BANDIX_API_BASE/api/dns/stats"
|
||||
|
||||
# 通用函数:创建简单的JSON响应
|
||||
make_value() {
|
||||
@@ -223,6 +225,72 @@ get_connection_devices() {
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
# 获取 DNS 查询记录
|
||||
get_dns_queries() {
|
||||
# 检查 DNS 监控是否启用
|
||||
local dns_enabled=$(uci get bandix.dns.enabled 2>/dev/null)
|
||||
if [ "$dns_enabled" != "1" ]; then
|
||||
make_error "DNS monitoring is not enabled"
|
||||
return
|
||||
fi
|
||||
|
||||
# 构建查询参数
|
||||
local query_params=""
|
||||
local domain="$1"
|
||||
local device="$2"
|
||||
local is_query="$3"
|
||||
local dns_server="$4"
|
||||
local page="$5"
|
||||
local page_size="$6"
|
||||
|
||||
[ -n "$domain" ] && query_params="${query_params}domain=$(printf '%s' "$domain" | sed 's/ /%20/g')&"
|
||||
[ -n "$device" ] && query_params="${query_params}device=$(printf '%s' "$device" | sed 's/ /%20/g')&"
|
||||
[ -n "$is_query" ] && query_params="${query_params}is_query=$is_query&"
|
||||
[ -n "$dns_server" ] && query_params="${query_params}dns_server=$(printf '%s' "$dns_server" | sed 's/ /%20/g')&"
|
||||
[ -n "$page" ] && query_params="${query_params}page=$page&"
|
||||
[ -n "$page_size" ] && query_params="${query_params}page_size=$page_size&"
|
||||
|
||||
# 移除末尾的 &
|
||||
query_params=$(echo "$query_params" | sed 's/&$//')
|
||||
|
||||
local url="$BANDIX_DNS_QUERIES_API"
|
||||
[ -n "$query_params" ] && url="${url}?${query_params}"
|
||||
|
||||
# 从 Bandix API 获取 DNS 查询数据
|
||||
local response=$(curl -s --connect-timeout 2 --max-time 10 -X GET "$url" 2>/dev/null)
|
||||
|
||||
# 检查API调用是否成功
|
||||
if [ $? -ne 0 ] || [ -z "$response" ]; then
|
||||
make_error "Failed to connect to Bandix service"
|
||||
return
|
||||
fi
|
||||
|
||||
# 直接返回API结果
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
# 获取 DNS 统计信息
|
||||
get_dns_stats() {
|
||||
# 检查 DNS 监控是否启用
|
||||
local dns_enabled=$(uci get bandix.dns.enabled 2>/dev/null)
|
||||
if [ "$dns_enabled" != "1" ]; then
|
||||
make_error "DNS monitoring is not enabled"
|
||||
return
|
||||
fi
|
||||
|
||||
# 从 Bandix API 获取 DNS 统计数据
|
||||
local response=$(curl -s --connect-timeout 2 --max-time 10 -X GET "$BANDIX_DNS_STATS_API" 2>/dev/null)
|
||||
|
||||
# 检查API调用是否成功
|
||||
if [ $? -ne 0 ] || [ -z "$response" ]; then
|
||||
make_error "Failed to connect to Bandix service"
|
||||
return
|
||||
fi
|
||||
|
||||
# 直接返回API结果
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
list)
|
||||
json_init
|
||||
@@ -247,6 +315,18 @@ case "$1" in
|
||||
json_add_object "getConnection"
|
||||
json_close_object
|
||||
|
||||
json_add_object "getDnsQueries"
|
||||
json_add_string "domain"
|
||||
json_add_string "device"
|
||||
json_add_string "is_query"
|
||||
json_add_string "dns_server"
|
||||
json_add_int "page"
|
||||
json_add_int "page_size"
|
||||
json_close_object
|
||||
|
||||
json_add_object "getDnsStats"
|
||||
json_close_object
|
||||
|
||||
json_dump
|
||||
json_cleanup
|
||||
;;
|
||||
@@ -351,6 +431,40 @@ case "$1" in
|
||||
# logger "luci.bandix: getConnection called"
|
||||
get_connection_devices
|
||||
;;
|
||||
getDnsQueries)
|
||||
# logger "luci.bandix: getDnsQueries called"
|
||||
# 从 stdin 读取 JSON 参数
|
||||
read input
|
||||
|
||||
if [ -n "$input" ]; then
|
||||
# 解析参数
|
||||
domain=$(echo "$input" | jsonfilter -e '$[0]' 2>/dev/null)
|
||||
[ -z "$domain" ] && domain=$(echo "$input" | jsonfilter -e '$.domain' 2>/dev/null)
|
||||
|
||||
device=$(echo "$input" | jsonfilter -e '$[1]' 2>/dev/null)
|
||||
[ -z "$device" ] && device=$(echo "$input" | jsonfilter -e '$.device' 2>/dev/null)
|
||||
|
||||
is_query=$(echo "$input" | jsonfilter -e '$[2]' 2>/dev/null)
|
||||
[ -z "$is_query" ] && is_query=$(echo "$input" | jsonfilter -e '$.is_query' 2>/dev/null)
|
||||
|
||||
dns_server=$(echo "$input" | jsonfilter -e '$[3]' 2>/dev/null)
|
||||
[ -z "$dns_server" ] && dns_server=$(echo "$input" | jsonfilter -e '$.dns_server' 2>/dev/null)
|
||||
|
||||
page=$(echo "$input" | jsonfilter -e '$[4]' 2>/dev/null)
|
||||
[ -z "$page" ] && page=$(echo "$input" | jsonfilter -e '$.page' 2>/dev/null)
|
||||
|
||||
page_size=$(echo "$input" | jsonfilter -e '$[5]' 2>/dev/null)
|
||||
[ -z "$page_size" ] && page_size=$(echo "$input" | jsonfilter -e '$.page_size' 2>/dev/null)
|
||||
|
||||
get_dns_queries "$domain" "$device" "$is_query" "$dns_server" "$page" "$page_size"
|
||||
else
|
||||
get_dns_queries "" "" "" "" "" ""
|
||||
fi
|
||||
;;
|
||||
getDnsStats)
|
||||
# logger "luci.bandix: getDnsStats called"
|
||||
get_dns_stats
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -27,9 +27,17 @@
|
||||
"path": "bandix/connection"
|
||||
}
|
||||
},
|
||||
"admin/network/bandix/dns": {
|
||||
"title": "DNS",
|
||||
"order": 20,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "bandix/dns"
|
||||
}
|
||||
},
|
||||
"admin/network/bandix/settings": {
|
||||
"title": "Settings",
|
||||
"order": 20,
|
||||
"order": 25,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "bandix/settings"
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
"getMetrics",
|
||||
"setRateLimit",
|
||||
"getConnection",
|
||||
"setHostname"
|
||||
"setHostname",
|
||||
"getDnsQueries",
|
||||
"getDnsStats"
|
||||
]
|
||||
},
|
||||
"uci": [
|
||||
@@ -22,7 +24,9 @@
|
||||
"getStatus",
|
||||
"getMetrics",
|
||||
"getConnection",
|
||||
"setHostname"
|
||||
"setHostname",
|
||||
"getDnsQueries",
|
||||
"getDnsStats"
|
||||
]
|
||||
},
|
||||
"uci": [
|
||||
|
||||
Reference in New Issue
Block a user