Quellcode durchsuchen

Remove borsh borsh new borsch

tags/0.9
9seconds vor 7 Jahren
Ursprung
Commit
d3e685de97

+ 21
- 0
mtproto/rpc/handshake_request.go Datei anzeigen

@@ -0,0 +1,21 @@
1
+package rpc
2
+
3
+import "bytes"
4
+
5
+type HandshakeRequest struct {
6
+}
7
+
8
+func (r *HandshakeRequest) Bytes() []byte {
9
+	buf := &bytes.Buffer{}
10
+
11
+	buf.Write(TagHandshake)
12
+	buf.Write(HandshakeFlags)
13
+	buf.Write(HandshakeSenderPID)
14
+	buf.Write(HandshakePeerPID)
15
+
16
+	return buf.Bytes()
17
+}
18
+
19
+func NewHandshakeRequest() *HandshakeRequest {
20
+	return &HandshakeRequest{}
21
+}

mtproto/rpc/rpc_handshake_response.go → mtproto/rpc/handshake_response.go Datei anzeigen

@@ -6,14 +6,14 @@ import (
6 6
 	"github.com/juju/errors"
7 7
 )
8 8
 
9
-type RPCHandshakeResponse struct {
9
+type HandshakeResponse struct {
10 10
 	Type      []byte
11 11
 	Flags     []byte
12 12
 	SenderPID []byte
13 13
 	PeerPID   []byte
14 14
 }
15 15
 
16
-func (r *RPCHandshakeResponse) Bytes() []byte {
16
+func (r *HandshakeResponse) Bytes() []byte {
17 17
 	buf := &bytes.Buffer{}
18 18
 
19 19
 	buf.Write(r.Type[:])
@@ -24,23 +24,23 @@ func (r *RPCHandshakeResponse) Bytes() []byte {
24 24
 	return buf.Bytes()
25 25
 }
26 26
 
27
-func (r *RPCHandshakeResponse) Valid(req *RPCHandshakeRequest) error {
28
-	if !bytes.Equal(r.Type, RPCTagHandshake) {
27
+func (r *HandshakeResponse) Valid(req *HandshakeRequest) error {
28
+	if !bytes.Equal(r.Type, TagHandshake) {
29 29
 		return errors.New("Unexpected handshake tag")
30 30
 	}
31
-	if !bytes.Equal(r.PeerPID, RPCHandshakeSenderPID) {
31
+	if !bytes.Equal(r.PeerPID, HandshakeSenderPID) {
32 32
 		return errors.New("Incorrect sender PID")
33 33
 	}
34 34
 
35 35
 	return nil
36 36
 }
37 37
 
38
-func NewRPCHandshakeResponse(data []byte) (*RPCHandshakeResponse, error) {
38
+func NewHandshakeResponse(data []byte) (*HandshakeResponse, error) {
39 39
 	if len(data) != 32 {
40 40
 		return nil, errors.New("Incorrect handshake response length")
41 41
 	}
42 42
 
43
-	return &RPCHandshakeResponse{
43
+	return &HandshakeResponse{
44 44
 		Type:      data[:4],
45 45
 		Flags:     data[4:8],
46 46
 		SenderPID: data[8:20],

mtproto/rpc/rpc_nonce_request.go → mtproto/rpc/nonce_request.go Datei anzeigen

@@ -9,25 +9,25 @@ import (
9 9
 	"github.com/juju/errors"
10 10
 )
11 11
 
12
-type RPCNonceRequest struct {
12
+type NonceRequest struct {
13 13
 	KeySelector []byte
14 14
 	CryptoTS    []byte
15 15
 	Nonce       []byte
16 16
 }
17 17
 
18
-func (r *RPCNonceRequest) Bytes() []byte {
18
+func (r *NonceRequest) Bytes() []byte {
19 19
 	buf := &bytes.Buffer{}
20 20
 
21
-	buf.Write(RPCTagNonce)
21
+	buf.Write(TagNonce)
22 22
 	buf.Write(r.KeySelector)
23
-	buf.Write(RPCNonceCryptoAES)
23
+	buf.Write(NonceCryptoAES)
24 24
 	buf.Write(r.CryptoTS)
25 25
 	buf.Write(r.Nonce)
26 26
 
27 27
 	return buf.Bytes()
28 28
 }
29 29
 
30
-func NewRPCNonceRequest(proxySecret []byte) (*RPCNonceRequest, error) {
30
+func NewNonceRequest(proxySecret []byte) (*NonceRequest, error) {
31 31
 	nonce := make([]byte, 16)
32 32
 	keySelector := make([]byte, 4)
33 33
 	cryptoTS := make([]byte, 4)
@@ -40,7 +40,7 @@ func NewRPCNonceRequest(proxySecret []byte) (*RPCNonceRequest, error) {
40 40
 	timestamp := time.Now().Truncate(time.Second).Unix() % 4294967296 // 256 ^ 4 - do not know how to name
41 41
 	binary.LittleEndian.PutUint32(cryptoTS, uint32(timestamp))
42 42
 
43
-	return &RPCNonceRequest{
43
+	return &NonceRequest{
44 44
 		KeySelector: keySelector,
45 45
 		CryptoTS:    cryptoTS,
46 46
 		Nonce:       nonce,

mtproto/rpc/rpc_nonce_response.go → mtproto/rpc/nonce_response.go Datei anzeigen

@@ -6,17 +6,17 @@ import (
6 6
 	"github.com/juju/errors"
7 7
 )
8 8
 
9
-type RPCNonceResponse struct {
10
-	RPCNonceRequest
9
+type NonceResponse struct {
10
+	NonceRequest
11 11
 
12
-	RPCType []byte
13
-	Crypto  []byte
12
+	Type   []byte
13
+	Crypto []byte
14 14
 }
15 15
 
16
-func (r *RPCNonceResponse) Bytes() []byte {
16
+func (r *NonceResponse) Bytes() []byte {
17 17
 	buf := &bytes.Buffer{}
18 18
 
19
-	buf.Write(r.RPCType)
19
+	buf.Write(r.Type)
20 20
 	buf.Write(r.KeySelector)
21 21
 	buf.Write(r.Crypto)
22 22
 	buf.Write(r.CryptoTS)
@@ -25,11 +25,11 @@ func (r *RPCNonceResponse) Bytes() []byte {
25 25
 	return buf.Bytes()
26 26
 }
27 27
 
28
-func (r *RPCNonceResponse) Valid(req *RPCNonceRequest) error {
29
-	if !bytes.Equal(r.RPCType, RPCTagNonce) {
28
+func (r *NonceResponse) Valid(req *NonceRequest) error {
29
+	if !bytes.Equal(r.Type, TagNonce) {
30 30
 		return errors.New("Unexpected RPC type")
31 31
 	}
32
-	if !bytes.Equal(r.Crypto, RPCNonceCryptoAES) {
32
+	if !bytes.Equal(r.Crypto, NonceCryptoAES) {
33 33
 		return errors.New("Unexpected crypto type")
34 34
 	}
35 35
 	if !bytes.Equal(r.KeySelector, req.KeySelector) {
@@ -39,18 +39,18 @@ func (r *RPCNonceResponse) Valid(req *RPCNonceRequest) error {
39 39
 	return nil
40 40
 }
41 41
 
42
-func NewRPCNonceResponse(data []byte) (*RPCNonceResponse, error) {
42
+func NewNonceResponse(data []byte) (*NonceResponse, error) {
43 43
 	if len(data) != 32 {
44 44
 		return nil, errors.New("Unexpected message length")
45 45
 	}
46 46
 
47
-	return &RPCNonceResponse{
48
-		RPCNonceRequest: RPCNonceRequest{
47
+	return &NonceResponse{
48
+		NonceRequest: NonceRequest{
49 49
 			KeySelector: data[4:8],
50 50
 			CryptoTS:    data[12:16],
51 51
 			Nonce:       data[16:],
52 52
 		},
53
-		RPCType: data[:4],
54
-		Crypto:  data[8:12],
53
+		Type:   data[:4],
54
+		Crypto: data[8:12],
55 55
 	}, nil
56 56
 }

+ 24
- 0
mtproto/rpc/proxy_flags.go Datei anzeigen

@@ -0,0 +1,24 @@
1
+package rpc
2
+
3
+import "encoding/binary"
4
+
5
+type proxyRequestFlags uint32
6
+
7
+const (
8
+	proxyRequestFlagsHasAdTag     proxyRequestFlags = 0x8
9
+	proxyRequestFlagsEncrypted                      = 0x2
10
+	proxyRequestFlagsMagic                          = 0x1000
11
+	proxyRequestFlagsExtMode2                       = 0x20000
12
+	proxyRequestFlagsIntermediate                   = 0x20000000
13
+	proxyRequestFlagsAbdridged                      = 0x40000000
14
+	proxyRequestFlagsQuickAck                       = 0x80000000
15
+)
16
+
17
+var proxyRequestFlagsEncryptedPrefix [8]byte
18
+
19
+func (r proxyRequestFlags) Bytes() []byte {
20
+	converted := make([]byte, 4)
21
+	binary.LittleEndian.PutUint32(converted, uint32(r))
22
+
23
+	return converted
24
+}

mtproto/rpc/rpc_proxy_request.go → mtproto/rpc/proxy_request.go Datei anzeigen

@@ -11,8 +11,8 @@ import (
11 11
 	"github.com/9seconds/mtg/mtproto"
12 12
 )
13 13
 
14
-type RPCProxyRequest struct {
15
-	Flags        RPCProxyRequestFlags
14
+type ProxyRequest struct {
15
+	Flags        proxyRequestFlags
16 16
 	ConnectionID []byte
17 17
 	OurIPPort    []byte
18 18
 	ClientIPPort []byte
@@ -20,25 +20,25 @@ type RPCProxyRequest struct {
20 20
 	Options      *mtproto.ConnectionOpts
21 21
 }
22 22
 
23
-func (r *RPCProxyRequest) Bytes(message []byte) []byte {
23
+func (r *ProxyRequest) Bytes(message []byte) []byte {
24 24
 	buf := &bytes.Buffer{}
25 25
 
26 26
 	flags := r.Flags
27 27
 	if r.Options.QuickAck {
28
-		flags |= RPCProxyRequestFlagsQuickAck
28
+		flags |= proxyRequestFlagsQuickAck
29 29
 	}
30 30
 
31
-	if bytes.HasPrefix(message, rpcProxyRequestFlagsEncryptedPrefix[:]) {
32
-		flags |= RPCProxyRequestFlagsEncrypted
31
+	if bytes.HasPrefix(message, proxyRequestFlagsEncryptedPrefix[:]) {
32
+		flags |= proxyRequestFlagsEncrypted
33 33
 	}
34 34
 
35
-	buf.Write(RPCTagProxyRequest)
35
+	buf.Write(TagProxyRequest)
36 36
 	buf.Write(flags.Bytes())
37 37
 	buf.Write(r.ConnectionID[:])
38 38
 	buf.Write(r.ClientIPPort[:])
39 39
 	buf.Write(r.OurIPPort[:])
40
-	buf.Write(RPCProxyRequestExtraSize)
41
-	buf.Write(RPCProxyRequestProxyTag)
40
+	buf.Write(ProxyRequestExtraSize)
41
+	buf.Write(ProxyRequestProxyTag)
42 42
 	buf.WriteByte(byte(len(r.ADTag)))
43 43
 	buf.Write(r.ADTag)
44 44
 	buf.Write(bytes.Repeat([]byte{0x00}, buf.Len()%4))
@@ -47,17 +47,17 @@ func (r *RPCProxyRequest) Bytes(message []byte) []byte {
47 47
 	return buf.Bytes()
48 48
 }
49 49
 
50
-func NewRPCProxyRequest(clientAddr, ownAddr *net.TCPAddr, opts *mtproto.ConnectionOpts, adTag []byte) (*RPCProxyRequest, error) {
51
-	flags := RPCProxyRequestFlagsHasAdTag | RPCProxyRequestFlagsMagic | RPCProxyRequestFlagsExtMode2
50
+func NewProxyRequest(clientAddr, ownAddr *net.TCPAddr, opts *mtproto.ConnectionOpts, adTag []byte) (*ProxyRequest, error) {
51
+	flags := proxyRequestFlagsHasAdTag | proxyRequestFlagsMagic | proxyRequestFlagsExtMode2
52 52
 
53 53
 	switch opts.ConnectionType {
54 54
 	case mtproto.ConnectionTypeAbridged:
55
-		flags |= RPCProxyRequestFlagsAbdridged
55
+		flags |= proxyRequestFlagsAbdridged
56 56
 	case mtproto.ConnectionTypeIntermediate:
57
-		flags |= RPCProxyRequestFlagsIntermediate
57
+		flags |= proxyRequestFlagsIntermediate
58 58
 	}
59 59
 
60
-	request := RPCProxyRequest{
60
+	request := &ProxyRequest{
61 61
 		Flags:        flags,
62 62
 		ADTag:        adTag,
63 63
 		Options:      opts,
@@ -79,5 +79,5 @@ func NewRPCProxyRequest(clientAddr, ownAddr *net.TCPAddr, opts *mtproto.Connecti
79 79
 	binary.LittleEndian.PutUint32(port[:], uint32(ownAddr.Port))
80 80
 	copy(request.OurIPPort[16:], port[:])
81 81
 
82
-	return &request, nil
82
+	return request, nil
83 83
 }

+ 16
- 16
mtproto/rpc/rpc.go Datei anzeigen

@@ -1,30 +1,30 @@
1 1
 package rpc
2 2
 
3 3
 const (
4
-	RPCNonceSeqNo     = -2
5
-	RPCHandshakeSeqNo = -1
4
+	SeqNoNonce     = -2
5
+	SeqNoHandshake = -1
6 6
 )
7 7
 
8 8
 var (
9
-	RPCTagCloseExt     = []byte{0xa2, 0x34, 0xb6, 0x5e}
10
-	RPCTagProxyAns     = []byte{0x0d, 0xda, 0x03, 0x44}
11
-	RPCTagSimpleAck    = []byte{0x9b, 0x40, 0xac, 0x3b}
12
-	RPCTagHandshake    = []byte{0xf5, 0xee, 0x82, 0x76}
13
-	RPCTagNonce        = []byte{0xaa, 0x87, 0xcb, 0x7a}
14
-	RPCTagProxyRequest = []byte{0xee, 0xf1, 0xce, 0x36}
9
+	TagCloseExt     = []byte{0xa2, 0x34, 0xb6, 0x5e}
10
+	TagProxyAns     = []byte{0x0d, 0xda, 0x03, 0x44}
11
+	TagSimpleAck    = []byte{0x9b, 0x40, 0xac, 0x3b}
12
+	TagHandshake    = []byte{0xf5, 0xee, 0x82, 0x76}
13
+	TagNonce        = []byte{0xaa, 0x87, 0xcb, 0x7a}
14
+	TagProxyRequest = []byte{0xee, 0xf1, 0xce, 0x36}
15 15
 
16
-	RPCNonceCryptoAES = []byte{0x01, 0x00, 0x00, 0x00}
16
+	NonceCryptoAES = []byte{0x01, 0x00, 0x00, 0x00}
17 17
 
18
-	RPCHandshakeFlags = []byte{0x00, 0x00, 0x00, 0x00}
18
+	HandshakeFlags = []byte{0x00, 0x00, 0x00, 0x00}
19 19
 
20
-	RPCProxyRequestExtraSize = []byte{0x18, 0x00, 0x00, 0x00}
21
-	RPCProxyRequestProxyTag  = []byte{0xae, 0x26, 0x1e, 0xdb}
20
+	ProxyRequestExtraSize = []byte{0x18, 0x00, 0x00, 0x00}
21
+	ProxyRequestProxyTag  = []byte{0xae, 0x26, 0x1e, 0xdb}
22 22
 
23
-	RPCHandshakeSenderPID = []byte{}
24
-	RPCHandshakePeerPID   = []byte{}
23
+	HandshakeSenderPID []byte
24
+	HandshakePeerPID   []byte
25 25
 )
26 26
 
27 27
 func init() {
28
-	RPCHandshakeSenderPID = []byte("IPIPPRPDTIME")
29
-	RPCHandshakePeerPID = []byte("IPIPPRPDTIME")
28
+	HandshakeSenderPID = []byte("IPIPPRPDTIME")
29
+	HandshakePeerPID = []byte("IPIPPRPDTIME")
30 30
 }

+ 0
- 21
mtproto/rpc/rpc_handshake_request.go Datei anzeigen

@@ -1,21 +0,0 @@
1
-package rpc
2
-
3
-import "bytes"
4
-
5
-type RPCHandshakeRequest struct {
6
-}
7
-
8
-func (r *RPCHandshakeRequest) Bytes() []byte {
9
-	buf := &bytes.Buffer{}
10
-
11
-	buf.Write(RPCTagHandshake)
12
-	buf.Write(RPCHandshakeFlags)
13
-	buf.Write(RPCHandshakeSenderPID)
14
-	buf.Write(RPCHandshakePeerPID)
15
-
16
-	return buf.Bytes()
17
-}
18
-
19
-func NewRPCHandshakeRequest() *RPCHandshakeRequest {
20
-	return &RPCHandshakeRequest{}
21
-}

+ 0
- 24
mtproto/rpc/rpc_proxy_flags.go Datei anzeigen

@@ -1,24 +0,0 @@
1
-package rpc
2
-
3
-import "encoding/binary"
4
-
5
-type RPCProxyRequestFlags uint32
6
-
7
-const (
8
-	RPCProxyRequestFlagsHasAdTag     RPCProxyRequestFlags = 0x8
9
-	RPCProxyRequestFlagsEncrypted                         = 0x2
10
-	RPCProxyRequestFlagsMagic                             = 0x1000
11
-	RPCProxyRequestFlagsExtMode2                          = 0x20000
12
-	RPCProxyRequestFlagsIntermediate                      = 0x20000000
13
-	RPCProxyRequestFlagsAbdridged                         = 0x40000000
14
-	RPCProxyRequestFlagsQuickAck                          = 0x80000000
15
-)
16
-
17
-var rpcProxyRequestFlagsEncryptedPrefix [8]byte
18
-
19
-func (r RPCProxyRequestFlags) Bytes() []byte {
20
-	converted := make([]byte, 4)
21
-	binary.LittleEndian.PutUint32(converted, uint32(r))
22
-
23
-	return converted
24
-}

+ 2
- 3
mtproto/wrappers/crypt.go Datei anzeigen

@@ -22,7 +22,7 @@ const (
22 22
 
23 23
 var emptyIP = [4]byte{0x00, 0x00, 0x00, 0x00}
24 24
 
25
-func NewMiddleProxyCipherRWC(conn wrappers.ReadWriteCloserWithAddr, req *rpc.RPCNonceRequest, resp *rpc.RPCNonceResponse, secret []byte) wrappers.ReadWriteCloserWithAddr {
25
+func NewMiddleProxyCipherRWC(conn wrappers.ReadWriteCloserWithAddr, req *rpc.NonceRequest, resp *rpc.NonceResponse, secret []byte) wrappers.ReadWriteCloserWithAddr {
26 26
 	localAddr := conn.LocalAddr()
27 27
 	remoteAddr := conn.RemoteAddr()
28 28
 
@@ -35,8 +35,7 @@ func NewMiddleProxyCipherRWC(conn wrappers.ReadWriteCloserWithAddr, req *rpc.RPC
35 35
 	return wrappers.NewBlockCipherRWC(conn, enc, dec)
36 36
 }
37 37
 
38
-func makeKeys(purpose CipherPurpose, req *rpc.RPCNonceRequest, resp *rpc.RPCNonceResponse,
39
-	client *net.TCPAddr, remote *net.TCPAddr, secret []byte) ([]byte, []byte) {
38
+func makeKeys(purpose CipherPurpose, req *rpc.NonceRequest, resp *rpc.NonceResponse, client *net.TCPAddr, remote *net.TCPAddr, secret []byte) ([]byte, []byte) {
40 39
 	message := bytes.Buffer{}
41 40
 	message.Write(resp.Nonce[:])
42 41
 	message.Write(req.Nonce[:])

+ 2
- 2
mtproto/wrappers/crypt_test.go Datei anzeigen

@@ -21,13 +21,13 @@ var proxySecret = []byte{196, 249, 250, 202, 150, 120, 230, 187, 72, 173,
21 21
 	183, 6, 27, 38, 93, 178, 18}
22 22
 
23 23
 func TestMakeKeys(t *testing.T) {
24
-	req, err := rpc.NewRPCNonceRequest(proxySecret)
24
+	req, err := rpc.NewNonceRequest(proxySecret)
25 25
 	assert.Nil(t, err)
26 26
 
27 27
 	copy(req.Nonce[:], []byte{24, 49, 53, 111, 198, 10, 235, 180, 230, 112, 92, 78, 1, 201, 106, 105})
28 28
 	binary.LittleEndian.PutUint32(req.CryptoTS[:], 1528396015)
29 29
 
30
-	resp := &rpc.RPCNonceResponse{}
30
+	resp := &rpc.NonceResponse{}
31 31
 	copy(resp.Nonce[:], []byte{247, 40, 210, 56, 65, 12, 101, 170, 216, 155, 14, 253, 250, 238, 219, 226})
32 32
 
33 33
 	cltAddr := &net.TCPAddr{

+ 5
- 5
mtproto/wrappers/proxy_request.go Datei anzeigen

@@ -17,7 +17,7 @@ type ProxyRequestReadWriteCloserWithAddr struct {
17 17
 	wrappers.BufferedReader
18 18
 
19 19
 	conn wrappers.ReadWriteCloserWithAddr
20
-	req  *rpc.RPCProxyRequest
20
+	req  *rpc.ProxyRequest
21 21
 }
22 22
 
23 23
 func (p *ProxyRequestReadWriteCloserWithAddr) Read(buf []byte) (int, error) {
@@ -29,11 +29,11 @@ func (p *ProxyRequestReadWriteCloserWithAddr) Read(buf []byte) (int, error) {
29 29
 			return errors.Annotate(err, "Cannot read RPC tag")
30 30
 		}
31 31
 
32
-		if bytes.Equal(ansBuf.Bytes(), rpc.RPCTagCloseExt) {
32
+		if bytes.Equal(ansBuf.Bytes(), rpc.TagCloseExt) {
33 33
 			return p.readCloseExt()
34
-		} else if bytes.Equal(ansBuf.Bytes(), rpc.RPCTagProxyAns) {
34
+		} else if bytes.Equal(ansBuf.Bytes(), rpc.TagProxyAns) {
35 35
 			return p.readProxyAns(buf)
36
-		} else if bytes.Equal(ansBuf.Bytes(), rpc.RPCTagSimpleAck) {
36
+		} else if bytes.Equal(ansBuf.Bytes(), rpc.TagSimpleAck) {
37 37
 			return p.readSimpleAck()
38 38
 		}
39 39
 
@@ -99,7 +99,7 @@ func (p *ProxyRequestReadWriteCloserWithAddr) RemoteAddr() *net.TCPAddr {
99 99
 }
100 100
 
101 101
 func NewProxyRequestRWC(conn wrappers.ReadWriteCloserWithAddr, connOpts *mtproto.ConnectionOpts, adTag []byte) (wrappers.ReadWriteCloserWithAddr, error) {
102
-	req, err := rpc.NewRPCProxyRequest(connOpts.ClientAddr, conn.LocalAddr(), connOpts, adTag)
102
+	req, err := rpc.NewProxyRequest(connOpts.ClientAddr, conn.LocalAddr(), connOpts, adTag)
103 103
 	if err != nil {
104 104
 		return nil, errors.Annotate(err, "Cannot create new RPC proxy request")
105 105
 	}

+ 12
- 10
telegram/middle.go Datei anzeigen

@@ -50,7 +50,7 @@ func NewMiddleTelegram(conf *config.Config, logger *zap.SugaredLogger) Telegram
50 50
 }
51 51
 
52 52
 func (t *middleTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.ReadWriteCloserWithAddr) (wrappers.ReadWriteCloserWithAddr, error) {
53
-	rpcNonceConn := mtwrappers.NewFrameRWC(conn, rpc.RPCNonceSeqNo)
53
+	rpcNonceConn := mtwrappers.NewFrameRWC(conn, rpc.SeqNoNonce)
54 54
 
55 55
 	rpcNonceReq, err := t.sendRPCNonceRequest(rpcNonceConn)
56 56
 	if err != nil {
@@ -62,7 +62,7 @@ func (t *middleTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.Re
62 62
 	}
63 63
 
64 64
 	secureConn := mtwrappers.NewMiddleProxyCipherRWC(conn, rpcNonceReq, rpcNonceResp, t.proxySecret)
65
-	secureConn = mtwrappers.NewFrameRWC(secureConn, rpc.RPCHandshakeSeqNo)
65
+	secureConn = mtwrappers.NewFrameRWC(secureConn, rpc.SeqNoHandshake)
66 66
 
67 67
 	rpcHandshakeReq, err := t.sendRPCHandshakeRequest(secureConn)
68 68
 	if err != nil {
@@ -76,8 +76,8 @@ func (t *middleTelegram) Init(connOpts *mtproto.ConnectionOpts, conn wrappers.Re
76 76
 	return mtwrappers.NewProxyRequestRWC(secureConn, connOpts, t.conf.AdTag)
77 77
 }
78 78
 
79
-func (t *middleTelegram) sendRPCNonceRequest(conn io.Writer) (*rpc.RPCNonceRequest, error) {
80
-	rpcNonceReq, err := rpc.NewRPCNonceRequest(t.proxySecret)
79
+func (t *middleTelegram) sendRPCNonceRequest(conn io.Writer) (*rpc.NonceRequest, error) {
80
+	rpcNonceReq, err := rpc.NewNonceRequest(t.proxySecret)
81 81
 	if err != nil {
82 82
 		return nil, errors.Annotate(err, "Cannot create RPC nonce request")
83 83
 	}
@@ -88,14 +88,15 @@ func (t *middleTelegram) sendRPCNonceRequest(conn io.Writer) (*rpc.RPCNonceReque
88 88
 	return rpcNonceReq, nil
89 89
 }
90 90
 
91
-func (t *middleTelegram) receiveRPCNonceResponse(conn io.Reader, req *rpc.RPCNonceRequest) (*rpc.RPCNonceResponse, error) {
91
+func (t *middleTelegram) receiveRPCNonceResponse(conn io.Reader, req *rpc.NonceRequest) (*rpc.NonceResponse, error) {
92 92
 	var ans [128]byte
93 93
 
94 94
 	n, err := conn.Read(ans[:])
95 95
 	if err != nil {
96 96
 		return nil, errors.Annotate(err, "Cannot read RPC nonce response")
97 97
 	}
98
-	rpcNonceResp, err := rpc.NewRPCNonceResponse(ans[:n])
98
+
99
+	rpcNonceResp, err := rpc.NewNonceResponse(ans[:n])
99 100
 	if err != nil {
100 101
 		return nil, errors.Annotate(err, "Cannot initialize RPC nonce response")
101 102
 	}
@@ -106,8 +107,8 @@ func (t *middleTelegram) receiveRPCNonceResponse(conn io.Reader, req *rpc.RPCNon
106 107
 	return rpcNonceResp, nil
107 108
 }
108 109
 
109
-func (t *middleTelegram) sendRPCHandshakeRequest(conn io.Writer) (*rpc.RPCHandshakeRequest, error) {
110
-	req := rpc.NewRPCHandshakeRequest()
110
+func (t *middleTelegram) sendRPCHandshakeRequest(conn io.Writer) (*rpc.HandshakeRequest, error) {
111
+	req := rpc.NewHandshakeRequest()
111 112
 	if _, err := conn.Write(req.Bytes()); err != nil {
112 113
 		return nil, errors.Annotate(err, "Cannot send RPC handshake request")
113 114
 	}
@@ -115,14 +116,15 @@ func (t *middleTelegram) sendRPCHandshakeRequest(conn io.Writer) (*rpc.RPCHandsh
115 116
 	return req, nil
116 117
 }
117 118
 
118
-func (t *middleTelegram) receiveRPCHandshakeResponse(conn io.Reader, req *rpc.RPCHandshakeRequest) (*rpc.RPCHandshakeResponse, error) {
119
+func (t *middleTelegram) receiveRPCHandshakeResponse(conn io.Reader, req *rpc.HandshakeRequest) (*rpc.HandshakeResponse, error) {
119 120
 	var ans [128]byte
120 121
 
121 122
 	n, err := conn.Read(ans[:])
122 123
 	if err != nil {
123 124
 		return nil, errors.Annotate(err, "Cannot read RPC handshake response")
124 125
 	}
125
-	rpcHandshakeResp, err := rpc.NewRPCHandshakeResponse(ans[:n])
126
+
127
+	rpcHandshakeResp, err := rpc.NewHandshakeResponse(ans[:n])
126 128
 	if err != nil {
127 129
 		return nil, errors.Annotate(err, "Cannot initialize RPC handshake response")
128 130
 	}

Laden…
Abbrechen
Speichern