feat: 全部是 WireGuard 节点的订阅, 支持输出为 Surge 模块

This commit is contained in:
xream 2024-04-25 16:55:32 +08:00
parent 6f7da57e3a
commit 8cbb4492be
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
3 changed files with 17 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.14.300", "version": "2.14.301",
"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": {

View File

@ -219,7 +219,7 @@ function produce(proxies, targetPlatform, type, opts = {}) {
$.log(`Producing proxies for target: ${targetPlatform}`); $.log(`Producing proxies for target: ${targetPlatform}`);
if (typeof producer.type === 'undefined' || producer.type === 'SINGLE') { if (typeof producer.type === 'undefined' || producer.type === 'SINGLE') {
let localPort = 10000; let localPort = 10000;
const list = proxies let list = proxies
.map((proxy) => { .map((proxy) => {
try { try {
let line = producer.produce(proxy, type, opts); let line = producer.produce(proxy, type, opts);
@ -245,7 +245,18 @@ function produce(proxies, targetPlatform, type, opts = {}) {
} }
}) })
.filter((line) => line.length > 0); .filter((line) => line.length > 0);
return type === 'internal' ? list : list.join('\n'); list = type === 'internal' ? list : list.join('\n');
if (
targetPlatform.startsWith('Surge') &&
proxies.length > 0 &&
proxies.every((p) => p.type === 'wireguard')
) {
list = `#!name=${proxies[0]?.subName}
#!desc=${proxies[0]?._desc ?? ''}
#!category=${proxies[0]?._category ?? ''}
${list}`;
}
return list;
} else if (producer.type === 'ALL') { } else if (producer.type === 'ALL') {
return producer.produce(proxies, type, opts); return producer.produce(proxies, type, opts);
} }

View File

@ -762,8 +762,8 @@ function wireguard(proxy) {
} }
const result = new Result(proxy); const result = new Result(proxy);
result.append(`# WireGuard Proxy ${proxy.name} result.append(`# > WireGuard Proxy ${proxy.name}
${proxy.name}=wireguard`); # ${proxy.name}=wireguard`);
proxy['section-name'] = getIfNotBlank(proxy['section-name'], proxy.name); proxy['section-name'] = getIfNotBlank(proxy['section-name'], proxy.name);
@ -821,7 +821,7 @@ ${proxy.name}=wireguard`);
); );
result.append(` result.append(`
# WireGuard Section ${proxy.name} # > WireGuard Section ${proxy.name}
[WireGuard ${proxy['section-name']}] [WireGuard ${proxy['section-name']}]
private-key = ${proxy['private-key']}`); private-key = ${proxy['private-key']}`);