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
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233
  1. package hub
  2. import (
  3. "context"
  4. "errors"
  5. "sync"
  6. "go.uber.org/zap"
  7. )
  8. var (
  9. Registry *registry
  10. Hub *hub
  11. ErrTimeout = errors.New("timeout")
  12. ErrClosed = errors.New("channel was closed")
  13. ErrCannotCreateConnection = errors.New("cannot create connection")
  14. initOnce sync.Once
  15. )
  16. func Init(ctx context.Context) {
  17. initOnce.Do(func() {
  18. Registry = &registry{
  19. conns: map[string]*ctxChannel{},
  20. ctx: ctx,
  21. }
  22. Hub = &hub{
  23. subs: map[string]*connectionHub{},
  24. logger: zap.S().Named("hub"),
  25. }
  26. })
  27. }