diff --git a/web/controller/inbound.go b/web/controller/inbound.go index 799830b8..e3477936 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -13,7 +13,6 @@ import ( "github.com/mhsanaei/3x-ui/v2/web/session" "github.com/gin-gonic/gin" - "github.com/gin-gonic/gin/binding" ) // InboundController handles HTTP requests related to Xray inbounds management. @@ -123,8 +122,7 @@ func (a *InboundController) addInbound(c *gin.Context) { c.Request.Body = io.NopCloser(bytes.NewBuffer(bodyBytes)) inbound := &model.Inbound{} - err := c.ShouldBindWith(inbound, binding.Form) - // err := c.ShouldBind(inbound) + err := c.ShouldBind(inbound) if err != nil { jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err) return diff --git a/web/service/inbound.go b/web/service/inbound.go index ec15ecbb..e319fab3 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -2460,7 +2460,18 @@ func (s *InboundService) syncWithSlaves(method string, path string, contentType continue } for key, value := range tmp { - form.Set(key, fmt.Sprintf("%v", value)) + if value == nil { // skip nil fields + continue + } + + // if the field is a slice or a map, marshal it to JSON + switch vv := value.(type) { + case map[string]interface{}, []interface{}: + jsonVal, _ := json.Marshal(vv) + form.Set(key, string(jsonVal)) + default: + form.Set(key, fmt.Sprintf("%v", value)) + } } default: logger.Warningf("Unsupported body type: %T for form encoding on server %s", v, server.Name)