-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from 9seconds/channels
Promoted channels
- Loading branch information
Showing
51 changed files
with
2,516 additions
and
627 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package client | ||
|
||
import ( | ||
"io" | ||
"net" | ||
|
||
"github.com/9seconds/mtg/config" | ||
"github.com/9seconds/mtg/mtproto" | ||
"github.com/9seconds/mtg/wrappers" | ||
) | ||
|
||
// Init has to initialize client connection based on given config. | ||
type Init func(net.Conn, *config.Config) (*mtproto.ConnectionOpts, io.ReadWriteCloser, error) | ||
// Init defines common method for initializing client connections. | ||
type Init func(net.Conn, string, *config.Config) (wrappers.Wrap, *mtproto.ConnectionOpts, error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package client | ||
|
||
import ( | ||
"net" | ||
|
||
"github.com/9seconds/mtg/config" | ||
"github.com/9seconds/mtg/mtproto" | ||
"github.com/9seconds/mtg/wrappers" | ||
) | ||
|
||
// MiddleInit initializes client connection for proxy which has to | ||
// support promoted channels, connect to Telegram middle proxies etc. | ||
func MiddleInit(socket net.Conn, connID string, conf *config.Config) (wrappers.Wrap, *mtproto.ConnectionOpts, error) { | ||
conn, opts, err := DirectInit(socket, connID, conf) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
connStream := conn.(wrappers.StreamReadWriteCloser) | ||
|
||
newConn := wrappers.NewMTProtoAbridged(connStream, opts) | ||
if opts.ConnectionType != mtproto.ConnectionTypeAbridged { | ||
newConn = wrappers.NewMTProtoIntermediate(connStream, opts) | ||
} | ||
|
||
opts.ConnectionProto = mtproto.ConnectionProtocolIPv4 | ||
if socket.LocalAddr().(*net.TCPAddr).IP.To4() == nil { | ||
opts.ConnectionProto = mtproto.ConnectionProtocolIPv6 | ||
} | ||
|
||
return newConn, opts, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.