mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 22:44:02 +03:00
Bugfix rpc handshake
This commit is contained in:
+3
-1
@@ -14,6 +14,8 @@ const telegramDialTimeout = 10 * time.Second
|
||||
|
||||
type tgDialer struct {
|
||||
net.Dialer
|
||||
|
||||
conf *config.Config
|
||||
}
|
||||
|
||||
func (t *tgDialer) dial(addr string) (net.Conn, error) {
|
||||
@@ -34,5 +36,5 @@ func (t *tgDialer) dialRWC(addr string) (wrappers.ReadWriteCloserWithAddr, error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return wrappers.NewTimeoutRWC(conn), nil
|
||||
return wrappers.NewTimeoutRWC(conn, t.conf.PublicIPv4, t.conf.PublicIPv6), nil
|
||||
}
|
||||
|
||||
+4
-1
@@ -57,7 +57,10 @@ func (t *directTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.Re
|
||||
// to Telegram bypassing middleproxies.
|
||||
func NewDirectTelegram(conf *config.Config) Telegram {
|
||||
return &directTelegram{baseTelegram{
|
||||
dialer: tgDialer{net.Dialer{Timeout: telegramDialTimeout}},
|
||||
dialer: tgDialer{
|
||||
Dialer: net.Dialer{Timeout: telegramDialTimeout},
|
||||
conf: conf,
|
||||
},
|
||||
v4Addresses: directV4Addresses,
|
||||
v6Addresses: directV6Addresses,
|
||||
}}
|
||||
|
||||
+7
-3
@@ -1,6 +1,7 @@
|
||||
package telegram
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -24,7 +25,10 @@ func NewMiddleTelegram(conf *config.Config, logger *zap.SugaredLogger) Telegram
|
||||
tg := &middleTelegram{
|
||||
middleTelegramCaller: middleTelegramCaller{
|
||||
baseTelegram: baseTelegram{
|
||||
dialer: tgDialer{net.Dialer{Timeout: telegramDialTimeout}},
|
||||
dialer: tgDialer{
|
||||
Dialer: net.Dialer{Timeout: telegramDialTimeout},
|
||||
conf: conf,
|
||||
},
|
||||
},
|
||||
logger: logger,
|
||||
httpClient: &http.Client{
|
||||
@@ -54,8 +58,7 @@ func (t *middleTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.Re
|
||||
return nil, err
|
||||
}
|
||||
|
||||
secureConn := mtwrappers.NewMiddleProxyCipherRWC(conn, rpcNonceReq,
|
||||
rpcNonceResp, connOpts.ClientAddr, t.proxySecret)
|
||||
secureConn := mtwrappers.NewMiddleProxyCipherRWC(conn, rpcNonceReq, rpcNonceResp, t.proxySecret)
|
||||
secureConn = mtwrappers.NewFrameRWC(secureConn, rpc.RPCHandshakeSeqNo)
|
||||
|
||||
rpcHandshakeReq, err := t.sendRPCHandshakeRequest(secureConn)
|
||||
@@ -123,6 +126,7 @@ func (t *middleTelegram) receiveRPCHandshakeResponse(conn io.Reader, req *rpc.RP
|
||||
if err = rpcHandshakeResp.Valid(req); err != nil {
|
||||
return nil, errors.Annotate(err, "Invalid RPC handshake response")
|
||||
}
|
||||
fmt.Println("VICTORY")
|
||||
|
||||
return rpcHandshakeResp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user