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:
authorMHSanaei <ho3ein.sanaei@gmail.com>2023-06-05 00:02:19 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-06-05 00:02:19 +0300
commit70f250dfe1e24249a4cc8102e3fef65959dfb15a (patch)
tree9fdc990d656267abf6facafd851ab7b4835be977 /web/controller/inbound.go
parent1030bcf321f15ada665ca3c55436d7c2449b5faf (diff)
[feature] using xray api and more
Improve DB performance [api] backward compatibility: add client by update Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/controller/inbound.go')
-rw-r--r--web/controller/inbound.go29
1 files changed, 20 insertions, 9 deletions
diff --git a/web/controller/inbound.go b/web/controller/inbound.go
index 815f1788..461c4b27 100644
--- a/web/controller/inbound.go
+++ b/web/controller/inbound.go
@@ -79,7 +79,6 @@ func (a *InboundController) getInbound(c *gin.Context) {
}
jsonObj(c, inbound, nil)
}
-
func (a *InboundController) getClientTraffics(c *gin.Context) {
email := c.Param("email")
clientTraffics, err := a.inboundService.GetClientTrafficByEmail(email)
@@ -178,13 +177,15 @@ func (a *InboundController) addInboundClient(c *gin.Context) {
return
}
- err = a.inboundService.AddInboundClient(data)
+ needRestart := false
+
+ needRestart, err = a.inboundService.AddInboundClient(data)
if err != nil {
jsonMsg(c, "Something went wrong!", err)
return
}
jsonMsg(c, "Client(s) added", nil)
- if err == nil {
+ if err == nil && needRestart {
a.xrayService.SetToNeedRestart()
}
}
@@ -197,13 +198,15 @@ func (a *InboundController) delInboundClient(c *gin.Context) {
}
clientId := c.Param("clientId")
- err = a.inboundService.DelInboundClient(id, clientId)
+ needRestart := false
+
+ needRestart, err = a.inboundService.DelInboundClient(id, clientId)
if err != nil {
jsonMsg(c, "Something went wrong!", err)
return
}
jsonMsg(c, "Client deleted", nil)
- if err == nil {
+ if err == nil && needRestart {
a.xrayService.SetToNeedRestart()
}
}
@@ -218,13 +221,15 @@ func (a *InboundController) updateInboundClient(c *gin.Context) {
return
}
- err = a.inboundService.UpdateInboundClient(inbound, clientId)
+ needRestart := false
+
+ needRestart, err = a.inboundService.UpdateInboundClient(inbound, clientId)
if err != nil {
jsonMsg(c, "Something went wrong!", err)
return
}
jsonMsg(c, "Client updated", nil)
- if err == nil {
+ if err == nil && needRestart {
a.xrayService.SetToNeedRestart()
}
}
@@ -237,13 +242,15 @@ func (a *InboundController) resetClientTraffic(c *gin.Context) {
}
email := c.Param("email")
- err = a.inboundService.ResetClientTraffic(id, email)
+ needRestart := false
+
+ needRestart, err = a.inboundService.ResetClientTraffic(id, email)
if err != nil {
jsonMsg(c, "Something went wrong!", err)
return
}
jsonMsg(c, "traffic reseted", nil)
- if err == nil {
+ if err == nil && needRestart {
a.xrayService.SetToNeedRestart()
}
}
@@ -253,6 +260,8 @@ func (a *InboundController) resetAllTraffics(c *gin.Context) {
if err != nil {
jsonMsg(c, "Something went wrong!", err)
return
+ } else {
+ a.xrayService.SetToNeedRestart()
}
jsonMsg(c, "All traffics reseted", nil)
}
@@ -268,6 +277,8 @@ func (a *InboundController) resetAllClientTraffics(c *gin.Context) {
if err != nil {
jsonMsg(c, "Something went wrong!", err)
return
+ } else {
+ a.xrayService.SetToNeedRestart()
}
jsonMsg(c, "All traffics of client reseted", nil)
}