diff --git a/web/controller/inbound.go b/web/controller/inbound.go
index a23aed073f..033b8e9912 100644
--- a/web/controller/inbound.go
+++ b/web/controller/inbound.go
@@ -33,6 +33,7 @@ func (a *InboundController) initRouter(g *gin.RouterGroup) {
g.POST("/clientIps/:email", a.getClientIps)
g.POST("/clearClientIps/:email", a.clearClientIps)
+ g.POST("/resetClientTraffic/:email", a.resetClientTraffic)
}
@@ -143,4 +144,14 @@ func (a *InboundController) clearClientIps(c *gin.Context) {
return
}
jsonMsg(c, "Log Cleared", nil)
-}
\ No newline at end of file
+}
+func (a *InboundController) resetClientTraffic(c *gin.Context) {
+ email := c.Param("email")
+
+ err := a.inboundService.ResetClientTraffic(email)
+ if err != nil {
+ jsonMsg(c, "something worng!", err)
+ return
+ }
+ jsonMsg(c, "traffic reseted", nil)
+}
diff --git a/web/html/xui/form/protocol/vless.html b/web/html/xui/form/protocol/vless.html
index db577c4ce0..409efeeb9a 100644
--- a/web/html/xui/form/protocol/vless.html
+++ b/web/html/xui/form/protocol/vless.html
@@ -44,13 +44,19 @@
+
+
+ clear the log
+
+
+
+
+
-
- clear log
@@ -89,45 +95,51 @@
v-model="vless._expiryTime" style="width: 300px;">
+
+
+ reset traffic
+
+
+
+
+
[[ sizeFormat(getUpStats(vless.email)) ]] / [[ sizeFormat(getDownStats(vless.email)) ]]
-
- used : [[ sizeFormat(getUpStats(vless.email) + getDownStats(vless.email)) ]]
-
+ used : [[ sizeFormat(getUpStats(vless.email) + getDownStats(vless.email)) ]]
+
+
+
+
+
+
-
-
-
-
-
diff --git a/web/html/xui/form/protocol/vmess.html b/web/html/xui/form/protocol/vmess.html
index 9c27e561d8..5bffe90316 100644
--- a/web/html/xui/form/protocol/vmess.html
+++ b/web/html/xui/form/protocol/vmess.html
@@ -43,12 +43,18 @@
+
+
+ clear the log
+
+
+
+
+
-
- clear log
@@ -84,47 +90,55 @@
v-model="vmess._expiryTime" style="width: 300px;">
+
+
+ reset traffic
+
+
+
+
+
[[ sizeFormat(getUpStats(vmess.email)) ]] / [[ sizeFormat(getDownStats(vmess.email)) ]]
-
- used : [[ sizeFormat(getUpStats(vmess.email) + getDownStats(vmess.email)) ]]
-
+ used : [[ sizeFormat(getUpStats(vmess.email) + getDownStats(vmess.email)) ]]
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
diff --git a/web/html/xui/inbound_modal.html b/web/html/xui/inbound_modal.html
index 99399b98d6..aed2a03be4 100644
--- a/web/html/xui/inbound_modal.html
+++ b/web/html/xui/inbound_modal.html
@@ -112,6 +112,24 @@
}
event.target.value = ""
},
+ async resetClientTraffic(client,event) {
+ const msg = await HttpUtil.post('/xui/inbound/resetClientTraffic/'+ client.email);
+ if (!msg.success) {
+ return;
+ }
+ clientStats = this.inbound.clientStats
+ if(clientStats.length > 0)
+ {
+ for (const key in clientStats) {
+ if (Object.hasOwnProperty.call(clientStats, key)) {
+ if(clientStats[key]['email'] == client.email){
+ clientStats[key]['up'] = 0
+ clientStats[key]['down'] = 0
+ }
+ }
+ }
+ }
+ },
isExpiry(index) {
return this.inbound.isExpiry(index)
},
diff --git a/web/service/inbound.go b/web/service/inbound.go
index 37a73eae0c..f9c0e732e8 100644
--- a/web/service/inbound.go
+++ b/web/service/inbound.go
@@ -387,6 +387,22 @@ func (s *InboundService) ClearClientIps(clientEmail string) (error) {
err := result.Error
+ if err != nil {
+ return err
+ }
+ return nil
+}
+func (s *InboundService) ResetClientTraffic(clientEmail string) (error) {
+ db := database.GetDB()
+
+ result := db.Model(xray.ClientTraffic{}).
+ Where("email = ?", clientEmail).
+ Update("up", 0).
+ Update("down", 0)
+
+ err := result.Error
+
+
if err != nil {
return err
}