Commit Graph

394 Commits

Author SHA1 Message Date
Lonami Exo
97cab7347b Make lint happier 2017-09-04 17:10:04 +02:00
Lonami Exo
7f700c3bc1 Remove unused attributes and methods from the base TLObject class 2017-09-04 16:39:16 +02:00
Lonami Exo
0e45f46ad5 Properly ignore core types when generating code 2017-09-04 16:38:03 +02:00
Lonami Exo
e8cdcf369d Sort generated code by name for more predictable results 2017-09-04 15:11:46 +02:00
Lonami Exo
c5b562d4f6 Move the from tlobject import TLObject to only the top of the file 2017-09-04 14:08:36 +02:00
Lonami Exo
64f1031a45 Move comments from auto-generated code to the generator itself 2017-09-04 14:05:30 +02:00
Lonami Exo
c3f679597c Move the auto-generated notice to only the top of the file 2017-09-04 13:57:40 +02:00
Lonami Exo
e83b250a22 Replace generated directory modules with simply files 2017-09-04 13:51:47 +02:00
Lonami Exo
7eab28206b Change the code generator to use a single file per namespace 2017-09-04 13:44:39 +02:00
Lonami Exo
dc238df2e0 Update to v0.13 2017-09-04 12:18:45 +02:00
Lonami Exo
a5d86b4572 Update to layer 71 2017-09-04 11:54:37 +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
62a52679f4 Ensure the state of the requests is clean before invoking them 2017-09-03 13:45:13 +02:00
Lonami Exo
27408b46da Only reconnect from background thread if .disconnect wasn't called 2017-09-03 13:44:52 +02:00
Lonami Exo
626778bd32 Ignore EBADF when closing the socket 2017-09-03 13:44:29 +02:00
Lonami Exo
68cdc9eaf1 Treat OSError.errno == EBADF as a ConnectionResetError 2017-09-03 11:54:26 +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
fa34c4bb77 Handle ConnectionResetError on background thread (removed on 9bc1f64) 2017-09-03 10:05:18 +02:00
Lonami Exo
2a5d08b23d Turn socket.timeout error into the more general TimeoutError 2017-09-03 10:01:00 +02:00
Lonami Exo
494b82ea9d Fix check to avoid (dis)connecting if already (dis)connected 2017-09-03 09:59:37 +02:00
Lonami Exo
4de4026bb3 Move the "constant read" thread to the main TelegramClient 2017-09-03 09:56:10 +02:00
Lonami Exo
69d182815f Merge branch 'constant_read'
Since the secondary thread for constant read is not part of the
TelegramClient anymore, there is no need to restart it. It will
be ran when connecting again.
2017-09-02 21:51:11 +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
cc280a129d Remove TcpClient.write/read shared locks
Since they were shared between write and read, and now the read
is done constantly on a separate thread, the read lock would
cause the write method to be locked and not functional at all
2017-09-02 18:49:29 +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
49c5cf745f Fix SignUpRequest using an incorrectly named parameter 2017-09-02 16:54:06 +02:00
Lonami Exo
0197271f74 Fix SignUpRequest using an incorrectly named parameter 2017-09-02 16:52:56 +02:00
alexvelickiy
5f4e79542f Restore updates thread on reconnection and fix restarting it 2017-08-31 18:57:32 +02:00
Lonami Exo
bea1b7f526 Preserve backward compatibility with old .sign_in() code 2017-08-31 10:38:53 +02:00
Lonami
5f636fdf31 Let .sign_in() call .send_code_request() 2017-08-31 10:34:09 +02:00
Lonami Exo
8bff10d956 Fix get_input_* not skipping None entities (#215)
This was an issue when parsing optional parameters, since None
could not be specified, resulting in a strange crash.
2017-08-30 11:12:25 +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
7ad2ece168 Simplify modifying TelegramClient.session through its __init__ 2017-08-29 16:06:14 +02:00
Lonami Exo
22673aec0e Replace the old Session+pickle with JsonSession (name change) 2017-08-29 15:59:08 +02:00
Lonami Exo
82304b18eb Attempt at supporting IPv6 (#211 and #112) 2017-08-29 13:49:41 +02:00
Lonami Exo
592e107f52 Recreate the TCP socket only when needed 2017-08-29 13:35:56 +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
bc72e52834 Reuse the AESModeCTR class on CdnDecrypter 2017-08-28 20:30:33 +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
adfebfc82c Remove ThreadTcpClient test (committed by mistake) 2017-08-28 17:46:31 +02:00
Lonami Exo
2c6377e069 Update to v0.12.2 2017-08-28 17:29:08 +02:00
Lonami Exo
06b2d5d786 Fix CDN client not being disconnected 2017-08-28 16:33:23 +02:00