Commit Graph

112 Commits

Author SHA1 Message Date
Lonami Exo
207d5ebdcb Avoid packing more than 1024 messages in a single container 2018-11-19 08:29:44 +01:00
Lonami Exo
7dece209a0 Cancel tasks on reconnect instead of awaiting them
This prevents us from locking forever on any task that doesn't
rely on cancellation tokens, in this case, Connection.recv()'s
_recv_queue.get() would never complete after the server closed
the connection.

Additionally, working with cancellation tokens in asyncio is
somewhat annoying to do.

Last but not least removing the Connection._disconnected future
avoids the need to use its state (if an exception was set it
should be retrieved) to prevent asyncio from complaining, which
it was before.
2018-10-21 16:20:05 +02:00
Lonami Exo
0686ec4440 Implement after_msg_id back 2018-10-19 16:53:50 +02:00
Lonami Exo
9dc4009152 Handle the right errors 2018-10-19 14:41:50 +02:00
Lonami Exo
e2fe3eb503 Use new broken MessagePacker 2018-10-19 13:24:52 +02:00
Lonami Exo
0cc8bca098 Delete TcpClient 2018-10-05 13:26:44 +02:00
painor
340f5614b5 Add name mention formatting to HTML and Markdown (#1019) 2018-10-04 15:56:32 +02:00
Lonami Exo
92c9bb12b7 Use asyncio.open_connection in the TcpClient
(cherry picked from commit 573fed1f512831cd9790130cc878655fef2fde98)
2018-09-19 19:03:36 +02:00
Lonami Exo
a688c8a4ce Fix exception ignored warnings and invalid state #935 2018-08-04 15:06:11 +02:00
Lonami Exo
200a4e47b8 Clarify some strings 2018-07-25 02:21:44 +02:00
Lonami Exo
aa67f107af Temporarily use blocking SSL sockets on connect 2018-07-19 20:56:45 +02:00
Lonami Exo
4027ac6a6f Wrap socket with SSL after connecting
See https://github.com/Anorov/PySocks/issues/29
2018-07-19 20:38:53 +02:00
Lonami Exo
38c65adf35 Set timezone info when reading datetimes 2018-07-12 00:30:57 +02:00
Lonami
128053750d
Implement HTTP(S) mode (closes #112) (#883) 2018-07-08 17:45:49 +02:00
Lonami Exo
53c660d0dc Don't remove reader if fd == -1 2018-06-30 13:26:28 +02:00
Lonami Exo
d64eb7ea2b Avoid cyclic imports on older Python versions 2018-06-29 11:04:42 +02:00
Lonami Exo
c8ee0bdca9 Fix socket may be None when closing twice 2018-06-20 17:59:11 +02:00
Lonami Exo
4e9a84c3b5 Remove underscore from module names 2018-06-18 21:02:42 +02:00
Lonami Exo
145d4b7105 Remove socket fd from the loop reader upon closing 2018-06-17 15:48:26 +02:00
Lonami Exo
226c35ff8f Pump up default timeout from 5 to 10s 2018-06-17 11:46:56 +02:00
Lonami Exo
0f14f3b16a Support custom event loops 2018-06-14 19:35:12 +02:00
Lonami Exo
df1dfdf8ea Remove some redundant except 2018-06-14 16:13:46 +02:00
Lonami Exo
c9ea1bafc0 Apply @andr-04 asyncio commits to TcpClient 2018-06-14 16:08:23 +02:00
Lonami Exo
64dd957189 Fix None first_query and TcpClient.disconnect() 2018-06-11 19:51:01 +02:00
Lonami Exo
7e68274f26 Keep consistent structure and remove done TODO 2018-06-09 15:42:10 +02:00
Lonami Exo
be279ce3f5 Make TLMessage always have a valid TLObject
This simplifies the flow instead of having separate request/body
attributes, and also means that BinaryReader.tgread_object() can
be used without so many special cases.
2018-06-09 13:48:27 +02:00
Lonami Exo
f7e8907c6f Create RpcResult class and generalise core special cases
This results in a cleaner MTProtoSender, which now can always
read a TLObject with a guaranteed item, if the message is OK.
2018-06-09 13:13:55 +02:00
Lonami Exo
9477c75fce Fix basic requests sending and receiving 2018-06-06 21:42:48 +02:00
Lonami Exo
e469258ab9 Create a new MTProtoSender structure and its foundation
This means that the TcpClient and the Connection (currently only
ConnectionTcpFull) will no longer be concerned about handling
errors, but the MTProtoSender will.

The foundation of the library will now be based on asyncio.
2018-06-06 20:41:01 +02:00
Lonami Exo
2fb5215f5f Fix parsers misbehaving with None text 2018-06-03 13:48:43 +02:00
Lonami Exo
8d7c7a19c0 Add some setters for custom.Message 2018-06-03 11:53:18 +02:00
Lonami Exo
e2a0de1913 Don't retry forever on TcpClient.connect() 2018-04-25 10:06:11 +02:00
Lonami Exo
eabaa3854a Replace offset with match.start() to allow custom regex 2018-04-03 13:47:40 +02:00
Lonami Exo
33e908de42 Fix markdown regex not supporting [] inside URLs 2018-03-22 19:02:08 +01:00
Lonami Exo
987cf41ec6 Higher timeout and log them as warning if any data was received
This might be the cause for  "number of retries reached 0" so
more specific logging calls might be useful. If while reading
a response it times out but  some data had already been read,
said data will be lost.

The sequence of events that triggered reaching 0 retries was:
- Sending requests with IDs XYZ
- socket.timeout while reading
- Items timed out. Retrying
- Processing RPC result
- Received response for XYZ
- Lost request with ID XYZ
2018-03-18 20:08:00 +01:00
Lonami Exo
a7f98fd3cc Ignore bad file descriptor while closing 2018-03-02 17:26:42 +01:00
Lonami Exo
229cd78df0 Fix markdown's URL regex not acceping newlines 2018-02-27 14:10:02 +01:00
Lonami Exo
6f16aeb553 Add logging calls on the TcpClient 2018-02-26 13:41:07 +01:00
Dmitry Bukhta
0731a1d698 Raise ProxyConnectionError instead looping forever (#621)
We shouldn't try reconnecting when using a proxy if what's
unavailable is the proxy server (and not Telegram servers).
2018-02-20 17:05:02 +01:00
Lonami Exo
83d9d1d78e Fix markdown parser not inverting delimiters dict 2018-02-16 20:30:19 +01:00
Lonami Exo
75d99fbb53 Fix HTML entity parsing failing when needing surrogates 2018-02-15 11:52:46 +01:00
Lonami Exo
2ffe2b71dc Except OSError with errno.WSAEACCES when connecting
"OSError: [WinError 10013] An attempt was made to access a
socket in a way forbidden by its access permissions."
2018-02-03 11:44:05 +01:00
frizzlywitch
3b8365f871 Remove square braces from IPv6 addresses (#561) 2018-01-26 14:38:13 +01:00
Tulir Asokan
5f2f04c6c2 Add HTML parse mode (#554) 2018-01-22 10:06:11 +01:00
Lonami Exo
33e50aaee1 Reuse .on_response/.__str__/.stringify, override iff necessary 2018-01-19 12:12:52 +01:00
Lonami Exo
46b088d44c Also handle ECONNREFUSED on .connect() (report on #392) 2018-01-08 12:26:32 +01:00
Lonami Exo
59a1a6aef2 Stop working with bytes on the markdown parser 2018-01-07 16:19:41 +01:00
Lonami Exo
3eafe18d0b Implement MtProto 2.0 (closes #484, thanks @delivrance!)
Huge shoutout to @delivrance's pyrogram, specially this commit:
pyrogram/pyrogram/commit/42f9a2d6994baaf9ecad590d1ff4d175a8c56454
2018-01-06 01:55:11 +01:00
Lonami Exo
ec4ca5dbfc More consistent with asyncio branch (style/small fixes)
Like passing an extra (invalid) dt parameter when serializing
a datetime, and handling more errors in the TcpClient class.
2018-01-05 18:31:48 +01:00
Dmitry D. Chernov
6ec6967ff9 Make exception types correspond to Python docs 2017-12-28 09:48:02 +10:00