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.

proxy_flags.go 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package rpc
  2. import (
  3. "encoding/binary"
  4. "strings"
  5. )
  6. type proxyRequestFlags uint32
  7. const (
  8. proxyRequestFlagsHasAdTag proxyRequestFlags = 0x8
  9. proxyRequestFlagsEncrypted = 0x2
  10. proxyRequestFlagsMagic = 0x1000
  11. proxyRequestFlagsExtMode2 = 0x20000
  12. proxyRequestFlagsIntermediate = 0x20000000
  13. proxyRequestFlagsAbdridged = 0x40000000
  14. proxyRequestFlagsQuickAck = 0x80000000
  15. )
  16. var proxyRequestFlagsEncryptedPrefix [8]byte
  17. func (r proxyRequestFlags) Bytes() []byte {
  18. converted := make([]byte, 4)
  19. binary.LittleEndian.PutUint32(converted, uint32(r))
  20. return converted
  21. }
  22. func (r proxyRequestFlags) String() string {
  23. flags := make([]string, 0, 7)
  24. if r&proxyRequestFlagsHasAdTag != 0 {
  25. flags = append(flags, "HAS_AD_TAG")
  26. }
  27. if r&proxyRequestFlagsEncrypted != 0 {
  28. flags = append(flags, "ENCRYPTED")
  29. }
  30. if r&proxyRequestFlagsMagic != 0 {
  31. flags = append(flags, "MAGIC")
  32. }
  33. if r&proxyRequestFlagsExtMode2 != 0 {
  34. flags = append(flags, "EXT_MODE_2")
  35. }
  36. if r&proxyRequestFlagsIntermediate != 0 {
  37. flags = append(flags, "INTERMEDIATE")
  38. }
  39. if r&proxyRequestFlagsAbdridged != 0 {
  40. flags = append(flags, "ABRIDGED")
  41. }
  42. if r&proxyRequestFlagsQuickAck != 0 {
  43. flags = append(flags, "QUICK_ACK")
  44. }
  45. return strings.Join(flags, " | ")
  46. }