Skip to content

Commit

Permalink
feat: sing-box includeUnsupportedProxy 开启支持 Hysteria2 端口跳跃
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Dec 29, 2024
1 parent 222551e commit 5fce134
Show file tree
Hide file tree
Showing 2 changed files with 18 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.15.3",
"version": "2.15.4",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
19 changes: 17 additions & 2 deletions backend/src/core/proxy-utils/producers/sing-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ const hysteriaParser = (proxy = {}) => {
smuxParser(proxy.smux, parsedProxy);
return parsedProxy;
};
const hysteria2Parser = (proxy = {}) => {
const hysteria2Parser = (proxy = {}, includeUnsupportedProxy) => {
const parsedProxy = {
tag: proxy.name,
type: 'hysteria2',
Expand All @@ -580,6 +580,16 @@ const hysteria2Parser = (proxy = {}) => {
};
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (includeUnsupportedProxy) {
if (proxy['hop-interval'])
parsedProxy.hop_interval = /^\d+$/.test(proxy['hop-interval'])
? `${proxy['hop-interval']}s`
: proxy['hop-interval'];
if (proxy['ports'])
parsedProxy.server_ports = proxy['ports']
.split(/\s*,\s*/)
.map((p) => p.replace(/\s*-\s*/, ':'));
}
if (proxy.up) parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
if (proxy.down) parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
if (proxy.obfs === 'salamander') parsedProxy.obfs.type = 'salamander';
Expand Down Expand Up @@ -790,7 +800,12 @@ export default function singbox_Producer() {
list.push(hysteriaParser(proxy));
break;
case 'hysteria2':
list.push(hysteria2Parser(proxy));
list.push(
hysteria2Parser(
proxy,
opts['include-unsupported-proxy'],
),
);
break;
case 'tuic':
if (!proxy.token || proxy.token.length === 0) {
Expand Down

0 comments on commit 5fce134

Please sign in to comment.