Skip to content

Commit 1e8dd78

Browse files
committed
feat: 支持 scMaxEachPostBytes 和 xmux
1 parent 8bcba35 commit 1e8dd78

3 files changed

Lines changed: 59 additions & 7 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.21.79",
3+
"version": "2.21.80",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/core/proxy-utils/parsers/index.js

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,14 +863,50 @@ function URI_VLESS() {
863863
'It is too complex to convert the downloadSettings in extra into the Mihomo format, so it is not supported.',
864864
);
865865
}
866-
proxy[`${proxy.network}-opts`] = {
867-
'no-grpc-header': extra?.['noGRPCHeader'],
868-
'x-padding-bytes': extra?.['xPaddingBytes'],
869-
// 'sc-max-each-post-bytes': extra['scMaxEachPostBytes'],
870-
// 'sc-min-posts-interval-ms': extra['scMinPostsIntervalMs'],
871-
mode: params.mode,
866+
const xhttpOpts = {
872867
...proxy[`${proxy.network}-opts`],
868+
mode: params.mode,
873869
};
870+
if (extra?.['noGRPCHeader'] === true) {
871+
xhttpOpts['no-grpc-header'] = true;
872+
}
873+
if (isNotBlank(extra?.['xPaddingBytes'])) {
874+
xhttpOpts['x-padding-bytes'] = extra['xPaddingBytes'];
875+
}
876+
if (
877+
typeof extra?.['scMaxEachPostBytes'] === 'number' &&
878+
Number.isFinite(extra['scMaxEachPostBytes'])
879+
) {
880+
xhttpOpts['sc-max-each-post-bytes'] =
881+
extra['scMaxEachPostBytes'];
882+
}
883+
if (isPlainObject(extra?.xmux)) {
884+
const reuseSettings = {};
885+
const xmuxFieldMap = {
886+
maxConnections: 'max-connections',
887+
maxConcurrency: 'max-concurrency',
888+
cMaxReuseTimes: 'c-max-reuse-times',
889+
hMaxRequestTimes: 'h-max-request-times',
890+
hMaxReusableSecs: 'h-max-reusable-secs',
891+
};
892+
for (const [sourceKey, targetKey] of Object.entries(
893+
xmuxFieldMap,
894+
)) {
895+
const value = extra.xmux[sourceKey];
896+
if (typeof value === 'string' && value !== '') {
897+
reuseSettings[targetKey] = value;
898+
} else if (
899+
typeof value === 'number' &&
900+
Number.isFinite(value)
901+
) {
902+
reuseSettings[targetKey] = `${value}`;
903+
}
904+
}
905+
if (Object.keys(reuseSettings).length > 0) {
906+
xhttpOpts['reuse-settings'] = reuseSettings;
907+
}
908+
}
909+
proxy[`${proxy.network}-opts`] = xhttpOpts;
874910
} else {
875911
proxy._mode = params.mode;
876912
}

backend/src/test/proxy-parsers/v2ray-and-platforms.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,14 @@ describe('VMess and VLESS parser coverage', function () {
376376
const extra = JSON.stringify({
377377
noGRPCHeader: true,
378378
xPaddingBytes: '64-128',
379+
scMaxEachPostBytes: 1000000,
380+
xmux: {
381+
maxConnections: 0,
382+
maxConcurrency: '16-32',
383+
cMaxReuseTimes: '64-128',
384+
hMaxRequestTimes: '600-900',
385+
hMaxReusableSecs: '1800-3000',
386+
},
379387
});
380388
const proxy = parseOne(
381389
`vless://${UUID}@vless-xhttp.example.com:443?type=xhttp&security=tls&host=cdn.example.com&path=%2Fxhttp&mode=stream-up&extra=${encodeURIComponent(extra)}#VLESS%20XHTTP`,
@@ -398,6 +406,14 @@ describe('VMess and VLESS parser coverage', function () {
398406
},
399407
'no-grpc-header': true,
400408
'x-padding-bytes': '64-128',
409+
'sc-max-each-post-bytes': 1000000,
410+
'reuse-settings': {
411+
'max-connections': '0',
412+
'max-concurrency': '16-32',
413+
'c-max-reuse-times': '64-128',
414+
'h-max-request-times': '600-900',
415+
'h-max-reusable-secs': '1800-3000',
416+
},
401417
},
402418
});
403419
});

0 commit comments

Comments
 (0)