mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 16:01:55 +03:00
Move mtproto consts to rpc
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package mtproto
|
package rpc
|
||||||
|
|
||||||
// SeqNo* is the number of the sequence which have special meaning for
|
// SeqNo* is the number of the sequence which have special meaning for
|
||||||
// the Telegram.
|
// the Telegram.
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import "github.com/9seconds/mtg/mtproto"
|
var HandshakeRequest = append(TagHandshake,
|
||||||
|
append(HandshakeFlags,
|
||||||
var HandshakeRequest = append(mtproto.TagHandshake,
|
append(HandshakeSenderPID, HandshakePeerPID...)...)...)
|
||||||
append(mtproto.HandshakeFlags,
|
|
||||||
append(mtproto.HandshakeSenderPID, mtproto.HandshakePeerPID...)...)...)
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/mtproto"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type HandshakeResponse struct {
|
type HandshakeResponse struct {
|
||||||
@@ -29,10 +27,10 @@ func (r *HandshakeResponse) Bytes() []byte {
|
|||||||
|
|
||||||
// Valid checks that handshake response compliments request.
|
// Valid checks that handshake response compliments request.
|
||||||
func (r *HandshakeResponse) Valid() error {
|
func (r *HandshakeResponse) Valid() error {
|
||||||
if !bytes.Equal(r.Type, mtproto.TagHandshake) {
|
if !bytes.Equal(r.Type, TagHandshake) {
|
||||||
return errors.New("Unexpected handshake tag")
|
return errors.New("Unexpected handshake tag")
|
||||||
}
|
}
|
||||||
if !bytes.Equal(r.PeerPID, mtproto.HandshakeSenderPID) {
|
if !bytes.Equal(r.PeerPID, HandshakeSenderPID) {
|
||||||
return errors.New("Incorrect sender PID")
|
return errors.New("Incorrect sender PID")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/mtproto"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type NonceRequest struct {
|
type NonceRequest struct {
|
||||||
@@ -20,11 +18,11 @@ type NonceRequest struct {
|
|||||||
func (r *NonceRequest) Bytes() []byte {
|
func (r *NonceRequest) Bytes() []byte {
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
|
|
||||||
buf.Write(mtproto.TagNonce) // nolint: gosec
|
buf.Write(TagNonce)
|
||||||
buf.Write(r.KeySelector) // nolint: gosec
|
buf.Write(r.KeySelector)
|
||||||
buf.Write(mtproto.NonceCryptoAES) // nolint: gosec
|
buf.Write(NonceCryptoAES)
|
||||||
buf.Write(r.CryptoTS) // nolint: gosec
|
buf.Write(r.CryptoTS)
|
||||||
buf.Write(r.Nonce) // nolint: gosec
|
buf.Write(r.Nonce)
|
||||||
|
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/9seconds/mtg/mtproto"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type NonceResponse struct {
|
type NonceResponse struct {
|
||||||
@@ -29,10 +27,10 @@ func (r *NonceResponse) Bytes() []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *NonceResponse) Valid(req *NonceRequest) error {
|
func (r *NonceResponse) Valid(req *NonceRequest) error {
|
||||||
if !bytes.Equal(r.Type, mtproto.TagNonce) {
|
if !bytes.Equal(r.Type, TagNonce) {
|
||||||
return errors.New("Unexpected RPC type")
|
return errors.New("Unexpected RPC type")
|
||||||
}
|
}
|
||||||
if !bytes.Equal(r.Crypto, mtproto.NonceCryptoAES) {
|
if !bytes.Equal(r.Crypto, NonceCryptoAES) {
|
||||||
return errors.New("Unexpected crypto type")
|
return errors.New("Unexpected crypto type")
|
||||||
}
|
}
|
||||||
if !bytes.Equal(r.KeySelector, req.KeySelector) {
|
if !bytes.Equal(r.KeySelector, req.KeySelector) {
|
||||||
|
|||||||
Reference in New Issue
Block a user