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
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

init.go 902B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package faketls
  2. import (
  3. "container/ring"
  4. "context"
  5. "sync"
  6. "time"
  7. "mtg/config"
  8. )
  9. var (
  10. connectionServerInstance connectionServer
  11. connectionServerInitOnce sync.Once
  12. )
  13. const (
  14. connectionServerKeepCertificates = 5
  15. connectionServerUpdateEvery = 10 * time.Minute
  16. )
  17. func Init(ctx context.Context) {
  18. connectionServerInitOnce.Do(func() {
  19. if config.C.CloakHost == "" {
  20. return
  21. }
  22. connectionServerInstance = connectionServer{
  23. channelGet: make(chan chan<- []byte),
  24. ctx: ctx,
  25. }
  26. cert, err := connectionServerInstance.fetch()
  27. if err != nil {
  28. panic(err)
  29. }
  30. r := ring.New(connectionServerKeepCertificates)
  31. for i := 0; i < connectionServerKeepCertificates; i++ {
  32. r.Value = cert
  33. r = r.Next()
  34. }
  35. connectionServerInstance.nextWriteItem = r
  36. connectionServerInstance.nextReadItem = r
  37. go connectionServerInstance.run(connectionServerUpdateEvery)
  38. })
  39. }