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
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

consts.go 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package tlstypes
  2. type RecordType uint8
  3. const (
  4. RecordTypeHandshake RecordType = 0x16
  5. RecordTypeApplicationData RecordType = 0x17
  6. RecordTypeChangeCipherSpec RecordType = 0x14
  7. )
  8. type HandshakeType uint8
  9. const (
  10. HandshakeTypeClient HandshakeType = 0x01
  11. HandshakeTypeServer HandshakeType = 0x02
  12. )
  13. type CipherSuiteType uint8
  14. const (
  15. CipherSuiteType_TLS_AES_128_GCM_SHA256 CipherSuiteType = iota // nolint: stylecheck, golint
  16. CipherSuiteType_TLS_AES_256_GCM_SHA384 // nolint: stylecheck, golint
  17. CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256 // nolint: stylecheck, golint
  18. )
  19. func (c CipherSuiteType) Bytes() []byte {
  20. switch c {
  21. case CipherSuiteType_TLS_AES_128_GCM_SHA256:
  22. return CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes
  23. case CipherSuiteType_TLS_AES_256_GCM_SHA384:
  24. return CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes
  25. }
  26. return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes
  27. }
  28. type Version uint8
  29. func (v Version) Bytes() []byte {
  30. switch v {
  31. case Version13:
  32. return Version13Bytes
  33. case Version12:
  34. return Version12Bytes
  35. case Version11:
  36. return Version11Bytes
  37. }
  38. return Version10Bytes
  39. }
  40. const (
  41. VersionUnknown Version = iota
  42. Version10
  43. Version11
  44. Version12
  45. Version13
  46. )
  47. var (
  48. Version10Bytes = []byte{0x03, 0x01}
  49. Version11Bytes = []byte{0x03, 0x02}
  50. Version12Bytes = []byte{0x03, 0x03}
  51. Version13Bytes = []byte{0x03, 0x04}
  52. CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes = []byte{0x13, 0x01} // nolint: stylecheck, golint
  53. CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes = []byte{0x13, 0x02} // nolint: stylecheck, golint
  54. CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes = []byte{0x13, 0x03} // nolint; stylecheck, golint
  55. )
  56. type Byter interface {
  57. Bytes() []byte
  58. }
  59. type RawBytes []byte
  60. func (r RawBytes) Bytes() []byte {
  61. return []byte(r)
  62. }