Let decision reasons decide on the DNS reply

This commit is contained in:
Patrick Pacher
2020-04-30 13:44:10 +02:00
parent f89d0672b3
commit 2dda3813fa
7 changed files with 173 additions and 47 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/miekg/dns"
"github.com/safing/portbase/log"
"github.com/safing/portmaster/nameserver/nsutil"
)
// ListMatch represents an entity that has been
@@ -62,9 +63,10 @@ func (br ListBlockReason) MarshalJSON() ([]byte, error) {
})
}
// ToRRs returns a set of dns TXT records that describe the
// block reason.
func (br ListBlockReason) ToRRs() []dns.RR {
// GetExtraRR implements the nsutil.RRProvider interface
// and adds additional TXT records justifying the reason
// the request was blocked.
func (br ListBlockReason) GetExtraRR(_ *dns.Msg, _ string, _ interface{}) []dns.RR {
rrs := make([]dns.RR, 0, len(br))
for _, lm := range br {
@@ -95,3 +97,5 @@ func (br ListBlockReason) ToRRs() []dns.RR {
return rrs
}
var _ nsutil.RRProvider = ListBlockReason(nil)

View File

@@ -261,9 +261,6 @@ func (e *Entity) mergeList(key string, list []string) {
}
e.ListOccurences[key] = mergeStringList(e.ListOccurences[key], list)
//e.Lists = mergeStringList(e.Lists, list)
//e.ListsMap = buildLookupMap(e.Lists)
}
func (e *Entity) getDomainLists() {
@@ -289,8 +286,6 @@ func (e *Entity) getDomainLists() {
for _, domain := range domainsToInspect {
subdomains := splitDomain(domain)
domains = append(domains, subdomains...)
log.Tracef("intel: subdomain list resolving is enabled: %s => %v", domains, subdomains)
}
} else {
domains = domainsToInspect
@@ -446,8 +441,8 @@ func (e *Entity) MatchLists(lists []string) bool {
}
}
makeDistinct(e.BlockedByLists)
makeDistinct(e.BlockedEntities)
e.BlockedByLists = makeDistinct(e.BlockedByLists)
e.BlockedEntities = makeDistinct(e.BlockedEntities)
return len(e.BlockedByLists) > 0
}