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
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

proxy_flags.go 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package rpc
  2. import (
  3. "encoding/binary"
  4. "strings"
  5. )
  6. type ProxyRequestFlags uint32
  7. const (
  8. ProxyRequestFlagsHasAdTag ProxyRequestFlags = 0x8
  9. ProxyRequestFlagsEncrypted ProxyRequestFlags = 0x2
  10. ProxyRequestFlagsMagic ProxyRequestFlags = 0x1000
  11. ProxyRequestFlagsExtMode2 ProxyRequestFlags = 0x20000
  12. ProxyRequestFlagsIntermediate ProxyRequestFlags = 0x20000000
  13. ProxyRequestFlagsAbdridged ProxyRequestFlags = 0x40000000
  14. ProxyRequestFlagsQuickAck ProxyRequestFlags = 0x80000000
  15. ProxyRequestFlagsPad ProxyRequestFlags = 0x8000000
  16. )
  17. var ProxyRequestFlagsEncryptedPrefix [8]byte
  18. func (r ProxyRequestFlags) Bytes() []byte {
  19. converted := make([]byte, 4)
  20. binary.LittleEndian.PutUint32(converted, uint32(r))
  21. return converted
  22. }
  23. func (r ProxyRequestFlags) String() string {
  24. flags := make([]string, 0, 7)
  25. if r&ProxyRequestFlagsHasAdTag != 0 {
  26. flags = append(flags, "HAS_AD_TAG")
  27. }
  28. if r&ProxyRequestFlagsEncrypted != 0 {
  29. flags = append(flags, "ENCRYPTED")
  30. }
  31. if r&ProxyRequestFlagsMagic != 0 {
  32. flags = append(flags, "MAGIC")
  33. }
  34. if r&ProxyRequestFlagsExtMode2 != 0 {
  35. flags = append(flags, "EXT_MODE_2")
  36. }
  37. if r&ProxyRequestFlagsIntermediate != 0 {
  38. flags = append(flags, "INTERMEDIATE")
  39. }
  40. if r&ProxyRequestFlagsAbdridged != 0 {
  41. flags = append(flags, "ABRIDGED")
  42. }
  43. if r&ProxyRequestFlagsQuickAck != 0 {
  44. flags = append(flags, "QUICK_ACK")
  45. }
  46. if r&ProxyRequestFlagsPad != 0 {
  47. flags = append(flags, "PAD")
  48. }
  49. return strings.Join(flags, " | ")
  50. }