mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-30 08:28:10 +00:00
feat: Surge 仅 SOCKS5/SOCKS5-TLS、Shadowsocks、HTTP/2 CONNECT 和 External 保留 udp-relay
This commit is contained in:
3 files changed
+59
-30
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.38.5",
|
||||
"version": "2.38.6",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||
"main": "src/main.js",
|
||||
"packageManager": "pnpm@11.0.9",
|
||||
|
||||
@@ -362,9 +362,6 @@ function trojan(proxy) {
|
||||
// tfo
|
||||
result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo');
|
||||
|
||||
// udp
|
||||
result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp');
|
||||
|
||||
// test-url
|
||||
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
|
||||
result.appendIfPresent(
|
||||
@@ -417,9 +414,6 @@ function anytls(proxy) {
|
||||
// tfo
|
||||
result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo');
|
||||
|
||||
// udp
|
||||
result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp');
|
||||
|
||||
// test-url
|
||||
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
|
||||
result.appendIfPresent(
|
||||
@@ -480,9 +474,6 @@ function trusttunnel(proxy) {
|
||||
// tfo
|
||||
result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo');
|
||||
|
||||
// udp
|
||||
result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp');
|
||||
|
||||
// test-url
|
||||
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
|
||||
result.appendIfPresent(
|
||||
@@ -544,7 +535,6 @@ function masque_surge(proxy) {
|
||||
} else if (isPresent(proxy, 'fast-open')) {
|
||||
result.append(`,tfo=${proxy['fast-open']}`);
|
||||
}
|
||||
result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp');
|
||||
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
|
||||
result.appendIfPresent(
|
||||
`,test-timeout=${proxy['test-timeout']}`,
|
||||
@@ -663,9 +653,6 @@ function vmess(proxy, includeUnsupportedProxy) {
|
||||
// tfo
|
||||
result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo');
|
||||
|
||||
// udp
|
||||
result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp');
|
||||
|
||||
// test-url
|
||||
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
|
||||
result.appendIfPresent(
|
||||
@@ -729,9 +716,6 @@ function ssh(proxy) {
|
||||
// tfo
|
||||
result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo');
|
||||
|
||||
// udp
|
||||
result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp');
|
||||
|
||||
// test-url
|
||||
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
|
||||
result.appendIfPresent(
|
||||
@@ -784,9 +768,6 @@ function http(proxy) {
|
||||
// tfo
|
||||
result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo');
|
||||
|
||||
// udp
|
||||
result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp');
|
||||
|
||||
// test-url
|
||||
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
|
||||
result.appendIfPresent(
|
||||
@@ -835,9 +816,6 @@ function direct(proxy) {
|
||||
// tfo
|
||||
result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo');
|
||||
|
||||
// udp
|
||||
result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp');
|
||||
|
||||
// test-url
|
||||
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
|
||||
result.appendIfPresent(
|
||||
@@ -991,9 +969,6 @@ function snell(proxy) {
|
||||
// tfo
|
||||
result.appendIfPresent(`,tfo=${proxy.tfo}`, 'tfo');
|
||||
|
||||
// udp
|
||||
result.appendIfPresent(`,udp-relay=${proxy.udp}`, 'udp');
|
||||
|
||||
// test-url
|
||||
result.appendIfPresent(`,test-url=${proxy['test-url']}`, 'test-url');
|
||||
result.appendIfPresent(
|
||||
|
||||
@@ -936,6 +936,60 @@ describe('Proxy text producers', function () {
|
||||
);
|
||||
});
|
||||
|
||||
it('emits udp-relay only for applicable Surge policies', function () {
|
||||
// https://manual.nssurge.com/policies/udp.html
|
||||
const proxies = [
|
||||
{ type: 'ss', cipher: 'aes-128-gcm' },
|
||||
{ type: 'socks5' },
|
||||
{ type: 'socks5', tls: true },
|
||||
{ type: 'h2-connect' },
|
||||
{ type: 'external', exec: '/usr/bin/ssh', 'local-port': 1080 },
|
||||
{ type: 'http' },
|
||||
{ type: 'http', tls: true },
|
||||
{ type: 'trusttunnel' },
|
||||
{ type: 'ssh' },
|
||||
{ type: 'direct' },
|
||||
{ type: 'vmess', uuid: UUID },
|
||||
{ type: 'trojan' },
|
||||
{ type: 'anytls' },
|
||||
{ type: 'masque-surge' },
|
||||
{ type: 'tuic', token: 'secret' },
|
||||
{ type: 'tuic', uuid: UUID },
|
||||
{ type: 'hysteria2' },
|
||||
{ type: 'wireguard-surge', 'section-name': 'test' },
|
||||
...[1, 2, 3, 4, 5, 6].map((version) => ({
|
||||
type: 'snell',
|
||||
psk: 'secret',
|
||||
version,
|
||||
})),
|
||||
];
|
||||
|
||||
for (const platform of ['Surge', 'SurgeMac']) {
|
||||
for (const proxy of proxies) {
|
||||
if (proxy.type === 'external' && platform === 'Surge') continue;
|
||||
for (const udp of [true, false, undefined]) {
|
||||
const output = produceExternal(platform, {
|
||||
name: proxy.type,
|
||||
server: 'example.com',
|
||||
port: 443,
|
||||
password: 'secret',
|
||||
...proxy,
|
||||
udp,
|
||||
});
|
||||
const expected =
|
||||
['ss', 'socks5', 'h2-connect', 'external'].includes(
|
||||
proxy.type,
|
||||
) && udp != null
|
||||
? [`,udp-relay=${udp}`]
|
||||
: [];
|
||||
|
||||
expect(output.match(/,udp-relay=[^,\n]+/g) || [], output)
|
||||
.to.deep.equal(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('emits Surge alpn and server-cert-verify-name for TLS protocol outputs', function () {
|
||||
const alpn = ['http/1.1', 'h2', 'h3'];
|
||||
const nameCertVerify = 'verify.example.com';
|
||||
@@ -1090,7 +1144,7 @@ describe('Proxy text producers', function () {
|
||||
ecn: false,
|
||||
});
|
||||
expect(produceExternal('Surge', proxy)).to.equal(
|
||||
'Surge MASQUE=masque,masque.example.com,443,username="user",password="secret",port-hopping="8443;8445-8447",port-hopping-interval=30,sni="sni.example.com",alpn="h3",skip-cert-verify=true,udp-relay=false,ecn=false',
|
||||
'Surge MASQUE=masque,masque.example.com,443,username="user",password="secret",port-hopping="8443;8445-8447",port-hopping-interval=30,sni="sni.example.com",alpn="h3",skip-cert-verify=true,ecn=false',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1262,8 +1316,8 @@ describe('Proxy text producers', function () {
|
||||
|
||||
expect(output).to.equal(
|
||||
[
|
||||
'Surge Snell v6=snell,snell.example.com,443,version=6,psk="secret",mode=unsafe-raw,udp-relay=true',
|
||||
'Surge Snell v5 Mode=snell,snell.example.com,443,version=5,psk="secret",udp-relay=true',
|
||||
'Surge Snell v6=snell,snell.example.com,443,version=6,psk="secret",mode=unsafe-raw',
|
||||
'Surge Snell v5 Mode=snell,snell.example.com,443,version=5,psk="secret"',
|
||||
].join('\n'),
|
||||
);
|
||||
expect(errors).to.deep.equal([
|
||||
@@ -1523,7 +1577,7 @@ describe('Proxy text producers', function () {
|
||||
|
||||
expect(output.split('\n')).to.deep.equal([
|
||||
`Surge H2 Round Trip=h2-connect,h2.example.com,443,headers="X-Padding:"<random-string(16-32)>"",max-streams=1,sni="sni.example.com",udp-relay=true`,
|
||||
`Surge Trust Round Trip=trust-tunnel,trust.example.com,443,username="user",password="pass",headers="X-Client:"Surge"",max-streams=3,sni="sni.example.com",udp-relay=true`,
|
||||
`Surge Trust Round Trip=trust-tunnel,trust.example.com,443,username="user",password="pass",headers="X-Client:"Surge"",max-streams=3,sni="sni.example.com"`,
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user