mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-07-31 20:51:59 +08:00
feat: 支持 v2ray SOCKS URI 的输入和输出
This commit is contained in:
parent
6f82294c49
commit
71fc9affbf
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.16.37",
|
"version": "2.16.38",
|
||||||
"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": {
|
||||||
|
@ -76,7 +76,46 @@ function URI_PROXY() {
|
|||||||
};
|
};
|
||||||
return { name, test, parse };
|
return { name, test, parse };
|
||||||
}
|
}
|
||||||
|
function URI_SOCKS() {
|
||||||
|
const name = 'URI SOCKS Parser';
|
||||||
|
const test = (line) => {
|
||||||
|
return /^socks:\/\//.test(line);
|
||||||
|
};
|
||||||
|
const parse = (line) => {
|
||||||
|
// parse url
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
let [__, type, auth, server, port, query, name] = line.match(
|
||||||
|
/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/,
|
||||||
|
);
|
||||||
|
if (port) {
|
||||||
|
port = parseInt(port, 10);
|
||||||
|
} else {
|
||||||
|
$.error(`port is not present in line: ${line}`);
|
||||||
|
throw new Error(`port is not present in line: ${line}`);
|
||||||
|
}
|
||||||
|
let username, password;
|
||||||
|
if (auth) {
|
||||||
|
const parsed = Base64.decode(decodeURIComponent(auth)).split(':');
|
||||||
|
username = parsed[0];
|
||||||
|
password = parsed[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
const proxy = {
|
||||||
|
name:
|
||||||
|
name != null
|
||||||
|
? decodeURIComponent(name)
|
||||||
|
: `${type} ${server}:${port}`,
|
||||||
|
type: 'socks5',
|
||||||
|
server,
|
||||||
|
port,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
};
|
||||||
|
|
||||||
|
return proxy;
|
||||||
|
};
|
||||||
|
return { name, test, parse };
|
||||||
|
}
|
||||||
// Parse SS URI format (only supports new SIP002, legacy format is depreciated).
|
// Parse SS URI format (only supports new SIP002, legacy format is depreciated).
|
||||||
// reference: https://github.com/shadowsocks/shadowsocks-org/wiki/SIP002-URI-Scheme
|
// reference: https://github.com/shadowsocks/shadowsocks-org/wiki/SIP002-URI-Scheme
|
||||||
function URI_SS() {
|
function URI_SS() {
|
||||||
@ -1467,6 +1506,7 @@ function isIP(ip) {
|
|||||||
|
|
||||||
export default [
|
export default [
|
||||||
URI_PROXY(),
|
URI_PROXY(),
|
||||||
|
URI_SOCKS(),
|
||||||
URI_SS(),
|
URI_SS(),
|
||||||
URI_SSR(),
|
URI_SSR(),
|
||||||
URI_VMess(),
|
URI_VMess(),
|
||||||
|
@ -16,6 +16,7 @@ function Base64Encoded() {
|
|||||||
const keys = [
|
const keys = [
|
||||||
'dm1lc3M', // vmess
|
'dm1lc3M', // vmess
|
||||||
'c3NyOi8v', // ssr://
|
'c3NyOi8v', // ssr://
|
||||||
|
'c29ja3M6Ly', // socks://
|
||||||
'dHJvamFu', // trojan
|
'dHJvamFu', // trojan
|
||||||
'c3M6Ly', // ss:/
|
'c3M6Ly', // ss:/
|
||||||
'c3NkOi8v', // ssd://
|
'c3NkOi8v', // ssd://
|
||||||
|
@ -27,6 +27,11 @@ export default function URI_Producer() {
|
|||||||
proxy.server = `[${proxy.server}]`;
|
proxy.server = `[${proxy.server}]`;
|
||||||
}
|
}
|
||||||
switch (proxy.type) {
|
switch (proxy.type) {
|
||||||
|
case 'socks5':
|
||||||
|
result = `socks://${encodeURIComponent(
|
||||||
|
Base64.encode(`${proxy.username}:${proxy.password}`),
|
||||||
|
)}@${proxy.server}:${proxy.port}#${proxy.name}`;
|
||||||
|
break;
|
||||||
case 'ss':
|
case 'ss':
|
||||||
const userinfo = `${proxy.cipher}:${proxy.password}`;
|
const userinfo = `${proxy.cipher}:${proxy.password}`;
|
||||||
result = `ss://${
|
result = `ss://${
|
||||||
|
Loading…
x
Reference in New Issue
Block a user