diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js
index d0ac503d..13ae44c9 100644
--- a/web/assets/js/model/xray.js
+++ b/web/assets/js/model/xray.js
@@ -6,6 +6,7 @@ const Protocols = {
DOKODEMO: 'dokodemo-door',
SOCKS: 'socks',
HTTP: 'http',
+ WIREGUARD: 'wireguard',
};
const SSMethods = {
@@ -1445,6 +1446,7 @@ Inbound.Settings = class extends XrayCommonClass {
case Protocols.DOKODEMO: return new Inbound.DokodemoSettings(protocol);
case Protocols.SOCKS: return new Inbound.SocksSettings(protocol);
case Protocols.HTTP: return new Inbound.HttpSettings(protocol);
+ case Protocols.WIREGUARD: return new Inbound.WireguardSettings(protocol);
default: return null;
}
}
@@ -1458,6 +1460,7 @@ Inbound.Settings = class extends XrayCommonClass {
case Protocols.DOKODEMO: return Inbound.DokodemoSettings.fromJson(json);
case Protocols.SOCKS: return Inbound.SocksSettings.fromJson(json);
case Protocols.HTTP: return Inbound.HttpSettings.fromJson(json);
+ case Protocols.WIREGUARD: return Inbound.WireguardSettings.fromJson(json);
default: return null;
}
}
@@ -2048,3 +2051,68 @@ Inbound.HttpSettings.HttpAccount = class extends XrayCommonClass {
return new Inbound.HttpSettings.HttpAccount(json.user, json.pass);
}
};
+
+Inbound.WireguardSettings = class extends XrayCommonClass {
+ constructor(protocol, mtu=1420, secretKey='', peers=[new Inbound.WireguardSettings.Peer()], kernelMode=false) {
+ super(protocol);
+ this.mtu = mtu;
+ this.secretKey = secretKey;
+ this.peers = peers;
+ this.kernelMode = kernelMode;
+ }
+
+ addPeer() {
+ this.peers.push(new Inbound.WireguardSettings.Peer());
+ }
+
+ delPeer(index) {
+ this.peers.splice(index, 1);
+ }
+
+ static fromJson(json={}){
+ return new Inbound.WireguardSettings(
+ Protocols.WIREGUARD,
+ json.mtu,
+ json.secretKey,
+ json.peers.map(peer => Inbound.WireguardSettings.Peer.fromJson(peer)),
+ json.kernelMode,
+ );
+ }
+
+ toJson() {
+ return {
+ mtu: this.mtu?? undefined,
+ secretKey: this.secretKey,
+ peers: Inbound.WireguardSettings.Peer.toJsonArray(this.peers),
+ kernelMode: this.kernelMode,
+ };
+ }
+};
+
+Inbound.WireguardSettings.Peer = class extends XrayCommonClass {
+ constructor(publicKey='', psk='', allowedIPs=['0.0.0.0/0','::/0'], keepAlive=0) {
+ super();
+ this.publicKey = publicKey;
+ this.psk = psk;
+ this.allowedIPs = allowedIPs;
+ this.keepAlive = keepAlive;
+ }
+
+ static fromJson(json={}){
+ return new Inbound.WireguardSettings.Peer(
+ json.publicKey,
+ json.preSharedKey,
+ json.allowedIPs,
+ json.keepAlive
+ );
+ }
+
+ toJson() {
+ return {
+ publicKey: this.publicKey,
+ preSharedKey: this.psk.length>0 ? this.psk : undefined,
+ allowedIPs: this.allowedIPs,
+ keepAlive: this.keepAlive?? undefined,
+ };
+ }
+};
\ No newline at end of file
diff --git a/web/html/xui/form/inbound.html b/web/html/xui/form/inbound.html
index dc94fc35..0127a4a5 100644
--- a/web/html/xui/form/inbound.html
+++ b/web/html/xui/form/inbound.html
@@ -95,6 +95,11 @@
{{template "form/http"}}
+
+
+ {{template "form/wireguard"}}
+
+
{{template "form/streamSettings"}}
diff --git a/web/html/xui/form/protocol/wireguard.html b/web/html/xui/form/protocol/wireguard.html
new file mode 100644
index 00000000..09bf3c8a
--- /dev/null
+++ b/web/html/xui/form/protocol/wireguard.html
@@ -0,0 +1,42 @@
+{{define "form/wireguard"}}
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+ Peer [[ index + 1 ]]
+ inbound.settings.delPeer(index)"
+ style="color: rgb(255, 77, 79);cursor: pointer;"/>
+
+
+
+
+
+
+
+
+
+ {{ i18n "pages.xray.wireguard.allowedIPs" }} +
+
+
+
+ -
+
+
+
+
+
+
+
+
+{{end}}
\ No newline at end of file