74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Verify neko-12 chrome flags + open Studio via CDP."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
"107.173.30.245",
|
|
22,
|
|
"root",
|
|
"Xiao4669805",
|
|
timeout=45,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=120,
|
|
)
|
|
|
|
cmd = r"""
|
|
set +e
|
|
echo '=== mounted flags ==='
|
|
docker exec douyinweb-neko-12 grep -n 'no-wasm-simd\|WebAssemblySimd\|max-old-space' /etc/neko/browser-launch.sh
|
|
echo '=== chrome cmdline snippet ==='
|
|
docker exec douyinweb-neko-12 sh -c 'for p in /proc/[0-9]*; do
|
|
cmd=$(tr "\0" " " < "$p/cmdline" 2>/dev/null)
|
|
case "$cmd" in
|
|
*remote-debugging-port=9222*) echo "$cmd" | tr " " "\n" | grep -E "js-flags|wasm|WebAssembly|max-old|remote-debugging" ; echo "---"; break ;;
|
|
esac
|
|
done'
|
|
echo '=== CDP ==='
|
|
docker exec douyinweb-neko-12 python3 -c '
|
|
import json, urllib.request, time
|
|
STUDIO="https://studio.youtube.com/channel/UCfP5vcTQEfrHc13yTmmokQw/livestreaming"
|
|
for i in range(20):
|
|
try:
|
|
urllib.request.urlopen("http://127.0.0.1:9222/json/version", timeout=2).read()
|
|
print("devtools_ok")
|
|
break
|
|
except Exception as e:
|
|
time.sleep(1)
|
|
else:
|
|
raise SystemExit("no_devtools")
|
|
# try new tab
|
|
ok=False
|
|
for method in ("PUT","GET"):
|
|
try:
|
|
req=urllib.request.Request("http://127.0.0.1:9222/json/new?"+STUDIO, method=method)
|
|
body=urllib.request.urlopen(req, timeout=15).read()
|
|
print("opened", method, body[:160])
|
|
ok=True
|
|
break
|
|
except Exception as e:
|
|
print("fail", method, e)
|
|
time.sleep(8)
|
|
tabs=json.loads(urllib.request.urlopen("http://127.0.0.1:9222/json/list", timeout=5).read())
|
|
for t in tabs:
|
|
if t.get("type")=="page":
|
|
title=(t.get("title") or "")[:80]
|
|
url=(t.get("url") or "")[:140]
|
|
print("TAB", title, "|", url)
|
|
'
|
|
echo '=== recent traps ==='
|
|
dmesg -T 2>/dev/null | grep -i "invalid opcode" | tail -3
|
|
free -h | head -3
|
|
"""
|
|
_i, o, e = c.exec_command(cmd, timeout=120)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|