Skip to content

Commit 82b60f1

Browse files
committed
feat: sing-box 支持 naive 出站
1 parent f9050e5 commit 82b60f1

File tree

8 files changed

+61
-5
lines changed

8 files changed

+61
-5
lines changed

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.20.51",
3+
"version": "2.20.52",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ function lastParse(proxy) {
453453
'hysteria2',
454454
'juicity',
455455
'anytls',
456+
'naive',
456457
].includes(proxy.type)
457458
) {
458459
proxy.tls = true;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,7 @@ function Clash_All() {
11741174
}
11751175
if (
11761176
![
1177+
'naive',
11771178
'anytls',
11781179
'mieru',
11791180
'sudoku',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export default function Clash_Producer() {
169169
'hysteria2',
170170
'juicity',
171171
'anytls',
172+
'naive',
172173
].includes(proxy.type)
173174
) {
174175
delete proxy.tls;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function ClashMeta_Producer() {
1616
if (opts['include-unsupported-proxy']) return true;
1717
if (proxy.type === 'snell' && proxy.version >= 4) {
1818
return false;
19-
} else if (['juicity'].includes(proxy.type)) {
19+
} else if (['juicity', 'naive'].includes(proxy.type)) {
2020
return false;
2121
} else if (
2222
['ss'].includes(proxy.type) &&
@@ -245,6 +245,7 @@ export default function ClashMeta_Producer() {
245245
'hysteria2',
246246
'juicity',
247247
'anytls',
248+
'naive',
248249
].includes(proxy.type)
249250
) {
250251
delete proxy.tls;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function Shadowrocket_Producer() {
99
if (opts['include-unsupported-proxy']) return true;
1010
if (proxy.type === 'snell' && proxy.version >= 4) {
1111
return false;
12-
} else if (['mieru', 'sudoku'].includes(proxy.type)) {
12+
} else if (['mieru', 'sudoku', 'naive'].includes(proxy.type)) {
1313
return false;
1414
}
1515
return true;
@@ -213,6 +213,7 @@ export default function Shadowrocket_Producer() {
213213
'hysteria2',
214214
'juicity',
215215
'anytls',
216+
'naive',
216217
].includes(proxy.type)
217218
) {
218219
delete proxy.tls;

backend/src/core/proxy-utils/producers/sing-box.js

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,23 @@ const socks5Parser = (proxy = {}) => {
366366
type: 'socks',
367367
server: proxy.server,
368368
server_port: parseInt(`${proxy.port}`, 10),
369-
password: proxy.password,
370369
version: '5',
371370
};
372371
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
373372
throw 'invalid port';
374373
if (proxy.username) parsedProxy.username = proxy.username;
375374
if (proxy.password) parsedProxy.password = proxy.password;
376375
if (proxy.uot) parsedProxy.udp_over_tcp = true;
377-
if (proxy['udp-over-tcp']) parsedProxy.udp_over_tcp = true;
376+
if (proxy['udp-over-tcp']) {
377+
parsedProxy.udp_over_tcp = {
378+
enabled: true,
379+
version:
380+
!proxy['udp-over-tcp-version'] ||
381+
proxy['udp-over-tcp-version'] === 1
382+
? 1
383+
: 2,
384+
};
385+
}
378386
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
379387
networkParser(proxy, parsedProxy);
380388
tfoParser(proxy, parsedProxy);
@@ -625,6 +633,45 @@ const trojanParser = (proxy = {}) => {
625633
ipVersionParser(proxy, parsedProxy);
626634
return parsedProxy;
627635
};
636+
const naiveParser = (proxy = {}) => {
637+
const parsedProxy = {
638+
tag: proxy.name,
639+
type: 'naive',
640+
server: proxy.server,
641+
server_port: parseInt(`${proxy.port}`, 10),
642+
tls: { enabled: true, server_name: proxy.server, insecure: false },
643+
};
644+
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
645+
throw 'invalid port';
646+
if (proxy.username) parsedProxy.username = proxy.username;
647+
if (proxy.password) parsedProxy.password = proxy.password;
648+
if (proxy.uot) parsedProxy.udp_over_tcp = true;
649+
if (proxy['udp-over-tcp']) {
650+
parsedProxy.udp_over_tcp = {
651+
enabled: true,
652+
version:
653+
!proxy['udp-over-tcp-version'] ||
654+
proxy['udp-over-tcp-version'] === 1
655+
? 1
656+
: 2,
657+
};
658+
}
659+
const insecure_concurrency = parseInt(
660+
`${proxy['insecure-concurrency']}`,
661+
10,
662+
);
663+
if (Number.isInteger(insecure_concurrency) && insecure_concurrency >= 0)
664+
parsedProxy.insecure_concurrency = insecure_concurrency;
665+
if (proxy['extra-headers'])
666+
parsedProxy.extra_headers = proxy['extra-headers'];
667+
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
668+
tfoParser(proxy, parsedProxy);
669+
detourParser(proxy, parsedProxy);
670+
tlsParser(proxy, parsedProxy);
671+
smuxParser(proxy.smux, parsedProxy);
672+
ipVersionParser(proxy, parsedProxy);
673+
return parsedProxy;
674+
};
628675
const hysteriaParser = (proxy = {}) => {
629676
const parsedProxy = {
630677
tag: proxy.name,
@@ -941,6 +988,9 @@ export default function singbox_Producer() {
941988
);
942989
}
943990
break;
991+
case 'naive':
992+
list.push(naiveParser(proxy));
993+
break;
944994
case 'hysteria':
945995
list.push(hysteriaParser(proxy));
946996
break;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export default function Stash_Producer() {
273273
'hysteria2',
274274
'juicity',
275275
'anytls',
276+
'naive',
276277
].includes(proxy.type)
277278
) {
278279
delete proxy.tls;

0 commit comments

Comments
 (0)