Skip to content

Commit b0428bf

Browse files
committed
Refactor Cache type to use bool instead of string.
1 parent 6f147e9 commit b0428bf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

correlation/ti/ti.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111
)
1212

13-
type Cache map[string]string
13+
type Cache map[string]bool
1414

1515
var blockList map[string]string
1616
var channel chan string
@@ -45,10 +45,10 @@ func blocked(log string) bool {
4545
return false
4646
}
4747

48-
func (c *Cache) Add(k, v string) {
48+
func (c *Cache) Add(k string) {
4949
cacheLock.Lock()
5050
defer cacheLock.Unlock()
51-
(*c)[k] = v
51+
(*c)[k] = false
5252
}
5353

5454
func (c *Cache) IsCached(k string) bool {
@@ -119,7 +119,7 @@ func IsBlocklisted() {
119119

120120
}
121121

122-
cache.Add(sourceIp.String(), "false")
122+
cache.Add(sourceIp.String())
123123
}
124124

125125
if !cache.IsCached(destinationIp.String()) {
@@ -138,7 +138,7 @@ func IsBlocklisted() {
138138
)
139139
}
140140

141-
cache.Add(destinationIp.String(), "false")
141+
cache.Add(destinationIp.String())
142142
}
143143
}
144144
}()

0 commit comments

Comments
 (0)