智能DNS支持应答模式配置

This commit is contained in:
刘祥超
2022-09-23 19:01:18 +08:00
parent c94b3c26c1
commit d4a04bc798
2 changed files with 19 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ type NSCluster struct {
Hosts dbs.JSON `field:"hosts"` // DNS主机地址 Hosts dbs.JSON `field:"hosts"` // DNS主机地址
AutoRemoteStart bool `field:"autoRemoteStart"` // 自动远程启动 AutoRemoteStart bool `field:"autoRemoteStart"` // 自动远程启动
TimeZone string `field:"timeZone"` // 时区 TimeZone string `field:"timeZone"` // 时区
Answer dbs.JSON `field:"answer"` // 应答设置
} }
type NSClusterOperator struct { type NSClusterOperator struct {
@@ -37,6 +38,7 @@ type NSClusterOperator struct {
Hosts any // DNS主机地址 Hosts any // DNS主机地址
AutoRemoteStart any // 自动远程启动 AutoRemoteStart any // 自动远程启动
TimeZone any // 时区 TimeZone any // 时区
Answer any // 应答设置
} }
func NewNSClusterOperator() *NSClusterOperator { func NewNSClusterOperator() *NSClusterOperator {

View File

@@ -3,6 +3,7 @@ package models
import ( import (
"encoding/json" "encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ddosconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ddosconfigs"
) )
@@ -43,3 +44,19 @@ func (this *NSCluster) DecodeHosts() []string {
return hosts return hosts
} }
// DecodeAnswerConfig 解析应答设置
func (this *NSCluster) DecodeAnswerConfig() *dnsconfigs.NSAnswerConfig {
var config = dnsconfigs.DefaultNSAnswerConfig()
if IsNull(this.Answer) {
return config
}
err := json.Unmarshal(this.Answer, config)
if err != nil {
remotelogs.Error("NSCluster.DecodeAnswerConfig", "decode failed: "+err.Error())
}
return config
}