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
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

detector.go 513B

123456789101112131415161718192021222324252627282930313233343536
  1. package timeattack
  2. import (
  3. "fmt"
  4. "time"
  5. "github.com/9seconds/mtg/v2/mtglib"
  6. )
  7. type detector struct {
  8. time.Duration
  9. }
  10. func (d detector) Valid(then time.Time) error {
  11. now := time.Now()
  12. diff := now.Sub(then)
  13. if diff < 0 {
  14. diff = -diff
  15. }
  16. if diff > d.Duration {
  17. return fmt.Errorf("time is invalid. now=%d, then=%d, diff=%v",
  18. now.Unix(),
  19. then.Unix(),
  20. diff)
  21. }
  22. return nil
  23. }
  24. func NewDetector(duration time.Duration) mtglib.TimeAttackDetector {
  25. return detector{
  26. Duration: duration,
  27. }
  28. }