mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-14 19:56:02 +08:00
feat: 支持 Shadowsocks 2022 的 URI 输入/输出
This commit is contained in:
parent
bd87e9231e
commit
06f3e97af2
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.442",
|
"version": "2.14.443",
|
||||||
"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": {
|
||||||
|
@ -46,9 +46,15 @@ function URI_SS() {
|
|||||||
content = content.split('#')[0]; // strip proxy name
|
content = content.split('#')[0]; // strip proxy name
|
||||||
// handle IPV4 and IPV6
|
// handle IPV4 and IPV6
|
||||||
let serverAndPortArray = content.match(/@([^/]*)(\/|$)/);
|
let serverAndPortArray = content.match(/@([^/]*)(\/|$)/);
|
||||||
let userInfoStr = Base64.decode(
|
|
||||||
decodeURIComponent(content.split('@')[0]),
|
let rawUserInfoStr = decodeURIComponent(content.split('@')[0]); // 其实应该分隔之后, 用户名和密码再 decodeURIComponent. 但是问题不大
|
||||||
);
|
let userInfoStr;
|
||||||
|
if (rawUserInfoStr?.startsWith('2022-blake3-')) {
|
||||||
|
userInfoStr = rawUserInfoStr;
|
||||||
|
} else {
|
||||||
|
userInfoStr = Base64.decode(rawUserInfoStr);
|
||||||
|
}
|
||||||
|
|
||||||
let query = '';
|
let query = '';
|
||||||
if (!serverAndPortArray) {
|
if (!serverAndPortArray) {
|
||||||
if (content.includes('?')) {
|
if (content.includes('?')) {
|
||||||
@ -73,15 +79,21 @@ function URI_SS() {
|
|||||||
userInfoStr = content.split('@')[0];
|
userInfoStr = content.split('@')[0];
|
||||||
serverAndPortArray = content.match(/@([^/]*)(\/|$)/);
|
serverAndPortArray = content.match(/@([^/]*)(\/|$)/);
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverAndPort = serverAndPortArray[1];
|
const serverAndPort = serverAndPortArray[1];
|
||||||
const portIdx = serverAndPort.lastIndexOf(':');
|
const portIdx = serverAndPort.lastIndexOf(':');
|
||||||
proxy.server = serverAndPort.substring(0, portIdx);
|
proxy.server = serverAndPort.substring(0, portIdx);
|
||||||
proxy.port = `${serverAndPort.substring(portIdx + 1)}`.match(
|
proxy.port = `${serverAndPort.substring(portIdx + 1)}`.match(
|
||||||
/\d+/,
|
/\d+/,
|
||||||
)?.[0];
|
)?.[0];
|
||||||
const userInfo = userInfoStr.match(/(^.*?):(.*$)/);
|
let userInfo = userInfoStr.match(/(^.*?):(.*$)/);
|
||||||
proxy.cipher = userInfo[1];
|
proxy.cipher = userInfo?.[1];
|
||||||
proxy.password = userInfo[2];
|
proxy.password = userInfo?.[2];
|
||||||
|
// if (!proxy.cipher || !proxy.password) {
|
||||||
|
// userInfo = rawUserInfoStr.match(/(^.*?):(.*$)/);
|
||||||
|
// proxy.cipher = userInfo?.[1];
|
||||||
|
// proxy.password = userInfo?.[2];
|
||||||
|
// }
|
||||||
|
|
||||||
// handle obfs
|
// handle obfs
|
||||||
const idx = content.indexOf('?plugin=');
|
const idx = content.indexOf('?plugin=');
|
||||||
|
@ -29,9 +29,13 @@ export default function URI_Producer() {
|
|||||||
switch (proxy.type) {
|
switch (proxy.type) {
|
||||||
case 'ss':
|
case 'ss':
|
||||||
const userinfo = `${proxy.cipher}:${proxy.password}`;
|
const userinfo = `${proxy.cipher}:${proxy.password}`;
|
||||||
result = `ss://${Base64.encode(userinfo)}@${proxy.server}:${
|
result = `ss://${
|
||||||
proxy.port
|
proxy.cipher?.startsWith('2022-blake3-')
|
||||||
}${proxy.plugin ? '/' : ''}`;
|
? `${encodeURIComponent(
|
||||||
|
proxy.cipher,
|
||||||
|
)}:${encodeURIComponent(proxy.password)}`
|
||||||
|
: Base64.encode(userinfo)
|
||||||
|
}@${proxy.server}:${proxy.port}${proxy.plugin ? '/' : ''}`;
|
||||||
if (proxy.plugin) {
|
if (proxy.plugin) {
|
||||||
result += '?plugin=';
|
result += '?plugin=';
|
||||||
const opts = proxy['plugin-opts'];
|
const opts = proxy['plugin-opts'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user