feat: hysteria

This commit is contained in:
xream 2023-08-25 16:19:00 +08:00
parent 9cbbd0e86f
commit 4c6ba2cdc8
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
6 changed files with 50 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.14.26", "version": "2.14.27",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {

View File

@ -188,6 +188,8 @@ function lastParse(proxy) {
if (proxy.network === 'tcp') { if (proxy.network === 'tcp') {
delete proxy.network; delete proxy.network;
} }
}
if (['trojan', 'tuic', 'hysteria'].includes(proxy.type)) {
proxy.tls = true; proxy.tls = true;
} }
if (proxy.tls && !proxy.sni) { if (proxy.tls && !proxy.sni) {

View File

@ -344,6 +344,7 @@ function Clash_All() {
'trojan', 'trojan',
'tuic', 'tuic',
'vless', 'vless',
'hysteria',
].includes(proxy.type) ].includes(proxy.type)
) { ) {
throw new Error( throw new Error(

View File

@ -74,7 +74,9 @@ export default function Clash_Producer() {
proxy['http-opts'].headers.Host = [httpHost]; proxy['http-opts'].headers.Host = [httpHost];
} }
} }
if (['trojan', 'tuic', 'hysteria'].includes(proxy.type)) {
delete proxy.tls;
}
delete proxy['tls-fingerprint']; delete proxy['tls-fingerprint'];
return ' - ' + JSON.stringify(proxy) + '\n'; return ' - ' + JSON.stringify(proxy) + '\n';
}) })

View File

@ -49,6 +49,12 @@ export default function Stash_Producer() {
} else { } else {
proxy.alpn = ['h3']; proxy.alpn = ['h3'];
} }
if (
isPresent(proxy, 'tfo') &&
!isPresent(proxy, 'fast-open')
) {
proxy['fast-open'] = proxy.tfo;
}
// https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/adapter/outbound/tuic.go#L197 // https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/adapter/outbound/tuic.go#L197
if ( if (
(!proxy.token || proxy.token.length === 0) && (!proxy.token || proxy.token.length === 0) &&
@ -56,6 +62,18 @@ export default function Stash_Producer() {
) { ) {
proxy.version = 5; proxy.version = 5;
} }
} else if (proxy.type === 'hysteria') {
if (isPresent(proxy, 'alpn')) {
proxy.alpn = Array.isArray(proxy.alpn)
? proxy.alpn
: [proxy.alpn];
}
if (
isPresent(proxy, 'tfo') &&
!isPresent(proxy, 'fast-open')
) {
proxy['fast-open'] = proxy.tfo;
}
} }
if ( if (
@ -78,6 +96,10 @@ export default function Stash_Producer() {
} }
} }
if (['trojan', 'tuic', 'hysteria'].includes(proxy.type)) {
delete proxy.tls;
}
delete proxy['tls-fingerprint']; delete proxy['tls-fingerprint'];
return ' - ' + JSON.stringify(proxy) + '\n'; return ' - ' + JSON.stringify(proxy) + '\n';
}) })

View File

@ -61,6 +61,12 @@ export default function Stash_Producer() {
} else { } else {
proxy.alpn = ['h3']; proxy.alpn = ['h3'];
} }
if (
isPresent(proxy, 'tfo') &&
!isPresent(proxy, 'fast-open')
) {
proxy['fast-open'] = proxy.tfo;
}
// https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/adapter/outbound/tuic.go#L197 // https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/adapter/outbound/tuic.go#L197
if ( if (
(!proxy.token || proxy.token.length === 0) && (!proxy.token || proxy.token.length === 0) &&
@ -68,6 +74,18 @@ export default function Stash_Producer() {
) { ) {
proxy.version = 5; proxy.version = 5;
} }
} else if (proxy.type === 'hysteria') {
if (isPresent(proxy, 'alpn')) {
proxy.alpn = Array.isArray(proxy.alpn)
? proxy.alpn
: [proxy.alpn];
}
if (
isPresent(proxy, 'tfo') &&
!isPresent(proxy, 'fast-open')
) {
proxy['fast-open'] = proxy.tfo;
}
} }
if ( if (
@ -89,7 +107,9 @@ export default function Stash_Producer() {
proxy['http-opts'].headers.Host = [httpHost]; proxy['http-opts'].headers.Host = [httpHost];
} }
} }
if (['trojan', 'tuic', 'hysteria'].includes(proxy.type)) {
delete proxy.tls;
}
delete proxy['tls-fingerprint']; delete proxy['tls-fingerprint'];
return ' - ' + JSON.stringify(proxy) + '\n'; return ' - ' + JSON.stringify(proxy) + '\n';
}) })