[feature] using xray api #351

This commit is contained in:
Alireza Ahmadi
2023-06-04 10:53:43 +02:00
parent 3e5a71d65f
commit 9f7e2f21f3
8 changed files with 402 additions and 146 deletions

View File

@@ -147,13 +147,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()
}
}
@@ -166,13 +168,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()
}
}
@@ -187,13 +191,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()
}
}
@@ -206,13 +212,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()
}
}
@@ -222,6 +230,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)
}
@@ -237,6 +247,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)
}