Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334
  1. package antireplay
  2. import (
  3. "math"
  4. "sync"
  5. "github.com/dgraph-io/ristretto"
  6. "mtg/config"
  7. )
  8. var (
  9. Cache cache
  10. initOnce sync.Once
  11. )
  12. func Init() {
  13. initOnce.Do(func() {
  14. cost := float64(config.C.AntiReplayMaxSize) / 32.0
  15. cost = math.Ceil(cost)
  16. c, err := ristretto.NewCache(&ristretto.Config{
  17. NumCounters: int64(cost) * 10,
  18. MaxCost: config.C.AntiReplayMaxSize,
  19. BufferItems: 64,
  20. Metrics: false,
  21. })
  22. if err != nil {
  23. panic(err)
  24. }
  25. Cache.data = c
  26. })
  27. }