Preliminary debug state

This commit is contained in:
9seconds
2018-07-06 17:29:24 +03:00
parent 88faeb7195
commit a3933e6ede
21 changed files with 127 additions and 57 deletions
+2 -2
View File
@@ -30,11 +30,11 @@ func (t *tgDialer) dial(addr string) (net.Conn, error) {
return conn, nil
}
func (t *tgDialer) dialRWC(addr string) (wrappers.ReadWriteCloserWithAddr, error) {
func (t *tgDialer) dialRWC(addr, sock string) (wrappers.ReadWriteCloserWithAddr, error) {
conn, err := t.dial(addr)
if err != nil {
return nil, err
}
return wrappers.NewTimeoutRWC(conn, t.conf.PublicIPv4, t.conf.PublicIPv6), nil
return wrappers.NewTimeoutRWC(conn, sock, t.conf.PublicIPv4, t.conf.PublicIPv6), nil
}
+2 -2
View File
@@ -33,7 +33,7 @@ type directTelegram struct {
baseTelegram
}
func (t *directTelegram) Dial(connOpts *mtproto.ConnectionOpts) (wrappers.ReadWriteCloserWithAddr, error) {
func (t *directTelegram) Dial(sock string, connOpts *mtproto.ConnectionOpts) (wrappers.ReadWriteCloserWithAddr, error) {
dc := connOpts.DC
if dc < 0 {
dc = -dc
@@ -41,7 +41,7 @@ func (t *directTelegram) Dial(connOpts *mtproto.ConnectionOpts) (wrappers.ReadWr
dc = 1
}
return t.baseTelegram.dial(dc-1, connOpts.ConnectionProto)
return t.baseTelegram.dial(dc-1, sock, connOpts.ConnectionProto)
}
func (t *directTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.ReadWriteCloserWithAddr) (wrappers.ReadWriteCloserWithAddr, error) {
+2 -2
View File
@@ -39,7 +39,7 @@ type middleTelegramCaller struct {
httpClient *http.Client
}
func (t *middleTelegramCaller) Dial(connOpts *mtproto.ConnectionOpts) (wrappers.ReadWriteCloserWithAddr, error) {
func (t *middleTelegramCaller) Dial(sock string, connOpts *mtproto.ConnectionOpts) (wrappers.ReadWriteCloserWithAddr, error) {
dc := connOpts.DC
if dc == 0 {
dc = 1
@@ -47,7 +47,7 @@ func (t *middleTelegramCaller) Dial(connOpts *mtproto.ConnectionOpts) (wrappers.
t.dialerMutex.RLock()
defer t.dialerMutex.RUnlock()
return t.baseTelegram.dial(dc, connOpts.ConnectionProto)
return t.baseTelegram.dial(dc, sock, connOpts.ConnectionProto)
}
func (t *middleTelegramCaller) autoUpdate() {
+3 -3
View File
@@ -13,7 +13,7 @@ import (
// encapsulates logic of working with middleproxies or direct
// connections.
type Telegram interface {
Dial(*mtproto.ConnectionOpts) (wrappers.ReadWriteCloserWithAddr, error)
Dial(string, *mtproto.ConnectionOpts) (wrappers.ReadWriteCloserWithAddr, error)
Init(*mtproto.ConnectionOpts, wrappers.ReadWriteCloserWithAddr) (wrappers.ReadWriteCloserWithAddr, error)
}
@@ -24,7 +24,7 @@ type baseTelegram struct {
v6Addresses map[int16][]string
}
func (b *baseTelegram) dial(dcIdx int16, proto mtproto.ConnectionProtocol) (wrappers.ReadWriteCloserWithAddr, error) {
func (b *baseTelegram) dial(dcIdx int16, sock string, proto mtproto.ConnectionProtocol) (wrappers.ReadWriteCloserWithAddr, error) {
addrs := make([]string, 2)
if proto&mtproto.ConnectionProtocolIPv6 != 0 {
@@ -39,7 +39,7 @@ func (b *baseTelegram) dial(dcIdx int16, proto mtproto.ConnectionProtocol) (wrap
}
for _, addr := range addrs {
if conn, err := b.dialer.dialRWC(addr); err == nil {
if conn, err := b.dialer.dialRWC(addr, sock); err == nil {
return conn, err
}
}