108 Commits

Author SHA1 Message Date
mathieui
ccbba89cbd xmlstream: make dns_answers private 2021-02-04 19:22:13 +01:00
mathieui
d3063a0368 xmlstream: make connect_loop_wait private 2021-02-04 19:22:13 +01:00
mathieui
650e1a2ed5 docs/xmlstream: remove HTTP proxy references
It has been removed years ago.
2021-02-04 18:31:43 +01:00
mathieui
7932a03378 xmlstream: add a simple contextmanager for temporary events 2021-01-31 17:01:41 +01:00
mathieui
3f739e513b xmlstream: keep value of "end_session_on_disconnect"
That value should be set statically. Worst case is we fail to resume the
session.
2021-01-29 15:33:44 +01:00
mathieui
3642e2c7f4 xmlstream: ensure slow futures are scheduled on this loop 2021-01-29 15:33:44 +01:00
mathieui
f15311bda8 xmlstream: Make the reconnect handler a coroutine 2021-01-29 15:33:44 +01:00
mathieui
b2dfb4c1f3 xmlstream: do not touch connection state on abort()
leave it to the connection_lost handler
2021-01-29 15:33:44 +01:00
mathieui
d227579d56 xmlstream: set disconnected future on event 2021-01-29 15:33:44 +01:00
mathieui
571774edb4 xmlstream: end the parser when the stream has ended 2021-01-29 15:33:44 +01:00
mathieui
456dff0b61 xmlstream: rename run_filters 2021-01-29 15:33:44 +01:00
mathieui
a0b6bfcefe xmlstream: change the connection logic
* use asyncio wait_for to wait for a disconnected event
* abort the connection if the timeout is not enough
2021-01-29 15:33:44 +01:00
mathieui
9fbd40578c xmlstream: purge send queue and pending tasks on session end
and keep track of slow tasks
2021-01-29 15:33:44 +01:00
mathieui
8700f8d162 xmlstream: do not cancel the send filter task
it does not make sense to cancel it, it does not do anything when the
sending queue is empty, and clients should not fill the send queue when
not connected anyway.
2021-01-28 17:54:40 +01:00
mathieui
efdcd396d8 xmlstream: fix race conditions on handlers 2021-01-28 17:54:40 +01:00
mathieui
0eed84d0b2 xmlstream: handle done tasks in wait_until
and handle other loops properly
2021-01-28 17:54:40 +01:00
mathieui
49577e6c84 Handle connection errors in start_tls (fix #3449) 2021-01-22 22:04:41 +01:00
mathieui
f38c61a6b9 XMLStream: Only fire "disconnected" after removal of related objects
Otherwise we could end up reconnecting and getting some useful things
like the XML parser or other stuff removed afterwards.

Also, move 'session_end' before 'disconnected', it makes more sense that
way.
2021-01-17 18:30:57 +01:00
mathieui
95d40a3ca3 docs: update docstrings for sphinx conformity
Remove most references to timeout/callback/ifrom/timeout_callbacks args
2020-12-10 19:22:40 +01:00
mathieui
3d1e539d2b XMLStream: Add a wait_until coroutine
It will set a disposable handler on an event and wait on it with a
specific timeout. Useful for integration tests without callback hell.
2020-12-04 22:59:34 +01:00
ehendrix23
145bb7a36e Cancel run_filters task upon disconnect 2020-06-12 19:03:58 +02:00
mathieui
f884b67b8b Fix a regression introduced in 1.5.0
Due to the send queue, messages sent immediatly before calling
"disconnect" would not be sent.
2020-05-02 17:17:08 +02:00
Georg Lukas
5be46a5e68 fire 'disconnected' callback from abort() 2020-04-04 13:16:33 +02:00
Georg Lukas
ab9040c30e expose is_connecting state based on connection attempt future 2020-04-04 13:16:31 +02:00
Georg Lukas
621255027d Reset reconnect delay on manual reconnect, add delay event
This is just a hotfix workaround for an underlying problem. The
`_connect_routine` code is "blocking" (in an async way) for
`connect_loop_wait` seconds, so that a fresh-started manual reconnect
will be silenty delayed. This code does the following changes:

1. It moves the delay to before the DNS resolution (with the exponential
   back-off it might well be that the DNS records are changed while
   slixmpp is waiting).

2. It adds a new event `reconnect_delay` that gets passed the number of
   seconds it will delay before actually reconnecting

3. It resets the `connect_loop_wait` timer on a manual connect/reconnect
   call to fix the interactive experience.

A *proper fix* would replace the sleep in `_connect_routine` with a
properly timered re-invocation of it, but I don't understand enough of
asyncio for pulling off that magic, and this is actually a proper
improvement. Also I tested this and it works!
2020-03-29 14:21:05 +02:00
Georg Lukas
d85efec7a2 reconnect: fix callback when not currently connected
The 'disconnected' event is normally fired from connection_lost(), which
is called by the connection code when the connection is lost after being
established. However, if the connection wasn't successfully established,
a manual /reconnect no-ops because it waits for the 'disconnected'
callback which never fires. This patch does two things:

1. Immediately fire a 'disconnected' event in disconnect() if there is
   no transport.

2. Register the 'disconnected' event handler in reconnect() *before* it
   can be fired.
2020-03-23 18:59:29 +01:00
mathieui
a0f5cb6e09
Put the queue exception at toplevel 2019-12-27 15:27:29 +01:00
mathieui
110bbf8afc
Improve the send queue code a bit 2019-12-27 15:27:29 +01:00
mathieui
d97efa0bd8
add a separate place for slow ass filters 2019-12-27 15:27:29 +01:00
mathieui
672f1b28f6
raise Exception 2019-12-27 15:27:29 +01:00
mathieui
27d3ae958b
Try/except around outbound stanza processing
to avoid killing the send loop when a filter has an error
2019-12-27 15:27:29 +01:00
mathieui
a32794ec35
Remove trailing whitespace 2019-12-27 15:27:28 +01:00
mathieui
31f6ef6814
Run the send queue in a separate coroutine
To be able to run async stream filters
2019-12-27 15:27:25 +01:00
Maxime “pep” Buquet
db13794e0f Revert "Remove a block of compatibility code"
This reverts commit 37bc1bb9b3bdc26b7f28b30406d1013f9b0f6ceb.

Confusion confusion. Mathieui thought this was a sleekxmpp thing when
it's actually been added not so long ago.
2019-08-28 00:12:10 +02:00
mathieui
37bc1bb9b3
Remove a block of compatibility code
even if the user makes that mistake, it does not cause problems down the
line.
2019-08-26 12:00:38 +02:00
Maxime “pep” Buquet
b29bb30eb7
Make generated stanza id truly random
Fix long-standing security issues where stanza @id be predictable.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-07-13 14:07:31 +02:00
Maxime “pep” Buquet
4435c81d77 xmlstream.disconnect: add compat behaviour, set wait to default 2.0 when True is passed. Update documentation
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-07-03 21:36:17 +02:00
Maxime “pep” Buquet
1ee0f72ead
xmlstream.disconnect: fix frenchism in docstring
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-04-24 23:35:33 +01:00
Maxime “pep” Buquet
4bb81228ae
xmlstream.disconnect: typing hints
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-04-24 23:35:06 +01:00
Georg Lukas
704161a285 mark end-of-stream as session-ending event 2019-03-26 15:16:52 +01:00
Georg Lukas
4f96e5fa75 Do not directly enqueue connect() as event handler, parameter mismatch 2019-03-26 12:09:43 +01:00
Georg Lukas
bcb90a653e Do not close stream on 0-timeout disconnect, allows 0198 resume 2019-03-26 11:02:28 +01:00
Georg Lukas
7e435b703d Propagate disconnect() reason into 'disconnected' event 2019-03-26 11:01:36 +01:00
ehendrix23
696a72247b Fix slixmpp.ClientXMPP.cancel_connection_attempt() 2019-02-22 00:41:02 +01:00
Florian Klien
d33366badd fixing deprecation warnings for pytest 2018-10-15 14:59:23 +02:00
mathieui
809c500002
Add the loop parameters at places where it has been forgotten 2018-10-09 12:34:56 +02:00
mathieui
490f15b8fc
Fix compatibility with python 3.5 and 3.6
which do not have loop.start_tls and require the old ssl implementation.
2018-08-08 23:35:33 +02:00
mathieui
7738a01311
Fix TLS with python 3.7
Use the "new" sslproto API instead of the deprecated TLS API.
Also remove the unused "socket" parameter in XMLStream.__init__.
2018-08-07 23:20:38 +02:00
Emmanuel Gil Peyrot
3502480384 Switch from @asyncio.coroutine to async def everywhere. 2018-07-01 18:46:33 +02:00
mathieui
979396bb1e
asyncio.async has been scheduled for removal for a long time now
move to asyncio.ensure_future
2018-02-11 19:25:38 +01:00