From 48ad787f45636a67dfbcedcb2637a321fc85e668 Mon Sep 17 00:00:00 2001 From: SilverPolarFox <269815039+SilverPolarFox@users.noreply.github.com> Date: Mon, 27 Apr 2026 20:25:15 +0300 Subject: [PATCH] WG inbound set DNS --- web/assets/js/model/inbound.js | 25 ++++++++++++++++++++----- web/html/form/protocol/wireguard.html | 8 ++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/web/assets/js/model/inbound.js b/web/assets/js/model/inbound.js index f695d251..2bdd5da3 100644 --- a/web/assets/js/model/inbound.js +++ b/web/assets/js/model/inbound.js @@ -2179,10 +2179,14 @@ class Inbound extends XrayCommonClass { } getWireguardTxt(address, port, remark, peerId) { +<<<<<<< HEAD + const DNS = this.settings.DNS || '1.1.1.1, 1.0.0.1'; +======= +>>>>>>> 0b5c239f98fd112df10ed4846377563a391ebf60 let txt = `[Interface]\n` txt += `PrivateKey = ${this.settings.peers[peerId].privateKey}\n` txt += `Address = ${this.settings.peers[peerId].allowedIPs[0]}\n` - txt += `DNS = 1.1.1.1, 1.0.0.1\n` + txt += `DNS = ${DNS}\n` if (this.settings.mtu) { txt += `MTU = ${this.settings.mtu}\n` } @@ -3035,7 +3039,8 @@ Inbound.WireguardSettings = class extends XrayCommonClass { mtu = 1420, secretKey = Wireguard.generateKeypair().privateKey, peers = [new Inbound.WireguardSettings.Peer()], - noKernelTun = false + noKernelTun = false, + DNS = '1.1.1.1, 1.0.0.1' ) { super(protocol); this.mtu = mtu; @@ -3043,10 +3048,15 @@ Inbound.WireguardSettings = class extends XrayCommonClass { this.pubKey = secretKey.length > 0 ? Wireguard.generateKeypair(secretKey).publicKey : ''; this.peers = peers; this.noKernelTun = noKernelTun; + this.DNS = DNS; + + this.peers.forEach(peer => { + peer.DNS = this.DNS; + }); } addPeer() { - this.peers.push(new Inbound.WireguardSettings.Peer(null, null, '', ['10.0.0.' + (this.peers.length + 2)])); + this.peers.push(new Inbound.WireguardSettings.Peer(null, null, '', ['10.0.0.' + (this.peers.length + 2)], 0, this.DNS)); } delPeer(index) { @@ -3060,6 +3070,7 @@ Inbound.WireguardSettings = class extends XrayCommonClass { json.secretKey, json.peers.map(peer => Inbound.WireguardSettings.Peer.fromJson(peer)), json.noKernelTun, + json.DNS, ); } @@ -3069,12 +3080,13 @@ Inbound.WireguardSettings = class extends XrayCommonClass { secretKey: this.secretKey, peers: Inbound.WireguardSettings.Peer.toJsonArray(this.peers), noKernelTun: this.noKernelTun, + DNS: this.DNS, }; } }; Inbound.WireguardSettings.Peer = class extends XrayCommonClass { - constructor(privateKey, publicKey, psk = '', allowedIPs = ['10.0.0.2/32'], keepAlive = 0) { + constructor(privateKey, publicKey, psk = '', allowedIPs = ['10.0.0.2/32'], keepAlive = 0, DNS = '1.1.1.1, 1.0.0.1') { super(); this.privateKey = privateKey this.publicKey = publicKey; @@ -3087,6 +3099,7 @@ Inbound.WireguardSettings.Peer = class extends XrayCommonClass { }) this.allowedIPs = allowedIPs; this.keepAlive = keepAlive; + this.DNS = DNS; } static fromJson(json = {}) { @@ -3095,7 +3108,8 @@ Inbound.WireguardSettings.Peer = class extends XrayCommonClass { json.publicKey, json.preSharedKey, json.allowedIPs, - json.keepAlive + json.keepAlive, + json.DNS ); } @@ -3109,6 +3123,7 @@ Inbound.WireguardSettings.Peer = class extends XrayCommonClass { preSharedKey: this.psk.length > 0 ? this.psk : undefined, allowedIPs: this.allowedIPs, keepAlive: this.keepAlive ?? undefined, + DNS: this.DNS, }; } }; diff --git a/web/html/form/protocol/wireguard.html b/web/html/form/protocol/wireguard.html index 6a5ff541..db3e933a 100644 --- a/web/html/form/protocol/wireguard.html +++ b/web/html/form/protocol/wireguard.html @@ -19,6 +19,10 @@ + + + + @@ -74,6 +78,10 @@ + + + +