diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2026-01-18 18:47:01 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2026-01-18 18:47:01 +0300 |
| commit | 88eab032be7197dd87d0b4c9864af4b6b4fd820b (patch) | |
| tree | 65ac15d0025541adbe53e9f9088e19104851f9d4 /web/assets/js | |
| parent | 20ec863f51f4fee88b35c3eaaf370a700b78109e (diff) | |
Add TUN protocol for inbound
Introduces TUN protocol to inbound.js, including a new TunSettings class. Updates inbound form to support TUN protocol and adds a dedicated form template for TUN settings. Translation files are updated with TUN-related strings for all supported languages.
Diffstat (limited to 'web/assets/js')
| -rw-r--r-- | web/assets/js/model/inbound.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/web/assets/js/model/inbound.js b/web/assets/js/model/inbound.js index 8d4b6819..e5fe368f 100644 --- a/web/assets/js/model/inbound.js +++ b/web/assets/js/model/inbound.js @@ -7,6 +7,7 @@ const Protocols = { MIXED: 'mixed', HTTP: 'http', WIREGUARD: 'wireguard', + TUN: 'tun', }; const SSMethods = { @@ -1739,6 +1740,7 @@ Inbound.Settings = class extends XrayCommonClass { case Protocols.MIXED: return new Inbound.MixedSettings(protocol); case Protocols.HTTP: return new Inbound.HttpSettings(protocol); case Protocols.WIREGUARD: return new Inbound.WireguardSettings(protocol); + case Protocols.TUN: return new Inbound.TunSettings(protocol); default: return null; } } @@ -1753,6 +1755,7 @@ Inbound.Settings = class extends XrayCommonClass { case Protocols.MIXED: return Inbound.MixedSettings.fromJson(json); case Protocols.HTTP: return Inbound.HttpSettings.fromJson(json); case Protocols.WIREGUARD: return Inbound.WireguardSettings.fromJson(json); + case Protocols.TUN: return Inbound.TunSettings.fromJson(json); default: return null; } } @@ -2586,3 +2589,34 @@ Inbound.WireguardSettings.Peer = class extends XrayCommonClass { }; } }; + +Inbound.TunSettings = class extends Inbound.Settings { + constructor( + protocol, + name = 'xray0', + mtu = 1500, + userLevel = 0 + ) { + super(protocol); + this.name = name; + this.mtu = mtu; + this.userLevel = userLevel; + } + + static fromJson(json = {}) { + return new Inbound.TunSettings( + Protocols.TUN, + json.name ?? 'xray0', + json.mtu ?? json.MTU ?? 1500, + json.userLevel ?? 0 + ); + } + + toJson() { + return { + name: this.name || 'xray0', + mtu: this.mtu || 1500, + userLevel: this.userLevel || 0, + }; + } +}; |
