fix(user-secret): 青果链接改官方口径 share.proxy.qg.net 的 key+pwd 查询串
用户明确:青果只做密码鉴权档,白名单档不做。拼装规则随之改为 https://share.proxy.qg.net/get?key=..&pwd=..,不再用 userinfo。
This commit is contained in:
@@ -1,25 +1,23 @@
|
||||
/**
|
||||
* 青果提取链接的拼装(唯一出处)。
|
||||
*
|
||||
* 青果没有「提取链接」可给用户填:用户只给 Authkey / Authpwd,链接由这里拼
|
||||
* (2026-10-31 用户拍板)。口径:`https://overseas.proxy.qg.net/get?key=<Authkey>&format=json`。
|
||||
* 青果没有「提取链接」可给用户填:用户只给 key(Authkey)与 pwd(Authpwd),
|
||||
* 链接由这里拼(2026-10-31 用户拍板)。青果官方口径(只做密码鉴权档):
|
||||
* `https://share.proxy.qg.net/get?key=<key>&pwd=<pwd>`
|
||||
* 白名单鉴权档不做(用户明确不需要),所以这里不会在缺 pwd 时去猜白名单路径。
|
||||
*
|
||||
* Authkey/Authpwd 额外放在 userinfo 里——青果返回的是隧道端点(`server: host:port`),
|
||||
* 连接它要做 Basic 认证,而服务端商标检测(16890)只收得到这一条 proxy_url,
|
||||
* 没有第二个传凭据的通道。空 Authkey 返回空串:没有 key 就没有可提取的东西,
|
||||
* 别拼一条必然失败的链接。
|
||||
* 为什么要拼而不是让用户填:青果产品页只给 key/pwd 两个值,没有可复制的链接;
|
||||
* 而服务端的商标检测(16890)只认 proxy_url,拼不出来就等于「填了账密仍被判未配置代理」。
|
||||
*
|
||||
* ⚠ 本文件保持**零依赖**:`node --test` 不认 Vite 的 `@/` 别名,带别名的模块
|
||||
* 进不了 tests/*.test.ts,这条拼装规则就没法被用例钉住。
|
||||
*/
|
||||
export const QINGGUO_EXTRACT_URL = 'https://overseas.proxy.qg.net/get'
|
||||
export const QINGGUO_EXTRACT_URL = 'https://share.proxy.qg.net/get'
|
||||
|
||||
export function composeQingguoLink(account: string, password: string): string {
|
||||
const key = (account || '').trim()
|
||||
if (!key) return ''
|
||||
const userinfo = password
|
||||
? `${encodeURIComponent(key)}:${encodeURIComponent(password)}@`
|
||||
: ''
|
||||
const base = `${QINGGUO_EXTRACT_URL.replace('https://', `https://${userinfo}`)}`
|
||||
return `${base}?key=${encodeURIComponent(key)}&format=json`
|
||||
const pwd = (password || '').trim()
|
||||
const query = `key=${encodeURIComponent(key)}` + (pwd ? `&pwd=${encodeURIComponent(pwd)}` : '')
|
||||
return `${QINGGUO_EXTRACT_URL}?${query}`
|
||||
}
|
||||
|
||||
@@ -3,27 +3,25 @@ import assert from 'node:assert/strict'
|
||||
import { composeQingguoLink, QINGGUO_EXTRACT_URL } from '../src/shared/utils/qingguo-link.ts'
|
||||
|
||||
/**
|
||||
* 青果没有「提取链接」可填,用户只给 Authkey/Authpwd,链接必须由前端拼出来
|
||||
* (2026-10-31 用户拍板)。拼不出来或拼错,用户就会在「填了账密」之后仍被
|
||||
* 商标检测的前置检查判成「未配置代理」——这正是 2026-10-31 用户报的那个问题。
|
||||
* 青果没有「提取链接」可填,用户只给 key(Authkey)/ pwd(Authpwd),链接必须由前端拼
|
||||
* (2026-10-31 用户拍板;官方口径 `https://share.proxy.qg.net/get?key=…&pwd=…`)。
|
||||
* 拼不出来或拼错,用户就会在「填了账密」之后仍被商标检测的前置检查判成「未配置代理」。
|
||||
*/
|
||||
test('青果只有 Authkey 时拼出带 key 的提取链接', () => {
|
||||
const link = composeQingguoLink(' 40F79A90 ', '')
|
||||
assert.equal(link, `${QINGGUO_EXTRACT_URL}?key=40F79A90&format=json`)
|
||||
test('青果按密码鉴权拼出 key+pwd 的提取链接', () => {
|
||||
assert.equal(composeQingguoLink('40F79A90', 'S3cret'),
|
||||
`${QINGGUO_EXTRACT_URL}?key=40F79A90&pwd=S3cret`)
|
||||
})
|
||||
|
||||
test('青果 Authkey+Authpwd 必须把账密放进 userinfo(隧道 Basic 认证没有第二个通道)', () => {
|
||||
const link = composeQingguoLink('40F79A90', 'Sec@ret:1')
|
||||
assert.ok(link.startsWith('https://40F79A90:Sec%40ret%3A1@overseas.proxy.qg.net/get?'), link)
|
||||
assert.ok(link.endsWith('&format=json'), link)
|
||||
test('只有 key 时也拼得出来(不猜白名单档,缺 pwd 就只带 key)', () => {
|
||||
assert.equal(composeQingguoLink(' 40F79A90 ', ''), `${QINGGUO_EXTRACT_URL}?key=40F79A90`)
|
||||
})
|
||||
|
||||
test('没填 Authkey 就不拼链接(空串=没配置,不许拼一条必然失败的链接)', () => {
|
||||
test('没填 key 就不拼链接(空串=没配置,不许拼一条必然失败的链接)', () => {
|
||||
assert.equal(composeQingguoLink('', 'pwd'), '')
|
||||
assert.equal(composeQingguoLink(' ', 'pwd'), '')
|
||||
})
|
||||
|
||||
test('key 里的特殊字符要编码,不能把查询串拼坏', () => {
|
||||
const link = composeQingguoLink('a&b=c', '')
|
||||
assert.ok(link.endsWith('?key=a%26b%3Dc&format=json'), link)
|
||||
test('key/pwd 里的特殊字符要编码,不能把查询串拼坏', () => {
|
||||
const link = composeQingguoLink('a&b=c', 'p@ss:1')
|
||||
assert.ok(link.endsWith('?key=a%26b%3Dc&pwd=p%40ss%3A1'), link)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user