默认传输通道改为 WSS,http 作为可回退通道

This commit is contained in:
yml2213
2026-10-14 21:33:23 +08:00
parent 8c4b15066f
commit cff831ae47
5 changed files with 22 additions and 19 deletions
+9 -7
View File
@@ -1,9 +1,9 @@
# huya-go
虎牙活动积分兑换/抢购的 Go 复刻版。支持两种传输层,CLI 与 GUI 默认都走 `http`:
虎牙活动积分兑换/抢购的 Go 复刻版。支持两种传输层,CLI 与 GUI 默认都走 `wss`:
- `http`(默认):走 `https://cdnws.api.huya.com/`,兼容原有命令。
- `wss`:实验实现。CLI 需要显式指定 `-transport wss`,GUI 在设置里切换;已按浏览器 HAR 改为 TAF `WebSocketCommand` 外层和 WSS 初始化流程,仍建议先用真实 Cookie 小流量验证。
- `wss`(默认):浏览器实际使用的通道。先调用 `launch.queryHttpDns` 解析可用 host,再走 TAF `WebSocketCommand` 外层与 WSS 初始化流程(`launch.wsLaunch` → `mobileui.getConfig`)。host 留空即自动解析,解析失败会回退内置默认 host。
- `http`:走 `https://cdnws.api.huya.com/`,作为可回退通道;CLI 用 `-transport http`,GUI 在设置里切换。
## 构建
@@ -57,21 +57,23 @@ CLI 示例:
直接兑换指定 PID:
```bash
./huya-go -cmd exchange -sid 2203 -pid 12889 -cookie-file cookie.txt -transport http
./huya-go -cmd exchange -sid 2203 -pid 12889 -cookie-file cookie.txt
```
按奖品名轮询并抢购:
```bash
./huya-go -cmd monitor -sid 2203 -name 小黄鸭 -cookie-file cookie.txt -transport http -loops 20 -delay 120 -concurrency 5
./huya-go -cmd monitor -sid 2203 -name 小黄鸭 -cookie-file cookie.txt -loops 20 -delay 120 -concurrency 5
```
定时开始:
```bash
./huya-go -cmd monitor -sid 2203 -pid 12889 -cookie-file cookie.txt -transport http -at "2026-07-06 20:00:00"
./huya-go -cmd monitor -sid 2203 -pid 12889 -cookie-file cookie.txt -at "2026-07-06 20:00:00"
```
以上默认都走 `wss`。需要回退到 http 传输时,给任意命令加上 `-transport http`。
## 多开(多实例)
同一台机器可以同时启动多个实例,互不干扰:
@@ -103,7 +105,7 @@ GUI 与 CLI 共用同一套结构化日志(分类 + 等级 + 账号标签)
- `-min-left`:目标奖品最少剩余库存,`0` 表示不限制(CLI 与 GUI 设置都支持)。
- `-cookie`:单账号 Cookie。
- `-cookie-file`:多账号 Cookie 文件。
- `-transport`:`http` 或 `wss`,默认 `http`;WSS 仍为实验通道。
- `-transport`:`wss` 或 `http`,默认 `wss`。
- `-wss-host`:WebSocket host。默认留空,自动调用 `launch.queryHttpDns` 解析(带 TTL 缓存、多 host 轮询),解析失败时回退内置默认 host;需要固定时可显式指定。
- `-timeout`:单次调用超时秒数。
- `-loops`、`-delay`、`-concurrency`:轮询次数、轮询间隔、并发账号数。