mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 16:24:03 +03:00
Add possibility to disable antireplay cache
This commit is contained in:
+13
-2
@@ -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)}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user