diff options
Diffstat (limited to 'web/controller/inbound.go')
| -rw-r--r-- | web/controller/inbound.go | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/web/controller/inbound.go b/web/controller/inbound.go index 86da9813..b274be64 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -159,24 +159,31 @@ func (a *InboundController) clearClientIps(c *gin.Context) { } 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) - return - } + var requestData []model.Inbound - needRestart := true + err := c.ShouldBindJSON(&requestData) + + if err != nil { + jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err) + return + } + + needRestart := true + + for _, data := range requestData { + + 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 && needRestart { + a.xrayService.SetToNeedRestart() + } - 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 && needRestart { - a.xrayService.SetToNeedRestart() - } } func (a *InboundController) delInboundClient(c *gin.Context) { |
