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
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

consts.go 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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
  17. CipherSuiteType_TLS_AES_256_GCM_SHA384 // nolint: stylecheck, golint
  18. CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256 // nolint: stylecheck, golint
  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. }
  27. return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes
  28. }
  29. type Version uint8
  30. func (v Version) Bytes() []byte {
  31. switch v {
  32. case Version13:
  33. return Version13Bytes
  34. case Version12:
  35. return Version12Bytes
  36. case Version11:
  37. return Version11Bytes
  38. }
  39. return Version10Bytes
  40. }
  41. const (
  42. VersionUnknown Version = iota
  43. Version10
  44. Version11
  45. Version12
  46. Version13
  47. )
  48. var (
  49. Version10Bytes = []byte{0x03, 0x01}
  50. Version11Bytes = []byte{0x03, 0x02}
  51. Version12Bytes = []byte{0x03, 0x03}
  52. Version13Bytes = []byte{0x03, 0x04}
  53. CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes = []byte{0x13, 0x01} // nolint: stylecheck, golint
  54. CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes = []byte{0x13, 0x02} // nolint: stylecheck, golint
  55. CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes = []byte{0x13, 0x03} // nolint; stylecheck, golint
  56. )
  57. type Byter interface {
  58. WriteBytes(io.Writer)
  59. Len() int
  60. }
  61. type RawBytes []byte
  62. func (r RawBytes) WriteBytes(writer io.Writer) {
  63. writer.Write(r) // nolint: errcheck
  64. }
  65. func (r RawBytes) Len() int {
  66. return len(r)
  67. }