mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 05:09:01 +08:00
feat: 支持更多不规范的 VLESS/SS URI
This commit is contained in:
parent
6564d9497a
commit
64117c50c7
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.189",
|
"version": "2.14.190",
|
||||||
"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": {
|
||||||
|
@ -32,8 +32,18 @@ function URI_SS() {
|
|||||||
// handle IPV4 and IPV6
|
// handle IPV4 and IPV6
|
||||||
let serverAndPortArray = content.match(/@([^/]*)(\/|$)/);
|
let serverAndPortArray = content.match(/@([^/]*)(\/|$)/);
|
||||||
let userInfoStr = Base64.decode(content.split('@')[0]);
|
let userInfoStr = Base64.decode(content.split('@')[0]);
|
||||||
|
let query = '';
|
||||||
if (!serverAndPortArray) {
|
if (!serverAndPortArray) {
|
||||||
|
// 暂时先这样处理 目前够用
|
||||||
|
if (content.includes('?plugin=')) {
|
||||||
|
const parsed = content.match(/^(.*)(\?plugin=.*)$/);
|
||||||
|
content = parsed[1];
|
||||||
|
query = parsed[2];
|
||||||
|
}
|
||||||
content = Base64.decode(content);
|
content = Base64.decode(content);
|
||||||
|
if (query) {
|
||||||
|
content = `${content}${query}`;
|
||||||
|
}
|
||||||
userInfoStr = content.split('@')[0];
|
userInfoStr = content.split('@')[0];
|
||||||
serverAndPortArray = content.match(/@([^/]*)(\/|$)/);
|
serverAndPortArray = content.match(/@([^/]*)(\/|$)/);
|
||||||
}
|
}
|
||||||
@ -47,7 +57,6 @@ function URI_SS() {
|
|||||||
const userInfo = userInfoStr.split(':');
|
const userInfo = userInfoStr.split(':');
|
||||||
proxy.cipher = userInfo[0];
|
proxy.cipher = userInfo[0];
|
||||||
proxy.password = userInfo[1];
|
proxy.password = userInfo[1];
|
||||||
|
|
||||||
// handle obfs
|
// handle obfs
|
||||||
const idx = content.indexOf('?plugin=');
|
const idx = content.indexOf('?plugin=');
|
||||||
if (idx !== -1) {
|
if (idx !== -1) {
|
||||||
@ -84,6 +93,9 @@ function URI_SS() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (/(&|\?)uot=(1|true)/i.test(query)) {
|
||||||
|
proxy['udp-over-tcp'] = true;
|
||||||
|
}
|
||||||
return proxy;
|
return proxy;
|
||||||
};
|
};
|
||||||
return { name, test, parse };
|
return { name, test, parse };
|
||||||
@ -416,16 +428,31 @@ function URI_VLESS() {
|
|||||||
if (!proxy.network && isShadowrocket && params.obfs) {
|
if (!proxy.network && isShadowrocket && params.obfs) {
|
||||||
proxy.network = params.obfs;
|
proxy.network = params.obfs;
|
||||||
}
|
}
|
||||||
|
if (['websocket'].includes(proxy.network)) {
|
||||||
|
proxy.network = 'ws';
|
||||||
|
}
|
||||||
if (proxy.network && !['tcp', 'none'].includes(proxy.network)) {
|
if (proxy.network && !['tcp', 'none'].includes(proxy.network)) {
|
||||||
const opts = {};
|
const opts = {};
|
||||||
if (params.host) {
|
const host = params.host ?? params.obfsParam;
|
||||||
opts.headers = { Host: params.host };
|
if (host) {
|
||||||
|
if (params.obfsParam) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(host);
|
||||||
|
opts.headers = parsed;
|
||||||
|
} catch (e) {
|
||||||
|
opts.headers = { Host: host };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
opts.headers = { Host: host };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (params.serviceName) {
|
if (params.serviceName) {
|
||||||
opts[`${proxy.network}-service-name`] = params.serviceName;
|
opts[`${proxy.network}-service-name`] = params.serviceName;
|
||||||
} else if (isShadowrocket && params.path) {
|
} else if (isShadowrocket && params.path) {
|
||||||
opts[`${proxy.network}-service-name`] = params.path;
|
if (!['ws', 'http'].includes(proxy.network)) {
|
||||||
delete params.path;
|
opts[`${proxy.network}-service-name`] = params.path;
|
||||||
|
delete params.path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (params.path) {
|
if (params.path) {
|
||||||
opts.path = params.path;
|
opts.path = params.path;
|
||||||
|
@ -39,6 +39,9 @@ export default function URI_Producer() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (proxy['udp-over-tcp']) {
|
||||||
|
result = `${result}${proxy.plugin ? '&' : '?'}uot=1`;
|
||||||
|
}
|
||||||
result += `#${encodeURIComponent(proxy.name)}`;
|
result += `#${encodeURIComponent(proxy.name)}`;
|
||||||
break;
|
break;
|
||||||
case 'ssr':
|
case 'ssr':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user