Agent 节点免填地址/端口/API令牌(前后端校验)+ 补翻译
This commit is contained in:
@@ -118,8 +118,8 @@ type NodeMutationRequest struct {
|
||||
Name string `json:"name" form:"name" validate:"required"`
|
||||
Remark string `json:"remark" form:"remark"`
|
||||
Scheme string `json:"scheme" form:"scheme" validate:"omitempty,oneof=http https"`
|
||||
Address string `json:"address" form:"address" validate:"required"`
|
||||
Port int `json:"port" form:"port" validate:"gte=1,lte=65535"`
|
||||
Address string `json:"address" form:"address"`
|
||||
Port int `json:"port" form:"port" validate:"gte=0,lte=65535"`
|
||||
BasePath string `json:"basePath" form:"basePath"`
|
||||
ApiToken *string `json:"apiToken,omitempty" form:"apiToken"`
|
||||
ClearApiToken bool `json:"clearApiToken,omitempty" form:"clearApiToken"`
|
||||
@@ -140,6 +140,16 @@ func (r *NodeMutationRequest) validateCredentials(create bool) error {
|
||||
if r == nil {
|
||||
return common.NewError("node request is required")
|
||||
}
|
||||
// Agent nodes dial out to the master; address/port are not needed.
|
||||
// Traditional nodes still require them.
|
||||
if r.NodeType != "agent" {
|
||||
if strings.TrimSpace(r.Address) == "" {
|
||||
return common.NewError("address is required")
|
||||
}
|
||||
if r.Port < 1 || r.Port > 65535 {
|
||||
return common.NewError("port must be between 1 and 65535")
|
||||
}
|
||||
}
|
||||
if r.ApiToken != nil && r.ClearApiToken {
|
||||
return common.NewError("apiToken and clearApiToken are mutually exclusive")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user