Skip to content

Commit

Permalink
feat: 支持 dialer-proxy, detour
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Apr 14, 2024
1 parent cb66c8d commit 93a5ce6
Show file tree
Hide file tree
Showing 7 changed files with 45 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.14.281",
"version": "2.14.282",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions backend/src/core/proxy-utils/parsers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,9 @@ function Clash_All() {
if (proxy.fingerprint) {
proxy['tls-fingerprint'] = proxy.fingerprint;
}
if (proxy['dialer-proxy']) {
proxy['underlying-proxy'] = proxy['dialer-proxy'];
}

if (proxy['benchmark-url']) {
proxy['test-url'] = proxy['benchmark-url'];
Expand Down
6 changes: 6 additions & 0 deletions backend/src/core/proxy-utils/producers/clash.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ export default function Clash_Producer() {
proxy.fingerprint = proxy['tls-fingerprint'];
}
delete proxy['tls-fingerprint'];

if (proxy['underlying-proxy']) {
proxy['dialer-proxy'] = proxy['underlying-proxy'];
}
delete proxy['underlying-proxy'];

if (isPresent(proxy, 'tls') && typeof proxy.tls !== 'boolean') {
delete proxy.tls;
}
Expand Down
6 changes: 6 additions & 0 deletions backend/src/core/proxy-utils/producers/clashmeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ export default function ClashMeta_Producer() {
proxy.fingerprint = proxy['tls-fingerprint'];
}
delete proxy['tls-fingerprint'];

if (proxy['underlying-proxy']) {
proxy['dialer-proxy'] = proxy['underlying-proxy'];
}
delete proxy['underlying-proxy'];

if (isPresent(proxy, 'tls') && typeof proxy.tls !== 'boolean') {
delete proxy.tls;
}
Expand Down
6 changes: 6 additions & 0 deletions backend/src/core/proxy-utils/producers/shadowrocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ export default function ShadowRocket_Producer() {
proxy.fingerprint = proxy['tls-fingerprint'];
}
delete proxy['tls-fingerprint'];

if (proxy['underlying-proxy']) {
proxy['dialer-proxy'] = proxy['underlying-proxy'];
}
delete proxy['underlying-proxy'];

if (isPresent(proxy, 'tls') && typeof proxy.tls !== 'boolean') {
delete proxy.tls;
}
Expand Down
17 changes: 17 additions & 0 deletions backend/src/core/proxy-utils/producers/sing-box.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import ClashMeta_Producer from './clashmeta';
import $ from '@/core/app';

const detourParser = (proxy, parsedProxy) => {
if (proxy['dialer-proxy']) parsedProxy.detour = proxy['dialer-proxy'];
};
const tfoParser = (proxy, parsedProxy) => {
parsedProxy.tcp_fast_open = false;
if (proxy.tfo) parsedProxy.tcp_fast_open = true;
Expand Down Expand Up @@ -249,6 +252,7 @@ const sshParser = (proxy = {}) => {
parsedProxy.host_key_algorithms = proxy['host-key-algorithms'];
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
return parsedProxy;
};

Expand All @@ -274,6 +278,7 @@ const httpParser = (proxy = {}) => {
}
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
tlsParser(proxy, parsedProxy);
return parsedProxy;
};
Expand All @@ -295,6 +300,7 @@ const socks5Parser = (proxy = {}) => {
if (proxy['udp-over-tcp']) parsedProxy.udp_over_tcp = true;
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
return parsedProxy;
};

Expand Down Expand Up @@ -326,6 +332,7 @@ const shadowTLSParser = (proxy = {}) => {
throw '端口值非法';
if (proxy['fast-open'] === true) stPart.udp_fragment = true;
tfoParser(proxy, stPart);
detourParser(proxy, stPart);
smuxParser(proxy.smux, ssPart);
return { type: 'ss-with-st', ssPart, stPart };
};
Expand All @@ -344,6 +351,7 @@ const ssParser = (proxy = {}) => {
if (proxy['udp-over-tcp']) parsedProxy.udp_over_tcp = true;
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
smuxParser(proxy.smux, parsedProxy);
if (proxy.plugin) {
const optArr = [];
Expand Down Expand Up @@ -421,6 +429,7 @@ const ssrParser = (proxy = {}) => {
parsedProxy.protocol_param = proxy['protocol-param'];
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
smuxParser(proxy.smux, parsedProxy);
return parsedProxy;
};
Expand Down Expand Up @@ -457,6 +466,7 @@ const vmessParser = (proxy = {}) => {
if (proxy.network === 'grpc') grpcParser(proxy, parsedProxy);

tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
tlsParser(proxy, parsedProxy);
smuxParser(proxy.smux, parsedProxy);
return parsedProxy;
Expand All @@ -479,6 +489,7 @@ const vlessParser = (proxy = {}) => {
if (proxy.network === 'grpc') grpcParser(proxy, parsedProxy);

tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
smuxParser(proxy.smux, parsedProxy);
tlsParser(proxy, parsedProxy);
return parsedProxy;
Expand All @@ -499,6 +510,7 @@ const trojanParser = (proxy = {}) => {
if (proxy.network === 'ws') wsParser(proxy, parsedProxy);

tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
tlsParser(proxy, parsedProxy);
smuxParser(proxy.smux, parsedProxy);
return parsedProxy;
Expand Down Expand Up @@ -545,6 +557,7 @@ const hysteriaParser = (proxy = {}) => {
}
}
tlsParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
tfoParser(proxy, parsedProxy);
smuxParser(proxy.smux, parsedProxy);
return parsedProxy;
Expand All @@ -569,6 +582,7 @@ const hysteria2Parser = (proxy = {}) => {
if (!parsedProxy.obfs.type) delete parsedProxy.obfs;
tlsParser(proxy, parsedProxy);
tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
smuxParser(proxy.smux, parsedProxy);
return parsedProxy;
};
Expand Down Expand Up @@ -597,6 +611,7 @@ const tuic5Parser = (proxy = {}) => {
if (proxy['heartbeat-interval'])
parsedProxy.heartbeat = `${proxy['heartbeat-interval']}ms`;
tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
tlsParser(proxy, parsedProxy);
smuxParser(proxy.smux, parsedProxy);
return parsedProxy;
Expand Down Expand Up @@ -650,6 +665,7 @@ const wireguardParser = (proxy = {}) => {
}
}
tfoParser(proxy, parsedProxy);
detourParser(proxy, parsedProxy);
smuxParser(proxy.smux, parsedProxy);
return parsedProxy;
};
Expand Down Expand Up @@ -789,6 +805,7 @@ export default function singbox_Producer() {
$.error(e.message ?? e);
}
});

return type === 'internal'
? list
: JSON.stringify({ outbounds: list }, null, 2);
Expand Down
6 changes: 6 additions & 0 deletions backend/src/core/proxy-utils/producers/stash.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ export default function Stash_Producer() {
proxy.fingerprint = proxy['tls-fingerprint'];
}
delete proxy['tls-fingerprint'];

if (proxy['underlying-proxy']) {
proxy['dialer-proxy'] = proxy['underlying-proxy'];
}
delete proxy['underlying-proxy'];

if (isPresent(proxy, 'tls') && typeof proxy.tls !== 'boolean') {
delete proxy.tls;
}
Expand Down

0 comments on commit 93a5ce6

Please sign in to comment.