feat: Shadowsocks URI 支持 Shadow TLS plugin

This commit is contained in:
xream 2025-02-10 06:32:17 +08:00
parent 07d5a913f0
commit 4a2a2297f6
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
5 changed files with 22 additions and 8 deletions

View File

@ -5,7 +5,7 @@
* ╚════██║██║ ██║██╔══██╗╚════╝╚════██║ ██║ ██║ ██║██╔══██╗██╔══╝ * ╚════██║██║ ██║██╔══██╗╚════╝╚════██║ ██║ ██║ ██║██╔══██╗██╔══╝
* ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗ * ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗
* ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ * ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
* Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket! * Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket!
* @updated: <%= updated %> * @updated: <%= updated %>
* @version: <%= pkg.version %> * @version: <%= pkg.version %>
* @author: Peng-YM * @author: Peng-YM

View File

@ -1,7 +1,7 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.16.31", "version": "2.16.32",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {
"preinstall": "npx only-allow pnpm", "preinstall": "npx only-allow pnpm",

View File

@ -146,11 +146,10 @@ function URI_SS() {
// } // }
// handle obfs // handle obfs
const idx = content.indexOf('?plugin='); const pluginMatch = content.match(/[?&]plugin=([^&]+)/);
if (idx !== -1) { if (pluginMatch) {
const pluginInfo = ( const pluginInfo = (
'plugin=' + 'plugin=' + decodeURIComponent(pluginMatch[1])
decodeURIComponent(content.split('?plugin=')[1].split('&')[0])
).split(';'); ).split(';');
const params = {}; const params = {};
for (const item of pluginInfo) { for (const item of pluginInfo) {
@ -175,6 +174,16 @@ function URI_SS() {
tls: getIfPresent(params.tls), tls: getIfPresent(params.tls),
}; };
break; break;
case 'shadow-tls': {
proxy.plugin = 'shadow-tls';
const version = getIfNotBlank(params['version']);
proxy['plugin-opts'] = {
host: getIfNotBlank(params['host']),
password: getIfNotBlank(params['password']),
version: version ? parseInt(version, 10) : undefined,
};
break;
}
default: default:
throw new Error( throw new Error(
`Unsupported plugin option: ${params.plugin}`, `Unsupported plugin option: ${params.plugin}`,

View File

@ -1,6 +1,6 @@
import { isPresent } from '@/core/proxy-utils/producers/utils'; import { isPresent } from '@/core/proxy-utils/producers/utils';
export default function ShadowRocket_Producer() { export default function Shadowrocket_Producer() {
const type = 'ALL'; const type = 'ALL';
const produce = (proxies, type, opts = {}) => { const produce = (proxies, type, opts = {}) => {
const list = proxies const list = proxies

View File

@ -54,6 +54,11 @@ export default function URI_Producer() {
}${opts.tls ? ';tls' : ''}`, }${opts.tls ? ';tls' : ''}`,
); );
break; break;
case 'shadow-tls':
result += encodeURIComponent(
`shadow-tls;host=${opts.host};password=${opts.password};version=${opts.version}`,
);
break;
default: default:
throw new Error( throw new Error(
`Unsupported plugin option: ${proxy.plugin}`, `Unsupported plugin option: ${proxy.plugin}`,