Commit graph

2197 commits

Author SHA1 Message Date
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
Jonas Schäfer
a503c8534f parsers: add support for handled-count-too-high error 2024-09-01 13:01:29 +02:00
Jonas Schäfer
0f0759b207 parsers: add support for <optional/> in stream management feature 2024-09-01 13:01:29 +02: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
bfe723cf46 parsers: make stream errors more ergonomic for error processing 2024-09-01 08:54:50 +00:00
Jonas Schäfer
b39ad99ecd parsers: add stream error XSO 2024-09-01 08:54:50 +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
c01eb090b8 xso-proc: improve error messages on cast mismatch for extracts
The old error message was pointing at the `FromXml` / `AsXml` invocation
and not on the field which actually caused the problem. The new error
message points exactly at the type of the affected field.
2024-08-31 10:50:44 +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
xmppftw
cc3400bac7 Reorganize component modules 2024-08-12 10:59:20 +00:00
xmppftw
e6863bd9dd Reorganized client modules 2024-08-12 10:59:20 +00:00
xmppftw
46dc30c045 Deny doc warnings in Gitlab CI
Github/Gitea/Forgejo CI not affected because it doesnt build docs yet
2024-08-12 10:47:23 +00:00
xmppftw
df106dfbaf Relative dependencies 2024-08-12 10:39:09 +00:00
Jonas Schäfer
54e1a98cde parsers: add starttls XSOs 2024-08-12 12:35:26 +02:00
Jonas Schäfer
3c78310272 parsers: add umbrella enum for SASL elements
This is useful if, for example during stream negotiation, you want to
parse SASL elements and nothing else. It is also useful if you want to
write down an enum of all XMPP-related stream-level elements you accept
and don't want to loose your fingers typing all the SASL options.
2024-08-12 12:32:12 +02:00
Jonas Schäfer
fc68a57757 parsers: provide stub FromXml/AsXml implementations on Presence 2024-08-12 12:32:12 +02:00
Jonas Schäfer
b931af3c25 parsers: provide stub FromXml/AsXml implementations on Iq 2024-08-12 12:32:12 +02:00
Jonas Schäfer
5c990a553c xso: enable rxml macros when enabling xso_proc
We build syn then anyway, so we can build rxml macros, too.
2024-08-12 12:32:12 +02:00
Jonas Schäfer
6b4886857e xso: offer is_xml_whitespace function 2024-08-12 12:32:12 +02:00
xmppftw
c63b554e9e Fix broken link 2024-08-11 20:06:39 +02:00
xmppftw
38baf53de5 Absolute document link 2024-08-11 17:42:58 +00:00
xmppftw
e153468117 Link is link, remove doc warning 2024-08-11 17:22:31 +00:00
Jonas Schäfer
cbc4648b3c parsers: port SASL over to derive macros
You may note that I removed the `exhaustive` flag on the
DefinedCondition enum. This is because other elements in the same
namespace may occur as siblings of that enum, hence using `exhaustive`
may cause incorrect parse errors.

(If parsing attempts to process the `<text/>` child as DefinedCondition
first, DefinedCondition will return a fatal parser error if it is set as
exhaustive because no condition matches `text`.)
2024-08-11 07:58:13 +02:00
Jonas Schäfer
1ecb95881c xso: add support for extracting tuples 2024-08-11 07:58:12 +02:00
Jonas Schäfer
ad2c79cbe7 xso: document some specific trait implementations 2024-08-11 07:45:05 +02:00
Jonas Schäfer
2ff81b3923 xso: add support for fallible parsing and serialisation 2024-08-11 07:45:05 +02:00
Jonas Schäfer
02a928a47c xso: add some tests 2024-08-11 07:45:05 +02:00
Jonas Schäfer
f1ab857c6e xso: move helper iterators and builders into separate module
This declutters the main `xso` namespace. In addition, if (when) we
introduce more complex generic implementations, we might want to have
tests for these, and those can then live there, too, without making the
main `lib.rs` file gigantic (or moving the tests too far away from the
tested code).
2024-08-11 07:45:05 +02:00
xmppftw
9f4af1625d Component is now behind insecure-tcp feature flag 2024-08-10 18:09:12 +02:00
xmppftw
16a78d3bb5 More documentation for tokio_xmpp 2024-08-10 16:57:51 +02:00
xmppftw
0b58561003 Rename AsyncClient to Client 2024-08-10 16:57:51 +02:00
xmppftw
311e7406f0 Make Client and Component more unified, and connectors too 2024-08-10 16:57:49 +02:00
xmppftw
fde4c2b640 Move XmppCodec and XmppStream to proto module 2024-08-10 16:49:26 +02:00