dnsforward -- rename BlockedTTL to BlockedResponseTTL to be in line with app's config variable.

This commit is contained in:
Eugene Bujak 2018-11-28 18:14:12 +03:00
parent e4a3564706
commit 7120f551c8
2 changed files with 18 additions and 18 deletions

View File

@ -30,7 +30,7 @@ func startDNSServer() error {
newconfig := dnsforward.ServerConfig{ newconfig := dnsforward.ServerConfig{
UDPListenAddr: &net.UDPAddr{Port: config.CoreDNS.Port}, UDPListenAddr: &net.UDPAddr{Port: config.CoreDNS.Port},
BlockedTTL: config.CoreDNS.BlockedResponseTTL, BlockedResponseTTL: config.CoreDNS.BlockedResponseTTL,
Filters: filters, Filters: filters,
} }

View File

@ -75,14 +75,14 @@ func (s *Server) RUnlock() {
// The zero ServerConfig is empty and ready for use. // The zero ServerConfig is empty and ready for use.
type ServerConfig struct { type ServerConfig struct {
UDPListenAddr *net.UDPAddr // if nil, then default is is used (port 53 on *) UDPListenAddr *net.UDPAddr // if nil, then default is is used (port 53 on *)
BlockedTTL uint32 // if 0, then default is used (3600) BlockedResponseTTL uint32 // if 0, then default is used (3600)
Upstreams []Upstream Upstreams []Upstream
Filters []Filter Filters []Filter
} }
var defaultValues = ServerConfig{ var defaultValues = ServerConfig{
UDPListenAddr: &net.UDPAddr{Port: 53}, UDPListenAddr: &net.UDPAddr{Port: 53},
BlockedTTL: 3600, BlockedResponseTTL: 3600,
Upstreams: []Upstream{ Upstreams: []Upstream{
//// dns over HTTPS //// dns over HTTPS
// &dnsOverHTTPS{Address: "https://1.1.1.1/dns-query"}, // &dnsOverHTTPS{Address: "https://1.1.1.1/dns-query"},
@ -273,17 +273,17 @@ func (s *Server) reconfigureListenAddr(new ServerConfig) error {
return nil return nil
} }
func (s *Server) reconfigureBlockedTTL(new ServerConfig) { func (s *Server) reconfigureBlockedResponseTTL(new ServerConfig) {
newVal := new.BlockedTTL newVal := new.BlockedResponseTTL
if newVal == 0 { if newVal == 0 {
newVal = defaultValues.BlockedTTL newVal = defaultValues.BlockedResponseTTL
} }
oldVal := s.BlockedTTL oldVal := s.BlockedResponseTTL
if oldVal == 0 { if oldVal == 0 {
oldVal = defaultValues.BlockedTTL oldVal = defaultValues.BlockedResponseTTL
} }
if newVal != oldVal { if newVal != oldVal {
s.BlockedTTL = new.BlockedTTL s.BlockedResponseTTL = new.BlockedResponseTTL
} }
} }
@ -341,7 +341,7 @@ func (s *Server) reconfigureFilters(new ServerConfig) {
} }
func (s *Server) Reconfigure(new ServerConfig) error { func (s *Server) Reconfigure(new ServerConfig) error {
s.reconfigureBlockedTTL(new) s.reconfigureBlockedResponseTTL(new)
s.reconfigureUpstreams(new) s.reconfigureUpstreams(new)
s.reconfigureFilters(new) s.reconfigureFilters(new)
@ -510,13 +510,13 @@ func (s *Server) genSOA(request *dns.Msg) []dns.RR {
Hdr: dns.RR_Header{ Hdr: dns.RR_Header{
Name: zone, Name: zone,
Rrtype: dns.TypeSOA, Rrtype: dns.TypeSOA,
Ttl: s.BlockedTTL, Ttl: s.BlockedResponseTTL,
Class: dns.ClassINET, Class: dns.ClassINET,
}, },
Mbox: "hostmaster.", // zone will be appended later if it's not empty or "." Mbox: "hostmaster.", // zone will be appended later if it's not empty or "."
} }
if soa.Hdr.Ttl == 0 { if soa.Hdr.Ttl == 0 {
soa.Hdr.Ttl = defaultValues.BlockedTTL soa.Hdr.Ttl = defaultValues.BlockedResponseTTL
} }
if len(zone) > 0 && zone[0] != '.' { if len(zone) > 0 && zone[0] != '.' {
soa.Mbox += zone soa.Mbox += zone