mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-30 00:10:30 +00:00
feat: 调整 SS URI UDP 逻辑
This commit is contained in:
4 files changed
+60
-5
No files matched your search
@@ -401,7 +401,11 @@ function URI_SS() {
|
||||
}
|
||||
}
|
||||
|
||||
proxy.udp = !!params['udp'];
|
||||
proxy.udp = ![false, 0, '0', 'false', 'off'].includes(
|
||||
typeof params['udp'] === 'string'
|
||||
? params['udp'].toLowerCase()
|
||||
: params['udp'],
|
||||
);
|
||||
|
||||
const serverAndPort = serverAndPortArray[1];
|
||||
const portIdx = serverAndPort.lastIndexOf(':');
|
||||
|
||||
@@ -893,6 +893,7 @@ export default function URI_Producer() {
|
||||
if (proxy.tfo) {
|
||||
query += '&tfo=1';
|
||||
}
|
||||
query += `&udp=${proxy.udp ? 1 : 0}`;
|
||||
let ssTransport = '';
|
||||
if (proxy.network) {
|
||||
let ssType = proxy.network;
|
||||
|
||||
@@ -92,6 +92,7 @@ describe('Proxy URI parser coverage', function () {
|
||||
port: 8388,
|
||||
cipher: 'aes-128-gcm',
|
||||
password: 'secret',
|
||||
udp: true,
|
||||
plugin: 'obfs',
|
||||
'plugin-opts': {
|
||||
mode: 'http',
|
||||
@@ -119,6 +120,23 @@ describe('Proxy URI parser coverage', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('disables shadowsocks UDP for explicit false query values', function () {
|
||||
const userInfo = encodeURIComponent(
|
||||
Base64.encode('aes-128-gcm:secret'),
|
||||
);
|
||||
|
||||
expect(
|
||||
parseOne(
|
||||
`ss://${userInfo}@ss.example.com:8388?udp=0#SS%20UDP%200`,
|
||||
).udp,
|
||||
).to.equal(false);
|
||||
expect(
|
||||
parseOne(
|
||||
`ss://${userInfo}@ss.example.com:8388?udp=false#SS%20UDP%20False`,
|
||||
).udp,
|
||||
).to.equal(false);
|
||||
});
|
||||
|
||||
it('parses SIP002 plain shadowsocks userinfo with percent-encoded credentials', function () {
|
||||
const password = 'sec:ret@/plus+';
|
||||
const proxy = parseOne(
|
||||
|
||||
@@ -2478,6 +2478,38 @@ describe('Proxy text producers', function () {
|
||||
);
|
||||
});
|
||||
|
||||
it('serializes explicit shadowsocks UDP flags as numeric URI values', function () {
|
||||
const enabled = produceExternal('URI', {
|
||||
type: 'ss',
|
||||
name: 'SS UDP On',
|
||||
server: 'ss.example.com',
|
||||
port: 8388,
|
||||
cipher: 'aes-128-gcm',
|
||||
password: 'secret',
|
||||
udp: true,
|
||||
});
|
||||
const disabled = produceExternal('URI', {
|
||||
type: 'ss',
|
||||
name: 'SS UDP Off',
|
||||
server: 'ss.example.com',
|
||||
port: 8388,
|
||||
cipher: 'aes-128-gcm',
|
||||
password: 'secret',
|
||||
udp: false,
|
||||
});
|
||||
|
||||
expect(enabled).to.equal(
|
||||
`ss://${Base64.encode(
|
||||
'aes-128-gcm:secret',
|
||||
)}@ss.example.com:8388?udp=1#SS%20UDP%20On`,
|
||||
);
|
||||
expect(disabled).to.equal(
|
||||
`ss://${Base64.encode(
|
||||
'aes-128-gcm:secret',
|
||||
)}@ss.example.com:8388?udp=0#SS%20UDP%20Off`,
|
||||
);
|
||||
});
|
||||
|
||||
it('produces URI shadowsocks httpupgrade links with early data metadata', function () {
|
||||
const output = produceExternal('URI', {
|
||||
type: 'ss',
|
||||
@@ -2717,8 +2749,8 @@ describe('Proxy text producers', function () {
|
||||
|
||||
expect(output).to.equal(
|
||||
[
|
||||
`ss://${userInfo}@ss.example.com:443/?plugin=${muxOnPlugin}#Clash%20Boolean%20Mux%20On`,
|
||||
`ss://${userInfo}@ss.example.com:443/?plugin=${muxOffPlugin}#Clash%20Boolean%20Mux%20Off`,
|
||||
`ss://${userInfo}@ss.example.com:443/?plugin=${muxOnPlugin}&udp=1#Clash%20Boolean%20Mux%20On`,
|
||||
`ss://${userInfo}@ss.example.com:443/?plugin=${muxOffPlugin}&udp=1#Clash%20Boolean%20Mux%20Off`,
|
||||
].join('\n'),
|
||||
);
|
||||
});
|
||||
@@ -2763,8 +2795,8 @@ describe('Proxy text producers', function () {
|
||||
|
||||
expect(output).to.equal(
|
||||
[
|
||||
`ss://${userInfo}@ss.example.com:443/?plugin=${muxOnPlugin}#Clash%20String%20Mux%20On`,
|
||||
`ss://${userInfo}@ss.example.com:443/?plugin=${muxOffPlugin}#Clash%20String%20Mux%20Off`,
|
||||
`ss://${userInfo}@ss.example.com:443/?plugin=${muxOnPlugin}&udp=1#Clash%20String%20Mux%20On`,
|
||||
`ss://${userInfo}@ss.example.com:443/?plugin=${muxOffPlugin}&udp=1#Clash%20String%20Mux%20Off`,
|
||||
].join('\n'),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user