mirror of
https://github.com/safing/portmaster
synced 2025-09-02 18:49:14 +00:00
Improve logging of loaded intel data
This commit is contained in:
parent
62729cc889
commit
8a98f69fca
1 changed files with 46 additions and 10 deletions
|
@ -237,8 +237,8 @@ func (e *Entity) GetIP() (net.IP, bool) {
|
||||||
|
|
||||||
func (e *Entity) getLocation(ctx context.Context) {
|
func (e *Entity) getLocation(ctx context.Context) {
|
||||||
e.fetchLocationOnce.Do(func() {
|
e.fetchLocationOnce.Do(func() {
|
||||||
// need IP!
|
// Only check if we have a global IP address.
|
||||||
if e.IP == nil {
|
if e.IP == nil || !e.IPScope.IsGlobal() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,6 +254,31 @@ func (e *Entity) getLocation(ctx context.Context) {
|
||||||
e.Coordinates = &loc.Coordinates
|
e.Coordinates = &loc.Coordinates
|
||||||
e.ASN = loc.AutonomousSystemNumber
|
e.ASN = loc.AutonomousSystemNumber
|
||||||
e.ASOrg = loc.AutonomousSystemOrganization
|
e.ASOrg = loc.AutonomousSystemOrganization
|
||||||
|
|
||||||
|
// Log result.
|
||||||
|
if log.GetLogLevel() == log.TraceLevel {
|
||||||
|
// Build flags
|
||||||
|
var flags string
|
||||||
|
if loc.IsAnycast {
|
||||||
|
flags += " anycast"
|
||||||
|
}
|
||||||
|
if loc.IsSatelliteProvider {
|
||||||
|
flags += " satellite"
|
||||||
|
}
|
||||||
|
if loc.IsAnonymousProxy {
|
||||||
|
flags += " anonymous"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log location
|
||||||
|
log.Tracer(ctx).Tracef(
|
||||||
|
"intel: located %s in %s (AS%d by %s)%s",
|
||||||
|
e.IP,
|
||||||
|
loc.Country.ISOCode,
|
||||||
|
loc.AutonomousSystemNumber,
|
||||||
|
loc.AutonomousSystemOrganization,
|
||||||
|
flags,
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +343,6 @@ func (e *Entity) getDomainLists(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Tracer(ctx).Tracef("intel: loading domain list for %s", domain)
|
|
||||||
e.loadDomainListOnce.Do(func() {
|
e.loadDomainListOnce.Do(func() {
|
||||||
domainsToInspect := []string{domain}
|
domainsToInspect := []string{domain}
|
||||||
|
|
||||||
|
@ -347,8 +371,11 @@ func (e *Entity) getDomainLists(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(list) > 0 {
|
||||||
|
log.Tracer(ctx).Tracef("intel: loaded domain lists for %s: %s", d, strings.Join(list, ", "))
|
||||||
e.mergeList(d, list)
|
e.mergeList(d, list)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
e.domainListLoaded = true
|
e.domainListLoaded = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -389,7 +416,6 @@ func (e *Entity) getASNLists(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Tracer(ctx).Tracef("intel: loading ASN list for %d", asn)
|
|
||||||
e.loadAsnListOnce.Do(func() {
|
e.loadAsnListOnce.Do(func() {
|
||||||
asnStr := fmt.Sprintf("%d", asn)
|
asnStr := fmt.Sprintf("%d", asn)
|
||||||
list, err := filterlists.LookupASNString(asnStr)
|
list, err := filterlists.LookupASNString(asnStr)
|
||||||
|
@ -399,8 +425,12 @@ func (e *Entity) getASNLists(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.asnListLoaded = true
|
if len(list) > 0 {
|
||||||
|
log.Tracer(ctx).Tracef("intel: loaded ASN lists for %s: %s", asnStr, strings.Join(list, ", "))
|
||||||
e.mergeList(asnStr, list)
|
e.mergeList(asnStr, list)
|
||||||
|
}
|
||||||
|
|
||||||
|
e.asnListLoaded = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +444,6 @@ func (e *Entity) getCountryLists(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Tracer(ctx).Tracef("intel: loading country list for %s", country)
|
|
||||||
e.loadCountryListOnce.Do(func() {
|
e.loadCountryListOnce.Do(func() {
|
||||||
list, err := filterlists.LookupCountry(country)
|
list, err := filterlists.LookupCountry(country)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -423,8 +452,12 @@ func (e *Entity) getCountryLists(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.countryListLoaded = true
|
if len(list) > 0 {
|
||||||
|
log.Tracer(ctx).Tracef("intel: loaded country lists for %s: %s", country, strings.Join(list, ", "))
|
||||||
e.mergeList(country, list)
|
e.mergeList(country, list)
|
||||||
|
}
|
||||||
|
|
||||||
|
e.countryListLoaded = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +476,6 @@ func (e *Entity) getIPLists(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Tracer(ctx).Tracef("intel: loading IP list for %s", ip)
|
|
||||||
e.loadIPListOnce.Do(func() {
|
e.loadIPListOnce.Do(func() {
|
||||||
list, err := filterlists.LookupIP(ip)
|
list, err := filterlists.LookupIP(ip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -452,8 +484,12 @@ func (e *Entity) getIPLists(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e.ipListLoaded = true
|
if len(list) > 0 {
|
||||||
|
log.Tracer(ctx).Tracef("intel: loaded IP lists for %s: %s", ip.String(), strings.Join(list, ", "))
|
||||||
e.mergeList(ip.String(), list)
|
e.mergeList(ip.String(), list)
|
||||||
|
}
|
||||||
|
|
||||||
|
e.ipListLoaded = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue