diff --git a/web/assets/js/model/inbound.js b/web/assets/js/model/inbound.js
index a3c1d017..37fa0e4f 100644
--- a/web/assets/js/model/inbound.js
+++ b/web/assets/js/model/inbound.js
@@ -2250,10 +2250,11 @@ class Inbound extends XrayCommonClass {
}
getWireguardTxt(address, port, remark, peerId) {
+ const DNS = this.settings.DNS || '1.1.1.1, 1.0.0.1';
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`
}
@@ -2275,6 +2276,8 @@ class Inbound extends XrayCommonClass {
const peer = this.settings?.peers?.[peerId];
if (!peer) return '';
+ const DNS = this.settings.DNS || '1.1.1.1, 1.0.0.1';
+
const link = `wireguard://${address}:${port}`;
const url = new URL(link);
url.username = peer.privateKey || '';
@@ -2288,6 +2291,9 @@ class Inbound extends XrayCommonClass {
if (this.settings?.mtu) {
url.searchParams.set("mtu", this.settings.mtu);
}
+ if (DNS) {
+ url.searchParams.set("dns", DNS);
+ }
url.hash = encodeURIComponent(remark);
return url.toString();
@@ -3095,7 +3101,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;
@@ -3103,6 +3110,7 @@ Inbound.WireguardSettings = class extends XrayCommonClass {
this.pubKey = secretKey.length > 0 ? Wireguard.generateKeypair(secretKey).publicKey : '';
this.peers = peers;
this.noKernelTun = noKernelTun;
+ this.DNS = DNS || '1.1.1.1, 1.0.0.1';
}
addPeer() {
@@ -3118,8 +3126,9 @@ Inbound.WireguardSettings = class extends XrayCommonClass {
Protocols.WIREGUARD,
json.mtu,
json.secretKey,
- json.peers.map(peer => Inbound.WireguardSettings.Peer.fromJson(peer)),
+ (json.peers || []).map(peer => Inbound.WireguardSettings.Peer.fromJson(peer)),
json.noKernelTun,
+ json.DNS
);
}
@@ -3129,6 +3138,7 @@ Inbound.WireguardSettings = class extends XrayCommonClass {
secretKey: this.secretKey,
peers: Inbound.WireguardSettings.Peer.toJsonArray(this.peers),
noKernelTun: this.noKernelTun,
+ DNS: this.DNS || undefined,
};
}
};
diff --git a/web/html/form/protocol/wireguard.html b/web/html/form/protocol/wireguard.html
index 6a5ff541..189e5d15 100644
--- a/web/html/form/protocol/wireguard.html
+++ b/web/html/form/protocol/wireguard.html
@@ -19,6 +19,10 @@
+
+
+
+