add configure item for ttl

dns
Dingjun 8 years ago
parent 8b6c5a7f26
commit 8bc60e2527

@ -48,6 +48,7 @@ type cfg struct {
ServersString []string `json:"default_servers"` ServersString []string `json:"default_servers"`
servers []addr servers []addr
Timeout int `json:"timeout"` Timeout int `json:"timeout"`
TTL int `json:"ttl"`
BlacklistFiles []string `json:"blacklist_ips"` BlacklistFiles []string `json:"blacklist_ips"`
blacklistIps item blacklistIps item
Rules []Rule `json:"rules"` Rules []Rule `json:"rules"`

@ -1,6 +1,7 @@
{ {
"listen":["tcp:0.0.0.0:8053","udp::8053"], "listen":["tcp:0.0.0.0:8053","udp::8053"],
"default_servers":["tcp:208.67.222.222:53","tcp:8.8.8.8:53"], "default_servers":["tcp:208.67.222.222:53","tcp:8.8.8.8:53"],
"ttl":3600,
"timeout":1, "timeout":1,
"blacklist_ips":["ip.txt"], "blacklist_ips":["ip.txt"],
"rules":[ "rules":[

@ -116,7 +116,7 @@ func initRouters(c *cfg) {
c, c,
&dns.Client{Net: "tcp", Timeout: time.Duration(c.Timeout) * time.Second}, &dns.Client{Net: "tcp", Timeout: time.Duration(c.Timeout) * time.Second},
&dns.Client{Net: "udp", 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) dns.Handle(".", router)
} }

Loading…
Cancel
Save