Commit Graph

75 Commits

Author SHA1 Message Date
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
Hasan
c13164f5cf Use the correct amount of random bytes in DH request
The official documentation says a 2048 *bit* number.
`os.urandom` takes an argument that represents the number of *bytes*.
2048 bits is 256 bytes
2017-06-18 23:38:14 +02:00
Lonami Exo
8afb0a3f6b Rename Request.msg_id to request_msg_id to avoid name clash (fix #122) 2017-06-18 10:01:59 +02:00
Lonami Exo
2b85463ce6 Don't ignore more possible updates on .receive_updates() (closes #117) 2017-06-16 15:36:47 +02:00
Lonami Exo
3ed59d08e5 Fix commit 65912f9 by properly skipping lost messages 2017-06-11 17:53:53 +02:00
Lonami Exo
65912f926b Allow to send more than one request before receiving them (#105) 2017-06-11 14:58:16 +02:00
Lonami Exo
44ab85962b Completely change errors (make one class for each) 2017-06-10 11:47:51 +02:00
Lonami Exo
7adb4f09d6 Slightly reorganise the project structure 2017-06-09 16:13:39 +02:00
Lonami Exo
ba5bfa105f Use memoryview() on TcpClient.write() instead slicing the data 2017-06-09 11:50:30 +02:00
Lonami Exo
c6645a555d Prefer BufferedWriter over BinaryWriter for socket operations 2017-06-09 11:42:39 +02:00
Lonami Exo
5494cb15eb "Don't go nuts switching back and forth between (non-)blocking"
And other improvements (shutting down the socket, proper naming).
https://docs.python.org/3/howto/sockets.html#non-blocking-sockets
2017-06-09 11:27:52 +02:00
Lonami Exo
efd1c1ba64 Always acknowledge received errors for server not to resend them 2017-06-09 10:46:39 +02:00
Lonami Exo
1860054ec0 Make generate_sequence() thread-safe and move it to Session 2017-06-07 12:00:01 +01:00
Dmitry D. Chernov
5362f2578d Allow using lists and dicts for passing proxy settings 2017-06-05 09:26:10 +02:00
Lonami Exo
7acfd0c6c9 Update to v0.10 and some minor grammar fixes 2017-06-03 13:36:41 +02:00
Lonami Exo
153cbfd350 Use more straightforward calls of hashlib.sha1/sha256 2017-06-02 16:49:03 +02:00
Lonami Exo
d321096714 Tidy if/else branch on _recreate_socket 2017-05-30 11:42:14 +02:00
Lonami Exo
2399b7e55e Remove try/except if a proxy was used, make more members private 2017-05-30 10:40:33 +02:00
Lonami Exo
0b9d76bda1 Replace library print()'s with calls to _logger 2017-05-30 10:24:08 +02:00
Lonami Exo
7c84c72f06 Minor change to make the code more pythonic 2017-05-29 21:27:20 +02:00
Lonami Exo
042e3069a9 Move UpdatesThread from MtProtoSender to TelegramClient
This makes it easier to perform a proper reconnection
2017-05-29 21:24:47 +02:00
Lonami Exo
ebe4232b32 Change the way in which updates are read and handled 2017-05-29 20:41:11 +02:00
Lonami Exo
452532cce7 Make certain methods and members private 2017-05-29 17:06:48 +02:00
Lonami Exo
63b1881c83 Raise FloodWaitError instead sleeping 2017-05-29 16:46:17 +02:00
Lonami Exo
7f84374e98 Attempt at fixing msg_id too low/high (#95) 2017-05-26 16:39:59 +02:00
Lonami Exo
02a847b64a Make lint happier 2017-05-21 13:59:16 +02:00
Lonami Exo
63c89af983 Use relative imports always where possible 2017-05-21 13:02:54 +02:00
Lonami Exo
ca80b05694 Add shebangs and set proper file permissions 2017-05-20 15:58:44 +02:00
Lonami Exo
fb9104417e Add more errors, change the way InvalidDC is created 2017-05-20 15:25:07 +02:00
Lonami Exo
eb7fb2ac24 Make logging a lot less intrusive
See https://docs.python.org/3/howto/logging.html#library-config
2017-05-20 11:49:09 +02:00
Lonami Exo
6550d83d42 Fix closed sockets not being recreated as they should
See http://stackoverflow.com/a/15958099
2017-05-20 11:34:23 +02:00
Lonami Exo
468033fa7e Avoid counterintuitive automatic connection 2017-05-20 11:33:37 +02:00
Dmitry D. Chernov
bbd3eb7c28 Raise an exception if recv() returned 0 bytes
See for details: https://docs.python.org/3/howto/sockets.html
"When a recv returns 0 bytes, it means the other side has closed (or is in the process of closing) the connection. You will not receive any more data on this connection. Ever."
2017-05-20 11:02:19 +02:00
Lonami Exo
3c3946e6f1 Don't start the updates thread until signed in 2017-05-19 21:44:50 +02:00
Dmitry D. Chernov
0ef32a7d78 Fix syntax of exception throwing here and there 2017-05-19 08:32:40 +02:00
Dmitry D. Chernov
7f787affc6 MtProtoSender: Fix crash on receiving unknown RPC results
Such RPC results may arrive after reconnection, for example.
2017-05-19 08:32:40 +02:00
Dmitry D. Chernov
048bc81b74 MtProtoSender: Use threading.Event instead of boolean flags 2017-05-09 19:50:46 +02:00
Dmitry D. Chernov
7ffe2b3130 TcpClient: Combine two identical function calls into one 2017-05-09 19:50:46 +02:00
Dmitry D. Chernov
15e06f9ce2 TcpClient: Use threading.Event instead of boolean flag 2017-05-09 19:50:46 +02:00
Lonami Exo
6069188b54 MtProtoPlainSender was not connecting (closes #62) 2017-04-29 20:57:08 +02:00