mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 11:54:01 +03:00
Success path for fake tls is implemented
This commit is contained in:
+15
-5
@@ -3,14 +3,24 @@ package antireplay
|
||||
import "github.com/allegro/bigcache"
|
||||
|
||||
type cache struct {
|
||||
cache *bigcache.BigCache
|
||||
obfuscated2 *bigcache.BigCache
|
||||
tls *bigcache.BigCache
|
||||
}
|
||||
|
||||
func (c *cache) Add(data []byte) {
|
||||
c.cache.Set(string(data), nil) // nolint: errcheck
|
||||
func (c *cache) AddObfuscated2(data []byte) {
|
||||
c.obfuscated2.Set(string(data), nil) // nolint: errcheck
|
||||
}
|
||||
|
||||
func (c *cache) Has(data []byte) bool {
|
||||
_, err := c.cache.Get(string(data))
|
||||
func (c *cache) AddTLS(data []byte) {
|
||||
c.tls.Set(string(data), nil) // nolint: errcheck
|
||||
}
|
||||
|
||||
func (c *cache) HasObfuscated2(data []byte) bool {
|
||||
_, err := c.obfuscated2.Get(string(data))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func (c *cache) HasTLS(data []byte) bool {
|
||||
_, err := c.tls.Get(string(data))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
+13
-2
@@ -14,7 +14,17 @@ var (
|
||||
|
||||
func Init() {
|
||||
initOnce.Do(func() {
|
||||
c, err := bigcache.NewBigCache(bigcache.Config{
|
||||
c1, err := bigcache.NewBigCache(bigcache.Config{
|
||||
Shards: 1024,
|
||||
LifeWindow: config.C.AntiReplayEvictionTime,
|
||||
Hasher: hasher{},
|
||||
HardMaxCacheSize: config.C.AntiReplayMaxSize,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c2, err := bigcache.NewBigCache(bigcache.Config{
|
||||
Shards: 1024,
|
||||
LifeWindow: config.C.AntiReplayEvictionTime,
|
||||
Hasher: hasher{},
|
||||
@@ -25,7 +35,8 @@ func Init() {
|
||||
}
|
||||
|
||||
Cache = &cache{
|
||||
cache: c,
|
||||
obfuscated2: c1,
|
||||
tls: c2,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user