57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
|
|
|
package domains
|
|
|
|
import (
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
|
"github.com/TeaOSLab/EdgeUser/internal/web/actions/default/ns/domains/domainutils"
|
|
)
|
|
|
|
type VerifyPageAction struct {
|
|
actionutils.ParentAction
|
|
}
|
|
|
|
func (this *VerifyPageAction) RunPost(params struct {
|
|
DomainIds []int64
|
|
}) {
|
|
defer this.CreateLogInfo(codes.NSDomain_LogValidateNSDomains)
|
|
|
|
if len(params.DomainIds) == 0 {
|
|
this.Success()
|
|
return
|
|
}
|
|
|
|
for _, domainId := range params.DomainIds {
|
|
// 检查域名信息
|
|
domainResp, err := this.RPC().NSDomainRPC().FindNSDomain(this.UserContext(), &pb.FindNSDomainRequest{NsDomainId: domainId})
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
var domain = domainResp.NsDomain
|
|
if domain == nil || domain.Status != dnsconfigs.NSDomainStatusNone {
|
|
continue
|
|
}
|
|
|
|
verifyResp, err := this.RPC().NSDomainRPC().VerifyNSDomain(this.UserContext(), &pb.VerifyNSDomainRequest{NsDomainId: domainId})
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
if !verifyResp.IsOk {
|
|
var message = domainutils.VerifyMessageWithCode(verifyResp.ErrorCode)
|
|
if len(message) > 0 {
|
|
this.Fail("域名 '" + domain.Name + "' 验证失败:" + message)
|
|
return
|
|
}
|
|
this.Fail("域名 '" + domain.Name + "' 验证失败")
|
|
return
|
|
}
|
|
}
|
|
|
|
this.Success()
|
|
}
|