Files

88 lines
5.3 KiB
Bash

#!/bin/bash
set -e
BASE="http://127.0.0.1:18300"
ADMIN="test-admin-token"
DL="test-download-token"
H="Authorization: Bearer $ADMIN"
CT="Content-Type: application/json"
echo "=== 1. 创建远程订阅源 (sslinks) ==="
curl -s -X POST -H "$H" -H "$CT" \
-d '{"name":"remote-sslinks","type":"remote","url":"https://sub.sslinks.co.in/em9knZQ6ximoi9hhnKzJT3FayVZSb2PxKmPWzhzk?token=a8483f280b990786fe607e04d2724dd2","enabled":true}' \
"$BASE/api/sources" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'status={d[\"status\"]}, id={d.get(\"data\",{}).get(\"id\",\"?\")}'); print(d.get('error',{}).get('message','')) if d['status']!='success' else None"
echo ""
echo "=== 2. 创建远程订阅源 (smallstrawberry) ==="
curl -s -X POST -H "$H" -H "$CT" \
-d '{"name":"remote-smallstrawberry","type":"remote","url":"https://sub2.smallstrawberry.com/api/v1/client/subscribe?token=012ebcb597340abd624d1b0b954b9b36","enabled":true}' \
"$BASE/api/sources" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'status={d[\"status\"]}, id={d.get(\"data\",{}).get(\"id\",\"?\")}'); print(d.get('error',{}).get('message','')) if d['status']!='success' else None"
echo ""
echo "=== 3. 创建远程订阅源 (aisaka) ==="
curl -s -X POST -H "$H" -H "$CT" \
-d '{"name":"remote-aisaka","type":"remote","url":"https://kaze1.aisaka-taiga.com/oosaka/f2d2c3464d989d7ef78f2b5e20fa1cf9","enabled":true}' \
"$BASE/api/sources" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'status={d[\"status\"]}, id={d.get(\"data\",{}).get(\"id\",\"?\")}'); print(d.get('error',{}).get('message','')) if d['status']!='success' else None"
echo ""
echo "=== 4. 创建本地订阅源 (本地 VLESS 节点) ==="
curl -s -X POST -H "$H" -H "$CT" \
-d '{"name":"local-vless","type":"local","content":"vless://a2ec9c21-1c51-46cc-8cbd-d9eb63ad412c@seoul-ali-01.20140202.xyz:443?encryption=none&security=tls&sni=seoul-ali-01.20140202.xyz&insecure=0&allowInsecure=0&type=ws&host=seoul-ali-01.20140202.xyz&path=%2F5b334b45ba04a58e#Seoul-ALIBABA\nvless://28f0f856-bcb3-4046-9aeb-785376c44505@us-la-01-racknerd.20140202.xyz:443?encryption=none&security=tls&sni=us-la-01-racknerd.20140202.xyz&insecure=0&allowInsecure=0&type=ws&host=us-la-01-racknerd.20140202.xyz&path=%2F6f6bbc94c6c76083#US-LA-RACKNERD","enabled":true}' \
"$BASE/api/sources" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'status={d[\"status\"]}, id={d.get(\"data\",{}).get(\"id\",\"?\")}'); print(d.get('error',{}).get('message','')) if d['status']!='success' else None"
echo ""
echo "=== 5. 列出所有源 ==="
curl -s -H "$H" "$BASE/api/sources" | python3 -c "import sys,json; d=json.load(sys.stdin); [print(f' {s[\"id\"]} ({s[\"type\"]}) enabled={s[\"enabled\"]}') for s in d['data']]"
echo ""
echo "=== 6. 下载本地源 — mihomo ==="
curl -s "$BASE/sources/local-vless/$DL?target=mihomo" | head -30
echo ""
echo "=== 7. 下载本地源 — JSON ==="
curl -s "$BASE/sources/local-vless/$DL?target=json" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'proxies={len(d.get(\"proxies\",[]))}'); [print(f' {p.get(\"name\")} ({p.get(\"type\")}) -> {p.get(\"server\")}:{p.get(\"port\")}') for p in d.get('proxies',[])]"
echo ""
echo "=== 8. 下载本地源 — sing-box ==="
curl -s "$BASE/sources/local-vless/$DL?target=sing-box" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'outbounds={len(d.get(\"outbounds\",[]))}'); [print(f' {o.get(\"tag\",\"?\")} ({o.get(\"type\",\"?\")})') for o in d.get('outbounds',[])]"
echo ""
echo "=== 9. 下载本地源 — URI ==="
curl -s "$BASE/sources/local-vless/$DL?target=uri"
echo ""
echo ""
echo "=== 10. 下载本地源 — surge ==="
curl -s "$BASE/sources/local-vless/$DL?target=surge" | head -10
echo ""
echo "=== 11. 创建集合 (local-vless + remote-sslinks) ==="
curl -s -X POST -H "$H" -H "$CT" \
-d '{"name":"mixed-collection","sourceIds":["local-vless","remote-sslinks"],"templateId":"default","enabled":true}' \
"$BASE/api/collections" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'status={d[\"status\"]}, id={d.get(\"data\",{}).get(\"id\",\"?\")}'); print(d.get('error',{}).get('message','')) if d['status']!='success' else None"
echo ""
echo "=== 12. 下载集合 — mihomo ==="
curl -s "$BASE/collections/mixed-collection/$DL?target=mihomo" | head -40
echo ""
echo "=== 13. 远程源预览 — remote-sslinks ==="
curl -s -X POST -H "$H" -H "$CT" \
-d '{"name":"remote-sslinks","type":"remote","url":"https://sub.sslinks.co.in/em9knZQ6ximoi9hhnKzJT3FayVZSb2PxKmPWzhzk?token=a8483f280b990786fe607e04d2724dd2"}' \
"$BASE/api/preview/source" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'status={d[\"status\"]}'); data=d.get('data',{}); print(f'nodes={data.get(\"nodes\",\"?\")}'); print(d.get('error',{}).get('message','')) if d['status']!='success' else None"
echo ""
echo "=== 14. 远程源下载 — remote-sslinks mihomo ==="
curl -s "$BASE/sources/remote-sslinks/$DL?target=mihomo" 2>&1 | head -30
echo ""
echo "=== 15. 远程源下载 — remote-smallstrawberry mihomo ==="
curl -s "$BASE/sources/remote-smallstrawberry/$DL?target=mihomo" 2>&1 | head -30
echo ""
echo "=== 16. 远程源下载 — remote-aisaka mihomo ==="
curl -s "$BASE/sources/remote-aisaka/$DL?target=mihomo" 2>&1 | head -30
echo ""
echo "=== ALL TESTS DONE ==="