Commit graph xmpp-rs/tokio-xmpp
Author SHA1 Message Date
Emmanuel Gil Peyrot
c497967b1c xmpp-parsers: Reduce component handshake allocations
This function always appends to an existing string, so by passing it a
String directly we can avoid superfluous allocations.

Also tokio-xmpp was doing a bunch of &str to String for no reason around
there, let’s remove that too.
2025-02-10 17:06:15 +00:00
Emmanuel Gil Peyrot
b8f64037a9 tokio-xmpp: Fix build on insecure-tcp
insecure-tcp requires the io-util feature of tokio, so let’s enable it
there.

Fixes this error:
5   | use tokio::{io::BufStream, net::TcpStream};
    |             ^^^^^^^^^^^^^ no `BufStream` in `io`
2025-02-10 15:40:53 +01:00
Emmanuel Gil Peyrot
fa61f421bb xmpp-parsers: Use xso for pubsub events
Also split the PubSubEvent enum into Event and Payload.
2025-01-27 15:07:59 +01:00
Jonas Schäfer
8a4d548d9a tokio_xmpp: implement IQ tracking 2025-01-26 17:15:41 +01:00
Jonas Schäfer
ef9d0a95ff tokio_xmpp: improve Client docs
skip-changelog, to not add doc improvement noise.
2025-01-26 15:09:45 +00:00
Jonas Schäfer
fc62229dc5 tokio_xmpp: fix Client on servers without Stream Management
The Client::send_stanza method blocks on the stanza actually being sent
over the stream. Without this change, the method will never return
on streams without XEP-0198 Stream Management because `sm_state` is
then None and thus the StanzaToken's state is never advanced: it would
be stuck in Queued state.

In addition, a lack of advancement to Sent state may cause a deadlock on
XEP-0198-enabled streams if data is received so fast that the
frontend_tx mpsc::Sender in the stanzastream::Worker is filled up. In
such a case, the Worker cannot obtain a permit and will only service
writes. However, that will mean that no StanzaTokens can be advanced
beyond Queued state, because for that, reads need to be serviced (to
receive the SM acks).

If a burst of stanzas is then received while Client::send_stanza is
being awaited, send_stanza can only return if something reads from the
frontend mpsc in the meantime. We do not want to require user code to
drive the Client in full-duplex mode, hence this is a bug.

skip-changelog, because this fixes an unreleased feature.
2025-01-25 12:31:32 +00:00
33098e6f2c Message and message_correct::Replace now has typed Id 2024-12-30 20:50:43 +00:00
5bc94dce95 tokio_xmpp: Replace std::io calls with use std::io 2024-12-19 20:51:57 +01:00
1ce2f894aa tokio_xmpp: Replace std stuff with alloc/core stuff 2024-12-19 20:45:36 +01:00
50425617b5 parsers: Add Message::extract_valid_payload helper 2024-12-19 17:36:10 +01:00
Emmanuel Gil Peyrot
f8347165fd tokio-xmpp: Add forgotten ChangeLog entry for ktls support 2024-12-18 18:33:42 +00:00
Emmanuel Gil Peyrot
897c2abe0b tokio-xmpp: Refactor to provide channel-binding for ktls
Instead of having a second method to fetch channel-binding from the
TlsStream, do it directly in the connect() method, since after that we
don’t have enough information to fetch it any longer when using ktls.
2024-12-18 18:05:36 +00:00
7991cef904 Add tests for crate exports ; add structure to imports/exports 2024-12-18 18:03:18 +00:00
Jonas Schäfer
ce57ee4b38 tokio_xmpp: add example to demonstrate stream management 2024-12-17 18:16:02 +01:00
Jonas Schäfer
35ce86243f client: use stanzastream! 2024-12-17 18:16:02 +01:00
Jonas Schäfer
80f899daa0 tokio_xmpp: implement high-level, resilient stanza stream 2024-12-17 18:16:02 +01:00
Jonas Schäfer
56ce57ecde xmlstream: use Stanza for XmppStreamElement
Oftentimes, Stanza is at hand anyway, so this saves some typing.
2024-12-17 16:12:56 +01:00
Jonas Schäfer
c6f928d5c8 xmlstream: make sink implementation generic
This allows to use any serialisable type. The advantage is that moves
and clones are avoided (which would otherwise be needed to construct
e.g. a XmppStreamElement from a Stanza or Message).
2024-12-17 16:12:56 +01:00
Jonas Schäfer
519718d9b5 xmlstream: add support for boxing the transport
This is useful in situations where we don't want to care about the
specific type of the underlying transport.
2024-12-17 16:12:56 +01:00
Jonas Schäfer
2388f23b4e xmlstream: support receiving stream errors 2024-12-17 16:12:56 +01:00
Maxime “pep” Buquet
45be2b34f0 tokio-xmpp: Add 'component' feature
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2024-12-16 00:33:43 +00:00
Alvaro Parker
347e8d6f17 Impl Error for ReadError 2024-09-20 15:17:54 -03:00
Emmanuel Gil Peyrot
c24275c098 tokio-xmpp: Add support for kernel TLS
This drastically improve the debuggability of the network parts, by
moving the task of encrypting/decrypting TLS packets from userland to
the kernel.  This makes them appear in clear in strace as sendto() and
recvfrom().

