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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package record
  2. import "fmt"
  3. const TLSMaxRecordSize = 65535 // max uint16
  4. type Type uint8
  5. const (
  6. // TypeChangeCipherSpec defines a byte value of the TLS record when a
  7. // peer wants to change a specifications of the chosen cipher.
  8. TypeChangeCipherSpec Type = 0x14
  9. // TypeHandshake defines a byte value of the TLS record when a peer
  10. // initiates a new TLS connection and wants to make a handshake
  11. // ceremony.
  12. TypeHandshake Type = 0x16
  13. // TypeApplicationData defines a byte value of the TLS record when a
  14. // peer sends an user data, not a control frames.
  15. TypeApplicationData Type = 0x17
  16. )
  17. func (t Type) String() string {
  18. switch t {
  19. case TypeChangeCipherSpec:
  20. return "changeCipher(0x14)"
  21. case TypeHandshake:
  22. return "handshake(0x16)"
  23. case TypeApplicationData:
  24. return "applicationData(0x17)"
  25. }
  26. return fmt.Sprintf("unknown(%#x)", byte(t))
  27. }
  28. func (t Type) Valid() error {
  29. switch t {
  30. case TypeChangeCipherSpec, TypeHandshake, TypeApplicationData:
  31. return nil
  32. }
  33. return fmt.Errorf("unknown type %#x", byte(t))
  34. }
  35. type Version uint16
  36. const (
  37. // Version10 defines a TLS1.0.
  38. Version10 Version = 769 // 0x03 0x01
  39. // Version11 defines a TLS1.1.
  40. Version11 Version = 770 // 0x03 0x02
  41. // Version12 defines a TLS1.2.
  42. Version12 Version = 771 // 0x03 0x03
  43. // Version13 defines a TLS1.3.
  44. Version13 Version = 772 // 0x03 0x04
  45. )
  46. func (v Version) String() string {
  47. switch v {
  48. case Version10:
  49. return "tls1.0"
  50. case Version11:
  51. return "tls1.1"
  52. case Version12:
  53. return "tls1.2"
  54. case Version13:
  55. return "tls1.3"
  56. }
  57. return fmt.Sprintf("tls?(%d)", uint16(v))
  58. }
  59. func (v Version) Valid() error {
  60. switch v {
  61. case Version10, Version11, Version12, Version13:
  62. return nil
  63. }
  64. return fmt.Errorf("unknown version %d", uint16(v))
  65. }