Browse Source

删除测试用例

Pchen0 4 hours ago
parent
commit
816a96fdde
3 changed files with 0 additions and 643 deletions
  1. 0 173
      scripts/lepao-proxy-tls-test.js
  2. 0 279
      scripts/lepao-real-proxy-test.js
  3. 0 191
      scripts/proxy-u-xxoo365-test.js

+ 0 - 173
scripts/lepao-proxy-tls-test.js

@@ -1,173 +0,0 @@
-#!/usr/bin/env node
-'use strict'
-
-/**
- * 在学校服务器上测试「直连 vs HTTP 代理」访问 lepao HTTPS 时 TLS 是否正常。
- *
- * 用法(在项目根 ic-ctbu-backend 下执行):
- *   node scripts/lepao-proxy-tls-test.js direct
- *   node scripts/lepao-proxy-tls-test.js proxy 103.217.191.35:20028
- *   node scripts/lepao-proxy-tls-test.js qg-fetch       # 用 config.json 调青果 /get 取 1 个节点再测
- *
- * 环境与线上一致时务必对齐「真实 API + POST」(仅测主页 GET 通过不代表 beforeRun 等接口经代理可用):
- *   TEST_HTTPS_URL=https://lepao.ctbu.edu.cn/v3/api.php/Run2/beforeRunV260 TEST_POST=1 \\
- *     node scripts/lepao-proxy-tls-test.js qg-fetch
- *
- * 环境变量(可选):
- *   TEST_HTTPS_URL   默认 https://lepao.ctbu.edu.cn/
- *   TEST_POST        若为 1,则 POST,body 为 {}
- *   TEST_TIMEOUT_MS  默认 20000
- *   QG_PROXY_USER / QG_PROXY_PASSWORD  覆盖 config 里 authUser/authPassword
- *   QG_AREA / QG_AREA_EX / QG_ISP / QG_DISTINCT  qg-fetch 时传给青果(与线上一致可用来复现)
- *
- *   NODE_TLS_REJECT_UNAUTHORIZED=0  不推荐生产使用;设为 0 时本脚本与其它行为一致会做不安全 TLS
- */
-
-const path = require('path')
-const fs = require('fs')
-const axios = require('axios')
-const HttpsProxyAgent = require('https-proxy-agent')
-
-const QG_POOL_URL = 'https://share.proxy.qg.net/pool'
-
-function loadConfig() {
-    const p = path.join(__dirname, '..', 'config.json')
-    const raw = fs.readFileSync(p, 'utf8')
-    return JSON.parse(raw)
-}
-
-function buildProxyUrl(server, authUser, authPassword) {
-    const parts = String(server || '').trim().split(':')
-    const host = parts[0]
-    const port = parts[1]
-    if (!host || !port) throw new Error('代理 server 需为 host:port')
-    let userPart = ''
-    if (authUser) {
-        const u = encodeURIComponent(authUser)
-        const p = encodeURIComponent(authPassword != null ? String(authPassword) : '')
-        userPart = `${u}:${p}@`
-    }
-    return `http://${userPart}${host}:${port}`
-}
-
-async function probe(label, outbound) {
-    const url = process.env.TEST_HTTPS_URL || 'https://lepao.ctbu.edu.cn/'
-    const timeout = Number(process.env.TEST_TIMEOUT_MS || 20000)
-    const usePost = String(process.env.TEST_POST || '').trim() === '1'
-    const rejectUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED !== '0'
-
-    const base = {
-        timeout,
-        validateStatus: () => true,
-        ...outbound
-    }
-
-    console.log(`\n---------- ${label} ----------`)
-    console.log('REQUEST:', usePost ? 'POST' : 'GET', url)
-    console.log('timeout_ms:', timeout, 'rejectUnauthorized:', rejectUnauthorized)
-
-    const t0 = Date.now()
-    try {
-        const res = usePost
-            ? await axios.post(url, {}, { headers: { 'Content-Type': 'application/json' }, ...base })
-            : await axios.get(url, base)
-        const ms = Date.now() - t0
-        console.log('RESULT: OK', ms + 'ms', 'HTTP', res.status)
-        const bodyPreview = typeof res.data === 'string' ? res.data : JSON.stringify(res.data)
-        console.log('body_preview:', bodyPreview.slice(0, 300).replace(/\s+/g, ' '))
-    } catch (e) {
-        const ms = Date.now() - t0
-        console.log('RESULT: FAIL', ms + 'ms')
-        console.log('message:', e.message)
-        console.log('code:', e.code)
-        if (e.response) console.log('http_status:', e.response.status)
-    }
-}
-
-async function fetchOneProxyFromQg(config) {
-    const q = config.qgChannelProxy || {}
-    const key = String(q.extractKey || '').trim()
-    if (!key) throw new Error('config.json 缺少 qgChannelProxy.extractKey')
-
-    const params = { key, num: 1 }
-    const area = String(process.env.QG_AREA || '').trim()
-    const areaEx = String(process.env.QG_AREA_EX || '').trim()
-    if (area) params.area = area
-    if (areaEx) params.area_ex = areaEx
-    const isp = process.env.QG_ISP
-    if (isp === '1' || isp === '2' || isp === '3') params.isp = Number(isp)
-    if (process.env.QG_DISTINCT === '0') params.distinct = false
-    else params.distinct = true
-
-    const res = await axios.get(QG_POOL_URL, {
-        params,
-        timeout: 20000,
-        proxy: false,
-        validateStatus: () => true
-    })
-    const body = res.data
-    const code = body && body.code
-    if (code !== 'SUCCESS' || !Array.isArray(body.data) || !body.data[0]) {
-        throw new Error(`青果 /pool 失败: ${code || JSON.stringify(body).slice(0, 240)}`)
-    }
-    const item = body.data[0]
-    return {
-        server: item.server,
-        proxy_ip: item.proxy_ip,
-        deadline: item.deadline,
-        request_id: body.request_id
-    }
-}
-
-async function main() {
-    const mode = (process.argv[2] || 'direct').toLowerCase()
-    const cfg = loadConfig()
-    const q = cfg.qgChannelProxy || {}
-    const authUser = process.env.QG_PROXY_USER || q.authUser || ''
-    const authPassword = process.env.QG_PROXY_PASSWORD || q.authPassword || ''
-
-    if (process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0') {
-        console.warn('[WARN] NODE_TLS_REJECT_UNAUTHORIZED=0,TLS 未校验服务端证书。\n')
-    }
-
-    await probe('① 直连(无代理)', { proxy: false })
-
-    if (mode === 'direct') return
-
-    let serverArg
-    if (mode === 'proxy') {
-        serverArg = process.argv[3]
-        if (!serverArg) {
-            console.error('用法: node scripts/lepao-proxy-tls-test.js proxy host:port')
-            process.exit(1)
-        }
-    } else if (mode === 'qg-fetch') {
-        console.log('\n[qg-fetch] 正在请求青果 /get …')
-        const got = await fetchOneProxyFromQg(cfg)
-        serverArg = got.server
-        console.log(
-            '青果节点:',
-            got.server,
-            'proxy_ip=',
-            got.proxy_ip,
-            'deadline=',
-            got.deadline,
-            'request_id=',
-            got.request_id
-        )
-        if (!serverArg) throw new Error('青果返回无 server')
-    } else {
-        console.error('未知模式:', mode, '可用: direct | proxy <host:port> | qg-fetch')
-        process.exit(1)
-    }
-
-    const proxyUrl = buildProxyUrl(serverArg, authUser, authPassword)
-    const rejectUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED !== '0'
-    const agent = new HttpsProxyAgent(proxyUrl, { rejectUnauthorized })
-    await probe(`② HTTP 代理 → 学校 HTTPS (${serverArg})`, { proxy: false, httpsAgent: agent })
-}
-
-main().catch((e) => {
-    console.error(e.stack || e)
-    process.exit(1)
-})

