Files
gluetun/internal/dns/update.go

36 lines
955 B
Go
Raw Normal View History

2021-07-23 18:55:53 +00:00
package dns
import "context"
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()
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")
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
unboundSettings.Blacklist.FqdnHostnames = blockedHostnames
unboundSettings.Blacklist.IPs = blockedIPs
unboundSettings.Blacklist.IPPrefixes = blockedIPPrefixes
2021-07-23 18:55:53 +00:00
return l.conf.MakeUnboundConf(unboundSettings)
2021-07-23 18:55:53 +00:00
}