mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 14:44:02 +03:00
Bugfix rpc handshake
This commit is contained in:
@@ -2,7 +2,6 @@ package mtproto
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net"
|
||||
|
||||
"github.com/juju/errors"
|
||||
)
|
||||
@@ -19,7 +18,8 @@ type ConnectionOpts struct {
|
||||
DC int16
|
||||
ConnectionType ConnectionType
|
||||
ConnectionProto ConnectionProtocol
|
||||
ClientAddr *net.TCPAddr
|
||||
QuickAck bool
|
||||
SimpleAck bool
|
||||
}
|
||||
|
||||
// Different connection types which user requests from Telegram.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package rpc
|
||||
|
||||
import "bytes"
|
||||
import (
|
||||
"bytes"
|
||||
)
|
||||
|
||||
const (
|
||||
rpcHandshakeTagLength = 4
|
||||
|
||||
@@ -22,11 +22,12 @@ const (
|
||||
|
||||
var emptyIP = [4]byte{0x00, 0x00, 0x00, 0x00}
|
||||
|
||||
func NewMiddleProxyCipherRWC(conn wrappers.ReadWriteCloserWithAddr, req *rpc.RPCNonceRequest,
|
||||
resp *rpc.RPCNonceResponse, client *net.TCPAddr, secret []byte) wrappers.ReadWriteCloserWithAddr {
|
||||
remote := conn.Addr()
|
||||
encKey, encIV := makeKeys(CipherPurposeClient, req, resp, client, remote, secret)
|
||||
decKey, decIV := makeKeys(CipherPurposeServer, req, resp, client, remote, secret)
|
||||
func NewMiddleProxyCipherRWC(conn wrappers.ReadWriteCloserWithAddr, req *rpc.RPCNonceRequest, resp *rpc.RPCNonceResponse, secret []byte) wrappers.ReadWriteCloserWithAddr {
|
||||
localAddr := conn.LocalAddr()
|
||||
remoteAddr := conn.RemoteAddr()
|
||||
|
||||
encKey, encIV := makeKeys(CipherPurposeClient, req, resp, localAddr, remoteAddr, secret)
|
||||
decKey, decIV := makeKeys(CipherPurposeServer, req, resp, localAddr, remoteAddr, secret)
|
||||
|
||||
enc, _ := makeEncrypterDecrypter(encKey, encIV)
|
||||
_, dec := makeEncrypterDecrypter(decKey, decIV)
|
||||
|
||||
@@ -112,8 +112,12 @@ func (f *FrameRWC) Close() error {
|
||||
return f.conn.Close()
|
||||
}
|
||||
|
||||
func (f *FrameRWC) Addr() *net.TCPAddr {
|
||||
return f.conn.Addr()
|
||||
func (f *FrameRWC) LocalAddr() *net.TCPAddr {
|
||||
return f.conn.LocalAddr()
|
||||
}
|
||||
|
||||
func (f *FrameRWC) RemoteAddr() *net.TCPAddr {
|
||||
return f.conn.RemoteAddr()
|
||||
}
|
||||
|
||||
func NewFrameRWC(conn wrappers.ReadWriteCloserWithAddr, seqNo int32) wrappers.ReadWriteCloserWithAddr {
|
||||
|
||||
Reference in New Issue
Block a user