From 01f063e199c450fa705c26ca9efc38fb4ad864f9 Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Sun, 13 Nov 2022 11:29:13 -0500 Subject: [PATCH] fix vless methods , fix config editor --- web/assets/js/model/xray.js | 44 ++++++++++++++++++------------------- web/service/xray.go | 12 +++++----- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index 2229cba3..79843b4f 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -1259,28 +1259,6 @@ Inbound.VLESSSettings = class extends Inbound.Settings { fallbacks: Inbound.VLESSSettings.toJsonArray(this.fallbacks), }; } - get _expiryTime() { - if (this.expiryTime === 0 || this.expiryTime === "") { - return null; - } - return moment(this.expiryTime); - } - - set _expiryTime(t) { - if (t == null || t === "") { - this.expiryTime = 0; - } else { - this.expiryTime = t.valueOf(); - } - } - get _totalGB() { - return toFixed(this.totalGB / ONE_GB, 2); - } - - set _totalGB(gb) { - this.totalGB = toFixed(gb * ONE_GB, 0); - } - }; Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { @@ -1307,6 +1285,28 @@ Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { ); } + + get _expiryTime() { + if (this.expiryTime === 0 || this.expiryTime === "") { + return null; + } + return moment(this.expiryTime); + } + + set _expiryTime(t) { + if (t == null || t === "") { + this.expiryTime = 0; + } else { + this.expiryTime = t.valueOf(); + } + } + get _totalGB() { + return toFixed(this.totalGB / ONE_GB, 2); + } + + set _totalGB(gb) { + this.totalGB = toFixed(gb * ONE_GB, 0); + } }; Inbound.VLESSSettings.Fallback = class extends XrayCommonClass { constructor(name="", alpn='', path='', dest='', xver=0) { diff --git a/web/service/xray.go b/web/service/xray.go index bfdc23dd..bbfca08d 100644 --- a/web/service/xray.go +++ b/web/service/xray.go @@ -6,7 +6,6 @@ import ( "sync" "x-ui/logger" "x-ui/xray" - "x-ui/database/model" "go.uber.org/atomic" ) @@ -51,7 +50,7 @@ func (s *XrayService) GetXrayVersion() string { } return p.GetVersion() } -func RemoveIndex(s []model.Client, index int) []model.Client { +func RemoveIndex(s []interface{}, index int) []interface{} { return append(s[:index], s[index+1:]...) } @@ -78,9 +77,9 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) { continue } // get settings clients - settings := map[string][]model.Client{} + settings := map[string]interface{}{} json.Unmarshal([]byte(inbound.Settings), &settings) - clients := settings["clients"] + clients := settings["clients"].([]interface{}) @@ -90,10 +89,11 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) { for _, clientTraffic := range clientStats { for index, client := range clients { - if client.Email == clientTraffic.Email { + c := client.(map[string]interface{}) + if c["email"] == clientTraffic.Email { if ! clientTraffic.Enable { clients = RemoveIndex(clients,index) - logger.Info("Remove Inbound User",client.Email) + logger.Info("Remove Inbound User",c["email"] ,index) }