feat(worker): 每账号频道配额+创建限速 + 每频道 WS 连接上限,堵账单攻击面(#137 成本滥用)#327
Merged
Conversation
POST /api/channels 无配额——每频道一个 DO,任一 ap_ token 可无限造 DO+D1 行(账单攻击面)。 加:owned 频道数硬上限(MAX_CHANNELS_PER_ACCOUNT,quota_exceeded/403)+ 滚动窗创建限速 (MAX_CHANNEL_CREATES_PER_WINDOW,rate_limited/429),按 owner_account 计;legacy 无账号 token fail-open 不受限。do.ts onConnect 加每频道 WS 连接上限。默认宽松,单团队不会撞。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
补什么(#137 成本滥用,dimension 3)
POST /api/channels无每账号配额/创建限速——每频道一个 Durable Object,任一 ap_ token 可无限造 DO + D1 行(面向跨公司外部 agent 发 token 的产品,真实账单攻击面)。DO 内也无每频道 WS 连接上限。做了(真熔断,仿既有限速/队列上限手法)
MAX_CHANNELS_PER_ACCOUNT(超 →quota_exceeded/403),按owner_account从 D1 计数。MAX_CHANNEL_CREATES_PER_WINDOW/小时(超 →rate_limited/429)。onConnect排除刚接入的自己后计存活连接,>= maxConnectionsPerChannel()(缺省MAX_CONNECTIONS_PER_CHANNEL、worker env 可覆盖调参)则拒新连接。门禁(对 origin HEAD rebase 后亲验)
false &&)→ 超额建频道测试红。复绿。🤖 opus agent 实现、收尾截断我接管(审+提交+复验)。