mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-02-25 07:05:42 +08:00
自建DNS支持递归查询
This commit is contained in:
@@ -169,6 +169,30 @@ func (this *NSClusterDAO) FindClusterGrantId(tx *dbs.Tx, clusterId int64) (int64
|
||||
FindInt64Col(0)
|
||||
}
|
||||
|
||||
// UpdateRecursion 设置递归DNS
|
||||
func (this *NSClusterDAO) UpdateRecursion(tx *dbs.Tx, clusterId int64, recursionJSON []byte) error {
|
||||
err := this.Query(tx).
|
||||
Pk(clusterId).
|
||||
Set("recursion", recursionJSON).
|
||||
UpdateQuickly()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return this.NotifyUpdate(tx, clusterId)
|
||||
}
|
||||
|
||||
// FindClusterRecursion 读取递归DNS配置
|
||||
func (this *NSClusterDAO) FindClusterRecursion(tx *dbs.Tx, clusterId int64) ([]byte, error) {
|
||||
recursion, err := this.Query(tx).
|
||||
Result("recursion").
|
||||
Pk(clusterId).
|
||||
FindStringCol("")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []byte(recursion), nil
|
||||
}
|
||||
|
||||
// NotifyUpdate 通知更改
|
||||
func (this *NSClusterDAO) NotifyUpdate(tx *dbs.Tx, clusterId int64) error {
|
||||
return SharedNodeTaskDAO.CreateClusterTask(tx, nodeconfigs.NodeRoleDNS, clusterId, NSNodeTaskTypeConfigChanged)
|
||||
|
||||
@@ -9,6 +9,7 @@ type NSCluster struct {
|
||||
State uint8 `field:"state"` // 状态
|
||||
AccessLog string `field:"accessLog"` // 访问日志配置
|
||||
GrantId uint32 `field:"grantId"` // 授权ID
|
||||
Recursion string `field:"recursion"` // 递归DNS设置
|
||||
}
|
||||
|
||||
type NSClusterOperator struct {
|
||||
@@ -19,6 +20,7 @@ type NSClusterOperator struct {
|
||||
State interface{} // 状态
|
||||
AccessLog interface{} // 访问日志配置
|
||||
GrantId interface{} // 授权ID
|
||||
Recursion interface{} // 递归DNS设置
|
||||
}
|
||||
|
||||
func NewNSClusterOperator() *NSClusterOperator {
|
||||
|
||||
@@ -417,6 +417,20 @@ func (this *NSNodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64) (*dnsconfigs.
|
||||
}
|
||||
}
|
||||
|
||||
// 递归DNS配置
|
||||
recursionJSON, err := SharedNSClusterDAO.FindClusterRecursion(tx, int64(node.ClusterId))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(recursionJSON) > 0 {
|
||||
var recursionConfig = &dnsconfigs.RecursionConfig{}
|
||||
err = json.Unmarshal(recursionJSON, recursionConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config.RecursionConfig = recursionConfig
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user