diff --git a/cfg.go b/cfg.go index c368667..c97201a 100644 --- a/cfg.go +++ b/cfg.go @@ -48,6 +48,7 @@ type cfg struct { ServersString []string `json:"default_servers"` servers []addr Timeout int `json:"timeout"` + TTL int `json:"ttl"` BlacklistFiles []string `json:"blacklist_ips"` blacklistIps item Rules []Rule `json:"rules"` diff --git a/example_config/config.json b/example_config/config.json index 0c43fc5..e4bc881 100644 --- a/example_config/config.json +++ b/example_config/config.json @@ -1,6 +1,7 @@ { "listen":["tcp:0.0.0.0:8053","udp::8053"], "default_servers":["tcp:208.67.222.222:53","tcp:8.8.8.8:53"], + "ttl":3600, "timeout":1, "blacklist_ips":["ip.txt"], "rules":[ diff --git a/routers.go b/routers.go index 8f0a5ed..896ca7c 100644 --- a/routers.go +++ b/routers.go @@ -116,7 +116,7 @@ func initRouters(c *cfg) { c, &dns.Client{Net: "tcp", Timeout: time.Duration(c.Timeout) * time.Second}, &dns.Client{Net: "udp", Timeout: time.Duration(c.Timeout) * time.Second}, - newCache(1000, 5*60*60), // cache 5 hours + newCache(1000, int64(c.TTL)), // cache 5 hours } dns.Handle(".", router) }