mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 23:20:26 +08:00
智能DNS支持应答模式配置
This commit is contained in:
@@ -19,6 +19,7 @@ type NSCluster struct {
|
||||
Hosts dbs.JSON `field:"hosts"` // DNS主机地址
|
||||
AutoRemoteStart bool `field:"autoRemoteStart"` // 自动远程启动
|
||||
TimeZone string `field:"timeZone"` // 时区
|
||||
Answer dbs.JSON `field:"answer"` // 应答设置
|
||||
}
|
||||
|
||||
type NSClusterOperator struct {
|
||||
@@ -37,6 +38,7 @@ type NSClusterOperator struct {
|
||||
Hosts any // DNS主机地址
|
||||
AutoRemoteStart any // 自动远程启动
|
||||
TimeZone any // 时区
|
||||
Answer any // 应答设置
|
||||
}
|
||||
|
||||
func NewNSClusterOperator() *NSClusterOperator {
|
||||
|
||||
@@ -3,6 +3,7 @@ package models
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ddosconfigs"
|
||||
)
|
||||
|
||||
@@ -43,3 +44,19 @@ func (this *NSCluster) DecodeHosts() []string {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user