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
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

handshake.go 741B

12345678910111213141516171819202122232425262728293031323334353637
  1. package tlstypes
  2. import (
  3. "bytes"
  4. "mtg/utils"
  5. )
  6. type Handshake struct {
  7. Type HandshakeType
  8. Version Version
  9. Random [32]byte
  10. SessionID []byte
  11. Tail Byter
  12. }
  13. func (h *Handshake) Bytes() []byte {
  14. buf := bytes.Buffer{}
  15. packetBuf := bytes.Buffer{}
  16. buf.WriteByte(byte(h.Type))
  17. packetBuf.Write(h.Version.Bytes())
  18. packetBuf.Write(h.Random[:])
  19. packetBuf.WriteByte(byte(len(h.SessionID)))
  20. packetBuf.Write(h.SessionID)
  21. packetBuf.Write(h.Tail.Bytes())
  22. sizeUint24 := utils.ToUint24(uint32(packetBuf.Len()))
  23. sizeUint24Bytes := sizeUint24[:]
  24. sizeUint24Bytes[0], sizeUint24Bytes[2] = sizeUint24Bytes[2], sizeUint24Bytes[0]
  25. buf.Write(sizeUint24Bytes)
  26. packetBuf.WriteTo(&buf) // nolint: errcheck
  27. return buf.Bytes()
  28. }