feat: Urutau 1.0.0, lightweight threat intelligence and web analytics
Release / Plan (reuse the published image?) (push) Successful in 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 1m29s
CI / Tests (Linux, race detector) (push) Failing after 1m48s
CI / Dependency audit (push) Successful in 21s
Release / ci (push) Failing after 1m50s
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Skipped
Release / Gitea release (push) Skipped
Release / Plan (reuse the published image?) (push) Successful in 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 1m29s
CI / Tests (Linux, race detector) (push) Failing after 1m48s
CI / Dependency audit (push) Successful in 21s
Release / ci (push) Failing after 1m50s
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Skipped
Release / Gitea release (push) Skipped
Always-on Go service (stdlib only) that follows the Traefik JSON access log, the sshd log and the fail2ban log of a host, classifies attacks, scores sources, keeps bounded aggregates with snapshots, and serves an embedded dashboard with live updates, offline geolocation (DB-IP Lite), privacy-friendly traffic analytics, an exportable blocklist and token-authenticated federation between instances. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
b4a2c2c9ec
99 files changed
+15403
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
"strings"
|
||||
|
||||
"git.lucasrguerra.dev.br/ciberfauna/urutau/internal/core"
|
||||
)
|
||||
|
||||
// Enrich adds country, city and network to an IP row (no-op without an
|
||||
// enricher or when the row already carries the data, e.g. from a peer).
|
||||
func (s *Store) Enrich(x *IPSummary) {
|
||||
if s.enr == nil || x.CC != "" || x.ASN != 0 {
|
||||
return
|
||||
}
|
||||
addr := x.IP
|
||||
if p, err := netip.ParsePrefix(x.IP); err == nil {
|
||||
addr = p.Addr().String()
|
||||
}
|
||||
if a, err := netip.ParseAddr(addr); err != nil || a.Zone() != "" {
|
||||
return
|
||||
}
|
||||
g := s.enr.Geo(addr)
|
||||
x.CC, x.Country, x.City, x.ASN, x.ASOrg = g.CC, g.Country, g.City, g.ASN, g.ASOrg
|
||||
}
|
||||
|
||||
// UALabel renders a parsed User-Agent as "Chrome / Windows / desktop" or the
|
||||
// tool or bot name. Empty without an enricher.
|
||||
func (s *Store) UALabel(raw string) string {
|
||||
if s.enr == nil || raw == "" {
|
||||
return ""
|
||||
}
|
||||
return LabelUA(s.enr.UA(raw))
|
||||
}
|
||||
|
||||
// LabelUA formats a UAInfo.
|
||||
func LabelUA(u core.UAInfo) string {
|
||||
switch {
|
||||
case u.Tool != "":
|
||||
return u.Tool + " (tool)"
|
||||
case u.Bot && u.BotName != "":
|
||||
return u.BotName + " (bot)"
|
||||
}
|
||||
var parts []string
|
||||
for _, p := range []string{u.Browser, u.OS, u.Device} {
|
||||
if p != "" && p != "unknown" {
|
||||
parts = append(parts, p)
|
||||
}
|
||||
}
|
||||
return strings.Join(parts, " / ")
|
||||
}
|
||||
Reference in new issue
Block a user