feat: console_log.meshtastic 控制 packet 控制台输出;新增每客户端报文统计

- ConsoleLogConfig 增加 Meshtastic 字段(默认 true);旧配置自动补齐
- meshtasticFilterHook 增加 packetConsoleLog;OnPublish 中根据开关调用
  新的 printMeshtasticRecord 输出可读单行(key=value、按 type 着色),
  替代原来的 JSON dump;事件型 printJSON 调用保持不变
- 新增 internal/mqttforward/ClientStats,按 client_id 累计 in/out 报文计数
- meshtasticFilterHook 多挂 OnPacketRead / OnPacketSent / OnDisconnect
  事件,用于增减计数;Provides() 同步声明
- AdminMQTTClient JSON 视图删除 RemoteHost/RemotePort,新增
  packets_in / packets_out;前端 types.ts、AdminDashboard.vue 同步更新

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-19 17:09:00 +08:00
co-authored by Claude
parent 937580e24f
commit 49a287e6e7
7 changed files with 237 additions and 80 deletions
+20 -12
View File
@@ -83,10 +83,11 @@ type AIConfig struct {
// ConsoleLogConfig 控制各模块是否在控制台打印日志。后续若新增模块,按需扩展。
type ConsoleLogConfig struct {
Web bool `yaml:"web"`
MQTT bool `yaml:"mqtt"`
LLM bool `yaml:"llm"`
SQL bool `yaml:"sql"`
Web bool `yaml:"web"`
MQTT bool `yaml:"mqtt"`
LLM bool `yaml:"llm"`
SQL bool `yaml:"sql"`
Meshtastic bool `yaml:"meshtastic"`
}
type rawConfig struct {
@@ -99,10 +100,11 @@ type rawConfig struct {
}
type rawConsoleLogConfig struct {
Web *bool `yaml:"web"`
MQTT *bool `yaml:"mqtt"`
LLM *bool `yaml:"llm"`
SQL *bool `yaml:"sql"`
Web *bool `yaml:"web"`
MQTT *bool `yaml:"mqtt"`
LLM *bool `yaml:"llm"`
SQL *bool `yaml:"sql"`
Meshtastic *bool `yaml:"meshtastic"`
}
type rawAIConfig struct {
@@ -200,10 +202,11 @@ func Default() *Config {
DataDir: defaultDataDir(),
},
ConsoleLog: ConsoleLogConfig{
Web: true,
MQTT: true,
LLM: true,
SQL: true,
Web: true,
MQTT: true,
LLM: true,
SQL: true,
Meshtastic: true,
},
}
}
@@ -515,6 +518,11 @@ func normalize(raw rawConfig) (*Config, bool) {
} else {
cfg.ConsoleLog.SQL = *raw.ConsoleLog.SQL
}
if raw.ConsoleLog.Meshtastic == nil {
changed = true
} else {
cfg.ConsoleLog.Meshtastic = *raw.ConsoleLog.Meshtastic
}
}
return cfg, changed