mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-15 11:22:49 +03:00
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
|
||||
|
||||
- Ignoring client-specific filtering settings when filtering is disabled in
|
||||
general settings ([#2875]).
|
||||
- Disallowed domains are now case-insensitive ([#3115]).
|
||||
|
||||
[#2875]: https://github.com/AdguardTeam/AdGuardHome/issues/2875
|
||||
[#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
|
||||
// interfaces we should check the whole interface's network to cut off
|
||||
// all the loopback addresses as well.
|
||||
localAddrs = aghstrings.FilterOut(localAddrs, func(s string) (ok bool) {
|
||||
return ourAddrsSet.Has(s)
|
||||
})
|
||||
localAddrs = aghstrings.FilterOut(localAddrs, ourAddrsSet.Has)
|
||||
|
||||
var upsConfig proxy.UpstreamConfig
|
||||
upsConfig, err = proxy.ParseUpstreamsConfig(localAddrs, upstream.Options{
|
||||
|
@ -50,8 +50,6 @@ func (s *Server) getClientRequestFilteringSettings(ctx *dnsContext) *dnsfilter.F
|
||||
// filtered.
|
||||
func (s *Server) filterDNSRequest(ctx *dnsContext) (*dnsfilter.Result, error) {
|
||||
d := ctx.proxyCtx
|
||||
// TODO(e.burkov): Consistently use req instead of d.Req since it is
|
||||
// declared.
|
||||
req := d.Req
|
||||
host := strings.TrimSuffix(req.Question[0].Name, ".")
|
||||
res, err := s.dnsFilter.CheckHost(host, req.Question[0].Qtype, ctx.setts)
|
||||
|
@ -76,16 +76,6 @@ type filter struct {
|
||||
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 (
|
||||
statusFound = 1
|
||||
statusEnabledChanged = 2
|
||||
@ -689,41 +679,33 @@ func (filter *filter) LastTimeUpdated() time.Time {
|
||||
}
|
||||
|
||||
func enableFilters(async bool) {
|
||||
var filters []dnsfilter.Filter
|
||||
var whiteFilters []dnsfilter.Filter
|
||||
if config.DNS.FilteringEnabled {
|
||||
// convert array of filters
|
||||
|
||||
userFilter := userFilter()
|
||||
f := dnsfilter.Filter{
|
||||
ID: userFilter.ID,
|
||||
Data: userFilter.Data,
|
||||
}
|
||||
filters = append(filters, f)
|
||||
filters := []dnsfilter.Filter{{
|
||||
Data: []byte(strings.Join(config.UserRules, "\n")),
|
||||
}}
|
||||
|
||||
for _, filter := range config.Filters {
|
||||
if !filter.Enabled {
|
||||
continue
|
||||
}
|
||||
|
||||
f = dnsfilter.Filter{
|
||||
filters = append(filters, dnsfilter.Filter{
|
||||
ID: filter.ID,
|
||||
FilePath: filter.Path(),
|
||||
}
|
||||
filters = append(filters, f)
|
||||
})
|
||||
}
|
||||
for _, filter := range config.WhitelistFilters {
|
||||
if !filter.Enabled {
|
||||
continue
|
||||
}
|
||||
|
||||
f = dnsfilter.Filter{
|
||||
whiteFilters = append(whiteFilters, dnsfilter.Filter{
|
||||
ID: filter.ID,
|
||||
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
Block a user