From b008ff4ad236f20f0937dd02e747ca6581e776f3 Mon Sep 17 00:00:00 2001 From: Sanaei Date: Sun, 7 Sep 2025 22:35:38 +0200 Subject: Vlessenc (#3426) * mlkem768 * VlessEnc --- web/assets/js/model/inbound.js | 45 ++++++++++++++++++++++------- web/assets/js/model/outbound.js | 8 +++--- web/controller/server.go | 10 +++++++ web/html/form/outbound.html | 5 ++++ web/html/form/protocol/vless.html | 24 +++++++++++++++- web/html/form/tls_settings.html | 8 +++--- web/html/inbounds.html | 6 ++-- web/html/modals/inbound_info_modal.html | 6 ++++ web/html/modals/inbound_modal.html | 48 +++++++++++++++++++++++-------- web/service/server.go | 50 +++++++++++++++++++++++++++++++++ web/translation/translate.ar_EG.toml | 1 + web/translation/translate.en_US.toml | 1 + web/translation/translate.es_ES.toml | 1 + web/translation/translate.fa_IR.toml | 1 + web/translation/translate.id_ID.toml | 1 + web/translation/translate.ja_JP.toml | 1 + web/translation/translate.pt_BR.toml | 1 + web/translation/translate.ru_RU.toml | 1 + web/translation/translate.tr_TR.toml | 1 + web/translation/translate.uk_UA.toml | 1 + web/translation/translate.vi_VN.toml | 3 +- web/translation/translate.zh_CN.toml | 1 + web/translation/translate.zh_TW.toml | 1 + 23 files changed, 190 insertions(+), 35 deletions(-) (limited to 'web') diff --git a/web/assets/js/model/inbound.js b/web/assets/js/model/inbound.js index c91dbd11..1fc8ea19 100644 --- a/web/assets/js/model/inbound.js +++ b/web/assets/js/model/inbound.js @@ -1301,6 +1301,7 @@ class Inbound extends XrayCommonClass { const security = forceTls == 'same' ? this.stream.security : forceTls; const params = new Map(); params.set("type", this.stream.network); + params.set("encryption", this.settings.encryption); switch (type) { case "tcp": const tcp = this.stream.tcp; @@ -1859,13 +1860,16 @@ Inbound.VLESSSettings = class extends Inbound.Settings { constructor( protocol, vlesses = [new Inbound.VLESSSettings.VLESS()], - decryption = 'none', - fallbacks = [] + decryption = "none", + encryption = "", + fallbacks = [], ) { super(protocol); this.vlesses = vlesses; this.decryption = decryption; + this.encryption = encryption; this.fallbacks = fallbacks; + this.selectedAuth = "X25519, not Post-Quantum"; } addFallback() { @@ -1876,22 +1880,43 @@ Inbound.VLESSSettings = class extends Inbound.Settings { this.fallbacks.splice(index, 1); } - // decryption should be set to static value static fromJson(json = {}) { - return new Inbound.VLESSSettings( + const obj = new Inbound.VLESSSettings( Protocols.VLESS, - json.clients.map(client => Inbound.VLESSSettings.VLESS.fromJson(client)), - json.decryption || 'none', - Inbound.VLESSSettings.Fallback.fromJson(json.fallbacks),); + (json.clients || []).map(client => Inbound.VLESSSettings.VLESS.fromJson(client)), + json.decryption, + json.encryption, + Inbound.VLESSSettings.Fallback.fromJson(json.fallbacks || []) + ); + obj.selectedAuth = json.selectedAuth || "X25519, not Post-Quantum"; + return obj; } + toJson() { - return { + const json = { clients: Inbound.VLESSSettings.toJsonArray(this.vlesses), - decryption: this.decryption, - fallbacks: Inbound.VLESSSettings.toJsonArray(this.fallbacks), }; + + if (this.decryption) { + json.decryption = this.decryption; + } + + if (this.encryption) { + json.encryption = this.encryption; + } + + if (this.fallbacks && this.fallbacks.length > 0) { + json.fallbacks = Inbound.VLESSSettings.toJsonArray(this.fallbacks); + } + if (this.selectedAuth) { + json.selectedAuth = this.selectedAuth; + } + + return json; } + + }; Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { diff --git a/web/assets/js/model/outbound.js b/web/assets/js/model/outbound.js index ee78795f..2d5660fb 100644 --- a/web/assets/js/model/outbound.js +++ b/web/assets/js/model/outbound.js @@ -813,7 +813,7 @@ class Outbound extends CommonClass { var settings; switch (protocol) { case Protocols.VLESS: - settings = new Outbound.VLESSSettings(address, port, userData, url.searchParams.get('flow') ?? ''); + settings = new Outbound.VLESSSettings(address, port, userData, url.searchParams.get('flow') ?? '', url.searchParams.get('encryption') ?? 'none'); break; case Protocols.Trojan: settings = new Outbound.TrojanSettings(address, port, userData); @@ -1046,13 +1046,13 @@ Outbound.VmessSettings = class extends CommonClass { } }; Outbound.VLESSSettings = class extends CommonClass { - constructor(address, port, id, flow, encryption = 'none') { + constructor(address, port, id, flow, encryption) { super(); this.address = address; this.port = port; this.id = id; this.flow = flow; - this.encryption = encryption + this.encryption = encryption; } static fromJson(json = {}) { @@ -1071,7 +1071,7 @@ Outbound.VLESSSettings = class extends CommonClass { vnext: [{ address: this.address, port: this.port, - users: [{ id: this.id, flow: this.flow, encryption: 'none', }], + users: [{ id: this.id, flow: this.flow, encryption: this.encryption }], }], }; } diff --git a/web/controller/server.go b/web/controller/server.go index 2d2f741e..b1174b8f 100644 --- a/web/controller/server.go +++ b/web/controller/server.go @@ -55,6 +55,7 @@ func (a *ServerController) initRouter(g *gin.RouterGroup) { g.POST("/getNewX25519Cert", a.getNewX25519Cert) g.POST("/getNewmldsa65", a.getNewmldsa65) g.POST("/getNewEchCert", a.getNewEchCert) + g.POST("/getNewVlessEnc", a.getNewVlessEnc) } func (a *ServerController) refreshStatus() { @@ -266,3 +267,12 @@ func (a *ServerController) getNewEchCert(c *gin.Context) { } jsonObj(c, cert, nil) } + +func (a *ServerController) getNewVlessEnc(c *gin.Context) { + out, err := a.serverService.GetNewVlessEnc() + if err != nil { + jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.getNewVlessEncError"), err) + return + } + jsonObj(c, out, nil) +} diff --git a/web/html/form/outbound.html b/web/html/form/outbound.html index c7a786b7..cfaaafd7 100644 --- a/web/html/form/outbound.html +++ b/web/html/form/outbound.html @@ -226,6 +226,11 @@ +