Add possibility to disable antireplay cache

This commit is contained in:
9seconds
2020-02-03 11:26:37 +03:00
parent 566955b8b7
commit a47edf08d0
3 changed files with 25 additions and 6 deletions
+13 -2
View File
@@ -8,13 +8,24 @@ import (
"github.com/9seconds/mtg/config"
)
type CacheInterface interface {
AddObfuscated2([]byte)
AddTLS([]byte)
HasObfuscated2([]byte) bool
HasTLS([]byte) bool
}
var (
Cache cache
Cache CacheInterface
initOnce sync.Once
)
func Init() {
initOnce.Do(func() {
Cache.data = fastcache.New(config.C.AntiReplayMaxSize)
if config.C.AntiReplayMaxSize == 0 {
Cache = nilCache{}
} else {
Cache = cache{fastcache.New(config.C.AntiReplayMaxSize)}
}
})
}