mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 19:34:03 +03:00
FILE / ScuroNeko/mtg
antireplay/init.go
Исходный файл и его история в репозитории.
31 lines
472 B
Go
31 lines
472 B
Go
package antireplay
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/9seconds/mtg/config"
|
|
"github.com/VictoriaMetrics/fastcache"
|
|
)
|
|
|
|
type CacheInterface interface {
|
|
AddObfuscated2([]byte)
|
|
AddTLS([]byte)
|
|
HasObfuscated2([]byte) bool
|
|
HasTLS([]byte) bool
|
|
}
|
|
|
|
var (
|
|
Cache CacheInterface
|
|
initOnce sync.Once
|
|
)
|
|
|
|
func Init() {
|
|
initOnce.Do(func() {
|
|
if config.C.AntiReplayMaxSize == 0 {
|
|
Cache = nilCache{}
|
|
} else {
|
|
Cache = cache{fastcache.New(config.C.AntiReplayMaxSize)}
|
|
}
|
|
})
|
|
}
|