This commit is contained in:
binwiederhier
2025-07-04 07:38:58 +02:00
parent 7b470a7f6f
commit d8c8f31846
5 changed files with 39 additions and 24 deletions

View File

@@ -528,5 +528,11 @@ func visitorID(ip netip.Addr, u *user.User) string {
if u != nil && u.Tier != nil {
return fmt.Sprintf("user:%s", u.ID)
}
if ip.Is6() {
// IPv6 addresses are too long to be used as visitor IDs, so we use the first 8 bytes
ip = netip.PrefixFrom(ip, 64).Masked().Addr()
} else if ip.Is4() {
ip = netip.PrefixFrom(ip, 20).Masked().Addr()
}
return fmt.Sprintf("ip:%s", ip.String())
}