set -euo pipefail
TOKEN=$(SSHPASS="Zhxc6545398@" sshpass -e ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no -o StrictHostKeyChecking=accept-new -o ConnectTimeout=8 root@103.114.163.226 'set -euo pipefail
pid=$(ss -ltnp | awk '\''/:48090/ {match($0,/pid=([0-9]+)/,m); if(m[1]) print m[1]}'\'' | head -1)
JWT_SECRET=$(tr "\0" "\n" < /proc/$pid/environ | awk -F= '\''$1=="JWT_SECRET"{print substr($0,12)}'\'')
now=$(date +%s); exp=$((now+3600))
JWT_SECRET="$JWT_SECRET" USER_ID2="66" EMAIL="3354740692@qq.com" ROLE="user" NOW="$now" EXP="$exp" python3 - <<'\''PY2'\''
import os,json,base64,hmac,hashlib
b64=lambda b: base64.urlsafe_b64encode(b).rstrip(b"=").decode()
header={"alg":"HS256","typ":"JWT"}
payload={"user_id":int(os.environ["USER_ID2"]),"email":os.environ["EMAIL"],"role":os.environ["ROLE"],"token_version":0,"exp":int(os.environ["EXP"]),"iat":int(os.environ["NOW"]),"nbf":int(os.environ["NOW"])}
msg=b64(json.dumps(header,separators=(",",":")).encode())+"."+b64(json.dumps(payload,separators=(",",":")).encode())
sig=hmac.new(os.environ["JWT_SECRET"].encode(), msg.encode(), hashlib.sha256).digest()
print(msg+"."+b64(sig))
PY2
')
export TOKEN
python3 - <<'PY'
import os, urllib.request, json, time
for url in ["http://103.114.163.226:48090/api/v1/auth/me", "http://103.114.163.226:48090/api/v1/pay/alipay/precreate"]:
    body=None; method="GET"
    if url.endswith('/precreate'):
        body=json.dumps({"biz_type":"balance_recharge","amount_fen":1000,"description":"SubLB 余额充值 10 元","payment_method":"alipay"}).encode(); method="POST"
    req=urllib.request.Request(url, data=body, headers={"Authorization":"Bearer "+os.environ["TOKEN"],"Content-Type":"application/json"}, method=method)
    t=time.time()
    try:
        with urllib.request.urlopen(req, timeout=35) as r: raw=r.read().decode(); status=r.status
    except Exception as e:
        if hasattr(e,'read'): raw=e.read().decode(errors='replace'); status=getattr(e,'code',None)
        else: print(json.dumps({"url":url,"error":type(e).__name__,"message":str(e)})); continue
    try: data=json.loads(raw)
    except: data={"raw":raw[:300]}
    d=data.get('data') or {}
    print(json.dumps({"url":url,"status":status,"elapsed":round(time.time()-t,3),"code":data.get('code'),"message":data.get('message'),"has_user":bool(d.get('id') or d.get('user')),"has_order_id":bool(d.get('order_id')),"has_code_url":bool(d.get('code_url') or d.get('qr_code')),"raw_head":raw[:240]}, ensure_ascii=False))
PY
