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-07-18 02:10:22 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-07-18 02:10:22 +0300
commit1f78842b707a1190b6a84aded269d664254a7f1d (patch)
treef9226bfda4856a6289a657cff21234738be4f8c3 /web/controller/inbound.go
parent81a057d63876df5ba69260ac6b97aeeb7964c87d (diff)
[feature] using xray API for inbound
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/controller/inbound.go')
-rw-r--r--web/controller/inbound.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/web/controller/inbound.go b/web/controller/inbound.go
index d0e9cc03..219f1211 100644
--- a/web/controller/inbound.go
+++ b/web/controller/inbound.go
@@ -3,7 +3,6 @@ package controller
import (
"fmt"
"strconv"
-
"x-ui/database/model"
"x-ui/logger"
"x-ui/web/global"
@@ -99,11 +98,12 @@ func (a *InboundController) addInbound(c *gin.Context) {
}
user := session.GetLoginUser(c)
inbound.UserId = user.Id
- inbound.Enable = true
inbound.Tag = fmt.Sprintf("inbound-%v", inbound.Port)
- inbound, err = a.inboundService.AddInbound(inbound)
+
+ needRestart := false
+ inbound, needRestart, err = a.inboundService.AddInbound(inbound)
jsonMsgObj(c, I18nWeb(c, "pages.inbounds.create"), inbound, err)
- if err == nil {
+ if err == nil && needRestart {
a.xrayService.SetToNeedRestart()
}
}
@@ -114,9 +114,10 @@ func (a *InboundController) delInbound(c *gin.Context) {
jsonMsg(c, I18nWeb(c, "delete"), err)
return
}
- err = a.inboundService.DelInbound(id)
+ needRestart := true
+ needRestart, err = a.inboundService.DelInbound(id)
jsonMsgObj(c, I18nWeb(c, "delete"), id, err)
- if err == nil {
+ if err == nil && needRestart {
a.xrayService.SetToNeedRestart()
}
}
@@ -135,9 +136,10 @@ func (a *InboundController) updateInbound(c *gin.Context) {
jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err)
return
}
- inbound, err = a.inboundService.UpdateInbound(inbound)
+ needRestart := true
+ inbound, needRestart, err = a.inboundService.UpdateInbound(inbound)
jsonMsgObj(c, I18nWeb(c, "pages.inbounds.update"), inbound, err)
- if err == nil {
+ if err == nil && needRestart {
a.xrayService.SetToNeedRestart()
}
}
@@ -173,7 +175,7 @@ func (a *InboundController) addInboundClient(c *gin.Context) {
return
}
- needRestart := false
+ needRestart := true
needRestart, err = a.inboundService.AddInboundClient(data)
if err != nil {
@@ -194,7 +196,7 @@ func (a *InboundController) delInboundClient(c *gin.Context) {
}
clientId := c.Param("clientId")
- needRestart := false
+ needRestart := true
needRestart, err = a.inboundService.DelInboundClient(id, clientId)
if err != nil {
@@ -217,7 +219,7 @@ func (a *InboundController) updateInboundClient(c *gin.Context) {
return
}
- needRestart := false
+ needRestart := true
needRestart, err = a.inboundService.UpdateInboundClient(inbound, clientId)
if err != nil {
@@ -238,7 +240,7 @@ func (a *InboundController) resetClientTraffic(c *gin.Context) {
}
email := c.Param("email")
- needRestart := false
+ needRestart := true
needRestart, err = a.inboundService.ResetClientTraffic(id, email)
if err != nil {