Pull request: 2875 client settings
Merge in DNS/adguard-home from 2875-client-settings to master Updates #2875. Squashed commit of the following: commit 43e5af66acb8ace71a329fe2effae6a78492d73f Author: Eugene Burkov <e.burkov@adguard.com> Date: Wed May 12 18:12:03 2021 +0300 all: fix client settings applying
This commit is contained in:
parent
f41d5b9867
commit
29d847c366
|
@ -19,8 +19,11 @@ and this project adheres to
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Ignoring client-specific filtering settings when filtering is disabled in
|
||||||
|
general settings ([#2875]).
|
||||||
- Disallowed domains are now case-insensitive ([#3115]).
|
- Disallowed domains are now case-insensitive ([#3115]).
|
||||||
|
|
||||||
|
[#2875]: https://github.com/AdguardTeam/AdGuardHome/issues/2875
|
||||||
[#3115]: https://github.com/AdguardTeam/AdGuardHome/issues/3115
|
[#3115]: https://github.com/AdguardTeam/AdGuardHome/issues/3115
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -370,9 +370,7 @@ func (s *Server) setupResolvers(localAddrs []string) (err error) {
|
||||||
// really applicable here since in case of listening on all network
|
// really applicable here since in case of listening on all network
|
||||||
// interfaces we should check the whole interface's network to cut off
|
// interfaces we should check the whole interface's network to cut off
|
||||||
// all the loopback addresses as well.
|
// all the loopback addresses as well.
|
||||||
localAddrs = aghstrings.FilterOut(localAddrs, func(s string) (ok bool) {
|
localAddrs = aghstrings.FilterOut(localAddrs, ourAddrsSet.Has)
|
||||||
return ourAddrsSet.Has(s)
|
|
||||||
})
|
|
||||||
|
|
||||||
var upsConfig proxy.UpstreamConfig
|
var upsConfig proxy.UpstreamConfig
|
||||||
upsConfig, err = proxy.ParseUpstreamsConfig(localAddrs, upstream.Options{
|
upsConfig, err = proxy.ParseUpstreamsConfig(localAddrs, upstream.Options{
|
||||||
|
|
|
@ -50,8 +50,6 @@ func (s *Server) getClientRequestFilteringSettings(ctx *dnsContext) *dnsfilter.F
|
||||||
// filtered.
|
// filtered.
|
||||||
func (s *Server) filterDNSRequest(ctx *dnsContext) (*dnsfilter.Result, error) {
|
func (s *Server) filterDNSRequest(ctx *dnsContext) (*dnsfilter.Result, error) {
|
||||||
d := ctx.proxyCtx
|
d := ctx.proxyCtx
|
||||||
// TODO(e.burkov): Consistently use req instead of d.Req since it is
|
|
||||||
// declared.
|
|
||||||
req := d.Req
|
req := d.Req
|
||||||
host := strings.TrimSuffix(req.Question[0].Name, ".")
|
host := strings.TrimSuffix(req.Question[0].Name, ".")
|
||||||
res, err := s.dnsFilter.CheckHost(host, req.Question[0].Qtype, ctx.setts)
|
res, err := s.dnsFilter.CheckHost(host, req.Question[0].Qtype, ctx.setts)
|
||||||
|
|
|
@ -76,16 +76,6 @@ type filter struct {
|
||||||
dnsfilter.Filter `yaml:",inline"`
|
dnsfilter.Filter `yaml:",inline"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a helper object for working with the user rules
|
|
||||||
func userFilter() filter {
|
|
||||||
f := filter{
|
|
||||||
// User filter always has constant ID=0
|
|
||||||
Enabled: true,
|
|
||||||
}
|
|
||||||
f.Filter.Data = []byte(strings.Join(config.UserRules, "\n"))
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
statusFound = 1
|
statusFound = 1
|
||||||
statusEnabledChanged = 2
|
statusEnabledChanged = 2
|
||||||
|
@ -689,41 +679,33 @@ func (filter *filter) LastTimeUpdated() time.Time {
|
||||||
}
|
}
|
||||||
|
|
||||||
func enableFilters(async bool) {
|
func enableFilters(async bool) {
|
||||||
var filters []dnsfilter.Filter
|
|
||||||
var whiteFilters []dnsfilter.Filter
|
var whiteFilters []dnsfilter.Filter
|
||||||
if config.DNS.FilteringEnabled {
|
filters := []dnsfilter.Filter{{
|
||||||
// convert array of filters
|
Data: []byte(strings.Join(config.UserRules, "\n")),
|
||||||
|
}}
|
||||||
|
|
||||||
userFilter := userFilter()
|
for _, filter := range config.Filters {
|
||||||
f := dnsfilter.Filter{
|
if !filter.Enabled {
|
||||||
ID: userFilter.ID,
|
continue
|
||||||
Data: userFilter.Data,
|
|
||||||
}
|
}
|
||||||
filters = append(filters, f)
|
|
||||||
|
|
||||||
for _, filter := range config.Filters {
|
filters = append(filters, dnsfilter.Filter{
|
||||||
if !filter.Enabled {
|
ID: filter.ID,
|
||||||
continue
|
FilePath: filter.Path(),
|
||||||
}
|
})
|
||||||
|
}
|
||||||
f = dnsfilter.Filter{
|
for _, filter := range config.WhitelistFilters {
|
||||||
ID: filter.ID,
|
if !filter.Enabled {
|
||||||
FilePath: filter.Path(),
|
continue
|
||||||
}
|
|
||||||
filters = append(filters, f)
|
|
||||||
}
|
}
|
||||||
for _, filter := range config.WhitelistFilters {
|
|
||||||
if !filter.Enabled {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
f = dnsfilter.Filter{
|
whiteFilters = append(whiteFilters, dnsfilter.Filter{
|
||||||
ID: filter.ID,
|
ID: filter.ID,
|
||||||
FilePath: filter.Path(),
|
FilePath: filter.Path(),
|
||||||
}
|
})
|
||||||
whiteFilters = append(whiteFilters, f)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = Context.dnsFilter.SetFilters(filters, whiteFilters, async)
|
if err := Context.dnsFilter.SetFilters(filters, whiteFilters, async); err != nil {
|
||||||
|
log.Debug("enabling filters: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue