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
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

middle.go 931B

12345678910111213141516171819202122232425262728293031
  1. package client
  2. import (
  3. "net"
  4. "github.com/9seconds/mtg/config"
  5. "github.com/9seconds/mtg/mtproto"
  6. "github.com/9seconds/mtg/wrappers"
  7. )
  8. // MiddleInit initializes client connection for proxy which has to
  9. // support promoted channels, connect to Telegram middle proxies etc.
  10. func MiddleInit(socket net.Conn, connID string, conf *config.Config) (wrappers.Wrap, *mtproto.ConnectionOpts, error) {
  11. conn, opts, err := DirectInit(socket, connID, conf)
  12. if err != nil {
  13. return nil, nil, err
  14. }
  15. connStream := conn.(wrappers.StreamReadWriteCloser)
  16. newConn := wrappers.NewMTProtoAbridged(connStream, opts)
  17. if opts.ConnectionType != mtproto.ConnectionTypeAbridged {
  18. newConn = wrappers.NewMTProtoIntermediate(connStream, opts)
  19. }
  20. opts.ConnectionProto = mtproto.ConnectionProtocolIPv4
  21. if socket.LocalAddr().(*net.TCPAddr).IP.To4() == nil {
  22. opts.ConnectionProto = mtproto.ConnectionProtocolIPv6
  23. }
  24. return newConn, opts, err
  25. }