diff --git a/internal/web/actions/default/ns/domains/tsig.go b/internal/web/actions/default/ns/domains/tsig.go new file mode 100644 index 00000000..0b767dc6 --- /dev/null +++ b/internal/web/actions/default/ns/domains/tsig.go @@ -0,0 +1,80 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package domains + +import ( + "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/domains/domainutils" + "github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/iwind/TeaGo/actions" + "github.com/iwind/TeaGo/logs" +) + +type TsigAction struct { + actionutils.ParentAction +} + +func (this *TsigAction) Init() { + this.Nav("", "", "tsig") +} + +func (this *TsigAction) RunGet(params struct { + DomainId int64 +}) { + // 初始化域名信息 + err := domainutils.InitDomain(this.Parent(), params.DomainId) + if err != nil { + this.ErrorPage(err) + return + } + + // TSIG信息 + tsigResp, err := this.RPC().NSDomainRPC().FindEnabledNSDomainTSIG(this.AdminContext(), &pb.FindEnabledNSDomainTSIGRequest{NsDomainId: params.DomainId}) + if err != nil { + this.ErrorPage(err) + return + } + var tsigJSON = tsigResp.TsigJSON + + var tsigConfig = &dnsconfigs.TSIGConfig{} + if len(tsigJSON) > 0 { + err = json.Unmarshal(tsigJSON, tsigConfig) + if err != nil { + // 只是提示错误,仍然允许用户修改 + logs.Error(err) + } + } + this.Data["tsig"] = tsigConfig + + this.Show() +} + +func (this *TsigAction) RunPost(params struct { + DomainId int64 + IsOn bool + + Must *actions.Must + CSRF *actionutils.CSRF +}) { + defer this.CreateLogInfo("修改DNS域名 %d 的TSIG配置", params.DomainId) + + var tsigConfig = &dnsconfigs.TSIGConfig{ + IsOn: params.IsOn, + } + tsigJSON, err := json.Marshal(tsigConfig) + if err != nil { + this.ErrorPage(err) + return + } + _, err = this.RPC().NSDomainRPC().UpdateNSDomainTSIG(this.AdminContext(), &pb.UpdateNSDomainTSIGRequest{ + NsDomainId: params.DomainId, + TsigJSON: tsigJSON, + }) + if err != nil { + this.ErrorPage(err) + return + } + this.Success() +} diff --git a/internal/web/actions/default/ns/init.go b/internal/web/actions/default/ns/init.go index 4336f53d..d5839099 100644 --- a/internal/web/actions/default/ns/init.go +++ b/internal/web/actions/default/ns/init.go @@ -23,6 +23,7 @@ func init() { Post("/delete", new(domains.DeleteAction)). Get("/domain", new(domains.DomainAction)). GetPost("/update", new(domains.UpdateAction)). + GetPost("/tsig", new(domains.TsigAction)). // 域名密钥 Prefix("/ns/domains/keys"). diff --git a/web/public/js/components/ns/ns-access-log-box.js b/web/public/js/components/ns/ns-access-log-box.js index b95c61c4..2eb6bda8 100644 --- a/web/public/js/components/ns/ns-access-log-box.js +++ b/web/public/js/components/ns/ns-access-log-box.js @@ -34,5 +34,8 @@ Vue.component("ns-access-log-box", { }, template: `
[{{accessLog.region}}] {{accessLog.remoteAddr}} [{{accessLog.timeLocal}}] [{{accessLog.networking}}] {{accessLog.questionType}} {{accessLog.questionName}} -> {{accessLog.recordType}} {{accessLog.recordValue}} +
+ 错误:[{{accessLog.error}}] +
` }) \ No newline at end of file diff --git a/web/views/@default/ns/clusters/accessLogs/index.html b/web/views/@default/ns/clusters/accessLogs/index.html index 5c5ee66f..5f6aac20 100644 --- a/web/views/@default/ns/clusters/accessLogs/index.html +++ b/web/views/@default/ns/clusters/accessLogs/index.html @@ -30,7 +30,6 @@ 概要 -
diff --git a/web/views/@default/ns/domains/@domain_menu.html b/web/views/@default/ns/domains/@domain_menu.html index 3efd9210..7e418a5f 100644 --- a/web/views/@default/ns/domains/@domain_menu.html +++ b/web/views/@default/ns/domains/@domain_menu.html @@ -4,5 +4,6 @@ 详情({{domain.name}}) 记录({{domain.countRecords}}) 密钥({{domain.countKeys}}) + TSIG 修改 \ No newline at end of file diff --git a/web/views/@default/ns/domains/keys/index.html b/web/views/@default/ns/domains/keys/index.html index 886d505c..fc187b0f 100644 --- a/web/views/@default/ns/domains/keys/index.html +++ b/web/views/@default/ns/domains/keys/index.html @@ -12,8 +12,8 @@ - - + + diff --git a/web/views/@default/ns/domains/keys/index.js b/web/views/@default/ns/domains/keys/index.js index d438192b..5e697533 100644 --- a/web/views/@default/ns/domains/keys/index.js +++ b/web/views/@default/ns/domains/keys/index.js @@ -10,7 +10,7 @@ Tea.context(function () { this.updateKey = function (keyId) { teaweb.popup(Tea.url(".updatePopup?keyId=" + keyId), { - height: "26em", + height: "27em", callback: function () { teaweb.successRefresh("保存成功") } diff --git a/web/views/@default/ns/domains/tsig.html b/web/views/@default/ns/domains/tsig.html new file mode 100644 index 00000000..67114777 --- /dev/null +++ b/web/views/@default/ns/domains/tsig.html @@ -0,0 +1,16 @@ +{$layout} +{$template "domain_menu"} + + + + +
密钥名称算法密钥名称算法 密码 密码类型 状态
+ + + + +
是否启用TSIG * + +
+ + \ No newline at end of file diff --git a/web/views/@default/ns/domains/tsig.js b/web/views/@default/ns/domains/tsig.js new file mode 100644 index 00000000..295a9aaf --- /dev/null +++ b/web/views/@default/ns/domains/tsig.js @@ -0,0 +1,3 @@ +Tea.context(function () { + this.success = NotifyReloadSuccess("保存成功") +}) \ No newline at end of file