fix(huya): 一号一设备补完 — hydevice 设备参数跟随账号画像 + 画像一致性字段下沉

用户实弹测试暴露两个缺口:
1. Hebe/GUID32 全空: 登录路径走 get_profile, 未经过 account_env 补字段
   → _enrich_profile 下沉到 get_profile (幂等, 存量账号自动补齐)
2. sdid 前缀跨账号同源 (0UnHUgv0_qmfD4KAKlwzh...): env.js 是静态设备仿真
   (写死 M2102J2SC), 状态目录隔离只改了'存储', 没改'采集输入'
   → env.js makeEnv(overrides) 支持按画像覆盖 UA/屏幕/机型/Android版本;
     runner 接收 device.json; get_huya_sdid(device_hint=画像);
     下次登录每账号 hydevice 采集输入=各自绑定机型 → sdid 彻底分家
This commit is contained in:
yml2213
2026-08-29 16:51:41 +08:00
parent fda3d5257b
commit 4f099cc196
5 changed files with 91 additions and 13 deletions
+25 -3
View File
@@ -100,12 +100,34 @@ def _save_db(db: dict) -> None:
pass
def _enrich_profile(profile: dict) -> dict:
"""补齐 dfp 一致性字段 (幂等): guid32 / Hebe_D1-D5。
来源: R36 解密的真实 dfp 指纹 JSON 结构 (deviceinfo.guid + deviceinfo.Hebe_D1-D5)。
一号一设备: 每账号独立生成后终身不变, 供后续真实载荷构建与 GUI 设备绑定页展示。
"""
changed = False
if not profile.get("guid32"):
profile["guid32"] = hashlib.sha256(os.urandom(16) + b"guid").hexdigest()
changed = True
hebe = profile.get("hebe") or {}
if len(hebe) < 5:
profile["hebe"] = {f"Hebe_D{i}": hashlib.sha256(os.urandom(16) + f"hebe{i}".encode()).hexdigest()
for i in range(1, 6)}
changed = True
return profile if changed else profile
def get_profile(account: str, force_new: bool = False) -> dict:
"""按账号获取或创建画像(幂等:同账号复用同一套)。"""
"""按账号获取或创建画像(幂等:同账号复用同一套, 自动补齐缺失一致性字段)。"""
db = _load_db()
if not force_new and account in db:
return db[account]
p = generate_profile()
enriched = _enrich_profile(db[account])
if enriched is not db[account]:
db[account] = enriched
_save_db(db)
return enriched
p = _enrich_profile(generate_profile())
db[account] = p
_save_db(db)
return p