修正活动WSS AUTH帧对齐9.1抓包字节
This commit is contained in:
@@ -106,10 +106,21 @@ def test_wss_requires_web_device_cookie_fields():
|
||||
|
||||
|
||||
def test_activity_auth_frame_matches_latest_capture_layout():
|
||||
"""对齐 9.1 活动 AUTH(828 连接)逐字段结构。
|
||||
|
||||
9.1: tag3 ZERO 首字段 -> tag0 uid -> tag1 UA -> tag2 cookie(STRING4)
|
||||
-> tag3 STRING1 guid(32hex) -> tag4 INT8=1 -> tag5 "HUYA&ZH&2052"
|
||||
-> tag6 "" -> TAIL_BYTES
|
||||
"""
|
||||
async def build_frame():
|
||||
client = HuyaWssClient()
|
||||
client._activity_mode = True
|
||||
client.ws = type("FakeWs", (), {"send": AsyncMock()})()
|
||||
await client.send_auth(1199664135026, "udb_cred=" + "x" * 300, sequence=0x1D000109)
|
||||
await client.send_auth(
|
||||
1199664135026,
|
||||
"guid=" + "0a" * 16 + "; udb_cred=" + "x" * 300,
|
||||
sequence=0x1D000109,
|
||||
)
|
||||
return client.ws.send.call_args.args[0]
|
||||
|
||||
message = WssMessage.decode(asyncio.run(build_frame()))
|
||||
@@ -118,13 +129,20 @@ def test_activity_auth_frame_matches_latest_capture_layout():
|
||||
assert message.body.endswith(TAIL_BYTES)
|
||||
|
||||
stream = TafInputStream(message.body[: -len(TAIL_BYTES)])
|
||||
# 首字段:tag3 ZERO(9.1 活动帧的占位字段)
|
||||
assert stream.read_head() == (3, TafType.ZERO)
|
||||
assert stream.read_int64(0) == 1199664135026
|
||||
assert stream.read_string(1) == "webh5&0.0.1&websocket&&diypc_52775"
|
||||
assert stream.read_head() == (2, TafType.STRING4)
|
||||
cookie_len = int.from_bytes(stream.buf.read(4), "big")
|
||||
assert cookie_len > 255
|
||||
stream.buf.read(cookie_len)
|
||||
assert stream.read_int32(3) == 0
|
||||
# tag3 = STRING1 guid(9.1 中为 Cookie 里的 32hex guid)
|
||||
guid = stream.read_string(3)
|
||||
assert guid == "0a" * 16
|
||||
assert stream.read_int8(4) == 1
|
||||
assert stream.read_string(5) == "HUYA&ZH&2052"
|
||||
assert stream.read_string(6) == ""
|
||||
|
||||
# body 必须与 9.1 828 AUTH 同样以 TAIL_BYTES 收尾
|
||||
assert message.body[-len(TAIL_BYTES):] == TAIL_BYTES
|
||||
|
||||
Reference in New Issue
Block a user