2021-07-23 18:55:53 +00:00
|
|
|
package dns
|
|
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
2021-07-23 18:57:29 +00:00
|
|
|
func (l *Loop) updateFiles(ctx context.Context) (err error) {
|
2021-07-23 18:55:53 +00:00
|
|
|
l.logger.Info("downloading DNS over TLS cryptographic files")
|
|
|
|
|
if err := l.conf.SetupFiles(ctx); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
settings := l.GetSettings()
|
|
|
|
|
|
2022-01-06 06:40:23 -05:00
|
|
|
unboundSettings, err := settings.DoT.Unbound.ToUnboundFormat()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-23 18:55:53 +00:00
|
|
|
l.logger.Info("downloading hostnames and IP block lists")
|
2022-01-06 06:40:23 -05:00
|
|
|
blacklistSettings, err := settings.DoT.Blacklist.ToBlacklistFormat()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
blockedHostnames, blockedIPs, blockedIPPrefixes, errs :=
|
|
|
|
|
l.blockBuilder.All(ctx, blacklistSettings)
|
2021-07-23 18:55:53 +00:00
|
|
|
for _, err := range errs {
|
|
|
|
|
l.logger.Warn(err.Error())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO change to BlockHostnames() when migrating to qdm12/dns v2
|
2022-01-06 06:40:23 -05:00
|
|
|
unboundSettings.Blacklist.FqdnHostnames = blockedHostnames
|
|
|
|
|
unboundSettings.Blacklist.IPs = blockedIPs
|
|
|
|
|
unboundSettings.Blacklist.IPPrefixes = blockedIPPrefixes
|
2021-07-23 18:55:53 +00:00
|
|
|
|
2022-01-06 06:40:23 -05:00
|
|
|
return l.conf.MakeUnboundConf(unboundSettings)
|
2021-07-23 18:55:53 +00:00
|
|
|
}
|