Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsurbiks <43953720+surbiks@users.noreply.github.com>2024-02-07 10:55:31 +0300
committerGitHub <noreply@github.com>2024-02-07 10:55:31 +0300
commit13de2c6ca0d9101d247a81aa06dddbf338441703 (patch)
treef1310e123568c42425790c33fdc67dd6eedf5b3e /web/service
parent6cf29d5145bea39f731410e15472606223e0d7c0 (diff)
add outbound traffic reset (#1767)
Diffstat (limited to 'web/service')
-rw-r--r--web/service/outbound.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/web/service/outbound.go b/web/service/outbound.go
index dc0e0742..244d7a14 100644
--- a/web/service/outbound.go
+++ b/web/service/outbound.go
@@ -78,3 +78,25 @@ func (s *OutboundService) GetOutboundsTraffic() ([]*model.OutboundTraffics, erro
return traffics, nil
}
+
+func (s *OutboundService) ResetOutboundTraffic(tag string) error {
+ db := database.GetDB()
+
+ whereText := "tag "
+ if tag == "-alltags-" {
+ whereText += " <> ?"
+ } else {
+ whereText += " = ?"
+ }
+
+ result := db.Model(model.OutboundTraffics{}).
+ Where(whereText, tag).
+ Updates(map[string]interface{}{"up": 0, "down": 0, "total": 0})
+
+ err := result.Error
+ if err != nil {
+ return err
+ }
+
+ return nil
+}