Disable retrying of intel fetching

sync.Once cannot be refreshed while executing.
This commit is contained in:
Daniel 2021-08-23 23:12:53 +02:00
parent 9c72fcfa40
commit b3f7ed8586

View file

@ -97,7 +97,7 @@ type Entity struct {
reverseResolveOnce sync.Once
loadDomainListOnce sync.Once
loadIPListOnce sync.Once
loadCoutryListOnce sync.Once
loadCountryListOnce sync.Once
loadAsnListOnce sync.Once
}
@ -148,7 +148,7 @@ func (e *Entity) ResetLists() {
e.checkCNAMEs = false
e.loadDomainListOnce = sync.Once{}
e.loadIPListOnce = sync.Once{}
e.loadCoutryListOnce = sync.Once{}
e.loadCountryListOnce = sync.Once{}
e.loadAsnListOnce = sync.Once{}
}
@ -313,7 +313,7 @@ func (e *Entity) getDomainLists(ctx context.Context) {
return
}
var err error
log.Tracer(ctx).Tracef("intel: loading domain list for %s", domain)
e.loadDomainListOnce.Do(func() {
var domainsToInspect = []string{domain}
@ -324,6 +324,7 @@ func (e *Entity) getDomainLists(ctx context.Context) {
var domains []string
if e.resolveSubDomainLists {
log.Tracer(ctx).Trace("intel: subdomain filtering enabled, checking all subdomains too")
for _, domain := range domainsToInspect {
subdomains := splitDomain(domain)
domains = append(domains, subdomains...)
@ -335,9 +336,7 @@ func (e *Entity) getDomainLists(ctx context.Context) {
domains = makeDistinct(domains)
for _, d := range domains {
log.Tracer(ctx).Tracef("intel: loading domain list for %s", d)
var list []string
list, err = filterlists.LookupDomain(d)
list, err := filterlists.LookupDomain(d)
if err != nil {
log.Tracer(ctx).Errorf("intel: failed to get domain blocklists for %s: %s", d, err)
e.ListsError = err.Error()
@ -348,10 +347,6 @@ func (e *Entity) getDomainLists(ctx context.Context) {
}
e.domainListLoaded = true
})
if err != nil {
e.loadDomainListOnce = sync.Once{}
}
}
func splitDomain(domain string) []string {
@ -397,7 +392,6 @@ func (e *Entity) getASNLists(ctx context.Context) {
if err != nil {
log.Tracer(ctx).Errorf("intel: failed to get ASN blocklist for %d: %s", asn, err)
e.ListsError = err.Error()
e.loadAsnListOnce = sync.Once{}
return
}
@ -417,12 +411,11 @@ func (e *Entity) getCountryLists(ctx context.Context) {
}
log.Tracer(ctx).Tracef("intel: loading country list for %s", country)
e.loadCoutryListOnce.Do(func() {
e.loadCountryListOnce.Do(func() {
list, err := filterlists.LookupCountry(country)
if err != nil {
log.Tracer(ctx).Errorf("intel: failed to load country blocklist for %s: %s", country, err)
e.ListsError = err.Error()
e.loadCoutryListOnce = sync.Once{}
return
}
@ -453,13 +446,12 @@ func (e *Entity) getIPLists(ctx context.Context) {
log.Tracer(ctx).Tracef("intel: loading IP list for %s", ip)
e.loadIPListOnce.Do(func() {
list, err := filterlists.LookupIP(ip)
if err != nil {
log.Tracer(ctx).Errorf("intel: failed to get IP blocklist for %s: %s", ip.String(), err)
e.ListsError = err.Error()
e.loadIPListOnce = sync.Once{}
return
}
e.ipListLoaded = true
e.mergeList(ip.String(), list)
})