mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-03 04:10:25 +08:00
自建DNS增加全局配置
This commit is contained in:
13
README.md
Normal file
13
README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
目录结构:
|
||||
~~~
|
||||
pkg/
|
||||
dnsconfigs - 域名解析和NameServer相关配置
|
||||
messageconfigs - 消息通知相关配置
|
||||
nodeconfigs - 边缘节点相关配置
|
||||
serverconfigs - 网站服务相关配置
|
||||
systemconfigs - 系统全局配置
|
||||
|
||||
configutils/ - 配置公共函数等
|
||||
errors/ - 错误处理
|
||||
rpc/ - RPC通讯
|
||||
~~~
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package dnsconfigs
|
||||
|
||||
type AccessLogRef struct {
|
||||
IsPrior bool `yaml:"isPrior" json:"isPrior"` // 是否覆盖
|
||||
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用
|
||||
}
|
||||
|
||||
func (this *AccessLogRef) Init() error {
|
||||
return nil
|
||||
}
|
||||
13
pkg/dnsconfigs/ns_access_log_ref.go
Normal file
13
pkg/dnsconfigs/ns_access_log_ref.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package dnsconfigs
|
||||
|
||||
type NSAccessLogRef struct {
|
||||
IsPrior bool `yaml:"isPrior" json:"isPrior"` // 是否覆盖
|
||||
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用
|
||||
LogMissingDomains bool `yaml:"logMissingDomains" json:"logMissingDomains"` // 是否记录找不到的域名
|
||||
}
|
||||
|
||||
func (this *NSAccessLogRef) Init() error {
|
||||
return nil
|
||||
}
|
||||
@@ -5,10 +5,10 @@ package dnsconfigs
|
||||
import "fmt"
|
||||
|
||||
type NSNodeConfig struct {
|
||||
Id int64 `yaml:"id" json:"id"`
|
||||
NodeId string `yaml:"nodeId" json:"nodeId"`
|
||||
ClusterId int64 `yaml:"clusterId" json:"clusterId"`
|
||||
AccessLogRef *AccessLogRef `yaml:"accessLogRef" json:"accessLogRef"`
|
||||
Id int64 `yaml:"id" json:"id"`
|
||||
NodeId string `yaml:"nodeId" json:"nodeId"`
|
||||
ClusterId int64 `yaml:"clusterId" json:"clusterId"`
|
||||
AccessLogRef *NSAccessLogRef `yaml:"accessLogRef" json:"accessLogRef"`
|
||||
|
||||
paddedId string
|
||||
}
|
||||
|
||||
6
pkg/dnsconfigs/ns_setting.go
Normal file
6
pkg/dnsconfigs/ns_setting.go
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package dnsconfigs
|
||||
|
||||
type NSSetting struct {
|
||||
}
|
||||
1457
pkg/dnsconfigs/routes.go
Normal file
1457
pkg/dnsconfigs/routes.go
Normal file
File diff suppressed because it is too large
Load Diff
43
pkg/dnsconfigs/routes_test.go
Normal file
43
pkg/dnsconfigs/routes_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package dnsconfigs
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRoutes(t *testing.T) {
|
||||
// 检查代号是否有空,或者代号是否重复
|
||||
|
||||
var codeMap = map[string]bool{} // code => true
|
||||
|
||||
for _, routes := range [][]*Route{
|
||||
AllDefaultChinaProvinceRoutes,
|
||||
AllDefaultISPRoutes,
|
||||
AllDefaultWorldRegionRoutes,
|
||||
} {
|
||||
for _, route := range routes {
|
||||
if len(route.Name) == 0 {
|
||||
t.Fatal("route name should not empty:", route)
|
||||
}
|
||||
if len(route.AliasNames) == 0 {
|
||||
t.Fatal("route alias names should not empty:", route)
|
||||
}
|
||||
if len(route.Code) == 0 || route.Code == "world:" {
|
||||
t.Fatal("route code should not empty:", route)
|
||||
}
|
||||
|
||||
_, ok := codeMap[route.Code]
|
||||
if ok {
|
||||
t.Fatal("code duplicated:", route)
|
||||
}
|
||||
|
||||
codeMap[route.Code] = true
|
||||
|
||||
if strings.HasPrefix(route.Code, "world:sp:") || (strings.HasPrefix(route.Code, "world:") && route.Code != "world:UAR" && len(route.Code) != 8) {
|
||||
t.Log("no shorten code:", route)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,4 +9,5 @@ const (
|
||||
SettingCodeIPListVersion SettingCode = "ipListVersion" // IP名单的版本号
|
||||
SettingCodeAdminSecurityConfig SettingCode = "adminSecurityConfig" // 管理员安全设置
|
||||
SettingCodeDatabaseConfigSetting SettingCode = "databaseConfig" // 数据库相关配置
|
||||
SettingCodeNSAccessLogSetting SettingCode = "nsAccessLogSetting" // NS相关全局配置
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user