+ 0 - 279
scripts/lepao-real-proxy-test.js

@@ -1,279 +0,0 @@
-#!/usr/bin/env node
-'use strict'
-
-/**
- * 「加密表单 + postLepaoSchool(青果代理/回退)」探测乐跑 HTTPS 链路;报文格式与线上相同。
- *
- * 默认不写库不传 token:内置伪造 uid/token/学号,仅用于测 CONNECT/TLS/代理;业务上会返回登录失效属正常。
- * 也可用环境变量覆盖伪造字段(见 loadFakeAccount)。
- *
- * 用法(项目根):
- *
- *    node scripts/lepao-real-proxy-test.js
- *    node scripts/lepao-real-proxy-test.js --api getOssSts
- *
- * 真实账号(可选):
- *    node scripts/lepao-real-proxy-test.js --student-num 2025402496
- *    node scripts/lepao-real-proxy-test.js --student-num 2025402496 --create-user xxx
- *    LEPAO_TEST_UID=… LEPAO_TEST_TOKEN=… … node scripts/lepao-real-proxy-test.js --env
- *
- *    --timeout 20000          Charles: LEPAO_DEBUG_PROXY=1
- */
-
-const { URLSearchParams } = require('url')
-
-const db = require('../plugin/DataBase/db')
-const Redis = require('../plugin/DataBase/Redis')
-const { dataEncrypt, dataDecrypt, dataSign } = require('../plugin/Lepao/Crypto')
-const { postLepaoSchool } = require('../lib/Lepao/lepaoSchoolHttp')
-
-const DEFAULT_UA =
-    'Mozilla/5.0 (Linux; Android 16; 2211133C Build/BP2A.250605.031.A3; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/138.0.7204.180 Mobile Safari/537.36'
-
-const BASE = 'https://lepao.ctbu.edu.cn'
-
-const ENDPOINTS = {
-    beforeRun: {
-        path: '/v3/api.php/Run2/beforeRunV260',
-        buildRaw: ({ uid, token, school_id, student_num }) => ({
-            uid: Number(uid),
-            token,
-            school_id: Number(school_id),
-            term_id: 0,
-            course_id: 0,
-            class_id: 0,
-            student_num,
-            card_id: student_num,
-            timestamp: Number((Date.now() / 1000).toFixed(3)),
-            version: 1,
-            nonce: String(Math.floor(Math.random() * 900000 + 100000)),
-            ostype: 5
-        })
-    },
-    getOssSts: {
-        path: '/v3/api.php/WpIndex/getOssSts',
-        buildRaw: ({ uid, token, school_id, student_num }) => ({
-            uid: Number(uid),
-            token,
-            school_id: Number(school_id),
-            term_id: 0,
-            course_id: 0,
-            class_id: 0,
-            student_num,
-            card_id: student_num,
-            timestamp: Number((Date.now() / 1000).toFixed(3)),
-            version: 1,
-            nonce: String(Math.floor(Math.random() * 900000 + 100000)),
-            ostype: 5
-        })
-    }
-}
-
-const logger = {
-    info(...a) {
-        console.log('[INFO]', new Date().toISOString(), ...a)
-    },
-    warn(...a) {
-        console.warn('[WARN]', new Date().toISOString(), ...a)
-    },
-    error(...a) {
-        console.error('[ERROR]', new Date().toISOString(), ...a)
-    }
-}
-
-function parseArgs(argv) {
-    const out = { help: false, api: 'beforeRun', studentNum: null, createUser: null, useEnv: false, timeout: 20000 }
-    for (let i = 2; i < argv.length; i++) {
-        const a = argv[i]
-        if (a === '--help' || a === '-h') out.help = true
-        else if (a === '--env') out.useEnv = true
-        else if (a === '--student-num' && argv[i + 1]) out.studentNum = argv[++i]
-        else if (a === '--create-user' && argv[i + 1]) out.createUser = argv[++i]
-        else if (a.startsWith('--api=')) out.api = a.slice('--api='.length)
-        else if (a === '--api' && argv[i + 1]) out.api = argv[++i]
-        else if (a === '--timeout' && argv[i + 1]) out.timeout = Number(argv[++i])
-        else if (!a.startsWith('-') && !out.studentNum) out.studentNum = a
-    }
-    return out
-}
-
-async function loadAccountFromDb(studentNum, createUser) {
-    const conditionSql = createUser ? 'student_num = ? AND create_user = ?' : 'student_num = ?'
-    const queryParams = createUser ? [studentNum, createUser] : [studentNum]
-    const rows = await db.query(
-        `SELECT uid, token, school_id, userAgent FROM lepao_account WHERE ${conditionSql} LIMIT 5`,
-        queryParams
-    )
-    if (!rows || rows.length === 0) {
-        throw new Error('数据库中未找到该学号对应的 lepao_account')
-    }
-    if (rows.length > 1 && !createUser) {
-        throw new Error(`学号 ${studentNum} 存在多条记录,请附加 --create-user 指定其一`)
-    }
-    return { ...rows[0], student_num: studentNum }
-}
-
-function loadAccountFromEnv() {
-    const uid = Number(process.env.LEPAO_TEST_UID)
-    const token = String(process.env.LEPAO_TEST_TOKEN || '').trim()
-    const school_id = Number(process.env.LEPAO_TEST_SCHOOL_ID)
-    const student_num = String(process.env.LEPAO_TEST_STUDENT_NUM || '').trim()
-    const userAgent = process.env.LEPAO_TEST_USER_AGENT?.trim()
-
-    if (!uid || !token || !school_id || !student_num) {
-        throw new Error(
-            '请设置 LEPAO_TEST_UID LEPAO_TEST_TOKEN LEPAO_TEST_SCHOOL_ID LEPAO_TEST_STUDENT_NUM(可选 LEPAO_TEST_USER_AGENT)'
-        )
-    }
-    return {
-        uid,
-        token,
-        school_id,
-        student_num,
-        userAgent: userAgent || DEFAULT_UA
-    }
-}
-
-function numberFromEnv(key, fallback) {
-    const v = process.env[key]
-    if (v === undefined || v === '') return fallback
-    const n = Number(v)
-    return Number.isFinite(n) ? n : fallback
-}
-
-/** 伪造字段,仅校验加密/签名封装与出站链路;学校端通常返回登录失效属预期 */
-function loadFakeAccount() {
-    const uid = numberFromEnv('LEPAO_FAKE_UID', 1009001)
-    let token = String(process.env.LEPAO_FAKE_TOKEN || '').trim()
-    if (!token) token = 'FACEFACEFACEFACEFACEFACEFACEFACE'
-    const school_id = numberFromEnv('LEPAO_FAKE_SCHOOL_ID', 201)
-    let student_num = String(process.env.LEPAO_FAKE_STUDENT_NUM || '').trim()
-    if (!student_num) student_num = '2099123456'
-    const userAgent = String(process.env.LEPAO_FAKE_UA || process.env.LEPAO_TEST_USER_AGENT || DEFAULT_UA).trim()
-
-    const account = { uid, token, school_id, student_num, userAgent }
-    logger.info('[fake payload]', { uid: account.uid, school_id: account.school_id, student_num: account.student_num })
-    return account
-}
-
-function buildEncryptedForm(raw) {
-    raw.sign = dataSign(raw)
-    const form = new URLSearchParams()
-    form.append('ostype', '5')
-    const enc = dataEncrypt(JSON.stringify(raw))
-    if (!enc) throw new Error('dataEncrypt 失败')
-    form.append('data', enc)
-    return form
-}
-
-function printSummary(body) {
-    const result = typeof body === 'object' && body !== null ? body : null
-    if (!result) {
-        console.log('响应:', String(body).slice(0, 500))
-        return
-    }
-    console.log('status 字段:', result.status, 'info/msg:', result.info || result.msg)
-    let dataOut = result.data
-    if (result.is_encrypt === 1 && typeof dataOut === 'string') {
-        const dec = dataDecrypt(dataOut)
-        try {
-            dataOut = JSON.parse(dec)
-        } catch {
-            dataOut = dec
-        }
-        console.log('data(已解密):', JSON.stringify(dataOut, null, 2).slice(0, 4000))
-    } else {
-        console.log('data:', JSON.stringify(dataOut, null, 2).slice(0, 4000))
-    }
-}
-
-async function shutdownConnections() {
-    await db.close().catch(() => {})
-    try {
-        if (Redis.isOpen) {
-            await Redis.quit()
-        }
-    } catch (_) {
-        /* ignore */
-    }
-}
-
-const HELP_TEXT = `lepao-real-proxy-test.js
-  默认使用伪造账号(不写库),用于测代理/TLS/加密报文。
-    node scripts/lepao-real-proxy-test.js
-    node scripts/lepao-real-proxy-test.js --api getOssSts
-  伪造字段可用环境变量覆盖: LEPAO_FAKE_UID LEPAO_FAKE_TOKEN LEPAO_FAKE_SCHOOL_ID LEPAO_FAKE_STUDENT_NUM LEPAO_FAKE_UA
-  真实账号: --student-num <学号> [--create-user …] 或 --env + LEPAO_TEST_*
-  其它: --timeout <ms>   LEPAO_DEBUG_PROXY=1`
-
-async function main() {
-    try {
-        const args = parseArgs(process.argv)
-        if (args.help) {
-            console.log(HELP_TEXT)
-            throw new Error('HELP')
-        }
-
-        const ep = ENDPOINTS[args.api]
-        if (!ep) {
-            console.error(`未知 --api=${args.api},可选 beforeRun | getOssSts`)
-            throw new Error('BAD_API')
-        }
-
-        let account
-        if (args.useEnv) {
-            account = loadAccountFromEnv()
-        } else if (args.studentNum) {
-            account = await loadAccountFromDb(args.studentNum, args.createUser)
-        } else {
-            account = loadFakeAccount()
-        }
-
-        const raw = ep.buildRaw({
-            uid: account.uid,
-            token: account.token,
-            school_id: account.school_id,
-            student_num: String(account.student_num)
-        })
-        const form = buildEncryptedForm(raw)
-
-        const headers = {
-            'Content-Type': 'application/x-www-form-urlencoded',
-            Accept: '*/*',
-            'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
-            Referer: 'https://servicewechat.com/wxf94c4ddb63d87ede/32/page-frame.html',
-            'User-Agent': account.userAgent || DEFAULT_UA
-        }
-
-        const fullUrl = BASE + ep.path
-        const dataTag = args.useEnv ? '[env]' : args.studentNum ? '[db]' : '[fake]'
-        logger.info('接口:', args.api, fullUrl, dataTag, '学号:', String(account.student_num))
-
-        const apiRes = await postLepaoSchool(fullUrl, form, {
-            headers,
-            timeout: args.timeout,
-            logger
-        })
-
-        logger.info('axios HTTP 状态:', apiRes.status)
-        if (!args.studentNum && !args.useEnv) {
-            logger.info('提示: 伪造 token 时业务 status 非 1、提示重新登录等属于预期,关注是否出现 ECONNRESET/TLS 类错误')
-        }
-        printSummary(apiRes.data)
-    } finally {
-        await shutdownConnections()
-    }
-}
-
-main()
-    .then(() => process.exit(0))
-    .catch(err => {
-        const m = String(err.message)
-        if (m === 'HELP') {
-            process.exit(0)
-        }
-        if (m !== 'BAD_API') {
-            console.error(err.stack || err)
-        }
-        process.exit(1)
-    })

