Extract method Server.setRebindingConfig()

This commit is contained in:
Reinaldo de Souza Jr 2020-12-05 18:05:40 +01:00
parent 6e6ee9697a
commit f924523f6a
2 changed files with 16 additions and 8 deletions

View file

@ -309,14 +309,7 @@ func (s *Server) setConfig(dc dnsConfig) (restart bool) {
}
}
if dc.RebindingProtectionEnabled != nil {
s.conf.RebindingProtectionEnabled = *dc.RebindingProtectionEnabled
}
if dc.RebindingAllowedHosts != nil {
s.conf.RebindingAllowedHosts = *dc.RebindingAllowedHosts
restart = true
}
restart = restart || s.setRebindingConfig(dc)
s.Unlock()
s.conf.ConfigModified()
return restart

View file

@ -157,6 +157,21 @@ func processRebindingFilteringAfterResponse(ctx *dnsContext) int {
return resultDone
}
func (s *Server) setRebindingConfig(dc dnsConfig) bool {
restart := false
if dc.RebindingProtectionEnabled != nil {
s.conf.RebindingProtectionEnabled = *dc.RebindingProtectionEnabled
}
if dc.RebindingAllowedHosts != nil {
s.conf.RebindingAllowedHosts = *dc.RebindingAllowedHosts
restart = true
}
return restart
}
func (s *Server) preventRebindResponse(ctx *dnsContext) (*dnsfilter.Result, error) {
d := ctx.proxyCtx