chore(settings): refactor settings processing (#756)
- Better settings tree structure logged using `qdm12/gotree` - Read settings from environment variables, then files, then secret files - Settings methods to default them, merge them and override them - `DNS_PLAINTEXT_ADDRESS` default changed to `127.0.0.1` to use DoT. Warning added if set to something else. - `HTTPPROXY_LISTENING_ADDRESS` instead of `HTTPPROXY_PORT` (with retro-compatibility)
This commit is contained in:
@@ -9,17 +9,27 @@ func (l *Loop) updateFiles(ctx context.Context) (err error) {
|
||||
}
|
||||
settings := l.GetSettings()
|
||||
|
||||
unboundSettings, err := settings.DoT.Unbound.ToUnboundFormat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
l.logger.Info("downloading hostnames and IP block lists")
|
||||
blockedHostnames, blockedIPs, blockedIPPrefixes, errs := l.blockBuilder.All(
|
||||
ctx, settings.BlacklistBuild)
|
||||
blacklistSettings, err := settings.DoT.Blacklist.ToBlacklistFormat()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
blockedHostnames, blockedIPs, blockedIPPrefixes, errs :=
|
||||
l.blockBuilder.All(ctx, blacklistSettings)
|
||||
for _, err := range errs {
|
||||
l.logger.Warn(err.Error())
|
||||
}
|
||||
|
||||
// TODO change to BlockHostnames() when migrating to qdm12/dns v2
|
||||
settings.Unbound.Blacklist.FqdnHostnames = blockedHostnames
|
||||
settings.Unbound.Blacklist.IPs = blockedIPs
|
||||
settings.Unbound.Blacklist.IPPrefixes = blockedIPPrefixes
|
||||
unboundSettings.Blacklist.FqdnHostnames = blockedHostnames
|
||||
unboundSettings.Blacklist.IPs = blockedIPs
|
||||
unboundSettings.Blacklist.IPPrefixes = blockedIPPrefixes
|
||||
|
||||
return l.conf.MakeUnboundConf(settings.Unbound)
|
||||
return l.conf.MakeUnboundConf(unboundSettings)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user