1.4.5.2
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package domain
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
DomainId int64
|
||||
}) {
|
||||
this.RedirectURL("/ns/domains/records?domainId=" + types.String(params.DomainId))
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package domain
|
||||
|
||||
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/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type UpdateStatusPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdateStatusPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *UpdateStatusPopupAction) RunGet(params struct {
|
||||
DomainId int64
|
||||
}) {
|
||||
domainResp, err := this.RPC().NSDomainRPC().FindNSDomain(this.UserContext(), &pb.FindNSDomainRequest{NsDomainId: params.DomainId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var domain = domainResp.NsDomain
|
||||
if domain == nil {
|
||||
this.NotFound("NSDomain", params.DomainId)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["domain"] = maps.Map{
|
||||
"id": domain.Id,
|
||||
"name": domain.Name,
|
||||
"status": domain.Status,
|
||||
}
|
||||
|
||||
this.Data["statusList"] = dnsconfigs.FindAllNSDomainStatusList()
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *UpdateStatusPopupAction) RunPost(params struct {
|
||||
DomainId int64
|
||||
Status string
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
defer this.CreateLogInfo(codes.NSDomain_LogUpdateNSDomainStatus, params.DomainId, params.Status)
|
||||
|
||||
_, err := this.RPC().NSDomainRPC().UpdateNSDomainStatus(this.UserContext(), &pb.UpdateNSDomainStatusRequest{
|
||||
NsDomainId: params.DomainId,
|
||||
Status: params.Status,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package domain
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
||||
"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"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type VerifyPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *VerifyPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *VerifyPopupAction) RunGet(params struct {
|
||||
DomainId int64
|
||||
}) {
|
||||
domainResp, err := this.RPC().NSDomainRPC().FindNSDomain(this.UserContext(), &pb.FindNSDomainRequest{NsDomainId: params.DomainId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var domain = domainResp.NsDomain
|
||||
if domain == nil {
|
||||
this.NotFound("nsDomain", params.DomainId)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["domain"] = maps.Map{
|
||||
"id": domain.Id,
|
||||
"name": domain.Name,
|
||||
"status": domain.Status,
|
||||
}
|
||||
|
||||
// 当前用户可以使用的DNS Hosts
|
||||
if domain.NsCluster == nil || domain.NsCluster.Id <= 0 {
|
||||
this.WriteString("当前域名(" + domain.Name + ")所在集群已被删除,请删除当前域名后重新添加")
|
||||
return
|
||||
}
|
||||
|
||||
var hosts []string
|
||||
hostsResp, err := this.RPC().NSClusterRPC().FindNSClusterHosts(this.UserContext(), &pb.FindNSClusterHostsRequest{
|
||||
NsClusterId: domain.NsCluster.Id,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
hosts = hostsResp.Hosts
|
||||
|
||||
if hosts == nil {
|
||||
hosts = []string{}
|
||||
}
|
||||
this.Data["hosts"] = hosts
|
||||
|
||||
// TXT记录
|
||||
txtResp, err := this.RPC().NSDomainRPC().FindNSDomainVerifyingInfo(this.UserContext(), &pb.FindNSDomainVerifyingInfoRequest{NsDomainId: params.DomainId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["requireTXT"] = txtResp.RequireTXT
|
||||
this.Data["txt"] = txtResp.Txt
|
||||
this.Data["txtExpiresTime"] = timeutil.FormatTime("Y-m-d H:i:s", txtResp.ExpiresAt)
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *VerifyPopupAction) RunPost(params struct {
|
||||
DomainId int64
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
domainResp, err := this.RPC().NSDomainRPC().FindNSDomain(this.UserContext(), &pb.FindNSDomainRequest{NsDomainId: params.DomainId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["isOk"] = false
|
||||
this.Data["message"] = ""
|
||||
this.Data["rawErrorMessage"] = ""
|
||||
|
||||
var domain = domainResp.NsDomain
|
||||
if domain == nil {
|
||||
this.NotFound("nsDomain", params.DomainId)
|
||||
return
|
||||
}
|
||||
|
||||
if domain.Status == dnsconfigs.NSDomainStatusVerified {
|
||||
this.Data["message"] = "已验证"
|
||||
this.Success()
|
||||
return
|
||||
}
|
||||
|
||||
if domain.Status != dnsconfigs.NSDomainStatusNone {
|
||||
this.Data["message"] = "当前状态为:" + dnsconfigs.NSDomainStatusName(domain.Status) + ",不允许验证"
|
||||
this.Success()
|
||||
return
|
||||
}
|
||||
|
||||
// 提交验证
|
||||
verifyResp, err := this.RPC().NSDomainRPC().VerifyNSDomain(this.UserContext(), &pb.VerifyNSDomainRequest{NsDomainId: params.DomainId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
if !verifyResp.IsOk {
|
||||
var message = domainutils.VerifyMessageWithCode(verifyResp.ErrorCode)
|
||||
if len(verifyResp.CurrentTXTValues) > 0 {
|
||||
message += ",当前TXT解析结果为:" + strings.Join(verifyResp.CurrentTXTValues, ", ")
|
||||
} else if len(verifyResp.CurrentNSValues) > 0 {
|
||||
message += ",当前NS解析结果为:" + strings.Join(verifyResp.CurrentNSValues, ", ")
|
||||
}
|
||||
message += "。"
|
||||
|
||||
this.Data["message"] = message
|
||||
this.Data["rawErrorMessage"] = verifyResp.ErrorMessage
|
||||
|
||||
this.Success()
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["isOk"] = true
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user