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
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

init_test.go 605B

123456789101112131415161718192021222324252627282930
  1. package tls
  2. import (
  3. "encoding/binary"
  4. "github.com/stretchr/testify/mock"
  5. )
  6. type WriterMock struct {
  7. mock.Mock
  8. }
  9. func (m *WriterMock) Write(p []byte) (int, error) {
  10. args := m.Called(p)
  11. return args.Int(0), args.Error(1)
  12. }
  13. // makeTLSRecord builds a raw TLS record from hardcoded offsets:
  14. // type(1) + version(2, {3,3}) + length(2, big-endian) + payload.
  15. func MakeTLSRecord(recordType byte, payload []byte) []byte {
  16. buf := make([]byte, 5+len(payload))
  17. buf[0] = recordType
  18. buf[1] = 3
  19. buf[2] = 3
  20. binary.BigEndian.PutUint16(buf[3:5], uint16(len(payload)))
  21. copy(buf[5:], payload)
  22. return buf
  23. }