- optimization: blackholeip is parsed only once at startup

This commit is contained in:
bloved 2021-01-25 17:00:34 +01:00 committed by Gitea
parent fb58749c58
commit 4007fd9eea
3 changed files with 3 additions and 3 deletions

View File

@ -110,7 +110,7 @@ func init() {
conf.ZabovUpDNS = confRaw["upstream"].(string) conf.ZabovUpDNS = confRaw["upstream"].(string)
conf.ZabovSingleBL = confRaw["singlefilters"].(string) conf.ZabovSingleBL = confRaw["singlefilters"].(string)
conf.ZabovDoubleBL = confRaw["doublefilters"].(string) conf.ZabovDoubleBL = confRaw["doublefilters"].(string)
conf.ZabovAddBL = confRaw["blackholeip"].(string) conf.ZabovAddBL = net.ParseIP(confRaw["blackholeip"].(string))
conf.ZabovHostsFile = confRaw["hostsfile"].(string) conf.ZabovHostsFile = confRaw["hostsfile"].(string)
conf.ZabovDNSArray = fileByLines(conf.ZabovUpDNS) conf.ZabovDNSArray = fileByLines(conf.ZabovUpDNS)

View File

@ -282,7 +282,7 @@ func (mydns *handler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
msg.Answer = append(msg.Answer, &dns.A{ msg.Answer = append(msg.Answer, &dns.A{
Hdr: dns.RR_Header{Name: domain, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 60}, Hdr: dns.RR_Header{Name: domain, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 60},
A: net.ParseIP(ZabovConfig.ZabovAddBL), A: ZabovConfig.ZabovAddBL,
}) })
go logQuery(remIP, fqdn, QType, config, timetable, "killed") go logQuery(remIP, fqdn, QType, config, timetable, "killed")
} else { } else {

View File

@ -37,7 +37,7 @@ type handler struct{}
type ZabovConfig struct { type ZabovConfig struct {
ZabovSingleBL string // json:singlefilters -> ZabovSingleBL list of urls returning a file with just names of domains ZabovSingleBL string // json:singlefilters -> ZabovSingleBL list of urls returning a file with just names of domains
ZabovDoubleBL string // json:doublefilters -> ZabovDoubleBL list of urls returning a file with IP<space>domain ZabovDoubleBL string // json:doublefilters -> ZabovDoubleBL list of urls returning a file with IP<space>domain
ZabovAddBL string // json:blackholeip -> ZabovAddBL is the IP we want to send all the clients to. Usually is 127.0.0.1 ZabovAddBL net.IP // json:blackholeip -> ZabovAddBL is the IP we want to send all the clients to. Usually is 127.0.0.1
ZabovHostsFile string // json:hostsfile -> ZabovHostsFile is the file we use to keep our hosts ZabovHostsFile string // json:hostsfile -> ZabovHostsFile is the file we use to keep our hosts
ZabovUpDNS string // json:upstream -> ZabovUpDNS keeps the name of upstream DNSs ZabovUpDNS string // json:upstream -> ZabovUpDNS keeps the name of upstream DNSs
ZabovDNSArray []string // contains all the DNS we mention, parsed from ZabovUpDNS file ZabovDNSArray []string // contains all the DNS we mention, parsed from ZabovUpDNS file