mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-07-29 22:02:00 +08:00
feat: Loon WireGuard
This commit is contained in:
parent
4973454f58
commit
8c5dca71fb
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.28",
|
"version": "2.14.29",
|
||||||
"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": {
|
||||||
|
@ -503,6 +503,113 @@ function Loon_Http() {
|
|||||||
return { name, test, parse };
|
return { name, test, parse };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Loon_WireGuard() {
|
||||||
|
const name = 'Loon WireGuard Parser';
|
||||||
|
const test = (line) => {
|
||||||
|
return /^.*=\s*wireguard/i.test(line.split(',')[0]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const parse = (line) => {
|
||||||
|
const name = line.match(
|
||||||
|
/(^.*?)\s*?=\s*?wireguard\s*?,.+?\s*?=\s*?.+?/i,
|
||||||
|
)?.[1];
|
||||||
|
line = line.replace(name, '').replace(/^\s*?=\s*?wireguard\s*/i, '');
|
||||||
|
let peers = line.match(
|
||||||
|
/,\s*?peers\s*?=\s*?\[\s*?\{\s*?(.+?)\s*?\}\s*?\]/i,
|
||||||
|
)?.[1];
|
||||||
|
let serverPort = peers.match(
|
||||||
|
/(,|^)\s*?endpoint\s*?=\s*?"?(.+?):(\d+)"?\s*?(,|$)/i,
|
||||||
|
);
|
||||||
|
let server = serverPort?.[2];
|
||||||
|
let port = parseInt(serverPort?.[3], 10);
|
||||||
|
let mtu = line.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];
|
||||||
|
if (mtu) {
|
||||||
|
mtu = parseInt(mtu, 10);
|
||||||
|
}
|
||||||
|
let keepalive = line.match(
|
||||||
|
/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i,
|
||||||
|
)?.[2];
|
||||||
|
if (keepalive) {
|
||||||
|
keepalive = parseInt(keepalive, 10);
|
||||||
|
}
|
||||||
|
let reserved = peers.match(
|
||||||
|
/(,|^)\s*?reserved\s*?=\s*?"?(\[\s*?.+?\s*?\])"?\s*?(,|$)/i,
|
||||||
|
)?.[2];
|
||||||
|
if (reserved) {
|
||||||
|
reserved = JSON.parse(reserved);
|
||||||
|
}
|
||||||
|
|
||||||
|
let dns;
|
||||||
|
let dnsv4 = line.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];
|
||||||
|
let dnsv6 = line.match(
|
||||||
|
/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i,
|
||||||
|
)?.[2];
|
||||||
|
if (dnsv4 || dnsv6) {
|
||||||
|
dns = [];
|
||||||
|
if (dnsv4) {
|
||||||
|
dns.push(dnsv4);
|
||||||
|
}
|
||||||
|
if (dnsv6) {
|
||||||
|
dns.push(dnsv6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let allowedIps = peers
|
||||||
|
.match(/(,|^)\s*?allowed-ips\s*?=\s*?"(.+?)"\s*?(,|$)/i)?.[2]
|
||||||
|
?.split(',')
|
||||||
|
.map((i) => i.trim());
|
||||||
|
let preSharedKey = peers.match(
|
||||||
|
/(,|^)\s*?preshared-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i,
|
||||||
|
)?.[2];
|
||||||
|
let ip = line.match(
|
||||||
|
/(,|^)\s*?interface-ip\s*?=\s*?"?(.+?)"?\s*?(,|$)/i,
|
||||||
|
)?.[2];
|
||||||
|
let ipv6 = line.match(
|
||||||
|
/(,|^)\s*?interface-ipv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i,
|
||||||
|
)?.[2];
|
||||||
|
let publicKey = peers.match(
|
||||||
|
/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i,
|
||||||
|
)?.[2];
|
||||||
|
const proxy = {
|
||||||
|
type: 'wireguard',
|
||||||
|
name,
|
||||||
|
server,
|
||||||
|
port,
|
||||||
|
ip,
|
||||||
|
ipv6,
|
||||||
|
'private-key': line.match(
|
||||||
|
/(,|^)\s*?private-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i,
|
||||||
|
)?.[2],
|
||||||
|
'public-key': publicKey,
|
||||||
|
mtu,
|
||||||
|
keepalive,
|
||||||
|
reserved,
|
||||||
|
'allowed-ips': allowedIps,
|
||||||
|
'preshared-key': preSharedKey,
|
||||||
|
dns,
|
||||||
|
udp: true,
|
||||||
|
peers: [
|
||||||
|
{
|
||||||
|
server,
|
||||||
|
port,
|
||||||
|
ip,
|
||||||
|
ipv6,
|
||||||
|
'public-key': publicKey,
|
||||||
|
'pre-shared-key': preSharedKey,
|
||||||
|
allowed_ips: allowedIps,
|
||||||
|
reserved,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
proxy;
|
||||||
|
if (Array.isArray(proxy.dns) && proxy.dns.length > 0) {
|
||||||
|
proxy['remote-dns-resolve'] = true;
|
||||||
|
}
|
||||||
|
return proxy;
|
||||||
|
};
|
||||||
|
return { name, test, parse };
|
||||||
|
}
|
||||||
|
|
||||||
function Surge_SS() {
|
function Surge_SS() {
|
||||||
const name = 'Surge SS Parser';
|
const name = 'Surge SS Parser';
|
||||||
const test = (line) => {
|
const test = (line) => {
|
||||||
@ -588,6 +695,7 @@ export default [
|
|||||||
Loon_Vless(),
|
Loon_Vless(),
|
||||||
Loon_Trojan(),
|
Loon_Trojan(),
|
||||||
Loon_Http(),
|
Loon_Http(),
|
||||||
|
Loon_WireGuard(),
|
||||||
QX_SS(),
|
QX_SS(),
|
||||||
QX_SSR(),
|
QX_SSR(),
|
||||||
QX_VMess(),
|
QX_VMess(),
|
||||||
|
@ -58,6 +58,9 @@ export default function Clash_Producer() {
|
|||||||
proxy.keepalive =
|
proxy.keepalive =
|
||||||
proxy.keepalive ?? proxy['persistent-keepalive'];
|
proxy.keepalive ?? proxy['persistent-keepalive'];
|
||||||
proxy['persistent-keepalive'] = proxy.keepalive;
|
proxy['persistent-keepalive'] = proxy.keepalive;
|
||||||
|
proxy['preshared-key'] =
|
||||||
|
proxy['preshared-key'] ?? proxy['pre-shared-key'];
|
||||||
|
proxy['pre-shared-key'] = proxy['preshared-key'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -282,7 +282,7 @@ function wireguard(proxy) {
|
|||||||
proxy.ip = proxy.peers[0].ip;
|
proxy.ip = proxy.peers[0].ip;
|
||||||
proxy.ipv6 = proxy.peers[0].ipv6;
|
proxy.ipv6 = proxy.peers[0].ipv6;
|
||||||
proxy['public-key'] = proxy.peers[0]['public-key'];
|
proxy['public-key'] = proxy.peers[0]['public-key'];
|
||||||
proxy['pre-shared-key'] = proxy.peers[0]['pre-shared-key'];
|
proxy['preshared-key'] = proxy.peers[0]['pre-shared-key'];
|
||||||
proxy['allowed-ips'] = proxy.peers[0]['allowed_ips'];
|
proxy['allowed-ips'] = proxy.peers[0]['allowed_ips'];
|
||||||
proxy.reserved = proxy.peers[0].reserved;
|
proxy.reserved = proxy.peers[0].reserved;
|
||||||
}
|
}
|
||||||
@ -320,13 +320,13 @@ function wireguard(proxy) {
|
|||||||
if (reserved) {
|
if (reserved) {
|
||||||
reserved = `,reserved=[${reserved}]`;
|
reserved = `,reserved=[${reserved}]`;
|
||||||
}
|
}
|
||||||
let presharedKey = proxy['pre-shared-key'];
|
let presharedKey = proxy['preshared-key'] ?? proxy['pre-shared-key'];
|
||||||
if (presharedKey) {
|
if (presharedKey) {
|
||||||
presharedKey = `,preshared-key="${presharedKey}"`;
|
presharedKey = `,preshared-key="${presharedKey}"`;
|
||||||
}
|
}
|
||||||
result.append(
|
result.append(
|
||||||
`,peers=[{public-key="${proxy['public-key']}",allowed-ips="${
|
`,peers=[{public-key="${proxy['public-key']}",allowed-ips="${
|
||||||
allowedIps || '0.0.0.0/0,::/0'
|
allowedIps ?? '0.0.0.0/0,::/0'
|
||||||
}",endpoint=${proxy.server}:${proxy.port}${reserved ?? ''}${
|
}",endpoint=${proxy.server}:${proxy.port}${reserved ?? ''}${
|
||||||
presharedKey ?? ''
|
presharedKey ?? ''
|
||||||
}}]`,
|
}}]`,
|
||||||
|
@ -78,6 +78,9 @@ export default function Stash_Producer() {
|
|||||||
proxy.keepalive =
|
proxy.keepalive =
|
||||||
proxy.keepalive ?? proxy['persistent-keepalive'];
|
proxy.keepalive ?? proxy['persistent-keepalive'];
|
||||||
proxy['persistent-keepalive'] = proxy.keepalive;
|
proxy['persistent-keepalive'] = proxy.keepalive;
|
||||||
|
proxy['preshared-key'] =
|
||||||
|
proxy['preshared-key'] ?? proxy['pre-shared-key'];
|
||||||
|
proxy['pre-shared-key'] = proxy['preshared-key'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -91,6 +91,9 @@ export default function Stash_Producer() {
|
|||||||
proxy.keepalive =
|
proxy.keepalive =
|
||||||
proxy.keepalive ?? proxy['persistent-keepalive'];
|
proxy.keepalive ?? proxy['persistent-keepalive'];
|
||||||
proxy['persistent-keepalive'] = proxy.keepalive;
|
proxy['persistent-keepalive'] = proxy.keepalive;
|
||||||
|
proxy['preshared-key'] =
|
||||||
|
proxy['preshared-key'] ?? proxy['pre-shared-key'];
|
||||||
|
proxy['pre-shared-key'] = proxy['preshared-key'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user