Explorar el Código

Move mtproto consts to rpc

tags/1.0^2
9seconds hace 6 años
padre
commit
9534cb19d0

mtproto/consts.go → mtproto/rpc/consts.go Ver fichero

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

+ 3
- 5
mtproto/rpc/handshake_request.go Ver fichero

@@ -1,7 +1,5 @@
1 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 Ver fichero

@@ -4,8 +4,6 @@ import (
4 4
 	"bytes"
5 5
 	"errors"
6 6
 	"fmt"
7
-
8
-	"github.com/9seconds/mtg/mtproto"
9 7
 )
10 8
 
11 9
 type HandshakeResponse struct {
@@ -29,10 +27,10 @@ func (r *HandshakeResponse) Bytes() []byte {
29 27
 
30 28
 // Valid checks that handshake response compliments request.
31 29
 func (r *HandshakeResponse) Valid() error {
32
-	if !bytes.Equal(r.Type, mtproto.TagHandshake) {
30
+	if !bytes.Equal(r.Type, TagHandshake) {
33 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 34
 		return errors.New("Incorrect sender PID")
37 35
 	}
38 36
 

+ 5
- 7
mtproto/rpc/nonce_request.go Ver fichero

@@ -6,8 +6,6 @@ import (
6 6
 	"encoding/binary"
7 7
 	"fmt"
8 8
 	"time"
9
-
10
-	"github.com/9seconds/mtg/mtproto"
11 9
 )
12 10
 
13 11
 type NonceRequest struct {
@@ -20,11 +18,11 @@ type NonceRequest struct {
20 18
 func (r *NonceRequest) Bytes() []byte {
21 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 27
 	return buf.Bytes()
30 28
 }

+ 2
- 4
mtproto/rpc/nonce_response.go Ver fichero

@@ -4,8 +4,6 @@ import (
4 4
 	"bytes"
5 5
 	"errors"
6 6
 	"fmt"
7
-
8
-	"github.com/9seconds/mtg/mtproto"
9 7
 )
10 8
 
11 9
 type NonceResponse struct {
@@ -29,10 +27,10 @@ func (r *NonceResponse) Bytes() []byte {
29 27
 }
30 28
 
31 29
 func (r *NonceResponse) Valid(req *NonceRequest) error {
32
-	if !bytes.Equal(r.Type, mtproto.TagNonce) {
30
+	if !bytes.Equal(r.Type, TagNonce) {
33 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 34
 		return errors.New("Unexpected crypto type")
37 35
 	}
38 36
 	if !bytes.Equal(r.KeySelector, req.KeySelector) {

Loading…
Cancelar
Guardar