|
|
@@ -44,7 +44,7 @@ func (m *MTProtoAbridged) Read() ([]byte, error) {
|
|
44
|
44
|
if _, err := io.CopyN(buf, m.conn, 1); err != nil {
|
|
45
|
45
|
return nil, errors.Annotate(err, "Cannot read message length")
|
|
46
|
46
|
}
|
|
47
|
|
- msgLength := uint8(buf.Bytes()[0])
|
|
|
47
|
+ msgLength := uint32(buf.Bytes()[0])
|
|
48
|
48
|
buf.Reset()
|
|
49
|
49
|
|
|
50
|
50
|
m.logger.Debugw("Packet first byte",
|
|
|
@@ -59,27 +59,26 @@ func (m *MTProtoAbridged) Read() ([]byte, error) {
|
|
59
|
59
|
msgLength -= mtprotoAbridgedQuickAckLength
|
|
60
|
60
|
}
|
|
61
|
61
|
|
|
62
|
|
- msgLength32 := uint32(msgLength)
|
|
63
|
62
|
if msgLength == mtprotoAbridgedSmallPacketLength {
|
|
64
|
63
|
if _, err := io.CopyN(buf, m.conn, 3); err != nil {
|
|
65
|
64
|
return nil, errors.Annotate(err, "Cannot read the correct message length")
|
|
66
|
65
|
}
|
|
67
|
66
|
number := utils.Uint24{}
|
|
68
|
67
|
copy(number[:], buf.Bytes())
|
|
69
|
|
- msgLength32 = utils.FromUint24(number)
|
|
|
68
|
+ msgLength = utils.FromUint24(number)
|
|
70
|
69
|
}
|
|
71
|
|
- msgLength32 *= 4
|
|
|
70
|
+ msgLength *= 4
|
|
72
|
71
|
|
|
73
|
72
|
m.logger.Debugw("Packet length",
|
|
74
|
|
- "length", msgLength32,
|
|
|
73
|
+ "length", msgLength,
|
|
75
|
74
|
"simple_ack", m.opts.ReadHacks.SimpleAck,
|
|
76
|
75
|
"quick_ack", m.opts.ReadHacks.QuickAck,
|
|
77
|
76
|
"counter", m.readCounter,
|
|
78
|
77
|
)
|
|
79
|
78
|
|
|
80
|
79
|
buf.Reset()
|
|
81
|
|
- buf.Grow(int(msgLength32))
|
|
82
|
|
- if _, err := io.CopyN(buf, m.conn, int64(msgLength32)); err != nil {
|
|
|
80
|
+ buf.Grow(int(msgLength))
|
|
|
81
|
+ if _, err := io.CopyN(buf, m.conn, int64(msgLength)); err != nil {
|
|
83
|
82
|
return nil, errors.Annotate(err, "Cannot read message")
|
|
84
|
83
|
}
|
|
85
|
84
|
|