#!/bin/bash
export LC_ALL=C
line() { printf '\n----- %s -----\n' "$1"; }

line "SOURCES"
cat /opt/proxy-lab/sources.txt 2>/dev/null

line "CONFIG.ENV"
cat /opt/proxy-lab/config.env 2>/dev/null

line "SERVE.JSON"
cat /opt/proxy-lab/data/serve.json 2>/dev/null

line "HEALTHY.JSON (structure, redacted)"
python3 - <<'PY' 2>/dev/null
import json
d=json.load(open('/opt/proxy-lab/data/healthy.json'))
def shape(x,depth=0):
    if isinstance(x,dict):
        return {k:(shape(v,depth+1) if depth<2 else '...') for k,v in list(x.items())[:12]}
    if isinstance(x,list):
        return [shape(x[0],depth+1)] if x else []
    s=str(x)
    return (s[:6]+'…') if len(s)>8 else s
print(json.dumps(shape(d),indent=1,ensure_ascii=False)[:1200])
print('\ncount:', len(d) if isinstance(d,list) else list(d.keys()))
PY

line "PROXYLAB CLI"
timeout 20 python3 /opt/proxy-lab/proxylab.py --help 2>&1 | head -30

line "PROXYLAB SUBCOMMAND HELP"
for c in run serve; do
  printf '\n== %s --help\n' "$c"
  timeout 20 python3 /opt/proxy-lab/proxylab.py $c --help 2>&1 | head -20
done

line "PROXYLAB KEY LOGIC"
grep -nE "def (run|serve|test|fetch|pick|main)|add_argument|20808|172\.19|listen|SOURCE|http_proxy|generate_204" /opt/proxy-lab/proxylab.py 2>/dev/null | head -40

line "9ROUTER PROXY SETTINGS"
grep -ril 'proxy' /root/.9router 2>/dev/null | head -8
grep -rhoE '"(https?|socks[45])?[Pp]roxy[^,]{0,120}' /root/.9router 2>/dev/null | sort -u | head -12

line "END"
