feat: WireGuard ip 和 ipv6 字段兼容性调整

This commit is contained in:
xream committed 2026-03-13 20:36:32 +08:00
1 parent 9563df231c
commit 4c52afdbdf
2 files changed
+28 -1

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.21.47",
"version": "2.21.48",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
+27
View File
@@ -671,6 +671,33 @@ function lastParse(proxy) {
proxy['congestion-controller'] || 'cubic';
proxy['udp-relay-mode'] = proxy['udp-relay-mode'] || 'native';
}
if (['wireguard'].includes(proxy.type)) {
if (Array.isArray(proxy.peers) && proxy.peers.length > 0) {
const validPeer =
proxy.peers.find((peer) => peer.ip && peer.ipv6) ||
proxy.peers.find((peer) => peer.ip || peer.ipv6);
if (validPeer) {
if (!proxy.ip) {
proxy.ip = proxy.peers[0]?.ip;
}
if (!proxy.ipv6) {
proxy.ipv6 = proxy.peers[0]?.ipv6;
}
}
}
if (proxy.ip?.includes('/')) {
const [ip] = proxy.ip.split('/');
if (isIPv4(ip)) {
proxy.ip = ip;
}
}
if (proxy.ipv6?.includes('/')) {
const [ip] = proxy.ipv6.split('/');
if (isIPv6(ip)) {
proxy.ipv6 = ip;
}
}
}
return proxy;
}