fix(channel,user): owner 车道只认白名单,堵住群主/伪造 role 冒充主人(裁决 06.4.2/06.4.3/06.4.4)
- 适配器只描述平台身份:qq_obv11 的 owner/admin 一律上报 RoleMember,不再上报 RoleOwner - session 层唯一判主点只认白名单(owner.yaml Accounts ∪ 每渠道 adminIds),nil 档案 fail-closed 拒绝 - 新增「每渠道管理员层」:channels.json ChannelAccount.adminIds[] → runtimeconfig.AdminIDs → OwnerProfile.SetPlatformAdmins(整体替换语义,热重载后移除的 id 立即失效) - 组合根接线:启动即播种、面板保存先灌白名单再重载适配器(cmd/cyrene/wire_channels.go + 4 条端到端单测) - 06.4.3 节流与参与度状态按会话独立计数(ConversationKey 三处统一,空会话 GC);06.4.4 未知平台主动发言保守默认 1 条/分钟
This commit is contained in:
1 parent
7e7f53bb41
commit
af8591b78a
30 files changed
+1289
-144
No files matched your search
@@ -10,9 +10,10 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/logger"
|
||||
)
|
||||
|
||||
// Proactive push per-platform defaults (design/08 §3): weixin-ilink allows push
|
||||
// only within 24h of the last inbound message; OneBot allows push but must be
|
||||
// rate-limited to avoid wind-control flags; telegram/webhook push freely.
|
||||
// 主动推送的每平台默认值(design/08 §3):weixin-ilink 只允许在最后一条入站消息的
|
||||
// 24 小时内推送(超 24h 推不过去);OneBot 可推送但要限频以避开风控;telegram/webhook
|
||||
// 推送强、不设限;**能力未声明的未知平台保守默认**(裁决 06.4.4)——严格限频,绝不给
|
||||
// 「无限制」。真正的限幅落在适配器实现,策略层只声明口径(design/08 §3)。
|
||||
const (
|
||||
// iLinkWindow is the weixin-ilink proactive push window.
|
||||
iLinkWindow = 24 * time.Hour
|
||||
@@ -20,6 +21,10 @@ const (
|
||||
oneBotBurstLimit = 3
|
||||
// oneBotBurstWindow is the OneBot rate-limit window.
|
||||
oneBotBurstWindow = 10 * time.Second
|
||||
// unknownBurstLimit / unknownBurstWindow 是未知平台的保守默认:每分钟最多 1 条主动
|
||||
// 推送(比 OneBot 的 3 条/10s 更紧),保证「未知 ≠ 无限制」。
|
||||
unknownBurstLimit = 1
|
||||
unknownBurstWindow = time.Minute
|
||||
)
|
||||
|
||||
// ProactiveOptions configures a ProactivePolicy.
|
||||
@@ -57,17 +62,20 @@ func NewProactivePolicy(opts ProactiveOptions) *ProactivePolicy {
|
||||
return p
|
||||
}
|
||||
|
||||
// ProactivePolicyForPlatform returns the default proactive policy for a known
|
||||
// platform identifier, following design/08 §3. Unknown platforms get an
|
||||
// unrestricted policy, which is the conservative-outcome of "strong" channels.
|
||||
// ProactivePolicyForPlatform 返回某平台标识对应的默认主动推送策略(design/08 §3)。
|
||||
// 已声明的平台按其规格:weixin-ilink 走 24h 窗口、OneBot 限频、telegram/webhook 推送强
|
||||
// 不设限。**未知(能力未声明)平台保守默认**(裁决 06.4.4):给最严格的限频
|
||||
// (1 条/分钟),不再返回「无限制」——限幅落在适配器实现,策略层只声明口径。
|
||||
func ProactivePolicyForPlatform(platform string) *ProactivePolicy {
|
||||
switch platform {
|
||||
case "weixin-ilink":
|
||||
return NewProactivePolicy(ProactiveOptions{Window: iLinkWindow})
|
||||
case "qq-obv11", "qq-onebot", "onebot":
|
||||
return NewProactivePolicy(ProactiveOptions{RateLimit: oneBotBurstLimit, RateWindow: oneBotBurstWindow})
|
||||
default:
|
||||
case "telegram", "webhook":
|
||||
return NewProactivePolicy(ProactiveOptions{})
|
||||
default:
|
||||
return NewProactivePolicy(ProactiveOptions{RateLimit: unknownBurstLimit, RateWindow: unknownBurstWindow})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user