mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Fix minor bugs
This commit is contained in:
parent
564928a97f
commit
3db7457d30
2 changed files with 16 additions and 12 deletions
|
@ -292,6 +292,7 @@ func (e *Entity) getDomainLists(ctx context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
e.loadDomainListOnce.Do(func() {
|
||||
var domainsToInspect = []string{domain}
|
||||
|
||||
|
@ -314,10 +315,10 @@ func (e *Entity) getDomainLists(ctx context.Context) {
|
|||
|
||||
for _, d := range domains {
|
||||
log.Tracer(ctx).Tracef("intel: loading domain list for %s", d)
|
||||
list, err := filterlists.LookupDomain(d)
|
||||
var list []string
|
||||
list, err = filterlists.LookupDomain(d)
|
||||
if err != nil {
|
||||
log.Tracer(ctx).Errorf("intel: failed to get domain blocklists for %s: %s", d, err)
|
||||
e.loadDomainListOnce = sync.Once{}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -325,6 +326,10 @@ func (e *Entity) getDomainLists(ctx context.Context) {
|
|||
}
|
||||
e.domainListLoaded = true
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
e.loadDomainListOnce = sync.Once{}
|
||||
}
|
||||
}
|
||||
|
||||
func splitDomain(domain string) []string {
|
||||
|
|
|
@ -2,9 +2,7 @@ package filterlists
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/safing/portbase/database"
|
||||
"github.com/safing/portbase/log"
|
||||
|
@ -55,15 +53,16 @@ func LookupCountry(country string) ([]string, error) {
|
|||
|
||||
// LookupDomain returns a list of sources that mark the domain
|
||||
// as blocked. If domain is not stored in the cache database
|
||||
// a nil slice is returned.
|
||||
// a nil slice is returned. The caller is responsible for making
|
||||
// sure that the given domain is valid and canonical.
|
||||
func LookupDomain(domain string) ([]string, error) {
|
||||
// make sure we only fully qualified domains
|
||||
// ending in a dot.
|
||||
domain = strings.ToLower(domain)
|
||||
if domain[len(domain)-1] != '.' {
|
||||
domain += "."
|
||||
switch domain {
|
||||
case "", ".":
|
||||
// Return no lists for empty domains and the root zone.
|
||||
return nil, nil
|
||||
default:
|
||||
return lookupBlockLists("domain", domain)
|
||||
}
|
||||
return lookupBlockLists("domain", domain)
|
||||
}
|
||||
|
||||
// LookupASNString returns a list of sources that mark the ASN
|
||||
|
@ -89,7 +88,7 @@ func LookupIP(ip net.IP) ([]string, error) {
|
|||
func LookupIPString(ipStr string) ([]string, error) {
|
||||
ip := net.ParseIP(ipStr)
|
||||
if ip == nil {
|
||||
return nil, fmt.Errorf("invalid IP")
|
||||
return nil, errors.New("invalid IP")
|
||||
}
|
||||
|
||||
return LookupIP(ip)
|
||||
|
|
Loading…
Add table
Reference in a new issue