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 2.1KB

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