mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-27 06:43:08 +00:00
feat: Loon 支持 Tailscale
This commit is contained in:
6 files changed
+127
-4
No files matched your search
@@ -101,8 +101,8 @@ Push URLs may contain secrets: treat `SUB_STORE_PUSH_SERVICE` as privileged conf
|
||||
- [x] Clash Proxy JSON/JSON5/YAML(single line)
|
||||
> [NaiveProxy](https://telegram.me/zhetengsha/4308)
|
||||
- [x] QX (SS, SSR, VMess, Trojan, HTTP, SOCKS5, VLESS, AnyTLS)
|
||||
- [x] Loon (SS, SSR, VMess, Trojan, HTTP, SOCKS5, SOCKS5-TLS, WireGuard, VLESS, Hysteria 2, AnyTLS)
|
||||
- [x] Surge (Direct, SS, VMess, Trojan, HTTP, HTTPS, HTTP/2 CONNECT, SOCKS5, SOCKS5-TLS, AnyTLS, TrustTunnel, TUIC, Snell, Hysteria 2, MASQUE(Surge), SSH(Password authentication only), External Proxy Program(only for macOS), WireGuard(Surge to Surge))
|
||||
- [x] Loon (SS, SSR, VMess, Trojan, HTTP, SOCKS5, SOCKS5-TLS, WireGuard, VLESS, Hysteria 2, AnyTLS, TailScale)
|
||||
- [x] Surge (Direct, SS, VMess, Trojan, HTTP, HTTPS, HTTP/2 CONNECT, SOCKS5, SOCKS5-TLS, AnyTLS, TrustTunnel, TUIC, Snell, Hysteria 2, VLESS, MASQUE(Surge), SSH(Password authentication only), External Proxy Program(only for macOS), WireGuard(Surge to Surge))
|
||||
- [x] mihomo(Clash.Meta) Compatible (Direct, SS, SSR, VMess, Trojan, HTTP, SOCKS5, Snell, VLESS, WireGuard, Hysteria, Hysteria 2, TUIC, SSH, mieru, sudoku, AnyTLS, MASQUE, Tailscale, GOST Relay, Shadow QUIC, ZeroTier, OpenVPN)
|
||||
|
||||
Deprecated(The frontend doesn't show it, but the backend still supports it, with the query parameter `target=Clash`):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.44.9",
|
||||
"version": "2.44.10",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||
"main": "src/main.js",
|
||||
"packageManager": "pnpm@11.0.9",
|
||||
|
||||
@@ -2806,6 +2806,13 @@ function Loon_Socks5() {
|
||||
return { name, test, parse };
|
||||
}
|
||||
|
||||
function Loon_Tailscale() {
|
||||
const name = 'Loon Tailscale Parser';
|
||||
const test = (line) => /^[^=,]*=\s*tailscale\s*(?:,|$)/i.test(line);
|
||||
const parse = (line) => getLoonParser().parse(line);
|
||||
return { name, test, parse };
|
||||
}
|
||||
|
||||
function Loon_WireGuard() {
|
||||
const name = 'Loon WireGuard Parser';
|
||||
const test = (line) => {
|
||||
@@ -3203,6 +3210,7 @@ export default [
|
||||
Loon_Http(),
|
||||
Loon_Socks5(),
|
||||
Loon_WireGuard(),
|
||||
Loon_Tailscale(),
|
||||
QX_SS(),
|
||||
QX_SSR(),
|
||||
QX_VMess(),
|
||||
|
||||
@@ -72,7 +72,7 @@ const grammars = String.raw`
|
||||
}
|
||||
}
|
||||
|
||||
start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls) {
|
||||
start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls/tailscale) {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,22 @@ http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_m
|
||||
socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
||||
proxy.type = "socks5";
|
||||
}
|
||||
tailscale = tag equals "tailscale"i (tailscale_string/tailscale_bool/tailscale_mtu/idle_session_timeout/udp_relay/block_quic/others)* {
|
||||
proxy.type = "tailscale";
|
||||
if (proxy["exit-node"] === "auto") proxy["exit-node"] = "auto:any";
|
||||
if (proxy["exit-node"] === "none") proxy["exit-node"] = "";
|
||||
}
|
||||
|
||||
tailscale_string = comma key:("auth-key"/"control-url"/"hostname"/"exit-node"/"path-mode"/"ip-mode") equals value:(
|
||||
'"' match:$[^"]* '"' { return match; }
|
||||
/ match:$[^,"]* { return match.trim(); }
|
||||
) {
|
||||
if (value !== "" || key === "exit-node") {
|
||||
proxy[key === "ip-mode" ? "ip-version" : key] = value;
|
||||
}
|
||||
}
|
||||
tailscale_bool = comma key:("accept-routes"/"accept-dns"/"magic-dns") equals flag:bool { proxy[key] = flag; }
|
||||
tailscale_mtu = comma "mtu" equals match:$[0-9]+ { proxy.mtu = Number(match); }
|
||||
|
||||
address = comma server:server comma port:port {
|
||||
proxy.server = server;
|
||||
|
||||
@@ -40,6 +40,8 @@ export default function Loon_Producer() {
|
||||
return socks5(proxy);
|
||||
case 'wireguard':
|
||||
return wireguard(proxy);
|
||||
case 'tailscale':
|
||||
return tailscale(proxy);
|
||||
case 'hysteria2':
|
||||
return hysteria2(proxy);
|
||||
}
|
||||
@@ -700,6 +702,45 @@ function socks5(proxy) {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
function tailscale(proxy) {
|
||||
const result = new Result(proxy);
|
||||
result.append(`${proxy.name}=tailscale`);
|
||||
|
||||
let exitNode = proxy['exit-node'];
|
||||
if (exitNode === 'auto:any') exitNode = 'auto';
|
||||
if (exitNode === '') exitNode = 'none';
|
||||
const stringOptions = {
|
||||
'control-url': proxy['control-url'],
|
||||
'auth-key': proxy['auth-key'],
|
||||
hostname: proxy.hostname,
|
||||
'exit-node': exitNode,
|
||||
};
|
||||
for (const [key, value] of Object.entries(stringOptions)) {
|
||||
if (!value) continue;
|
||||
const quoted =
|
||||
key === 'control-url' || key === 'auth-key' || /[,\s]/.test(value);
|
||||
result.append(`,${key}=${quoted ? `"${value}"` : value}`);
|
||||
}
|
||||
for (const key of [
|
||||
'accept-routes',
|
||||
'accept-dns',
|
||||
'magic-dns',
|
||||
'path-mode',
|
||||
'mtu',
|
||||
'idle-session-timeout',
|
||||
'udp',
|
||||
]) {
|
||||
result.appendIfPresent(`,${key}=${proxy[key]}`, key);
|
||||
}
|
||||
const ipVersion = ipVersions[proxy['ip-version']] || proxy['ip-version'];
|
||||
result.appendIfPresent(`,ip-mode=${ipVersion}`, 'ip-version');
|
||||
const blockQuic = proxy['block-quic'];
|
||||
if (blockQuic === 'on' || blockQuic === 'off') {
|
||||
result.append(`,block-quic=${blockQuic === 'on'}`);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
function wireguard(proxy) {
|
||||
if (Array.isArray(proxy.peers) && proxy.peers.length > 0) {
|
||||
proxy.server = proxy.peers[0].server;
|
||||
|
||||
@@ -466,6 +466,63 @@ describe('Proxy text producers', function () {
|
||||
expect(output).to.equal(raw);
|
||||
});
|
||||
|
||||
it('round-trips Loon Tailscale with optional authentication and explicit settings', function () {
|
||||
const proxies = ProxyUtils.parse(
|
||||
[
|
||||
'Tailnet=tailscale',
|
||||
'Web Login = Tailscale, hostname="loon,device", exit-node=none',
|
||||
'Exit=tailscale,control-url="https://headscale.example.com/?key=a,b",auth-key="test-key=",hostname=loon-device,exit-node=auto,accept-routes=false,accept-dns=true,magic-dns=false,path-mode=derp,mtu=1200,idle-session-timeout=0,ip-mode=v4-only ,server-dns="system,https://dns.example.com/dns-query",udp=false,block-quic=false',
|
||||
].join('\n'),
|
||||
);
|
||||
expect(proxies).to.deep.equal([
|
||||
{ name: 'Tailnet', type: 'tailscale', udp: true },
|
||||
{
|
||||
name: 'Web Login',
|
||||
type: 'tailscale',
|
||||
hostname: 'loon,device',
|
||||
'exit-node': '',
|
||||
udp: true,
|
||||
},
|
||||
{
|
||||
name: 'Exit',
|
||||
type: 'tailscale',
|
||||
'control-url': 'https://headscale.example.com/?key=a,b',
|
||||
'auth-key': 'test-key=',
|
||||
hostname: 'loon-device',
|
||||
'exit-node': 'auto:any',
|
||||
'accept-routes': false,
|
||||
'accept-dns': true,
|
||||
'magic-dns': false,
|
||||
'path-mode': 'derp',
|
||||
mtu: 1200,
|
||||
'idle-session-timeout': 0,
|
||||
'ip-version': 'v4-only',
|
||||
'server-dns': ['system', 'https://dns.example.com/dns-query'],
|
||||
udp: false,
|
||||
'block-quic': 'off',
|
||||
},
|
||||
]);
|
||||
expect(
|
||||
ProxyUtils.parse(produceExternal('Loon', proxies)),
|
||||
).to.deep.equal(proxies);
|
||||
});
|
||||
|
||||
it('exports a mihomo Tailscale node to Loon', function () {
|
||||
const proxies = ProxyUtils.parse(`proxies:
|
||||
- name: Tailnet
|
||||
type: tailscale
|
||||
control-url: https://headscale.example.com
|
||||
auth-key: ""
|
||||
exit-node: auto:any
|
||||
accept-routes: false
|
||||
udp: false
|
||||
ip-version: ipv6-prefer`);
|
||||
|
||||
expect(produceExternal('Loon', proxies)).to.equal(
|
||||
'Tailnet=tailscale,control-url="https://headscale.example.com",exit-node=auto,accept-routes=false,udp=false,ip-mode=prefer-v6',
|
||||
);
|
||||
});
|
||||
|
||||
it('round-trips quoted and unquoted Loon server-dns for every protocol', function () {
|
||||
const inputs = [
|
||||
'SS=shadowsocks,ss.example.com,8388,aes-128-gcm,"secret"',
|
||||
@@ -479,6 +536,7 @@ describe('Proxy text producers', function () {
|
||||
'HTTPS=https,https.example.com,443',
|
||||
'SOCKS5=socks5,socks.example.com,1080',
|
||||
'WG=wireguard,interface-ip=10.0.0.2,private-key=private-key,peers=[{endpoint=wg.example.com:51820,public-key=public-key,allowed-ips="0.0.0.0/0"}]',
|
||||
'Tailnet=tailscale',
|
||||
];
|
||||
const serverDns = [
|
||||
'system',
|
||||
|
||||
Reference in new issue
Block a user