Skip to content

Commit

Permalink
Merge pull request #74 from aiexz/2.0
Browse files Browse the repository at this point in the history
32bit systems support
  • Loading branch information
AmarnathCJD committed Jan 21, 2024
2 parents 00e0b33 + 666c9a7 commit faabee3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

type ErrResponseCode struct {
Code int
Code int64
Message string
Description string
AdditionalInfo any // some errors has additional data like timeout seconds, dc id etc.
Expand All @@ -32,7 +32,7 @@ func RpcErrorToNative(r *objects.RpcError) error {
}

return &ErrResponseCode{
Code: int(r.ErrorCode),
Code: int64(r.ErrorCode),
Message: nativeErrorName,
Description: desc,
AdditionalInfo: additionalData,
Expand Down
8 changes: 4 additions & 4 deletions internal/encoding/tl/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const (
MagicNumber = 0xfe // 253

// https://core.telegram.org/schema/mtproto
CrcVector = 0x1cb5c415
CrcFalse = 0xbc799737
CrcTrue = 0x997275b5
CrcNull = 0x56730bcc
CrcVector uint32 = 0x1cb5c415
CrcFalse uint32 = 0xbc799737
CrcTrue uint32 = 0x997275b5
CrcNull uint32 = 0x56730bcc

bitsInByte = 8 // cause we don't want store magic numbers
)
6 changes: 3 additions & 3 deletions internal/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (t *transport) ReadMsg() (messages.Common, error) {
}

if len(data) == tl.WordLen {
code := int(binary.LittleEndian.Uint32(data))
code := int64(binary.LittleEndian.Uint32(data))
return nil, ErrCode(code)
}

Expand Down Expand Up @@ -121,8 +121,8 @@ func isPacketEncrypted(data []byte) bool {
return binary.LittleEndian.Uint64(authKeyHash) != 0
}

type ErrCode int
type ErrCode int64

func (e ErrCode) Error() string {
return fmt.Sprintf("code %v", int(e))
return fmt.Sprintf("code %v", int64(e))
}
4 changes: 2 additions & 2 deletions mtproto.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func (m *MTProto) startReadingResponses(ctx context.Context) {

default:
if e, ok := err.(transport.ErrCode); ok {
if int(e) == 4294966892 {
if int64(e) == 4294966892 {
err = m.makeAuthKey()
if err != nil {
m.Logger.Error(errors.Wrap(err, "making auth key"))
Expand Down Expand Up @@ -453,7 +453,7 @@ func (m *MTProto) readMsg() error {
response, err := m.transport.ReadMsg()
if err != nil {
if e, ok := err.(transport.ErrCode); ok {
return &ErrResponseCode{Code: int(e)}
return &ErrResponseCode{Code: int64(e)}
}
switch err {
case io.EOF, context.Canceled:
Expand Down

0 comments on commit faabee3

Please sign in to comment.