add clientStats to view

This commit is contained in:
Hossin Asaadi
2022-11-11 12:07:24 -05:00
parent 8deffb1b7c
commit 77d24fbede
5 changed files with 50 additions and 5 deletions

View File

@@ -44,7 +44,7 @@ class DBInbound {
this.streamSettings = "";
this.tag = "";
this.sniffing = "";
this.clientStats = ""
if (data == null) {
return;
}
@@ -125,6 +125,10 @@ class DBInbound {
if (!ObjectUtil.isEmpty(this.sniffing)) {
sniffing = JSON.parse(this.sniffing);
}
let clientStats = {};
if (!ObjectUtil.isEmpty(this.clientStats)) {
clientStats = JSON.parse(this.clientStats);
}
const config = {
port: this.port,
listen: this.listen,
@@ -133,6 +137,7 @@ class DBInbound {
streamSettings: streamSettings,
tag: this.tag,
sniffing: sniffing,
clientStats: clientStats,
};
return Inbound.fromJson(config);
}

View File

@@ -608,6 +608,7 @@ class Inbound extends XrayCommonClass {
streamSettings=new StreamSettings(),
tag='',
sniffing=new Sniffing(),
clientStats='',
) {
super();
this.port = port;
@@ -617,6 +618,10 @@ class Inbound extends XrayCommonClass {
this.stream = streamSettings;
this.tag = tag;
this.sniffing = sniffing;
this.clientStats = clientStats;
}
getClientStats() {
return this.clientStats;
}
get protocol() {
@@ -1066,6 +1071,7 @@ class Inbound extends XrayCommonClass {
StreamSettings.fromJson(json.streamSettings),
json.tag,
Sniffing.fromJson(json.sniffing),
json.clientStats
)
}
@@ -1082,6 +1088,7 @@ class Inbound extends XrayCommonClass {
streamSettings: streamSettings,
tag: this.tag,
sniffing: this.sniffing.toJson(),
clientStats: this.clientStats
};
}
}
@@ -1203,6 +1210,14 @@ Inbound.VmessSettings.Vmess = class extends XrayCommonClass {
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 = class extends Inbound.Settings {
@@ -1254,6 +1269,14 @@ Inbound.VLESSSettings = class extends Inbound.Settings {
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 {

View File

@@ -71,9 +71,15 @@
<a-date-picker :show-time="{ format: 'HH:mm' }" format="YYYY-MM-DD HH:mm"
v-model="vmess._expiryTime" style="width: 300px;"></a-date-picker>
</a-form-item>
<!--Add Svg Icon-->
<svg
<a-form layout="inline">
<a-tag color="blue">[[ sizeFormat(getUpStats(vmess.email)) ]] / [[ sizeFormat(getDownStats(vmess.email)) ]]</a-tag>
<a-form v-if="vmess.totalGB > 0">
<a-tag color="red">used : [[ sizeFormat(getUpStats(vmess.email) + getDownStats(vmess.email)) ]]</a-tag>
</a-form>
</a-form>
<!--Add Svg Icon-->
<svg
@click="addClient(inbound.protocol,vmess, inbound.settings.vmesses)"
xmlns="http://www.w3.org/2000/svg"

View File

@@ -115,6 +115,17 @@
isExpiry(index) {
return this.inbound.isExpiry(index)
},
getUpStats(email) {
console.log(email,this.inbound.clientStats[email])
if(this.inbound.clientStats[email])
return this.inbound.clientStats[email]["Up"]
},
getDownStats(email) {
if(this.inbound.clientStats[email])
return this.inbound.clientStats[email]["Down"]
},
},
});

View File

@@ -82,7 +82,7 @@ func (s *XrayService) GetXrayTraffic() ([]*xray.Traffic, error) {
if !s.IsXrayRunning() {
return nil, errors.New("xray is not running")
}
return p.GetTraffic(true)
return p.GetTraffic(false)
}
func (s *XrayService) GetXrayClientTraffic() ([]*xray.ClientTraffic, error) {
if !s.IsXrayRunning() {