I introduced a new tls-rust-ktls feature which depends on both rustls
and ktls, but isn’t enabled by default since it probably isn’t available
on every computer.  It requires the tls kernel module to be loaded,
which then can offload encryption/decryption to dedicated hardware if
available.

I have tested this change on Linux 6.11 on a rk3588.
2024-09-17 20:45:41 +00:00
Alvaro Parker
904bdeae11 add debug to StreamHeader 2024-09-17 12:07:06 -03:00
Emmanuel Gil Peyrot
ebfae4bddc tokio-xmpp: Run rustfmt on that one example
It started breaking CI for some reason, probably a rustfmt update.
2024-09-16 23:32:49 +02:00
Alvaro Parker
2ff89a9e42 fix typos 2024-09-16 18:29:44 -03:00
Emmanuel Gil Peyrot
425be4bef4 tokio-xmpp: Improve highlight_xml()
First switch to LazyLock from OnceLock, to simplify the code.

Then concatenate the colour reset escape code instead of using
format!(), since the vast majority of those strings have more capacity
than their length it will avoid a reallocation in most cases.
2024-09-01 12:32:50 +02:00
Jonas Schäfer
263839a5f8 xmlstream: add tests to capture thingy
This would've caught the embarrassing error made in the previous commit.
2024-09-01 09:07:34 +00:00
Jonas Schäfer
c795921631 xmlstream: fix crash
This happened when (a bit too hastily) applying suggestions from a
review.
2024-09-01 09:07:34 +00:00
Jonas Schäfer
ce4b739026 xmlstream: allow simplex stream shutdown
Unlike poll_close, poll_shutdown will only kill the sending side of the
stream. This is relevant to perform a fully clean shutdown procedure in
XMPP.
2024-09-01 10:02:36 +02:00
Jonas Schäfer
4cfe4f8429 xmlstream: implement simple timeout logic
This allows to detect and handle dying streams without getting stuck
forever.

Timeouts are always wrong, though, so we put the burden of choosing the
right values (mostly) on the creator of a stream.
2024-09-01 10:02:36 +02:00
Jonas Schäfer
960fd782bd xmlstream: fix clean shutdown sequence
Without the early return in XmlStream::poll_next in case of the stream
footer, the read state gets recreated and the logic at the top of that
function to actually handle stream shutdown gracefully is never
triggered.

Also that logic was incorrect; the correct behaviour is to wait for the
true EOF.
2024-09-01 10:02:36 +02:00
Jonas Schäfer
efc859abc0 xmlstream: re-introduce syntax-highlit logging of XML stream I/O 2024-09-01 10:02:36 +02:00
Jonas Schäfer
51884eedf7 Fix missing copyright header 2024-08-30 15:40:32 +02:00
Jonas Schäfer
c85c98b0bf xmlstream: improve responder-side of stream resets
This makes the stream resets a lot safer, by preventing the forbidden
send-read-reset combination of events: the reset function on the
responder side now takes the element to send right before the reset,
enforcing a send-reset pattern.
2024-08-29 16:47:13 +02:00
Jonas Schäfer
ab10e30ac0 Port crates to use new XSO-based xmlstream 2024-08-29 16:47:13 +02:00
Jonas Schäfer
7cfda820a6 xmlstream: introduce XMPP specifics 2024-08-29 16:43:20 +02:00
Jonas Schäfer
2c944ebbf8 xmlstream: add access to inner stream 2024-08-29 16:43:06 +02:00
Jonas Schäfer
2931df22db xmlstream: split initiation reset in two phases 2024-08-29 16:43:00 +02:00
Jonas Schäfer
c723897326 tokio_xmpp: introduce xmlstream module
This module provides XSO-based parsing, proper typestates and will
soon replace the proto module.
2024-08-29 16:42:57 +02:00
schnell
274baaef9a
add support for local trust store for rustls
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2024-08-22 15:38:39 +02:00
Jonas Schäfer
f77c21f0fc Update to rxml 0.12.0 2024-08-12 16:16:32 +02:00
cc3400bac7 Reorganize component modules 2024-08-12 10:59:20 +00:00
e6863bd9dd Reorganized client modules 2024-08-12 10:59:20 +00:00
df106dfbaf Relative dependencies 2024-08-12 10:39:09 +00:00
c63b554e9e Fix broken link 2024-08-11 20:06:39 +02:00
38baf53de5 Absolute document link 2024-08-11 17:42:58 +00:00
9f4af1625d Component is now behind insecure-tcp feature flag 2024-08-10 18:09:12 +02:00
16a78d3bb5 More documentation for tokio_xmpp 2024-08-10 16:57:51 +02:00
0b58561003 Rename AsyncClient to Client 2024-08-10 16:57:51 +02:00