Versions in this module Expand all Collapse all v0 v0.1.0 Jul 25, 2026 Changes in this version + const CryptoPAnKeyLen + const DefaultOutputBits + const KeyLen + const MinOutputBits + const RotateDaily + const RotateHourly + const RotateWeekly + var ErrInvalidAddr = errors.New("ipanon: invalid IP address") + var ErrInvalidConfig = errors.New("ipanon: invalid configuration") + var ErrInvalidKey = errors.New("ipanon: invalid key") + var ErrNotReversible = errors.New("ipanon: technique is not reversible") + func GenerateKey() ([]byte, error) + func KeyFromEnv(name string) ([]byte, error) + func LegacySaltedSHA256(salt, ip string) string + func Normalize(addr netip.Addr) (netip.Addr, error) + func ParseAddr(s string) (netip.Addr, error) + type Action uint8 + const ActionAnonymize + const ActionDrop + const ActionPassThrough + type AddrAnonymizer interface + AnonymizeAddr func(addr netip.Addr) (netip.Addr, error) + type Anonymizer interface + AnonymizeString func(addr netip.Addr) (string, error) + type CryptoPAn struct + func NewCryptoPAn(key []byte) (*CryptoPAn, error) + func (c *CryptoPAn) AnonymizeAddr(addr netip.Addr) (netip.Addr, error) + func (c *CryptoPAn) AnonymizePrefix(p netip.Prefix) (netip.Prefix, error) + func (c *CryptoPAn) AnonymizeString(addr netip.Addr) (string, error) + func (c *CryptoPAn) Kind() Kind + func (c *CryptoPAn) WithScopeRules(r ScopeRules) *CryptoPAn + type Dropper struct + func NewDropper() *Dropper + func (d *Dropper) AnonymizeAddr(addr netip.Addr) (netip.Addr, error) + func (d *Dropper) AnonymizeString(addr netip.Addr) (string, error) + func (d *Dropper) Kind() Kind + func (d *Dropper) WithScopeRules(r ScopeRules) *Dropper + type Encoding uint8 + const EncodingBase32 + const EncodingBase64URL + const EncodingHex + type Hasher struct + func NewHasher(keys KeyProvider) (*Hasher, error) + func (h *Hasher) AnonymizeString(addr netip.Addr) (string, error) + func (h *Hasher) Kind() Kind + func (h *Hasher) Token(addr netip.Addr) (string, KeyID, error) + func (h *Hasher) TokenAt(addr netip.Addr, t time.Time) (string, KeyID, error) + func (h *Hasher) WithEncoding(e Encoding) *Hasher + func (h *Hasher) WithOutputBits(n int) (*Hasher, error) + func (h *Hasher) WithScopeRules(r ScopeRules) *Hasher + type KeyID string + type KeyProvider interface + KeyAt func(t time.Time) ([]byte, KeyID, error) + type Kind uint8 + const KindCryptoPAn + const KindDrop + const KindHash + const KindInvalid + const KindPseudonym + const KindTruncate + func ParseKind(s string) (Kind, error) + func (k Kind) Anonymous() bool + func (k Kind) String() string + type Policy struct + Encoding Encoding + Key []byte + OutputBits int + Retention time.Duration + Reversible bool + RotationPeriod time.Duration + Scopes ScopeRules + Technique Kind + V4Bits int + V6Bits int + func PolicyAnalytics() Policy + func PolicyGoogleAnalytics() Policy + func PolicyRateLimit(key []byte) Policy + func PolicySecurityAudit(key []byte) Policy + func PolicyStrict() Policy + func (p Policy) Build() (Anonymizer, error) + func (p Policy) Validate() error + type Pseudonymizer struct + func NewPseudonymizer(master []byte, period time.Duration) (*Pseudonymizer, error) + func NewPseudonymizerWithKeys(keys *RotatingKeys) (*Pseudonymizer, error) + func (p *Pseudonymizer) AnonymizeString(addr netip.Addr) (string, error) + func (p *Pseudonymizer) Kind() Kind + func (p *Pseudonymizer) Period() time.Duration + func (p *Pseudonymizer) Token(addr netip.Addr) (string, KeyID, error) + func (p *Pseudonymizer) TokenAt(addr netip.Addr, t time.Time) (string, KeyID, error) + func (p *Pseudonymizer) WithEncoding(e Encoding) *Pseudonymizer + func (p *Pseudonymizer) WithKeyLabel(label bool) *Pseudonymizer + func (p *Pseudonymizer) WithOutputBits(n int) (*Pseudonymizer, error) + func (p *Pseudonymizer) WithScopeRules(r ScopeRules) *Pseudonymizer + func (p *Pseudonymizer) Zero() + type Reversible interface + Deanonymize func(addr netip.Addr) (netip.Addr, error) + type ReversibleCryptoPAn struct + func NewReversibleCryptoPAn(key []byte) (*ReversibleCryptoPAn, error) + func (c *ReversibleCryptoPAn) Deanonymize(addr netip.Addr) (netip.Addr, error) + func (c *ReversibleCryptoPAn) WithScopeRules(r ScopeRules) *ReversibleCryptoPAn + type RotatingKeys struct + func NewRotatingKeys(master []byte, period time.Duration) (*RotatingKeys, error) + func (r *RotatingKeys) Epoch(t time.Time) int64 + func (r *RotatingKeys) KeyAt(t time.Time) ([]byte, KeyID, error) + func (r *RotatingKeys) Period() time.Duration + func (r *RotatingKeys) Zero() + type Scope uint8 + const ScopeCGNAT + const ScopeGlobal + const ScopeLinkLocal + const ScopeLoopback + const ScopeMulticast + const ScopePrivate + const ScopeUnspecified + func ClassifyScope(addr netip.Addr) Scope + func (s Scope) String() string + type ScopeRules struct + CGNAT Action + LinkLocal Action + Loopback Action + Multicast Action + Private Action + Unspecified Action + func PassThroughInternal() ScopeRules + type StaticKey struct + func NewStaticKey(key []byte) (*StaticKey, error) + func (s *StaticKey) KeyAt(time.Time) ([]byte, KeyID, error) + func (s *StaticKey) Zero() + type Truncator struct + func NewTruncator(v4Bits, v6Bits int) (*Truncator, error) + func TruncateGA() *Truncator + func TruncateStrict() *Truncator + func (t *Truncator) AnonymizeAddr(addr netip.Addr) (netip.Addr, error) + func (t *Truncator) AnonymizeString(addr netip.Addr) (string, error) + func (t *Truncator) Bits() (v4, v6 int) + func (t *Truncator) Kind() Kind + func (t *Truncator) Prefix(addr netip.Addr) (netip.Prefix, error) + func (t *Truncator) WithScopeRules(r ScopeRules) *Truncator