修正虎牙活动wsLaunch包封装

This commit is contained in:
yml2213
2026-09-01 12:56:37 +08:00
parent 5a1456e3cb
commit 8e3c0e69bc
+14 -1
View File
@@ -163,6 +163,19 @@ class HuyaWssClient:
+ HuyaWssClient._make_big_tail() + HuyaWssClient._make_big_tail()
) )
@staticmethod
def _encode_activity_launch_body(wup_data: bytes) -> bytes:
"""活动 wsLaunch 使用浏览器的固定大包头,即使包体小于 255B。"""
if len(wup_data) < 4:
return wup_data + TAIL_BYTES
packet_len = len(wup_data)
return (
bytes([packet_len & 0xFF])
+ packet_len.to_bytes(4, "big")
+ wup_data[4:]
+ TAIL_BYTES
)
@staticmethod @staticmethod
def _normalize_biz_cookie(cookie: str) -> str: def _normalize_biz_cookie(cookie: str) -> str:
"""业务 RPC 的 huya_ua Cookie 值按浏览器 WSS 抓包修正""" """业务 RPC 的 huya_ua Cookie 值按浏览器 WSS 抓包修正"""
@@ -398,7 +411,7 @@ class HuyaWssClient:
wup.setRequestId(-1) wup.setRequestId(-1)
wup.iTimeout = 0 wup.iTimeout = 0
wup.newdata["tReq"] = os.get_bytes() wup.newdata["tReq"] = os.get_bytes()
body = self._encode_rpc_body(wup.encode()) body = self._encode_activity_launch_body(wup.encode())
msg = WssMessage(WssCommand.RPC_REQUEST, SEQ_ACTIVITY_WSLAUNCH, body) msg = WssMessage(WssCommand.RPC_REQUEST, SEQ_ACTIVITY_WSLAUNCH, body)
future = asyncio.Future() future = asyncio.Future()
self.rpc_queue.append(future) self.rpc_queue.append(future)