|
@@ -71,7 +71,7 @@ func (a *InboundController) getClientTraffics(c *gin.Context) {
|
|
|
email := c.Param("email")
|
|
|
clientTraffics, err := a.inboundService.GetClientTrafficByEmail(email)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Error getting traffics", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.trafficGetError"), err)
|
|
|
return
|
|
|
}
|
|
|
jsonObj(c, clientTraffics, nil)
|
|
@@ -81,7 +81,7 @@ func (a *InboundController) getClientTrafficsById(c *gin.Context) {
|
|
|
id := c.Param("id")
|
|
|
clientTraffics, err := a.inboundService.GetClientTrafficByID(id)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Error getting traffics", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.trafficGetError"), err)
|
|
|
return
|
|
|
}
|
|
|
jsonObj(c, clientTraffics, nil)
|
|
@@ -91,7 +91,7 @@ func (a *InboundController) addInbound(c *gin.Context) {
|
|
|
inbound := &model.Inbound{}
|
|
|
err := c.ShouldBind(inbound)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, I18nWeb(c, "pages.inbounds.create"), err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundCreateSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
user := session.GetLoginUser(c)
|
|
@@ -104,7 +104,7 @@ func (a *InboundController) addInbound(c *gin.Context) {
|
|
|
|
|
|
needRestart := false
|
|
|
inbound, needRestart, err = a.inboundService.AddInbound(inbound)
|
|
|
- jsonMsgObj(c, I18nWeb(c, "pages.inbounds.create"), inbound, err)
|
|
|
+ jsonMsgObj(c, I18nWeb(c, "pages.inbounds.toasts.inboundCreateSuccess"), inbound, err)
|
|
|
if err == nil && needRestart {
|
|
|
a.xrayService.SetToNeedRestart()
|
|
|
}
|
|
@@ -113,12 +113,12 @@ func (a *InboundController) addInbound(c *gin.Context) {
|
|
|
func (a *InboundController) delInbound(c *gin.Context) {
|
|
|
id, err := strconv.Atoi(c.Param("id"))
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, I18nWeb(c, "delete"), err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundDeleteSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
needRestart := true
|
|
|
needRestart, err = a.inboundService.DelInbound(id)
|
|
|
- jsonMsgObj(c, I18nWeb(c, "delete"), id, err)
|
|
|
+ jsonMsgObj(c, I18nWeb(c, "pages.inbounds.toasts.inboundDeleteSuccess"), id, err)
|
|
|
if err == nil && needRestart {
|
|
|
a.xrayService.SetToNeedRestart()
|
|
|
}
|
|
@@ -127,7 +127,7 @@ func (a *InboundController) delInbound(c *gin.Context) {
|
|
|
func (a *InboundController) updateInbound(c *gin.Context) {
|
|
|
id, err := strconv.Atoi(c.Param("id"))
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
inbound := &model.Inbound{
|
|
@@ -135,12 +135,12 @@ func (a *InboundController) updateInbound(c *gin.Context) {
|
|
|
}
|
|
|
err = c.ShouldBind(inbound)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
needRestart := true
|
|
|
inbound, needRestart, err = a.inboundService.UpdateInbound(inbound)
|
|
|
- jsonMsgObj(c, I18nWeb(c, "pages.inbounds.update"), inbound, err)
|
|
|
+ jsonMsgObj(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), inbound, err)
|
|
|
if err == nil && needRestart {
|
|
|
a.xrayService.SetToNeedRestart()
|
|
|
}
|
|
@@ -163,17 +163,17 @@ func (a *InboundController) clearClientIps(c *gin.Context) {
|
|
|
|
|
|
err := a.inboundService.ClearClientIps(email)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Update", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.updateSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
- jsonMsg(c, "Log Cleared", nil)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.logCleanSuccess"), nil)
|
|
|
}
|
|
|
|
|
|
func (a *InboundController) addInboundClient(c *gin.Context) {
|
|
|
data := &model.Inbound{}
|
|
|
err := c.ShouldBind(data)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -181,10 +181,10 @@ func (a *InboundController) addInboundClient(c *gin.Context) {
|
|
|
|
|
|
needRestart, err = a.inboundService.AddInboundClient(data)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Something went wrong!", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
|
|
|
return
|
|
|
}
|
|
|
- jsonMsg(c, "Client(s) added", nil)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundClientAddSuccess"), nil)
|
|
|
if needRestart {
|
|
|
a.xrayService.SetToNeedRestart()
|
|
|
}
|
|
@@ -193,7 +193,7 @@ func (a *InboundController) addInboundClient(c *gin.Context) {
|
|
|
func (a *InboundController) delInboundClient(c *gin.Context) {
|
|
|
id, err := strconv.Atoi(c.Param("id"))
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
clientId := c.Param("clientId")
|
|
@@ -202,10 +202,10 @@ func (a *InboundController) delInboundClient(c *gin.Context) {
|
|
|
|
|
|
needRestart, err = a.inboundService.DelInboundClient(id, clientId)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Something went wrong!", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
|
|
|
return
|
|
|
}
|
|
|
- jsonMsg(c, "Client deleted", nil)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundClientDeleteSuccess"), nil)
|
|
|
if needRestart {
|
|
|
a.xrayService.SetToNeedRestart()
|
|
|
}
|
|
@@ -217,7 +217,7 @@ func (a *InboundController) updateInboundClient(c *gin.Context) {
|
|
|
inbound := &model.Inbound{}
|
|
|
err := c.ShouldBind(inbound)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -225,10 +225,10 @@ func (a *InboundController) updateInboundClient(c *gin.Context) {
|
|
|
|
|
|
needRestart, err = a.inboundService.UpdateInboundClient(inbound, clientId)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Something went wrong!", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
|
|
|
return
|
|
|
}
|
|
|
- jsonMsg(c, "Client updated", nil)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundClientUpdateSuccess"), nil)
|
|
|
if needRestart {
|
|
|
a.xrayService.SetToNeedRestart()
|
|
|
}
|
|
@@ -237,17 +237,17 @@ func (a *InboundController) updateInboundClient(c *gin.Context) {
|
|
|
func (a *InboundController) resetClientTraffic(c *gin.Context) {
|
|
|
id, err := strconv.Atoi(c.Param("id"))
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
email := c.Param("email")
|
|
|
|
|
|
needRestart, err := a.inboundService.ResetClientTraffic(id, email)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Something went wrong!", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
|
|
|
return
|
|
|
}
|
|
|
- jsonMsg(c, "Traffic has been reset", nil)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.resetInboundClientTrafficSuccess"), nil)
|
|
|
if needRestart {
|
|
|
a.xrayService.SetToNeedRestart()
|
|
|
}
|
|
@@ -256,36 +256,36 @@ func (a *InboundController) resetClientTraffic(c *gin.Context) {
|
|
|
func (a *InboundController) resetAllTraffics(c *gin.Context) {
|
|
|
err := a.inboundService.ResetAllTraffics()
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Something went wrong!", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
|
|
|
return
|
|
|
} else {
|
|
|
a.xrayService.SetToNeedRestart()
|
|
|
}
|
|
|
- jsonMsg(c, "all traffic has been reset", nil)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.resetAllTrafficSuccess"), nil)
|
|
|
}
|
|
|
|
|
|
func (a *InboundController) resetAllClientTraffics(c *gin.Context) {
|
|
|
id, err := strconv.Atoi(c.Param("id"))
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
err = a.inboundService.ResetAllClientTraffics(id)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Something went wrong!", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
|
|
|
return
|
|
|
} else {
|
|
|
a.xrayService.SetToNeedRestart()
|
|
|
}
|
|
|
- jsonMsg(c, "All traffic from the client has been reset.", nil)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.resetAllClientTrafficSuccess"), nil)
|
|
|
}
|
|
|
|
|
|
func (a *InboundController) importInbound(c *gin.Context) {
|
|
|
inbound := &model.Inbound{}
|
|
|
err := json.Unmarshal([]byte(c.PostForm("data")), inbound)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Something went wrong!", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
|
|
|
return
|
|
|
}
|
|
|
user := session.GetLoginUser(c)
|
|
@@ -304,7 +304,7 @@ func (a *InboundController) importInbound(c *gin.Context) {
|
|
|
|
|
|
needRestart := false
|
|
|
inbound, needRestart, err = a.inboundService.AddInbound(inbound)
|
|
|
- jsonMsgObj(c, I18nWeb(c, "pages.inbounds.create"), inbound, err)
|
|
|
+ jsonMsgObj(c, I18nWeb(c, "pages.inbounds.toasts.inboundCreateSuccess"), inbound, err)
|
|
|
if err == nil && needRestart {
|
|
|
a.xrayService.SetToNeedRestart()
|
|
|
}
|
|
@@ -313,15 +313,15 @@ func (a *InboundController) importInbound(c *gin.Context) {
|
|
|
func (a *InboundController) delDepletedClients(c *gin.Context) {
|
|
|
id, err := strconv.Atoi(c.Param("id"))
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), err)
|
|
|
return
|
|
|
}
|
|
|
err = a.inboundService.DelDepletedClients(id)
|
|
|
if err != nil {
|
|
|
- jsonMsg(c, "Something went wrong!", err)
|
|
|
+ jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
|
|
|
return
|
|
|
}
|
|
|
- jsonMsg(c, "All depleted clients are deleted", nil)
|
|
|
+ jsonMsg(c, I18nWeb(c, "pages.inbounds.toasts.delDepletedClientsSuccess"), nil)
|
|
|
}
|
|
|
|
|
|
func (a *InboundController) onlines(c *gin.Context) {
|