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.

rpc_handshake_request.go 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package rpc
  2. import (
  3. "bytes"
  4. )
  5. const (
  6. rpcHandshakeTagLength = 4
  7. rpcHandshakeFlagsLength = 4
  8. rpcHandshakeSenderPIDLength = 12
  9. rpcHandshakePeerPIDLength = rpcHandshakeSenderPIDLength
  10. rpcHandshakeRequestLength = rpcHandshakeTagLength + rpcHandshakeFlagsLength + rpcHandshakeSenderPIDLength + rpcHandshakePeerPIDLength
  11. )
  12. var (
  13. rpcHandshakeSenderPID [rpcHandshakeSenderPIDLength]byte
  14. rpcHandshakePeerPID [rpcHandshakePeerPIDLength]byte
  15. rpcHandshakeTag = [rpcHandshakeTagLength]byte{0xf5, 0xee, 0x82, 0x76}
  16. rpcHandshakeFlags = [rpcHandshakeFlagsLength]byte{0x00, 0x00, 0x00, 0x00}
  17. )
  18. type RPCHandshakeRequest struct {
  19. }
  20. func (r *RPCHandshakeRequest) Bytes() []byte {
  21. buf := &bytes.Buffer{}
  22. buf.Grow(rpcHandshakeRequestLength)
  23. buf.Write(rpcHandshakeTag[:])
  24. buf.Write(rpcHandshakeFlags[:])
  25. buf.Write(rpcHandshakeSenderPID[:])
  26. buf.Write(rpcHandshakePeerPID[:])
  27. return buf.Bytes()
  28. }
  29. func init() {
  30. copy(rpcHandshakeSenderPID[:], "IPIPPRPDTIME")
  31. copy(rpcHandshakePeerPID[:], "IPIPPRPDTIME")
  32. }
  33. func NewRPCHandshakeRequest() *RPCHandshakeRequest {
  34. return &RPCHandshakeRequest{}
  35. }