forked from kevin/meshtastic_mqtt_server
安全加固:LLM 会话按 (bot,peer) 隔离+历史上限50条,LLM 入队按 (bot,from_node) 限流(60s内5条),瓦片磁盘缓存单源配额(3000文件/300MB 按mtime淘汰),签到墙读接口限速+全站每日1000条封顶,敏感数据落盘 AES-256-GCM 加密(MESH_SECRET_KEY, 兼容明文迁移),admin 改密需验证当前密码+pwd_version 会话撤销,后端 v1.5.0
This commit is contained in:
@@ -25,12 +25,16 @@ import (
|
||||
type SignStore interface {
|
||||
CreateSign(nodeID string, longName, shortName *string, signText string, signTime time.Time) (*storepkg.SignRecord, error)
|
||||
HasSignedOnDay(nodeID string, day time.Time) (bool, error)
|
||||
CountSignsOnDay(day time.Time) (int64, error)
|
||||
GetNodeInfo(nodeID string) (*storepkg.NodeInfoRecord, error)
|
||||
CountSigns(opts storepkg.ListOptions) (int64, error)
|
||||
CountSignsByDay(opts storepkg.ListOptions) ([]storepkg.SignDayCount, error)
|
||||
ListSigns(opts storepkg.ListOptions) ([]storepkg.SignRecord, error)
|
||||
}
|
||||
|
||||
// maxSignsPerDay 全站每日签到记录总量封顶,防止伪造节点刷公开签到墙。
|
||||
const maxSignsPerDay = 1000
|
||||
|
||||
// Tool 是签到工具。
|
||||
type Tool struct {
|
||||
enabled bool
|
||||
@@ -164,6 +168,15 @@ func (t *Tool) executeSign(ctx context.Context, params signParams, runtime agent
|
||||
return fmt.Sprintf("%s 今天已经签到过了,每个节点每天只能签到一次。", displayName(node)), nil
|
||||
}
|
||||
|
||||
// 全站每日签到总量封顶,防止伪造海量节点号刷爆公开签到墙。
|
||||
todayCount, err := t.store.CountSignsOnDay(now)
|
||||
if err != nil {
|
||||
return fmt.Sprintf("签到失败:统计今日签到数时出错:%v", err), nil
|
||||
}
|
||||
if todayCount >= maxSignsPerDay {
|
||||
return "今日签到人数已达上限,请明天再来。", nil
|
||||
}
|
||||
|
||||
signText := buildSignText(params)
|
||||
if signText == "" {
|
||||
// 结构化字段缺失时回退到用户原始文本
|
||||
|
||||
Reference in New Issue
Block a user