自建DNS增加全局配置

This commit is contained in:
GoEdgeLab
2021-08-07 20:40:36 +08:00
parent 34dcca675d
commit b67728f801
8 changed files with 1537 additions and 16 deletions

13
README.md Normal file
View File

@@ -0,0 +1,13 @@
目录结构:
~~~
pkg/
dnsconfigs - 域名解析和NameServer相关配置
messageconfigs - 消息通知相关配置
nodeconfigs - 边缘节点相关配置
serverconfigs - 网站服务相关配置
systemconfigs - 系统全局配置
configutils/ - 配置公共函数等
errors/ - 错误处理
rpc/ - RPC通讯
~~~

View File

@@ -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
}

View 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
}

View File

@@ -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
}

View 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

File diff suppressed because it is too large Load Diff

View 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)
}
}
}
}

View File

@@ -9,4 +9,5 @@ const (
SettingCodeIPListVersion SettingCode = "ipListVersion" // IP名单的版本号
SettingCodeAdminSecurityConfig SettingCode = "adminSecurityConfig" // 管理员安全设置
SettingCodeDatabaseConfigSetting SettingCode = "databaseConfig" // 数据库相关配置
SettingCodeNSAccessLogSetting SettingCode = "nsAccessLogSetting" // NS相关全局配置
)