Commit Graph
77 Commits
Author SHA1 Message Date
Confused Character 22bf0b4310 Add custom secret support to TcpMTProxy (#4309) 2024-02-16 22:45:38 +01:00
Lonami Exo 6a7a981b7a Fix asyncio.CancelledError was being swallowed by inner except
Closes #4104.
2023-05-08 22:34:12 +02:00
Lonami Exo ccf67d0f4f Exit receive loop on IOError or unhandled exceptions
May help with #4088.
2023-04-29 12:53:25 +02:00
Lonami Exo 03ff996ace Improve unhelpful 'readexactly size can not be less than zero'
Technically closes #4092, as the error is now properly handled.
2023-04-29 12:33:32 +02:00
David d419979406 Declare missing exception variable (#4087) 2023-04-12 17:36:43 +02:00
Lonami Exo acd3407418 Propagate errors at the connection level 2023-03-12 17:43:19 +01:00
Lonami Exo f3414d134a Handle invalid buffers at protocol level
See #4042.
2023-03-12 17:27:22 +01:00
Lonami Exo 83bafa25e3 Stop using asyncio.get_event_loop()
It is deprecated in newer Python versions.
Closes #4013.
2023-01-11 21:02:29 +01:00
Lonami Exo 17516318e6 Add a hard timeout on disconnect
Closes #3917.
2022-09-21 10:58:35 +02:00
Lonami Exo f2f43336c6 Always use python-socks when available
Relying on Python 3.6 or above to be installed to unconditionally
use this library would break user's code, because this is a new
optional dependency that users may not have installed.

Instead, always use the new library when available, which should
work better than pysocks because it natively supports asyncio.
2020-11-28 12:09:46 +01:00
Serhii Dylda 59da53ec48 Fix typing once again 2020-11-09 20:22:22 +01:00
Serhii Dylda a68800b3f0 Remove unnecessary if clause 2020-11-09 20:09:08 +01:00
Serhii Dylda 38d8a54cc1 Fix protocol typing for python-socks. 2020-11-09 20:05:09 +01:00
Serhii Dylda 633986cfa6 Replace PySocks with python-socks for Python >= 3.6
See discussion at (https://github.com/LonamiWebs/Telethon/pull/1623)

Small fixes for `local_addr` argument.
2020-11-09 19:59:54 +01:00
Lonami Exo d9ddf8858e Add missing local_addr to proxy connection, bump version
Bug introduced by #1587.
2020-10-22 10:13:29 +02:00
Stefan d2756cf68f Add support for local_ip address binding (#1587) 2020-10-07 10:03:19 +02:00
Lonami Exo 1c3e7dda01 Avoid explicitly passing the loop to asyncio
This behaviour is deprecated and will be removed in future versions
of Python. Technically, it could be considered a bug (invalid usage
causing different behaviour from the expected one), and in practice
it should not break much code (because .get_event_loop() would likely
be the same event loop anyway).
2020-07-25 18:39:35 +02:00
ov7a 79fb1a54cb Switch to blocking connect when using proxy (#1432)
Until a better fix is found, this should help proxy users.
2020-04-12 14:28:40 +02:00
Lonami Exo ecb27f33f7 Lower log severity on error during disconnect 2019-12-23 11:54:56 +01:00
painor 38b929b973 Fix several typos (#1328) 2019-11-10 11:29:43 +01:00
Lonami Exo 7e346180d7 Fix import ssl may fail under some Python installs
It's only required for certain proxy configurations, so we
don't want it to raise ImportError while the user imports
our library.
2019-10-31 19:20:18 +01:00
Lonami Exo baacecadc5 Document some errors, bump v1.10.7 2019-10-27 18:50:21 +01:00
Lonami Exo 278f0e9e98 Don't raise errors during disconnect 2019-05-10 18:54:10 +02:00
Lonami Exo cd4b915522 Add type hints to all public methods in the client 2019-05-03 21:38:41 +02:00
Lonami Exo 1e17ef1c98 Apply several lints 2019-05-03 21:38:41 +02:00
Lonami Exo 19664cd9cf Call self._writer.wait_closed() on disconnect
https://docs.python.org/3/library/asyncio-stream.html#asyncio.StreamWriter.wait_closed
2019-04-25 09:56:30 +02:00
yegor 8edbfbdced Fix dd mode in MTProxies (#1157) 2019-04-19 22:09:22 +02:00
Lonami Exo 7523869875 Except IOError and not ConnectionError
PySocks' errors do not subclass ConnectionError so the library
was unnecessarily logging them as unexpected, when any IOError
was actually expected.
2019-03-28 09:54:35 +01:00
Lonami Exo 04ba2e1fc7 Revert disconnect() to be async again (#1133)
It's the only way to properly clean all background tasks,
which the library makes heavy use for in MTProto/Connection
send and receive loops.

Some parts of the code even relied on the fact that it was
asynchronous (it used to return a future so you could await
it and not be breaking).

It's automatically syncified to reduce the damage of being
a breaking change.
2019-03-21 12:21:00 +01:00
Lonami Exo 2e4476a754 Workaround #1134 by early checking if proxy closes connection 2019-03-21 11:22:09 +01:00
Сергей Прохоров 43505e0aad Use issubclass instead of direct class comparison 2019-03-12 20:25:33 +01:00
Сергей Прохоров 4696dfc25e Rework class hierarchy, try to DRY more 2019-03-12 01:12:55 +01:00
Сергей Прохоров b873aa67cc Implement different mtproto proxy protocols; refactor obfuscated2 2019-03-10 03:26:24 +01:00
Lonami Exo 8429f9bd3c Update to v1.6 2019-02-27 21:04:18 +01:00
Lonami Exo abadf3c789 Provide a blanket implementation for _init_conn 2019-02-21 10:43:31 +01:00
Lonami Exo 6de7329ce7 Fix Connection abstraction leak 2019-02-21 10:41:33 +01:00
Dmitry D. Chernov d25442345e Fix incorrect sending of DC id when connecting to MTProxy 2019-02-12 21:17:08 +10:00
Dmitry D. Chernov 45d0ba9e2f Initial implementation of MTProxy support (#1107) 2019-02-11 00:16:46 +01:00
Dmitry D. Chernov 8c428e8566 Fix broken connection establishment in ConnectionTcpObfuscated
This regression was introduced in ebde3be820.
2019-02-11 07:54:59 +10:00
Dmitry D. Chernov c39cc06908 Fix incorrect check for reserved data prefix in ConnectionTcpObfuscated 2019-02-11 05:47:09 +10:00
Lonami Exo ae4d4ba3ef Fix-up missing loggers from f271316 2019-01-12 12:15:29 +01:00
Tulir Asokan f271316d7d Make logger fully configurable (#1087) 2019-01-11 15:52:30 +01:00
Sister Midnight f3013c6817 Fix ConnectionHttp SSL socket wrap (#1064) 2018-12-10 14:43:48 +01:00
Lonami Exo c48d41d99d Expect ConnectionError in the send loop 2018-12-06 16:27:09 +01:00
Lonami Exo d2e995ef95 Change code to recv and handle disconnections 2018-11-24 20:53:28 +01:00
Lonami Exo f046d1f0a3 Fix deadlock on unexpected disconnections 2018-11-10 11:23:19 +01:00
Lonami Exo 67c5572d7b Possibly fix possible deadlock 2018-10-28 11:53:28 +01:00
Lonami Exo b0e587c03d Except expected ConnectionError in the receive loop 2018-10-26 10:36:33 +02: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 f2e77f4030 Fix using the wrong logger in Connection 2018-10-21 16:10:09 +02:00