From 143a0365d0822e6786cdac3530a725bbf450f38f Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Tue, 4 Jul 2023 21:27:15 +0100 Subject: horrible --- src/stanza/mod.rs | 1 + src/stanza/sasl.rs | 32 ++++++++++++++++++++++++++++++++ src/stanza/stream.rs | 7 ++++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/stanza/sasl.rs (limited to 'src/stanza') diff --git a/src/stanza/mod.rs b/src/stanza/mod.rs index baf29e0..4eaa4c2 100644 --- a/src/stanza/mod.rs +++ b/src/stanza/mod.rs @@ -1 +1,2 @@ +pub mod sasl; pub mod stream; diff --git a/src/stanza/sasl.rs b/src/stanza/sasl.rs new file mode 100644 index 0000000..c0e41ab --- /dev/null +++ b/src/stanza/sasl.rs @@ -0,0 +1,32 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Deserialize, PartialEq, Debug)] +pub struct Mechanisms { + #[serde(rename = "$value")] + pub mechanisms: Vec, +} + +#[derive(Deserialize, PartialEq, Debug)] +pub struct Mechanism { + #[serde(rename = "$text")] + pub mechanism: String, +} + +#[derive(Serialize, Debug)] +#[serde(rename = "auth")] +pub struct Auth { + #[serde(rename = "@xmlns")] + pub ns: String, + #[serde(rename = "@mechanism")] + pub mechanism: String, + #[serde(rename = "$text")] + pub sasl_data: Option, +} + +#[derive(Deserialize, Debug)] +pub struct Challenge { + #[serde(rename = "@xmlns")] + pub ns: String, + #[serde(rename = "$text")] + pub sasl_data: String, +} diff --git a/src/stanza/stream.rs b/src/stanza/stream.rs index dde741d..4c0addd 100644 --- a/src/stanza/stream.rs +++ b/src/stanza/stream.rs @@ -1,5 +1,7 @@ use serde::{Deserialize, Serialize}; +use super::sasl::Mechanisms; + #[derive(Serialize, Deserialize)] #[serde(rename = "stream:stream")] struct Stream { @@ -31,6 +33,9 @@ pub enum StreamFeature { #[serde(rename = "starttls")] StartTls, // TODO: other stream features - Sasl, + #[serde(rename = "mechanisms")] + Sasl(Mechanisms), Bind, + #[serde(other)] + Unknown, } -- cgit