mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-30 16:38:30 +00:00
feat: WireGuard ip 和 ipv6 字段兼容性调整
This commit is contained in:
2 files changed
+28
-1
No files matched your search
@@ -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": {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user