mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 19:34:03 +03:00
Refactored all the things!
This commit is contained in:
+2
-10
@@ -9,14 +9,6 @@ import (
|
||||
"github.com/9seconds/mtg/wrappers"
|
||||
)
|
||||
|
||||
// Telegram defines an interface to connect to Telegram. This
|
||||
// encapsulates logic of working with middleproxies or direct
|
||||
// connections.
|
||||
type Telegram interface {
|
||||
Dial(string, *mtproto.ConnectionOpts) (wrappers.ReadWriteCloserWithAddr, error)
|
||||
Init(*mtproto.ConnectionOpts, wrappers.ReadWriteCloserWithAddr) (wrappers.ReadWriteCloserWithAddr, error)
|
||||
}
|
||||
|
||||
type baseTelegram struct {
|
||||
dialer tgDialer
|
||||
|
||||
@@ -24,7 +16,7 @@ type baseTelegram struct {
|
||||
v6Addresses map[int16][]string
|
||||
}
|
||||
|
||||
func (b *baseTelegram) dial(dcIdx int16, sock string, proto mtproto.ConnectionProtocol) (wrappers.ReadWriteCloserWithAddr, error) {
|
||||
func (b *baseTelegram) dial(dcIdx int16, connID string, proto mtproto.ConnectionProtocol) (wrappers.WrapStreamReadWriteCloser, error) {
|
||||
addrs := make([]string, 2)
|
||||
|
||||
if proto&mtproto.ConnectionProtocolIPv6 != 0 {
|
||||
@@ -39,7 +31,7 @@ func (b *baseTelegram) dial(dcIdx int16, sock string, proto mtproto.ConnectionPr
|
||||
}
|
||||
|
||||
for _, addr := range addrs {
|
||||
if conn, err := b.dialer.dialRWC(addr, sock); err == nil {
|
||||
if conn, err := b.dialer.dialRWC(addr, connID); err == nil {
|
||||
return conn, err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user