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

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