Skip to content

Commit

Permalink
feat: sing-box 支持 anytls
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Feb 23, 2025
1 parent 7e75031 commit d53947d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
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.16.53",
"version": "2.16.55",
"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 @@ -23,6 +23,7 @@ import { produceArtifact } from '@/restful/sync';
import { getFlag, removeFlag, getISO, MMDB } from '@/utils/geo';
import Gist from '@/utils/gist';
import { isPresent } from './producers/utils';
import { doh } from '@/utils/dns';

function preprocess(raw) {
for (const processor of PROXY_PREPROCESSORS) {
Expand Down Expand Up @@ -327,6 +328,7 @@ export const ProxyUtils = {
Gist,
download,
isValidUUID,
doh,
};

function tryParse(parser, line) {
Expand Down
20 changes: 20 additions & 0 deletions backend/src/core/proxy-utils/producers/sing-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,23 @@ const tuic5Parser = (proxy = {}) => {
smuxParser(proxy.smux, parsedProxy);
return parsedProxy;
};
const anytlsParser = (proxy = {}) => {
const parsedProxy = {
tag: proxy.name,
type: 'anytls',
server: proxy.server,
server_port: parseInt(`${proxy.port}`, 10),
password: proxy.password,
tls: { enabled: true, server_name: proxy.server, insecure: false },
};
if (/^\d+$/.test(proxy['idle-session-check-interval']))
parsedProxy.idle_session_check_interval = `${proxy['idle-session-check-interval']}s`;
if (/^\d+$/.test(proxy['idle-session-timeout']))
parsedProxy.idle_session_timeout = `${proxy['idle-session-timeout']}s`;
detourParser(proxy, parsedProxy);
tlsParser(proxy, parsedProxy);
return parsedProxy;
};

const wireguardParser = (proxy = {}) => {
const local_address = ['ip', 'ipv6']
Expand Down Expand Up @@ -829,6 +846,9 @@ export default function singbox_Producer() {
case 'wireguard':
list.push(wireguardParser(proxy));
break;
case 'anytls':
list.push(anytlsParser(proxy));
break;
default:
throw new Error(
`Platform sing-box does not support proxy type: ${proxy.type}`,
Expand Down

0 comments on commit d53947d

Please sign in to comment.