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.

handshake_frame_fuzz_test.go 981B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package obfuscation
  2. import (
  3. "encoding/binary"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func FuzzGenerateHandshakeFrame(f *testing.F) {
  8. f.Fuzz(func(t *testing.T, arg int16) {
  9. frame := generateHandshake(int(arg))
  10. assert.NotEqualValues(t, 0xef, frame.data[0])
  11. firstBytes := binary.LittleEndian.Uint32(frame.data[:4])
  12. assert.NotEqualValues(t, 0x44414548, firstBytes)
  13. assert.NotEqualValues(t, 0x54534f50, firstBytes)
  14. assert.NotEqualValues(t, 0x20544547, firstBytes)
  15. assert.NotEqualValues(t, 0x4954504f, firstBytes)
  16. assert.NotEqualValues(t, 0x02010316, firstBytes)
  17. assert.NotEqualValues(t, 0xeeeeeeee, firstBytes)
  18. assert.NotEqualValues(t, 0xdddddddd, firstBytes)
  19. assert.NotEqualValues(
  20. t,
  21. 0,
  22. frame.data[4]|frame.data[5]|frame.data[6]|frame.data[7])
  23. assert.Equal(t, hfConnectionType[:], frame.connectionType())
  24. if arg < 0 {
  25. arg = -arg
  26. } else if arg == 0 {
  27. arg = defaultDC
  28. }
  29. assert.EqualValues(t, arg, frame.dc())
  30. })
  31. }