Skip to content

Commit

Permalink
Unify caching in getter functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Marty committed Dec 20, 2018
1 parent 26c174e commit 5d01110
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ The getter functions are setup to cache their results so any further access to t
```
goos: darwin
goarch: amd64
BenchmarkGetJA3ByteString-4 1000000000 2.73 ns/op 0 B/op 0 allocs/op
BenchmarkGetJA3String-4 1000000000 2.44 ns/op 0 B/op 0 allocs/op
BenchmarkGetJA3Hash-4 1000000000 2.72 ns/op 0 B/op 0 allocs/op
BenchmarkGetSNI-4 300000000 5.61 ns/op 0 B/op 0 allocs/op
BenchmarkGetJA3ByteString-4 1000000000 2.65 ns/op 0 B/op 0 allocs/op
BenchmarkGetJA3String-4 50000000 39.3 ns/op 64 B/op 1 allocs/op
BenchmarkGetJA3Hash-4 1000000000 2.40 ns/op 0 B/op 0 allocs/op
BenchmarkGetSNI-4 300000000 5.57 ns/op 0 B/op 0 allocs/op
```
6 changes: 1 addition & 5 deletions ja3.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type JA3 struct {
ellipticCurvePF []uint8
sni []byte
ja3ByteString []byte
ja3String string
ja3Hash string
}

Expand All @@ -43,10 +42,7 @@ func (j *JA3) GetJA3ByteString() []byte {
// GetJA3String returns the JA3 string as a string. This function uses caching, so repeated calls to this function on
// the same JA3 object will not trigger any new calculations.
func (j *JA3) GetJA3String() string {
if j.ja3String == "" {
j.ja3String = string(j.GetJA3ByteString())
}
return j.ja3String
return string(j.GetJA3ByteString())
}

// GetJA3Hash returns the MD5 Digest of the JA3 string in hexadecimal representation. This function uses caching, so
Expand Down

0 comments on commit 5d01110

Please sign in to comment.