diff --git a/internal/web/actions/default/servers/groups/group/settings/remoteAddr/index.go b/internal/web/actions/default/servers/groups/group/settings/remoteAddr/index.go index 3997e424..36f6225e 100644 --- a/internal/web/actions/default/servers/groups/group/settings/remoteAddr/index.go +++ b/internal/web/actions/default/servers/groups/group/settings/remoteAddr/index.go @@ -10,6 +10,7 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/iwind/TeaGo/actions" + "strings" ) type IndexAction struct { @@ -55,9 +56,22 @@ func (this *IndexAction) RunPost(params struct { this.Fail("参数校验失败:" + err.Error()) } + remoteAddrConfig.Value = strings.TrimSpace(remoteAddrConfig.Value) + err = remoteAddrConfig.Init() + if err != nil { + this.Fail("配置校验失败:" + err.Error()) + return + } + + remoteAddrJSON, err := json.Marshal(remoteAddrConfig) + if err != nil { + this.ErrorPage(err) + return + } + _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebRemoteAddr(this.AdminContext(), &pb.UpdateHTTPWebRemoteAddrRequest{ HttpWebId: params.WebId, - RemoteAddrJSON: params.RemoteAddrJSON, + RemoteAddrJSON: remoteAddrJSON, }) if err != nil { this.ErrorPage(err) diff --git a/internal/web/actions/default/servers/server/settings/locations/remoteAddr/index.go b/internal/web/actions/default/servers/server/settings/locations/remoteAddr/index.go index 7474dca0..9de70758 100644 --- a/internal/web/actions/default/servers/server/settings/locations/remoteAddr/index.go +++ b/internal/web/actions/default/servers/server/settings/locations/remoteAddr/index.go @@ -9,6 +9,7 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/iwind/TeaGo/actions" + "strings" ) type IndexAction struct { @@ -47,9 +48,22 @@ func (this *IndexAction) RunPost(params struct { this.Fail("参数校验失败:" + err.Error()) } + remoteAddrConfig.Value = strings.TrimSpace(remoteAddrConfig.Value) + err = remoteAddrConfig.Init() + if err != nil { + this.Fail("配置校验失败:" + err.Error()) + return + } + + remoteAddrJSON, err := json.Marshal(remoteAddrConfig) + if err != nil { + this.ErrorPage(err) + return + } + _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebRemoteAddr(this.AdminContext(), &pb.UpdateHTTPWebRemoteAddrRequest{ HttpWebId: params.WebId, - RemoteAddrJSON: params.RemoteAddrJSON, + RemoteAddrJSON: remoteAddrJSON, }) if err != nil { this.ErrorPage(err) diff --git a/internal/web/actions/default/servers/server/settings/remoteAddr/index.go b/internal/web/actions/default/servers/server/settings/remoteAddr/index.go index 8da23e30..b6ef573a 100644 --- a/internal/web/actions/default/servers/server/settings/remoteAddr/index.go +++ b/internal/web/actions/default/servers/server/settings/remoteAddr/index.go @@ -10,6 +10,7 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/types" + "strings" ) type IndexAction struct { @@ -58,11 +59,25 @@ func (this *IndexAction) RunPost(params struct { err := json.Unmarshal(params.RemoteAddrJSON, remoteAddrConfig) if err != nil { this.Fail("参数校验失败:" + err.Error()) + return + } + + remoteAddrConfig.Value = strings.TrimSpace(remoteAddrConfig.Value) + err = remoteAddrConfig.Init() + if err != nil { + this.Fail("配置校验失败:" + err.Error()) + return + } + + remoteAddrJSON, err := json.Marshal(remoteAddrConfig) + if err != nil { + this.ErrorPage(err) + return } _, err = this.RPC().HTTPWebRPC().UpdateHTTPWebRemoteAddr(this.AdminContext(), &pb.UpdateHTTPWebRemoteAddrRequest{ HttpWebId: params.WebId, - RemoteAddrJSON: params.RemoteAddrJSON, + RemoteAddrJSON: remoteAddrJSON, }) if err != nil { this.ErrorPage(err)