增加威胁域名审计

This commit is contained in:
Alex Yang
2026-04-03 10:04:07 +08:00
parent 170cdb3537
commit f8e222aaf6
41 changed files with 81016 additions and 4672993 deletions
+47 -6
View File
@@ -76,14 +76,39 @@ type LogConfig struct {
MaxAge int `json:"maxAge"`
}
// QueryLogConfig 查询日志配置
type QueryLogConfig struct {
Enabled bool `json:"enabled"`
RingBufferSize int `json:"ringBufferSize"`
DatabasePath string `json:"databasePath"`
MaxDatabaseSizeMB int `json:"maxDatabaseSizeMB"`
EnableWAL bool `json:"enableWAL"`
// 归档配置
ArchiveEnabled bool `json:"archiveEnabled"`
ArchiveDir string `json:"archiveDir"`
ArchivePrefix string `json:"archivePrefix"`
CompressionLevel int `json:"compressionLevel"`
// 清理配置
RetentionDays int `json:"retentionDays"`
RetentionMonths int `json:"retentionMonths"`
// 查询配置
QueryTimeout int `json:"queryTimeout"`
EnableCache bool `json:"enableCache"`
CacheTTL int `json:"cacheTTL"`
}
// Config 整体配置
type Config struct {
DNS DNSConfig `json:"dns"`
HTTP HTTPConfig `json:"http"`
Shield ShieldConfig `json:"shield"`
GFWList GFWListConfig `json:"gfwList"` // GFWList配置
Threat ThreatConfig `json:"threat"` // 威胁检测配置
Log LogConfig `json:"log"`
DNS DNSConfig `json:"dns"`
HTTP HTTPConfig `json:"http"`
Shield ShieldConfig `json:"shield"`
GFWList GFWListConfig `json:"gfwList"` // GFWList 配置
Threat ThreatConfig `json:"threat"` // 威胁检测配置
Log LogConfig `json:"log"`
QueryLog QueryLogConfig `json:"queryLog"` // 查询日志配置
}
// ThreatConfig 威胁检测配置
@@ -158,6 +183,22 @@ func LoadConfig(path string) (*Config, error) {
MaxBackups: cfg.Section("log").Key("maxBackups").MustInt(10),
MaxAge: cfg.Section("log").Key("maxAge").MustInt(30),
},
QueryLog: QueryLogConfig{
Enabled: cfg.Section("queryLog").Key("enabled").MustBool(true),
RingBufferSize: cfg.Section("queryLog").Key("ringBufferSize").MustInt(10000),
DatabasePath: cfg.Section("queryLog").Key("databasePath").MustString("data/query_logs.db"),
MaxDatabaseSizeMB: cfg.Section("queryLog").Key("maxDatabaseSizeMB").MustInt(1024),
EnableWAL: cfg.Section("queryLog").Key("enableWAL").MustBool(true),
ArchiveEnabled: cfg.Section("queryLog").Key("archiveEnabled").MustBool(true),
ArchiveDir: cfg.Section("queryLog").Key("archiveDir").MustString("data/archive"),
ArchivePrefix: cfg.Section("queryLog").Key("archivePrefix").MustString("querylog"),
CompressionLevel: cfg.Section("queryLog").Key("compressionLevel").MustInt(6),
RetentionDays: cfg.Section("queryLog").Key("retentionDays").MustInt(0),
RetentionMonths: cfg.Section("queryLog").Key("retentionMonths").MustInt(0),
QueryTimeout: cfg.Section("queryLog").Key("queryTimeout").MustInt(5),
EnableCache: cfg.Section("queryLog").Key("enableCache").MustBool(true),
CacheTTL: cfg.Section("queryLog").Key("cacheTTL").MustInt(300),
},
Threat: ThreatConfig{
Enabled: cfg.Section("threat").Key("enabled").MustBool(true),
QueryRateThreshold: cfg.Section("threat").Key("queryRateThreshold").MustInt(0),