diff --git a/database/model/model.go b/database/model/model.go index 18211ef8..7d0a977c 100644 --- a/database/model/model.go +++ b/database/model/model.go @@ -106,3 +106,10 @@ type Client struct { CreatedAt int64 `json:"created_at,omitempty"` UpdatedAt int64 `json:"updated_at,omitempty"` } + +type VLESSSettings struct { + Clients []Client `json:"clients"` + Decryption string `json:"decryption"` + Encryption string `json:"encryption"` + Fallbacks []any `json:"fallbacks"` +} diff --git a/sub/subController.go b/sub/subController.go index 2f22ecab..3f053740 100644 --- a/sub/subController.go +++ b/sub/subController.go @@ -53,7 +53,6 @@ func (a *SUBController) initRouter(g *gin.RouterGroup) { gJson := g.Group(a.subJsonPath) gLink.GET(":subid", a.subs) - gJson.GET(":subid", a.subJsons) } @@ -85,7 +84,7 @@ func (a *SUBController) subs(c *gin.Context) { // Add headers c.Writer.Header().Set("Subscription-Userinfo", header) c.Writer.Header().Set("Profile-Update-Interval", a.updateInterval) - c.Writer.Header().Set("Profile-Title", "base64:" + base64.StdEncoding.EncodeToString([]byte(a.subTitle))) + c.Writer.Header().Set("Profile-Title", "base64:"+base64.StdEncoding.EncodeToString([]byte(a.subTitle))) if a.subEncrypt { c.String(200, base64.StdEncoding.EncodeToString([]byte(result))) @@ -119,7 +118,7 @@ func (a *SUBController) subJsons(c *gin.Context) { // Add headers c.Writer.Header().Set("Subscription-Userinfo", header) c.Writer.Header().Set("Profile-Update-Interval", a.updateInterval) - c.Writer.Header().Set("Profile-Title", "base64:" + base64.StdEncoding.EncodeToString([]byte(a.subTitle))) + c.Writer.Header().Set("Profile-Title", "base64:"+base64.StdEncoding.EncodeToString([]byte(a.subTitle))) c.String(200, jsonSub) } diff --git a/sub/subJsonService.go b/sub/subJsonService.go index 680a01c0..def8b855 100644 --- a/sub/subJsonService.go +++ b/sub/subJsonService.go @@ -184,8 +184,14 @@ func (s *SubJsonService) getConfig(inbound *model.Inbound, client model.Client, var newOutbounds []json_util.RawMessage switch inbound.Protocol { - case "vmess", "vless": - newOutbounds = append(newOutbounds, s.genVnext(inbound, streamSettings, client)) + case "vmess": + newOutbounds = append(newOutbounds, s.genVnext(inbound, streamSettings, client, "")) + case "vless": + var vlessSettings model.VLESSSettings + _ = json.Unmarshal([]byte(inbound.Settings), &vlessSettings) + + newOutbounds = append(newOutbounds, + s.genVnext(inbound, streamSettings, client, vlessSettings.Encryption)) case "trojan", "shadowsocks": newOutbounds = append(newOutbounds, s.genServer(inbound, streamSettings, client)) } @@ -284,7 +290,7 @@ func (s *SubJsonService) realityData(rData map[string]any) map[string]any { return rltyData } -func (s *SubJsonService) genVnext(inbound *model.Inbound, streamSettings json_util.RawMessage, client model.Client) json_util.RawMessage { +func (s *SubJsonService) genVnext(inbound *model.Inbound, streamSettings json_util.RawMessage, client model.Client, encryption string) json_util.RawMessage { outbound := Outbound{} usersData := make([]UserVnext, 1) @@ -295,7 +301,7 @@ func (s *SubJsonService) genVnext(inbound *model.Inbound, streamSettings json_ut } if inbound.Protocol == model.VLESS { usersData[0].Flow = client.Flow - usersData[0].Encryption = "none" + usersData[0].Encryption = encryption } vnextData := make([]VnextSetting, 1) diff --git a/sub/subService.go b/sub/subService.go index dfb0863e..e6e25e3a 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -313,6 +313,9 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { if inbound.Protocol != model.VLESS { return "" } + var vlessSettings model.VLESSSettings + _ = json.Unmarshal([]byte(inbound.Settings), &vlessSettings) + var stream map[string]any json.Unmarshal([]byte(inbound.StreamSettings), &stream) clients, _ := s.inboundService.GetClients(inbound) @@ -327,6 +330,9 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { port := inbound.Port streamNetwork := stream["network"].(string) params := make(map[string]string) + if vlessSettings.Encryption != "" { + params["encryption"] = vlessSettings.Encryption + } params["type"] = streamNetwork switch streamNetwork { diff --git a/web/assets/js/model/inbound.js b/web/assets/js/model/inbound.js index 11ecb68e..1fc8ea19 100644 --- a/web/assets/js/model/inbound.js +++ b/web/assets/js/model/inbound.js @@ -1861,14 +1861,15 @@ Inbound.VLESSSettings = class extends Inbound.Settings { protocol, vlesses = [new Inbound.VLESSSettings.VLESS()], decryption = "none", - fallbacks = [] + encryption = "", + fallbacks = [], ) { super(protocol); this.vlesses = vlesses; this.decryption = decryption; + this.encryption = encryption; this.fallbacks = fallbacks; this.selectedAuth = "X25519, not Post-Quantum"; - this.encryption = ""; } addFallback() { @@ -1883,13 +1884,11 @@ Inbound.VLESSSettings = class extends Inbound.Settings { const obj = new Inbound.VLESSSettings( Protocols.VLESS, (json.clients || []).map(client => Inbound.VLESSSettings.VLESS.fromJson(client)), - json.decryption || "none", + json.decryption, + json.encryption, Inbound.VLESSSettings.Fallback.fromJson(json.fallbacks || []) ); - - obj.encryption = json.encryption || ""; obj.selectedAuth = json.selectedAuth || "X25519, not Post-Quantum"; - return obj; } @@ -1910,6 +1909,9 @@ Inbound.VLESSSettings = class extends Inbound.Settings { if (this.fallbacks && this.fallbacks.length > 0) { json.fallbacks = Inbound.VLESSSettings.toJsonArray(this.fallbacks); } + if (this.selectedAuth) { + json.selectedAuth = this.selectedAuth; + } return json; } 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 08ecae1f..b1174b8f 100644 --- a/web/controller/server.go +++ b/web/controller/server.go @@ -271,7 +271,7 @@ func (a *ServerController) getNewEchCert(c *gin.Context) { func (a *ServerController) getNewVlessEnc(c *gin.Context) { out, err := a.serverService.GetNewVlessEnc() if err != nil { - jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.getNewmlkem768Error"), err) + 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 @@ +