mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-27 06:43:08 +00:00
feat: 完善 Shadowsocks URI extra 处理
This commit is contained in:
4 files changed
+28
-8
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.44.6",
|
||||
"version": "2.44.7",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||
"main": "src/main.js",
|
||||
"packageManager": "pnpm@11.0.9",
|
||||
|
||||
@@ -392,13 +392,16 @@ function URI_SS() {
|
||||
if (params.mode) {
|
||||
proxy._mode = params.mode;
|
||||
}
|
||||
if (params.extra) {
|
||||
proxy._extra = params.extra;
|
||||
}
|
||||
if (Object.keys(opts).length > 0) {
|
||||
_.set(proxy, params.security + '-opts', opts);
|
||||
}
|
||||
}
|
||||
if (
|
||||
params.extra &&
|
||||
(proxy.network === 'xhttp' || params.security === 'reality')
|
||||
) {
|
||||
proxy._extra = params.extra;
|
||||
}
|
||||
}
|
||||
|
||||
proxy.udp = ![false, 0, '0', 'false', 'off'].includes(
|
||||
|
||||
@@ -980,7 +980,10 @@ export default function URI_Producer() {
|
||||
let ssSpx = '';
|
||||
let ssSecurity = proxy.tls ? '&security=tls' : '';
|
||||
let ssMode = '';
|
||||
let ssExtra = '';
|
||||
const ssExtra =
|
||||
proxy._extra && (ssIsReality || proxy.network === 'xhttp')
|
||||
? `&extra=${encodeURIComponent(proxy._extra)}`
|
||||
: '';
|
||||
if (ssIsReality) {
|
||||
ssSecurity = `&security=reality`;
|
||||
const publicKey = proxy['reality-opts']?.['public-key'];
|
||||
@@ -995,9 +998,6 @@ export default function URI_Producer() {
|
||||
if (spiderX) {
|
||||
ssSpx = `&spx=${encodeURIComponent(spiderX)}`;
|
||||
}
|
||||
if (proxy._extra) {
|
||||
ssExtra = `&extra=${encodeURIComponent(proxy._extra)}`;
|
||||
}
|
||||
if (proxy._mode) {
|
||||
ssMode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
||||
}
|
||||
|
||||
@@ -2540,6 +2540,23 @@ describe('Proxy text producers', function () {
|
||||
);
|
||||
});
|
||||
|
||||
it('preserves XHTTP extra on shadowsocks URI round-trips', function () {
|
||||
const userInfo = Base64.encode('aes-128-gcm:example-password');
|
||||
const extra = JSON.stringify({
|
||||
xmux: { maxConcurrency: 8, cMaxReuseTimes: 32 },
|
||||
headers: { 'X-Test': 'a+b=c&d#e' },
|
||||
});
|
||||
const input = `ss://${userInfo}@ss.example.com:443?type=xhttp&security=tls&path=%2Fxhttp&extra=${encodeURIComponent(
|
||||
extra,
|
||||
)}#SS%20XHTTP`;
|
||||
const [proxy] = ProxyUtils.parse(input);
|
||||
expect(proxy._extra).to.equal(extra);
|
||||
|
||||
const output = produceExternal('URI', proxy);
|
||||
expect(new URL(output).searchParams.get('extra')).to.equal(extra);
|
||||
expect(Base64.decode(produceExternal('V2Ray', proxy))).to.equal(output);
|
||||
});
|
||||
|
||||
it('produces URI shadowsocks httpupgrade links with early data metadata', function () {
|
||||
const output = produceExternal('URI', {
|
||||
type: 'ss',
|
||||
|
||||
Reference in new issue
Block a user