优化代码

This commit is contained in:
刘祥超
2023-07-12 14:32:47 +08:00
parent 15618ad03b
commit cfde05f5af
3 changed files with 46 additions and 3 deletions

View File

@@ -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)