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_test.go 681B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package relay_test
  2. import (
  3. "bytes"
  4. "io"
  5. "sync"
  6. )
  7. type loggerMock struct{}
  8. func (l loggerMock) Printf(format string, args ...interface{}) {}
  9. type rwcMock struct {
  10. bytes.Buffer
  11. closed bool
  12. mutex sync.Mutex
  13. }
  14. func (r *rwcMock) Read(p []byte) (int, error) {
  15. r.mutex.Lock()
  16. defer r.mutex.Unlock()
  17. if r.closed {
  18. return 0, io.EOF
  19. }
  20. return r.Buffer.Read(p) // nolint: wrapcheck
  21. }
  22. func (r *rwcMock) Write(p []byte) (int, error) {
  23. r.mutex.Lock()
  24. defer r.mutex.Unlock()
  25. if r.closed {
  26. return 0, io.EOF
  27. }
  28. return r.Buffer.Write(p) // nolint: wrapcheck
  29. }
  30. func (r *rwcMock) Close() error {
  31. r.mutex.Lock()
  32. defer r.mutex.Unlock()
  33. r.closed = true
  34. return nil
  35. }