+ 0 - 191
scripts/proxy-u-xxoo365-test.js

@@ -1,191 +0,0 @@
-#!/usr/bin/env node
-'use strict'
-
-/**
- * 测试通过 HTTP 代理访问 u.xxoo365.top(HTTPS)。
- *
- * 用法(项目根目录执行):
- *   node scripts/proxy-u-xxoo365-test.js direct
- *   node scripts/proxy-u-xxoo365-test.js proxy 103.217.191.15:30104
- *   node scripts/proxy-u-xxoo365-test.js qg-fetch
- *
- * 可选环境变量:
- *   TEST_URL=https://u.xxoo365.top/
- *   TEST_TIMEOUT_MS=20000
- *   TEST_METHOD=GET              # GET / HEAD
- *   TEST_PATH=/health            # 会拼到 TEST_URL 的 origin 后
- *   QG_AREA=... QG_AREA_EX=... QG_ISP=1|2|3 QG_DISTINCT=0|1
- */
-
-const fs = require('fs')
-const path = require('path')
-const axios = require('axios')
-const HttpsProxyAgent = require('https-proxy-agent')
-
-const QG_POOL_URL = 'https://share.proxy.qg.net/pool'
-const DEFAULT_BROWSER_UA =
-    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36'
-
-function readConfig() {
-    const cfgPath = path.join(__dirname, '..', 'config.json')
-    return JSON.parse(fs.readFileSync(cfgPath, 'utf8'))
-}
-
-function buildTargetUrl() {
-    const base = (process.env.TEST_URL || 'https://u.xxoo365.top/').trim()
-    const pathOverride = (process.env.TEST_PATH || '').trim()
-    if (!pathOverride) return base
-    const u = new URL(base)
-    u.pathname = pathOverride.startsWith('/') ? pathOverride : `/${pathOverride}`
-    return u.toString()
-}
-
-function normalizeMethod() {
-    const m = (process.env.TEST_METHOD || 'GET').toUpperCase()
-    return m === 'HEAD' ? 'HEAD' : 'GET'
-}
-
-function buildBrowserHeaders(url, method) {
-    const u = new URL(url)
-    const ua = String(process.env.TEST_UA || DEFAULT_BROWSER_UA).trim()
-    const acceptLang = String(process.env.TEST_ACCEPT_LANGUAGE || 'zh-CN,zh;q=0.9,en;q=0.8').trim()
-    const accept =
-        method === 'HEAD'
-            ? String(process.env.TEST_ACCEPT || '*/*').trim()
-            : String(
-                  process.env.TEST_ACCEPT ||
-                      'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8'
-              ).trim()
-    return {
-        Accept: accept,
-        'Accept-Language': acceptLang,
-        'Cache-Control': 'no-cache',
-        Pragma: 'no-cache',
-        DNT: '1',
-        'Sec-Fetch-Dest': 'document',
-        'Sec-Fetch-Mode': 'navigate',
-        'Sec-Fetch-Site': 'none',
-        'Sec-Fetch-User': '?1',
-        'Upgrade-Insecure-Requests': '1',
-        'User-Agent': ua,
-        Referer: String(process.env.TEST_REFERER || `${u.origin}/`).trim()
-    }
-}
-
-function toProxyUrl(server, user, pass) {
-    const [host, portRaw] = String(server || '').trim().split(':')
-    const port = Number(portRaw)
-    if (!host || !Number.isFinite(port)) {
-        throw new Error(`代理地址非法: ${server}`)
-    }
-    let auth = ''
-    if (user) {
-        auth = `${encodeURIComponent(user)}:${encodeURIComponent(pass || '')}@`
-    }
-    return `http://${auth}${host}:${port}`
-}
-
-async function fetchProxyFromQg(cfg) {
-    const q = cfg.qgChannelProxy || {}
-    const key = String(q.extractKey || '').trim()
-    if (!key) {
-        throw new Error('config.json 缺少 qgChannelProxy.extractKey')
-    }
-    const params = { key, num: 1 }
-    const area = String(process.env.QG_AREA || '').trim()
-    const areaEx = String(process.env.QG_AREA_EX || '').trim()
-    if (area) params.area = area
-    if (areaEx) params.area_ex = areaEx
-    if (['1', '2', '3'].includes(String(process.env.QG_ISP || ''))) {
-        params.isp = Number(process.env.QG_ISP)
-    }
-    params.distinct = String(process.env.QG_DISTINCT || '1') !== '0'
-
-    const res = await axios.get(QG_POOL_URL, {
-        params,
-        timeout: 20000,
-        proxy: false,
-        validateStatus: () => true
-    })
-    const body = res.data || {}
-    if (body.code !== 'SUCCESS' || !Array.isArray(body.data) || !body.data[0]?.server) {
-        throw new Error(`青果 /pool 失败: ${body.code || JSON.stringify(body).slice(0, 180)}`)
-    }
-    return {
-        server: body.data[0].server,
-        proxy_ip: body.data[0].proxy_ip || null,
-        deadline: body.data[0].deadline || null,
-        request_id: body.request_id || null
-    }
-}
-
-async function probe(label, requestConfig) {
-    const timeout = Number(process.env.TEST_TIMEOUT_MS || 20000)
-    const url = buildTargetUrl()
-    const method = normalizeMethod()
-    const headers = buildBrowserHeaders(url, method)
-    const t0 = Date.now()
-    console.log(`\n=== ${label} ===`)
-    console.log('REQUEST:', method, url)
-
-    try {
-        const res = await axios({
-            url,
-            method,
-            timeout,
-            validateStatus: () => true,
-            headers,
-            ...requestConfig
-        })
-        const ms = Date.now() - t0
-        console.log('RESULT: OK', `${ms}ms`, 'HTTP', res.status)
-        if (method !== 'HEAD') {
-            const body = typeof res.data === 'string' ? res.data : JSON.stringify(res.data)
-            console.log('BODY_PREVIEW:', body.slice(0, 200).replace(/\s+/g, ' '))
-        }
-    } catch (e) {
-        const ms = Date.now() - t0
-        console.log('RESULT: FAIL', `${ms}ms`)
-        console.log('message:', e.message)
-        console.log('code:', e.code)
-        if (e.response) console.log('http_status:', e.response.status)
-    }
-}
-
-async function main() {
-    const mode = (process.argv[2] || 'direct').toLowerCase()
-    const cfg = readConfig()
-    const q = cfg.qgChannelProxy || {}
-    const user = String(process.env.QG_PROXY_USER || q.authUser || '').trim()
-    const pass = String(process.env.QG_PROXY_PASSWORD || q.authPassword || '').trim()
-    const rejectUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED !== '0'
-
-    if (mode === 'direct') {
-        await probe('直连', { proxy: false })
-        return
-    }
-
-    let server
-    if (mode === 'proxy') {
-        server = process.argv[3]
-        if (!server) throw new Error('proxy 模式需传 host:port')
-    } else if (mode === 'qg-fetch') {
-        const got = await fetchProxyFromQg(cfg)
-        server = got.server
-        console.log(
-            `[Qg] server=${got.server} proxy_ip=${got.proxy_ip || '—'} deadline=${got.deadline || '—'} request_id=${got.request_id || '—'}`
-        )
-    } else {
-        throw new Error('模式仅支持: direct | proxy <host:port> | qg-fetch')
-    }
-
-    const proxyUrl = toProxyUrl(server, user, pass)
-    const httpsAgent = new HttpsProxyAgent(proxyUrl, { rejectUnauthorized })
-    await probe(`代理 ${server}`, { proxy: false, httpsAgent })
-}
-
-main().catch(err => {
-    console.error(err.stack || err)
-    process.exit(1)
-})
-