mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-28 15:33:47 +00:00
feat: Egern Hysteria 2 支持 bandwidth; Hysteria 2 URI 支持解析 upmbps 和 downmbps
This commit is contained in:
5 files changed
+59
-1
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.23.10",
|
||||
"version": "2.23.11",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||
"main": "src/main.js",
|
||||
"packageManager": "pnpm@11.0.9",
|
||||
|
||||
@@ -2104,6 +2104,12 @@ function URI_Hysteria2() {
|
||||
if (/^\d+$/.test(keepalive)) {
|
||||
proxy['keepalive'] = parseInt(`${keepalive}`, 10);
|
||||
}
|
||||
if (params.upmbps) {
|
||||
proxy.up = params.upmbps;
|
||||
}
|
||||
if (params.downmbps) {
|
||||
proxy.down = params.downmbps;
|
||||
}
|
||||
|
||||
return proxy;
|
||||
};
|
||||
|
||||
@@ -181,6 +181,14 @@ export default function Egern_Producer() {
|
||||
server: proxy.server,
|
||||
port: proxy.port,
|
||||
auth: proxy.password,
|
||||
...(isPresent(proxy, 'up')
|
||||
? {
|
||||
bandwidth: parseInt(
|
||||
`${proxy.up}`.match(/\d+/)?.[0] || 0,
|
||||
10,
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
tfo: proxy.tfo || proxy['fast-open'],
|
||||
udp_relay:
|
||||
proxy.udp || proxy.udp_relay || proxy.udp_relay,
|
||||
|
||||
@@ -496,6 +496,22 @@ describe('Proxy URI parser coverage', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('parses Hysteria2 URI throughput fields', function () {
|
||||
const proxy = parseOne(
|
||||
'hy2://hy2-secret@hy2.example.com:443?upmbps=50&downmbps=100#Hy2%20Throughput',
|
||||
);
|
||||
|
||||
expectSubset(proxy, {
|
||||
type: 'hysteria2',
|
||||
name: 'Hy2 Throughput',
|
||||
server: 'hy2.example.com',
|
||||
port: 443,
|
||||
password: 'hy2-secret',
|
||||
up: '50',
|
||||
down: '100',
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects Hysteria2 salamander obfs without obfs-password', function () {
|
||||
const proxies = parseAll(
|
||||
'hy2://hy2-secret@hy2.example.com:443?obfs=salamander#Hy2%20Missing%20Password',
|
||||
|
||||
@@ -1341,6 +1341,34 @@ describe('Proxy structured producers', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('emits Egern Hysteria2 upload bandwidth as bandwidth', function () {
|
||||
const proxy = {
|
||||
type: 'hysteria2',
|
||||
name: 'Egern Hysteria2 Bandwidth',
|
||||
server: 'hy2.example.com',
|
||||
port: 443,
|
||||
password: 'secret',
|
||||
up: '50 Mbps',
|
||||
sni: 'peer.example.com',
|
||||
};
|
||||
|
||||
const internal = produceInternal('Egern', proxy)[0];
|
||||
const external = loadProducedYaml('Egern', proxy);
|
||||
|
||||
expectSubset(internal, {
|
||||
hysteria2: {
|
||||
name: 'Egern Hysteria2 Bandwidth',
|
||||
bandwidth: 50,
|
||||
},
|
||||
});
|
||||
expectSubset(external.proxies[0], {
|
||||
hysteria2: {
|
||||
name: 'Egern Hysteria2 Bandwidth',
|
||||
bandwidth: 50,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps Mihomo HTTP headers and filters unsupported h2-connect/trusttunnel header variants', function () {
|
||||
const { result, errors } = captureErrors(() =>
|
||||
produceInternal('Mihomo', [
|
||||
|
||||
Reference in new issue
Block a user