Pull request: improve anonymizer performance
Merge in DNS/adguard-home from imp-anonymizer to master Squashed commit of the following: commit 340237d747ede620756e8d213c9da825d038d691 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Dec 7 12:43:27 2021 +0300 querylog: mv slow version commit 96daf498200d0de86f62a3a1c1502f928fba2b0a Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Dec 6 21:21:13 2021 +0300 querylog: imp anonymizer
This commit is contained in:
@@ -245,6 +245,16 @@ func TestDecodeLogEntry_backwardCompatability(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// anonymizeIPSlow masks ip to anonymize the client if the ip is a valid one.
|
||||
// It only exists in purposes of benchmark comparison, see BenchmarkAnonymizeIP.
|
||||
func anonymizeIPSlow(ip net.IP) {
|
||||
if ip4 := ip.To4(); ip4 != nil {
|
||||
copy(ip4[net.IPv4len-2:net.IPv4len], []byte{0, 0})
|
||||
} else if len(ip) == net.IPv6len {
|
||||
copy(ip[net.IPv6len-10:net.IPv6len], []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkAnonymizeIP(b *testing.B) {
|
||||
benchCases := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user