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.

pools.go 604B

12345678910111213141516171819202122232425262728293031323334353637
  1. package obfuscated2
  2. import (
  3. "crypto/sha256"
  4. "hash"
  5. "sync"
  6. )
  7. var (
  8. sha256HasherPool = sync.Pool{
  9. New: func() interface{} {
  10. return sha256.New()
  11. },
  12. }
  13. handshakeFramePool = sync.Pool{
  14. New: func() interface{} {
  15. return &handshakeFrame{}
  16. },
  17. }
  18. )
  19. func acquireSha256Hasher() hash.Hash {
  20. return sha256HasherPool.Get().(hash.Hash)
  21. }
  22. func releaseSha256Hasher(h hash.Hash) {
  23. h.Reset()
  24. sha256HasherPool.Put(h)
  25. }
  26. func acquireHandshakeFrame() *handshakeFrame {
  27. return handshakeFramePool.Get().(*handshakeFrame)
  28. }
  29. func releaseHandshakeFrame(h *handshakeFrame) {
  30. handshakeFramePool.Put(h)
  31. }