fix vless methods , fix config editor

This commit is contained in:
Hossin Asaadi
2022-11-13 11:29:13 -05:00
parent 43bb16be4b
commit 01f063e199
2 changed files with 28 additions and 28 deletions

View File

@@ -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) {

View File

@@ -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)
}