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 символов.

12345678910111213141516171819202122232425262728293031323334
  1. package obfuscation
  2. import (
  3. "crypto/cipher"
  4. "github.com/9seconds/mtg/v2/essentials"
  5. )
  6. type conn struct {
  7. essentials.Conn
  8. sendCipher cipher.Stream
  9. recvCipher cipher.Stream
  10. }
  11. func (c conn) Read(p []byte) (int, error) {
  12. n, err := c.Conn.Read(p)
  13. if err != nil {
  14. return n, err
  15. }
  16. c.recvCipher.XORKeyStream(p, p[:n])
  17. return n, nil
  18. }
  19. func (c conn) Write(p []byte) (int, error) {
  20. // yes, this is a bit violent and goes against a contract in io.Writer
  21. // but we do it to avoid creating a new buffer just to perform this
  22. // encryption.
  23. c.sendCipher.XORKeyStream(p, p)
  24. return c.Conn.Write(p)
  25. }