Skip to content

Commit

Permalink
feat: 支持 socks5, socks5+tls, http, https(便于输入) 格式输入
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Dec 16, 2024
1 parent 06f3e97 commit 382d22e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Core functionalities:

> ⚠️ Do not use `Shadowrocket` to export URI and then import it as input. It is not a standard URI.
- [x] Normal Proxy(`socks5`, `socks5+tls`, `http`, `https`(it's ok))

example: `socks5+tls://user:pass@ip:port#name`

- [x] URI(SS, SSR, VMess, VLESS, Trojan, Hysteria, Hysteria 2, TUIC v5, WireGuard)
- [x] Clash Proxies YAML
- [x] Clash Proxy JSON(single line)
Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.443",
"version": "2.14.444",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
37 changes: 37 additions & 0 deletions backend/src/core/proxy-utils/parsers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,42 @@ function surge_port_hopping(raw) {
};
}

function URI_PROXY() {
// socks5+tls
// socks5
// http, https(可以这么写)
const name = 'URI PROXY Parser';
const test = (line) => {
return /^(socks5\+tls|socks5|http|https):\/\//.test(line);
};
const parse = (line) => {
// parse url
// eslint-disable-next-line no-unused-vars
let [__, type, tls, username, password, server, port, query, name] =
line.match(
/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?):(\d+?)(\?.*?)?(?:#(.*?))?$/,
);

const proxy = {
name:
name != null
? decodeURIComponent(name)
: `${type} ${server}:${port}`,
type,
tls: tls ? true : false,
server,
port,
username:
username != null ? decodeURIComponent(username) : undefined,
password:
password != null ? decodeURIComponent(password) : undefined,
};

return proxy;
};
return { name, test, parse };
}

// Parse SS URI format (only supports new SIP002, legacy format is depreciated).
// reference: https://github.com/shadowsocks/shadowsocks-org/wiki/SIP002-URI-Scheme
function URI_SS() {
Expand Down Expand Up @@ -1392,6 +1428,7 @@ function isIP(ip) {
}

export default [
URI_PROXY(),
URI_SS(),
URI_SSR(),
URI_VMess(),
Expand Down

0 comments on commit 382d22e

Please sign in to comment.