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
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

conn.go 528B

1234567891011121314151617181920212223242526272829303132333435
  1. package relay
  2. import (
  3. "context"
  4. "io"
  5. )
  6. type conn struct {
  7. io.ReadWriteCloser
  8. ctx context.Context
  9. tickChannel chan struct{}
  10. }
  11. func (c conn) Read(p []byte) (int, error) {
  12. n, err := c.ReadWriteCloser.Read(p)
  13. select {
  14. case <-c.ctx.Done():
  15. case c.tickChannel <- struct{}{}:
  16. }
  17. return n, err // nolint: wrapcheck
  18. }
  19. func (c conn) Write(p []byte) (int, error) {
  20. n, err := c.ReadWriteCloser.Write(p)
  21. select {
  22. case <-c.ctx.Done():
  23. case c.tickChannel <- struct{}{}:
  24. }
  25. return n, err // nolint: wrapcheck
  26. }