Преглед изворни кода

Move mtproto consts to rpc

tags/1.0^2
9seconds пре 6 година
родитељ
комит
9534cb19d0

mtproto/consts.go → mtproto/rpc/consts.go Прегледај датотеку

1
-package mtproto
1
+package rpc
2
 
2
 
3
 // SeqNo* is the number of the sequence which have special meaning for
3
 // SeqNo* is the number of the sequence which have special meaning for
4
 // the Telegram.
4
 // the Telegram.

+ 3
- 5
mtproto/rpc/handshake_request.go Прегледај датотеку

1
 package rpc
1
 package rpc
2
 
2
 
3
-import "github.com/9seconds/mtg/mtproto"
4
-
5
-var HandshakeRequest = append(mtproto.TagHandshake,
6
-	append(mtproto.HandshakeFlags,
7
-		append(mtproto.HandshakeSenderPID, mtproto.HandshakePeerPID...)...)...)
3
+var HandshakeRequest = append(TagHandshake,
4
+	append(HandshakeFlags,
5
+		append(HandshakeSenderPID, HandshakePeerPID...)...)...)

+ 2
- 4
mtproto/rpc/handshake_response.go Прегледај датотеку

4
 	"bytes"
4
 	"bytes"
5
 	"errors"
5
 	"errors"
6
 	"fmt"
6
 	"fmt"
7
-
8
-	"github.com/9seconds/mtg/mtproto"
9
 )
7
 )
10
 
8
 
11
 type HandshakeResponse struct {
9
 type HandshakeResponse struct {
29
 
27
 
30
 // Valid checks that handshake response compliments request.
28
 // Valid checks that handshake response compliments request.
31
 func (r *HandshakeResponse) Valid() error {
29
 func (r *HandshakeResponse) Valid() error {
32
-	if !bytes.Equal(r.Type, mtproto.TagHandshake) {
30
+	if !bytes.Equal(r.Type, TagHandshake) {
33
 		return errors.New("Unexpected handshake tag")
31
 		return errors.New("Unexpected handshake tag")
34
 	}
32
 	}
35
-	if !bytes.Equal(r.PeerPID, mtproto.HandshakeSenderPID) {
33
+	if !bytes.Equal(r.PeerPID, HandshakeSenderPID) {
36
 		return errors.New("Incorrect sender PID")
34
 		return errors.New("Incorrect sender PID")
37
 	}
35
 	}
38
 
36
 

+ 5
- 7
mtproto/rpc/nonce_request.go Прегледај датотеку

6
 	"encoding/binary"
6
 	"encoding/binary"
7
 	"fmt"
7
 	"fmt"
8
 	"time"
8
 	"time"
9
-
10
-	"github.com/9seconds/mtg/mtproto"
11
 )
9
 )
12
 
10
 
13
 type NonceRequest struct {
11
 type NonceRequest struct {
20
 func (r *NonceRequest) Bytes() []byte {
18
 func (r *NonceRequest) Bytes() []byte {
21
 	buf := &bytes.Buffer{}
19
 	buf := &bytes.Buffer{}
22
 
20
 
23
-	buf.Write(mtproto.TagNonce)       // nolint: gosec
24
-	buf.Write(r.KeySelector)          // nolint: gosec
25
-	buf.Write(mtproto.NonceCryptoAES) // nolint: gosec
26
-	buf.Write(r.CryptoTS)             // nolint: gosec
27
-	buf.Write(r.Nonce)                // nolint: gosec
21
+	buf.Write(TagNonce)
22
+	buf.Write(r.KeySelector)
23
+	buf.Write(NonceCryptoAES)
24
+	buf.Write(r.CryptoTS)
25
+	buf.Write(r.Nonce)
28
 
26
 
29
 	return buf.Bytes()
27
 	return buf.Bytes()
30
 }
28
 }

+ 2
- 4
mtproto/rpc/nonce_response.go Прегледај датотеку

4
 	"bytes"
4
 	"bytes"
5
 	"errors"
5
 	"errors"
6
 	"fmt"
6
 	"fmt"
7
-
8
-	"github.com/9seconds/mtg/mtproto"
9
 )
7
 )
10
 
8
 
11
 type NonceResponse struct {
9
 type NonceResponse struct {
29
 }
27
 }
30
 
28
 
31
 func (r *NonceResponse) Valid(req *NonceRequest) error {
29
 func (r *NonceResponse) Valid(req *NonceRequest) error {
32
-	if !bytes.Equal(r.Type, mtproto.TagNonce) {
30
+	if !bytes.Equal(r.Type, TagNonce) {
33
 		return errors.New("Unexpected RPC type")
31
 		return errors.New("Unexpected RPC type")
34
 	}
32
 	}
35
-	if !bytes.Equal(r.Crypto, mtproto.NonceCryptoAES) {
33
+	if !bytes.Equal(r.Crypto, NonceCryptoAES) {
36
 		return errors.New("Unexpected crypto type")
34
 		return errors.New("Unexpected crypto type")
37
 	}
35
 	}
38
 	if !bytes.Equal(r.KeySelector, req.KeySelector) {
36
 	if !bytes.Equal(r.KeySelector, req.KeySelector) {

Loading…
Откажи
Сачувај