v0.4.0:窗口调度/限流分类/可观测性,抢购改每账号独立循环,移除 CLI 只保留 GUI

This commit is contained in:
yml2213
2026-10-16 18:14:30 +08:00
parent 29aed15e4e
commit 8b3b14654f
20 changed files with 2309 additions and 664 deletions
+29
View File
@@ -0,0 +1,29 @@
package huya
import (
"errors"
"fmt"
"huya-go/internal/wup"
)
// ErrProtocolResponse 表示服务端响应的结构与协议约定不符(典型是缺少 tRsp/tResp)。
//
// 这类错误既不是网络错误也不是业务失败:它说明服务端回了一个解不出来的包
// (风控拦截、错误信封、被截断的帧都可能)。单独标记出来是为了让上层能把它
// 与普通失败分开统计(见 sniper.CategoryProtocol),并在报错里带上 WUP 诊断信息。
var ErrProtocolResponse = errors.New("协议响应异常")
// rawFrameHeadBytes 是 debug 日志里打印的原始帧前缀长度。
const rawFrameHeadBytes = 32
// protocolResponseError 组装「缺少 tRsp/tResp」错误,并带上 WUP 响应诊断。
//
// 过去这里只有一句文案,服务端返回的 iRet/status/context 全被丢掉,
// 事后只能重放抓包(2026-10-16 pc-3 同一账号连续 13 次命中,无法定性)。
func protocolResponseError(service, method string, resp *wup.Response) error {
if resp == nil {
return fmt.Errorf("%w: %s.%s 响应缺少 tRsp/tResp", ErrProtocolResponse, service, method)
}
return fmt.Errorf("%w: %s.%s 响应缺少 tRsp/tResp(%s)", ErrProtocolResponse, service, method, resp.Diagnose())
}