anonymize

package
v0.83.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LevelDefaultString = "default"
	LevelStrictString  = "strict"
)

LevelDefaultString and LevelStrictString are the wire forms of the levels, for boundaries that pass levels as strings (flags, protos, mobile bindings).

Variables

This section is empty.

Functions

func DefaultAddresses

func DefaultAddresses() (netip.Addr, netip.Addr)

func InternalAddresses added in v0.77.0

func InternalAddresses() (netip.Addr, netip.Addr)

InternalAddresses returns the pool starts used in strict mode for internal ranges. Both are reserved ranges that cannot collide with real addressing: 198.18.0.0 (RFC 2544 benchmarking), 2001:db8:1:: (RFC 3849 documentation).

Types

type Anonymizer

type Anonymizer struct {
	// contains filtered or unexported fields
}

func NewAnonymizer

func NewAnonymizer(startIPv4, startIPv6 netip.Addr) *Anonymizer

func (*Anonymizer) AnonymizeDNSLogLine

func (a *Anonymizer) AnonymizeDNSLogLine(logEntry string) string

func (*Anonymizer) AnonymizeDomain

func (a *Anonymizer) AnonymizeDomain(domain string) string

func (*Anonymizer) AnonymizeIP

func (a *Anonymizer) AnonymizeIP(ip netip.Addr) netip.Addr

func (*Anonymizer) AnonymizeIPString

func (a *Anonymizer) AnonymizeIPString(ip string) string

func (*Anonymizer) AnonymizeMAC added in v0.77.0

func (a *Anonymizer) AnonymizeMAC(mac string) string

AnonymizeMAC replaces a MAC address with a consistent placeholder from the locally administered range starting at 02:00:00:00:00:01, at every anonymization level. Broadcast, multicast, all-zero, and already assigned placeholder addresses are preserved. The colon and dash spellings of the same address share one placeholder; the output keeps the input's separator.

func (*Anonymizer) AnonymizeRoute added in v0.28.7

func (a *Anonymizer) AnonymizeRoute(route string) string

AnonymizeRoute anonymizes a route string by replacing IP addresses with anonymized versions and domain names with random strings.

func (*Anonymizer) AnonymizeSchemeURI

func (a *Anonymizer) AnonymizeSchemeURI(text string) string

AnonymizeSchemeURI finds and anonymizes URIs with ws, wss, rel, rels, stun, stuns, turn, and turns schemes.

func (*Anonymizer) AnonymizeString

func (a *Anonymizer) AnonymizeString(str string) string

func (*Anonymizer) AnonymizeUDPAddr added in v0.46.0

func (a *Anonymizer) AnonymizeUDPAddr(addr net.UDPAddr) net.UDPAddr

func (*Anonymizer) AnonymizeURI

func (a *Anonymizer) AnonymizeURI(uri string) string

func (*Anonymizer) AnonymizeWGKey added in v0.77.0

func (a *Anonymizer) AnonymizeWGKey(key string) string

AnonymizeWGKey replaces a WireGuard public key with a consistent random placeholder of the same shape. Keys are only anonymized at LevelStrict; placeholders already handed out pass through unchanged.

func (*Anonymizer) SetLevel added in v0.77.0

func (a *Anonymizer) SetLevel(level Level)

SetLevel selects the anonymization level. The zero value of a new Anonymizer is LevelDefault.

type Level added in v0.77.0

type Level int

Level selects how much the anonymizer redacts. Levels are ordered: a higher level redacts strictly more. On the wire (protos, flags) levels travel as their string form.

const (
	// LevelDefault anonymizes public IP addresses, IPv6 ULA, domains, and MAC
	// addresses. Internal IPv4 ranges (RFC 1918, CGNAT, link-local) are
	// preserved so support can reason about the real topology.
	LevelDefault Level = iota
	// LevelStrict additionally anonymizes internal IP ranges, peer names, and
	// WireGuard public keys.
	LevelStrict
)

func ParseLevel added in v0.77.0

func ParseLevel(s string) Level

ParseLevel maps s to a Level. Empty means LevelDefault; anything unrecognized maps to LevelStrict so an unknown request never yields less anonymization than intended.

func (Level) String added in v0.77.0

func (l Level) String() string

String returns the wire form of the level: "default" or "strict".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL