Lonami Exo
fe30f63d5d
Use autogen code on the authenticator instead hardcoding requests
2017-09-28 11:36:51 +02:00
Lonami Exo
c667a00281
Avoid using BinaryWriter where possible
2017-09-27 21:23:59 +02:00
Lonami Exo
833aeb86eb
Fix auth_key is unsigned
2017-09-27 21:04:52 +02:00
Lonami Exo
bd3dd371a2
Create a proper Message class (msg_id, seqno, body; only .to_bytes())
2017-09-27 21:01:20 +02:00
Lonami Exo
6df9fc558e
Create and use a new GzipPacked class, also when sending
2017-09-27 13:46:53 +02:00
Lonami Exo
efca981312
Fix adding a request twice (or container) to ._pending_receive
2017-09-27 13:26:35 +02:00
Lonami Exo
b83cd98ba0
Replace TLObject.on_send with the new .to_bytes()
...
This also replaces some int.to_bytes() calls with a faster
struct.pack (up to x4 faster). This approach is also around
x3 faster than creating a BinaryWriter just to serialize a
TLObject as bytes.
2017-09-26 14:36:02 +02:00
Lonami Exo
f233110732
Allow sending several requests at once through new MessageContainer
2017-09-25 20:52:27 +02:00
Lonami Exo
4a8e5c865a
Detect BrokenAuthKeyError on MtProtoSender._decode_msg
2017-09-22 13:32:00 +02:00
Lonami Exo
ffadcd029f
Save the session much less often (doable because 151e162
)
2017-09-21 19:12:46 +02:00
Lonami Exo
7f83a6109f
Fix authenticator was disconnecting when it shouldn't
2017-09-21 13:54:44 +02:00
Lonami Exo
2b2da843a1
Create a Connection only once and avoid no-op if was "connected"
2017-09-21 13:44:22 +02:00
Lonami Exo
4777b8dad4
Handle .connect() method more gracefully
2017-09-21 13:44:22 +02:00
Lonami Exo
2a3e5e5ed2
Handle BufferError's more gracefully
2017-09-17 19:39:41 +02:00
Lonami Exo
78155a21bd
Retry authentication for auth keys up to five times by default
2017-09-17 19:15:43 +02:00
Lonami Exo
e7a936222f
Catch -404 BrokenAuthKeyError on .connect()'s .do_authentication
2017-09-17 18:38:03 +02:00
Lonami Exo
12a39873f1
Workaround msg_seqno too low/high ( closes #95 )
2017-09-14 11:50:38 +02:00
Lonami Exo
a2fdd4b196
Ignore InvalidChecksumError's
2017-09-11 11:04:19 +02:00
Lonami Exo
25bbb20b0c
Use RLocks properly on MtProtoSender (only needed on net IO)
2017-09-07 21:32:46 +02:00
Lonami Exo
d4f36162cd
Create and use UpdateState to .process() unhandled TLObjects
2017-09-07 18:49:08 +02:00
Lonami Exo
15fd5390ae
Optimize imports
2017-09-04 17:18:33 +02:00
Lonami Exo
97cab7347b
Make lint happier
2017-09-04 17:10:04 +02:00
Lonami Exo
6f0bd14c2f
Use an Enum for the ConnectionMode and support specifying it
2017-09-04 11:24:10 +02:00
Lonami Exo
f8f389c850
Fix ack requests removing pending requests when they shouldn't
2017-09-03 11:21:42 +02:00
Lonami Exo
db6fd4bdc2
Fix RPC errors being ignored due to modifying the wrong attribute
2017-09-03 11:19:28 +02:00
Lonami Exo
83f3f66113
Fix MtProtoSender never clearing self._pending_receive requests
2017-09-03 10:50:55 +02:00
Lonami Exo
4de4026bb3
Move the "constant read" thread to the main TelegramClient
2017-09-03 09:56:10 +02:00
Lonami Exo
9bc1f64efe
Move update handling to the MtProtoSender, being functional again
2017-09-02 21:46:44 +02:00
Lonami Exo
21eaf8bd72
Allow setting whether the MtProtoSender should use constant_read
2017-09-02 21:27:11 +02:00
Lonami Exo
863d2e8368
Make confirm_received a flag, avoid race conditions, fix bg RPCError
...
There was a race condition between TelegramBareClient.invoke
receiving part and MtProtoSender._handle_rpc_result actually
reading the result after setting request.confirmed = True.
The .confirmed is now a threading.Event to avoid the sleep(0.1).
RPC errors have been moved inside the request so they're not
raised on a background thread anymore.
2017-09-02 20:41:00 +02:00
Lonami Exo
b908296efa
Remove unused TcpClien.read(timeout=...) param, change other accessors
2017-09-02 19:33:42 +02:00
Lonami Exo
36f51e1e3f
Remove ability to TcpClient.cancel_read()
...
This simplifies the process of sending and receiving data,
and makes use of Python's socket.settimeout instead a hand-crafted
version with a sort-of arbitrary self.delay = 0.1 (seconds), which
should improve the speed of the method
2017-09-02 19:14:11 +02:00
Lonami Exo
43b79c3d36
Add a thread to constantly read messages from the network
2017-09-02 18:27:22 +02:00
Lonami Exo
b4811261e9
Set a known buffer size if possible on BinaryWriter()s
2017-08-29 20:44:51 +02:00
Lonami Exo
cff7655a10
Add support for TCP intermediate mode ( #112 )
2017-08-29 11:39:44 +02:00
Lonami Exo
a3c2c462a7
Add support for tcp_obfuscated on the Connection class ( #112 )
2017-08-28 21:44:02 +02:00
Lonami Exo
fa22a3f848
Create a centralized Connection class, replaces TcpTransport ( #112 )
2017-08-28 21:23:31 +02:00
Lonami Exo
5404670469
Implement and use TCP obfuscated as a PoC ( #112 )
...
Credits to MadelineProto/Connection.php by @danog
2017-08-28 20:25:44 +02:00
Lonami Exo
00b5b5021b
Report errors to pwrtelegram.xyz by default
2017-08-25 15:34:20 +02:00
Lonami Exo
66876b6722
Use pycrypto's RSA instead the old weird RSA implementation
2017-08-23 21:49:27 +02:00
Lonami Exo
7844cd358e
Attempt at making layer migrations more smooth ( #158 )
2017-07-26 16:10:45 +02:00
Lonami Exo
160a3699ac
Fix confusing names "MtProtoRequest" and ".confirmed" ( #176 )
...
This also fixes the annoyingly confusing message:
"Odd msg_seqno expected (relevant message), but even received."
2017-07-24 16:54:48 +02:00
Lonami Exo
1f7ac71187
Debug level should always be used for logging since it's a library
2017-07-10 15:21:20 +02:00
Lonami Exo
83c8e98448
Ensure that message ids are signed once again
2017-06-27 18:45:52 +02:00
Lonami Exo
b0173c3ec2
Use more accurate values for msg_ids
2017-06-26 11:01:20 +02:00
Lonami Exo
843c16215c
Add timeout parameter on TcpClient.connect() too
2017-06-22 19:21:33 +02:00
Lonami Exo
e4fbd87c75
Turn timeout into a property instead leaving it as a parameter
2017-06-22 11:43:42 +02:00
Lonami Exo
a9a5c7e254
Use signed longs for every request_id ( #138 follow-up)
2017-06-21 10:21:09 +02:00
Lonami Exo
d58222d007
Use crc32 from zlib instead from binascii
...
It seems to be a bit faster stackoverflow.com/q/44502855
2017-06-20 11:03:46 +02:00
Lonami Exo
697434be37
Don't do anything on .connect() if it's already connected
2017-06-20 09:46:37 +02:00