feat: Shadowsocks v2ray-plugin plugin-opts 中 mode 使用真实取值; 增强 V2Ray URI 兼容性; Egern 过滤掉 v2ray-plugin; Shadowsocks v2ray-plugin plugin-opts 的 mode 相关的逻辑调整

1. mihomo 仅支持 mode: websocket
2. stash 仅支持 mode: websocket
3. shadowrocket 仅支持 mode: websocket 或 quic 或 http2  或 mkcp 或 grpc
4. sing-box 仅支持 mode: websocket 或 quic
This commit is contained in:
xream committed 2026-04-15 23:29:10 +08:00
1 parent 621d619080
commit 820c191b88
10 files changed
+236 -22

No files matched your search

@@ -99,6 +99,89 @@ describe('Proxy structured producers', function () {
});
});
it('keeps only websocket shadowsocks v2ray-plugin modes for Mihomo and Stash by default', function () {
const buildProxy = (name, mode) => ({
type: 'ss',
name,
server: 'ss.example.com',
port: 8388,
cipher: 'aes-128-gcm',
password: 'secret',
plugin: 'v2ray-plugin',
'plugin-opts': {
mode,
host: 'cdn.example.com',
path: '/socket',
tls: true,
},
});
const proxies = [
buildProxy('WS', 'websocket'),
buildProxy('QUIC', 'quic'),
];
for (const platform of ['Mihomo', 'Stash']) {
const internal = produceInternal(platform, proxies);
const external = loadProducedYaml(platform, proxies, {
'include-unsupported-proxy': true,
});
expect(internal, platform).to.have.length(1);
expect(internal[0].name, platform).to.equal('WS');
expect(external.proxies.map((proxy) => proxy.name), platform).to
.deep.equal(['WS', 'QUIC']);
}
});
it('keeps only supported shadowsocks v2ray-plugin modes for Shadowrocket by default', function () {
const buildProxy = (name, mode) => ({
type: 'ss',
name,
server: 'ss.example.com',
port: 8388,
cipher: 'aes-128-gcm',
password: 'secret',
plugin: 'v2ray-plugin',
'plugin-opts': {
mode,
host: 'cdn.example.com',
path: '/socket',
tls: true,
},
});
const proxies = [
buildProxy('WS', 'websocket'),
buildProxy('QUIC', 'quic'),
buildProxy('HTTP2', 'http2'),
buildProxy('MKCP', 'mkcp'),
buildProxy('GRPC', 'grpc'),
buildProxy('TLS', 'tls'),
];
const internal = produceInternal('Shadowrocket', proxies);
const external = loadProducedYaml('Shadowrocket', proxies, {
'include-unsupported-proxy': true,
});
expect(internal.map((proxy) => proxy.name)).to.deep.equal([
'WS',
'QUIC',
'HTTP2',
'MKCP',
'GRPC',
]);
expect(external.proxies.map((proxy) => proxy.name)).to.deep.equal([
'WS',
'QUIC',
'HTTP2',
'MKCP',
'GRPC',
'TLS',
]);
});
it('adds Clash.Meta reality defaults and preserves websocket early data', function () {
const proxy = {
type: 'vless',
@@ -701,6 +784,47 @@ describe('Proxy structured producers', function () {
});
});
it('maps shadowsocks obfs plugin fields into Egern nested structures', function () {
const proxy = {
type: 'ss',
name: 'Egern SS Obfs TLS',
server: 'ss.example.com',
port: 8388,
cipher: 'aes-128-gcm',
password: 'secret',
plugin: 'obfs',
'plugin-opts': {
mode: 'tls',
host: 'legacy.example.com',
path: '/legacy',
},
};
const internal = produceInternal('Egern', proxy)[0];
const external = loadProducedYaml('Egern', proxy);
expectSubset(internal, {
shadowsocks: {
name: 'Egern SS Obfs TLS',
method: 'aes-128-gcm',
server: 'ss.example.com',
port: 8388,
password: 'secret',
obfs: 'tls',
obfs_host: 'legacy.example.com',
obfs_uri: '/legacy',
},
});
expectSubset(external.proxies[0], {
shadowsocks: {
name: 'Egern SS Obfs TLS',
obfs: 'tls',
obfs_host: 'legacy.example.com',
obfs_uri: '/legacy',
},
});
});
it('preserves numeric v2ray-plugin mux values across Clash-family YAML producers', function () {
const buildProxy = (name, mux) => ({
type: 'ss',
@@ -955,6 +1079,51 @@ describe('Proxy structured producers', function () {
});
});
it('skips Egern shadowsocks proxies with unsupported plugins and keeps the rest of the subscription', function () {
const proxies = [
{
type: 'ss',
name: 'Invalid SS Plugin',
server: 'invalid.example.com',
port: 8388,
cipher: 'aes-128-gcm',
password: 'secret',
plugin: 'v2ray-plugin',
'plugin-opts': {
mode: 'websocket',
host: 'cdn.example.com',
path: '/socket',
tls: true,
},
},
{
type: 'ss',
name: 'Healthy SS',
server: 'ss.example.com',
port: 8388,
cipher: 'aes-128-gcm',
password: 'secret',
},
];
const internal = produceInternal('Egern', proxies);
const external = loadProducedYaml('Egern', proxies);
expect(internal).to.have.length(1);
expect(external.proxies).to.have.length(1);
expectSubset(internal[0], {
shadowsocks: {
name: 'Healthy SS',
method: 'aes-128-gcm',
},
});
expectSubset(external.proxies[0], {
shadowsocks: {
name: 'Healthy SS',
},
});
});
it('keeps numeric v2ray-plugin mux state in sing-box plugin opts', function () {
const buildProxy = (name, mux) => ({
type: 'ss',
@@ -589,7 +589,7 @@ describe('Proxy text producers', function () {
it('produces URI shadowsocks links with v2ray-plugin mux and tls flags', function () {
const plugin = encodeURIComponent(
'v2ray-plugin;obfs=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;tls;sni=sni.example.com;skip-cert-verify=true;mux=0',
'v2ray-plugin;obfs=websocket;mode=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;tls;sni=sni.example.com;skip-cert-verify=true;mux=0',
);
const output = produceExternal('URI', {
type: 'ss',
@@ -619,10 +619,10 @@ describe('Proxy text producers', function () {
it('normalizes boolean v2ray-plugin mux values to integers in URI links', function () {
const muxOnPlugin = encodeURIComponent(
'v2ray-plugin;obfs=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;tls;mux=1',
'v2ray-plugin;obfs=websocket;mode=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;tls;mux=1',
);
const muxOffPlugin = encodeURIComponent(
'v2ray-plugin;obfs=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;mux=0',
'v2ray-plugin;obfs=websocket;mode=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;mux=0',
);
const muxOnOutput = produceExternal('URI', {
@@ -701,10 +701,10 @@ describe('Proxy text producers', function () {
const output = produceExternal('URI', proxies);
const userInfo = Base64.encode('aes-128-gcm:secret');
const muxOnPlugin = encodeURIComponent(
'v2ray-plugin;obfs=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;tls;mux=1',
'v2ray-plugin;obfs=websocket;mode=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;tls;mux=1',
);
const muxOffPlugin = encodeURIComponent(
'v2ray-plugin;obfs=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;mux=0',
'v2ray-plugin;obfs=websocket;mode=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;mux=0',
);
expect(output).to.equal(
@@ -747,10 +747,10 @@ describe('Proxy text producers', function () {
const output = produceExternal('URI', proxies);
const userInfo = Base64.encode('aes-128-gcm:secret');
const muxOnPlugin = encodeURIComponent(
'v2ray-plugin;obfs=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;tls;mux=1',
'v2ray-plugin;obfs=websocket;mode=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;tls;mux=1',
);
const muxOffPlugin = encodeURIComponent(
'v2ray-plugin;obfs=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;mux=0',
'v2ray-plugin;obfs=websocket;mode=websocket;obfs-host=cdn.example.com;host=cdn.example.com;path=/socket;mux=0',
);
expect(output).to.equal(