mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-12-03 09:45:54 +00:00
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:
10 files changed
+236
-22
No files matched your search
@@ -318,7 +318,10 @@ function URI_SS() {
|
||||
case 'v2ray-plugin':
|
||||
proxy.plugin = 'v2ray-plugin';
|
||||
proxy['plugin-opts'] = {
|
||||
mode: 'websocket',
|
||||
mode:
|
||||
getIfNotBlank(params['obfs']) ||
|
||||
getIfNotBlank(params['mode']) ||
|
||||
'websocket',
|
||||
host:
|
||||
getIfNotBlank(params['obfs-host']) ||
|
||||
getIfNotBlank(params['host']),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
isPresent,
|
||||
produceProxyListOutput,
|
||||
supportsShadowsocksV2rayPluginMode,
|
||||
} from '@/core/proxy-utils/producers/utils';
|
||||
|
||||
const ipVersions = {
|
||||
@@ -17,7 +18,11 @@ export default function ClashMeta_Producer() {
|
||||
const list = proxies
|
||||
.filter((proxy) => {
|
||||
if (opts['include-unsupported-proxy']) return true;
|
||||
if (proxy.type === 'snell' && proxy.version >= 4) {
|
||||
if (
|
||||
!supportsShadowsocksV2rayPluginMode(proxy, ['websocket'])
|
||||
) {
|
||||
return false;
|
||||
} else if (proxy.type === 'snell' && proxy.version >= 4) {
|
||||
return false;
|
||||
} else if (
|
||||
['tailscale', 'juicity', 'naive'].includes(proxy.type)
|
||||
|
||||
@@ -152,10 +152,18 @@ export default function Egern_Producer() {
|
||||
proxy.udp || proxy.udp_relay || proxy.udp_relay,
|
||||
next_hop: proxy.next_hop,
|
||||
};
|
||||
if (original.plugin === 'obfs') {
|
||||
proxy.obfs = original['plugin-opts'].mode;
|
||||
proxy.obfs_host = original['plugin-opts'].host;
|
||||
proxy.obfs_uri = original['plugin-opts'].path;
|
||||
if (isPresent(original, 'plugin')) {
|
||||
if (original.plugin === 'obfs') {
|
||||
proxy.obfs = original['plugin-opts'].mode;
|
||||
proxy.obfs_host = original['plugin-opts'].host;
|
||||
proxy.obfs_uri = original['plugin-opts'].path;
|
||||
} else if (
|
||||
!['shadow-tls'].includes(original.plugin)
|
||||
) {
|
||||
throw new Error(
|
||||
`plugin ${original.plugin} is not supported`,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (proxy.type === 'hysteria2') {
|
||||
proxy = {
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
isPresent,
|
||||
isShadowsocksOverTls,
|
||||
produceProxyListOutput,
|
||||
supportsShadowsocksV2rayPluginMode,
|
||||
} from '@/core/proxy-utils/producers/utils';
|
||||
import $ from '@/core/app';
|
||||
|
||||
@@ -11,7 +12,17 @@ export default function Shadowrocket_Producer() {
|
||||
const list = proxies
|
||||
.filter((proxy) => {
|
||||
if (opts['include-unsupported-proxy']) return true;
|
||||
if (proxy.type === 'snell' && proxy.version >= 4) {
|
||||
if (
|
||||
!supportsShadowsocksV2rayPluginMode(proxy, [
|
||||
'websocket',
|
||||
'quic',
|
||||
'http2',
|
||||
'mkcp',
|
||||
'grpc',
|
||||
])
|
||||
) {
|
||||
return false;
|
||||
} else if (proxy.type === 'snell' && proxy.version >= 4) {
|
||||
return false;
|
||||
} else if (
|
||||
[
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
isPresent,
|
||||
produceProxyListOutput,
|
||||
supportsShadowsocksV2rayPluginMode,
|
||||
} from '@/core/proxy-utils/producers/utils';
|
||||
import $ from '@/core/app';
|
||||
|
||||
@@ -10,6 +11,7 @@ export default function Stash_Producer() {
|
||||
// https://stash.wiki/proxy-protocols/proxy-types#shadowsocks
|
||||
const list = proxies
|
||||
.filter((proxy) => {
|
||||
if (opts['include-unsupported-proxy']) return true;
|
||||
if (
|
||||
![
|
||||
'ss',
|
||||
@@ -51,6 +53,10 @@ export default function Stash_Producer() {
|
||||
(proxy.type === 'snell' && proxy.version >= 4)
|
||||
) {
|
||||
return false;
|
||||
} else if (
|
||||
!supportsShadowsocksV2rayPluginMode(proxy, ['websocket'])
|
||||
) {
|
||||
return false;
|
||||
} else if (
|
||||
['vless'].includes(proxy.type) &&
|
||||
proxy['reality-opts'] &&
|
||||
|
||||
@@ -548,14 +548,15 @@ export default function URI_Producer() {
|
||||
break;
|
||||
case 'v2ray-plugin':
|
||||
const mux = normalizePluginMuxValue(opts.mux);
|
||||
// 为了兼容性 多输出 mode 和 host 两个字段
|
||||
query += encodeURIComponent(
|
||||
`v2ray-plugin;obfs=${opts.mode}${
|
||||
opts.host ? ';obfs-host=' + opts.host : ''
|
||||
}${opts.host ? ';host=' + opts.host : ''}${
|
||||
opts.path ? ';path=' + opts.path : ''
|
||||
}${opts.tls ? ';tls' : ''}${
|
||||
opts.sni ? ';sni=' + opts.sni : ''
|
||||
}${
|
||||
`v2ray-plugin;obfs=${opts.mode};mode=${
|
||||
opts.mode
|
||||
}${opts.host ? ';obfs-host=' + opts.host : ''}${
|
||||
opts.host ? ';host=' + opts.host : ''
|
||||
}${opts.path ? ';path=' + opts.path : ''}${
|
||||
opts.tls ? ';tls' : ''
|
||||
}${opts.sni ? ';sni=' + opts.sni : ''}${
|
||||
opts['skip-cert-verify']
|
||||
? ';skip-cert-verify=' +
|
||||
opts['skip-cert-verify']
|
||||
|
||||
@@ -54,6 +54,17 @@ export function normalizePluginMuxValue(mux) {
|
||||
return mux;
|
||||
}
|
||||
|
||||
export function supportsShadowsocksV2rayPluginMode(proxy, supportedModes) {
|
||||
if (proxy?.type !== 'ss' || proxy?.plugin !== 'v2ray-plugin') return true;
|
||||
|
||||
const normalizedMode =
|
||||
typeof proxy?.['plugin-opts']?.mode === 'string'
|
||||
? proxy['plugin-opts'].mode.trim().toLowerCase()
|
||||
: proxy?.['plugin-opts']?.mode;
|
||||
|
||||
return supportedModes.includes(normalizedMode);
|
||||
}
|
||||
|
||||
export function produceProxyListOutput(list, type, opts = {}) {
|
||||
if (type === 'internal') return list;
|
||||
|
||||
|
||||
Reference in new issue
Block a user