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.

middle.go 620B

12345678910111213141516171819202122232425
  1. package client
  2. import (
  3. "net"
  4. "github.com/9seconds/mtg/config"
  5. "github.com/9seconds/mtg/mtproto"
  6. mtwrappers "github.com/9seconds/mtg/mtproto/wrappers"
  7. "github.com/9seconds/mtg/wrappers"
  8. )
  9. func MiddleInit(conn net.Conn, conf *config.Config) (*mtproto.ConnectionOpts, wrappers.ReadWriteCloserWithAddr, error) {
  10. opts, newConn, err := DirectInit(conn, conf)
  11. if err != nil {
  12. return nil, nil, err
  13. }
  14. if opts.ConnectionType == mtproto.ConnectionTypeAbridged {
  15. newConn = mtwrappers.NewAbridgedRWC(newConn, opts)
  16. } else {
  17. newConn = mtwrappers.NewIntermediateRWC(newConn, opts)
  18. }
  19. return opts, newConn, nil
  20. }