Files
EdgeCommon/pkg/dnsconfigs/ns_node_config.go

66 lines
1.4 KiB
Go
Raw Normal View History

2021-06-02 11:53:15 +08:00
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package dnsconfigs
2022-07-27 16:56:32 +08:00
import (
"fmt"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
)
2021-06-02 11:53:15 +08:00
type NSNodeConfig struct {
2021-08-23 09:59:43 +08:00
Id int64 `yaml:"id" json:"id"`
NodeId string `yaml:"nodeId" json:"nodeId"`
Secret string `yaml:"secret" json:"secret"`
ClusterId int64 `yaml:"clusterId" json:"clusterId"`
AccessLogRef *NSAccessLogRef `yaml:"accessLogRef" json:"accessLogRef"`
RecursionConfig *RecursionConfig `yaml:"recursionConfig" json:"recursionConfig"`
2021-06-02 11:53:15 +08:00
2022-07-27 16:56:32 +08:00
TCP *serverconfigs.TCPProtocolConfig `yaml:"tcp" json:"tcp"` // TCP配置
TLS *serverconfigs.TLSProtocolConfig `yaml:"tls" json:"tls"` // TLS配置
UDP *serverconfigs.UDPProtocolConfig `yaml:"udp" json:"udp"` // UDP配置
2021-06-02 11:53:15 +08:00
paddedId string
}
func (this *NSNodeConfig) Init() error {
this.paddedId = fmt.Sprintf("%08d", this.Id)
// accessLog
if this.AccessLogRef != nil {
err := this.AccessLogRef.Init()
if err != nil {
return err
}
}
2022-07-27 16:56:32 +08:00
// tcp
if this.TCP != nil {
err := this.TCP.Init()
if err != nil {
return err
}
}
// tls
if this.TLS != nil {
err := this.TLS.Init()
if err != nil {
return err
}
}
// udp
if this.UDP != nil {
err := this.UDP.Init()
if err != nil {
return err
}
}
2021-06-02 11:53:15 +08:00
return nil
}
func (this *NSNodeConfig) PaddedId() string {
return this.paddedId
}