实现缓存功能

This commit is contained in:
Alex Yang
2025-11-30 20:20:59 +08:00
parent f623654151
commit c16e147931
33 changed files with 276 additions and 445090 deletions

View File

@@ -12,6 +12,7 @@ type DNSConfig struct {
Timeout int `json:"timeout"`
StatsFile string `json:"statsFile"` // 统计数据持久化文件
SaveInterval int `json:"saveInterval"` // 数据保存间隔(秒)
CacheTTL int `json:"cacheTTL"` // DNS缓存过期时间分钟
}
// HTTPConfig HTTP控制台配置
@@ -88,6 +89,10 @@ func LoadConfig(path string) (*Config, error) {
if config.DNS.SaveInterval == 0 {
config.DNS.SaveInterval = 300 // 默认5分钟保存一次
}
// 默认DNS缓存TTL为30分钟
if config.DNS.CacheTTL == 0 {
config.DNS.CacheTTL = 30 // 默认30分钟
}
if config.HTTP.Port == 0 {
config.HTTP.Port = 8080
}