Skip to content

Commit f069fbb

Browse files
committed
feat: Egern Hysteria 2 支持 bandwidth; Hysteria 2 URI 支持解析 upmbps 和 downmbps
1 parent c07ca12 commit f069fbb

5 files changed

Lines changed: 59 additions & 1 deletion

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.23.10",
3+
"version": "2.23.11",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"packageManager": "pnpm@11.0.9",

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,6 +2104,12 @@ function URI_Hysteria2() {
21042104
if (/^\d+$/.test(keepalive)) {
21052105
proxy['keepalive'] = parseInt(`${keepalive}`, 10);
21062106
}
2107+
if (params.upmbps) {
2108+
proxy.up = params.upmbps;
2109+
}
2110+
if (params.downmbps) {
2111+
proxy.down = params.downmbps;
2112+
}
21072113

21082114
return proxy;
21092115
};

backend/src/core/proxy-utils/producers/egern.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ export default function Egern_Producer() {
181181
server: proxy.server,
182182
port: proxy.port,
183183
auth: proxy.password,
184+
...(isPresent(proxy, 'up')
185+
? {
186+
bandwidth: parseInt(
187+
`${proxy.up}`.match(/\d+/)?.[0] || 0,
188+
10,
189+
),
190+
}
191+
: {}),
184192
tfo: proxy.tfo || proxy['fast-open'],
185193
udp_relay:
186194
proxy.udp || proxy.udp_relay || proxy.udp_relay,

backend/src/test/proxy-parsers/uri.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,22 @@ describe('Proxy URI parser coverage', function () {
496496
});
497497
});
498498

499+
it('parses Hysteria2 URI throughput fields', function () {
500+
const proxy = parseOne(
501+
'hy2://hy2-secret@hy2.example.com:443?upmbps=50&downmbps=100#Hy2%20Throughput',
502+
);
503+
504+
expectSubset(proxy, {
505+
type: 'hysteria2',
506+
name: 'Hy2 Throughput',
507+
server: 'hy2.example.com',
508+
port: 443,
509+
password: 'hy2-secret',
510+
up: '50',
511+
down: '100',
512+
});
513+
});
514+
499515
it('rejects Hysteria2 salamander obfs without obfs-password', function () {
500516
const proxies = parseAll(
501517
'hy2://hy2-secret@hy2.example.com:443?obfs=salamander#Hy2%20Missing%20Password',

backend/src/test/proxy-producers/structured.spec.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,34 @@ describe('Proxy structured producers', function () {
13411341
});
13421342
});
13431343

1344+
it('emits Egern Hysteria2 upload bandwidth as bandwidth', function () {
1345+
const proxy = {
1346+
type: 'hysteria2',
1347+
name: 'Egern Hysteria2 Bandwidth',
1348+
server: 'hy2.example.com',
1349+
port: 443,
1350+
password: 'secret',
1351+
up: '50 Mbps',
1352+
sni: 'peer.example.com',
1353+
};
1354+
1355+
const internal = produceInternal('Egern', proxy)[0];
1356+
const external = loadProducedYaml('Egern', proxy);
1357+
1358+
expectSubset(internal, {
1359+
hysteria2: {
1360+
name: 'Egern Hysteria2 Bandwidth',
1361+
bandwidth: 50,
1362+
},
1363+
});
1364+
expectSubset(external.proxies[0], {
1365+
hysteria2: {
1366+
name: 'Egern Hysteria2 Bandwidth',
1367+
bandwidth: 50,
1368+
},
1369+
});
1370+
});
1371+
13441372
it('keeps Mihomo HTTP headers and filters unsupported h2-connect/trusttunnel header variants', function () {
13451373
const { result, errors } = captureErrors(() =>
13461374
produceInternal('Mihomo', [

0 commit comments

Comments
 (0)