mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-14 05:23:09 +00:00
add clientStats to view
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"]
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user