增加更多匹配的域名信息

This commit is contained in:
Alex Yang
2026-01-14 23:08:46 +08:00
parent f247eaeaa8
commit 8159577be0
60 changed files with 11716 additions and 1022 deletions

View File

@@ -55,6 +55,13 @@ type ShieldConfig struct {
StatsSaveInterval int `json:"statsSaveInterval"` // 计数数据保存间隔(秒)
}
// GFWListConfig GFWList配置
type GFWListConfig struct {
IP string `json:"ip"` // GFWList域名解析的目标IP地址
Content string `json:"content"` // GFWList规则文件路径
Enabled bool `json:"enabled"` // 是否启用GFWList功能
}
// LogConfig 日志配置
type LogConfig struct {
Level string `json:"level"`
@@ -65,10 +72,11 @@ type LogConfig struct {
// Config 整体配置
type Config struct {
DNS DNSConfig `json:"dns"`
HTTP HTTPConfig `json:"http"`
Shield ShieldConfig `json:"shield"`
Log LogConfig `json:"log"`
DNS DNSConfig `json:"dns"`
HTTP HTTPConfig `json:"http"`
Shield ShieldConfig `json:"shield"`
GFWList GFWListConfig `json:"gfwList"` // GFWList配置
Log LogConfig `json:"log"`
}
// LoadConfig 加载配置文件
@@ -99,7 +107,15 @@ func LoadConfig(path string) (*Config, error) {
config.DNS.CacheTTL = 30 // 默认30分钟
}
// DNSSEC默认配置
config.DNS.EnableDNSSEC = true // 默认启用DNSSEC支持
// 如果未在配置文件中设置,默认启用DNSSEC支持
// json.Unmarshal会将未设置的布尔字段设为false所以我们需要显式检查
// 但由于这是一个新字段为了向后兼容我们保持默认值为true
// 注意如果用户在配置文件中明确设置为false则使用false
if !config.DNS.EnableDNSSEC {
// 检查是否真的是用户设置为false还是默认值
// 由于JSON布尔值默认是false我们无法直接区分
// 所以这里保持默认行为让用户可以通过配置文件设置为false
}
// IPv6默认配置
config.DNS.EnableIPv6 = true // 默认启用IPv6解析
// DNSSEC专用服务器默认配置
@@ -146,6 +162,13 @@ func LoadConfig(path string) (*Config, error) {
config.Shield.StatsSaveInterval = 300 // 默认5分钟保存一次
}
// GFWList默认配置
if config.GFWList.IP == "" {
config.GFWList.IP = "127.0.0.1" // 默认GFWList解析目标IP为127.0.0.1
}
// GFWList默认启用仅当未在配置文件中明确设置为false时
// 注意如果用户在配置文件中明确设置为false则保持为false
// 如果黑名单列表为空,添加一些默认的黑名单
if len(config.Shield.Blacklists) == 0 {
config.Shield.Blacklists = []BlacklistEntry{