Skip to content

Commit

Permalink
feat: hysteria
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Aug 25, 2023
1 parent 9cbbd0e commit 4c6ba2c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.26",
"version": "2.14.27",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions backend/src/core/proxy-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ function lastParse(proxy) {
if (proxy.network === 'tcp') {
delete proxy.network;
}
}
if (['trojan', 'tuic', 'hysteria'].includes(proxy.type)) {
proxy.tls = true;
}
if (proxy.tls && !proxy.sni) {
Expand Down
1 change: 1 addition & 0 deletions backend/src/core/proxy-utils/parsers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ function Clash_All() {
'trojan',
'tuic',
'vless',
'hysteria',
].includes(proxy.type)
) {
throw new Error(
Expand Down
4 changes: 3 additions & 1 deletion backend/src/core/proxy-utils/producers/clash.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export default function Clash_Producer() {
proxy['http-opts'].headers.Host = [httpHost];
}
}

if (['trojan', 'tuic', 'hysteria'].includes(proxy.type)) {
delete proxy.tls;
}
delete proxy['tls-fingerprint'];
return ' - ' + JSON.stringify(proxy) + '\n';
})
Expand Down
22 changes: 22 additions & 0 deletions backend/src/core/proxy-utils/producers/shadowrocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,31 @@ export default function Stash_Producer() {
} else {
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
if (
(!proxy.token || proxy.token.length === 0) &&
!isPresent(proxy, 'version')
) {
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 (
Expand All @@ -78,6 +96,10 @@ export default function Stash_Producer() {
}
}

if (['trojan', 'tuic', 'hysteria'].includes(proxy.type)) {
delete proxy.tls;
}

delete proxy['tls-fingerprint'];
return ' - ' + JSON.stringify(proxy) + '\n';
})
Expand Down
22 changes: 21 additions & 1 deletion backend/src/core/proxy-utils/producers/stash.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,31 @@ export default function Stash_Producer() {
} else {
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
if (
(!proxy.token || proxy.token.length === 0) &&
!isPresent(proxy, 'version')
) {
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 (
Expand All @@ -89,7 +107,9 @@ export default function Stash_Producer() {
proxy['http-opts'].headers.Host = [httpHost];
}
}

if (['trojan', 'tuic', 'hysteria'].includes(proxy.type)) {
delete proxy.tls;
}
delete proxy['tls-fingerprint'];
return ' - ' + JSON.stringify(proxy) + '\n';
})
Expand Down

0 comments on commit 4c6ba2c

Please sign in to comment.