Update tokio-xmpp, switch to rustls
Some checks failed
moparisthebest/sendxmpp-rs/pipeline/head There was a failure building this commit

This commit is contained in:
Travis Burtrum 2022-11-04 22:59:46 -04:00
parent 294da89d22
commit 7aff2080df
3 changed files with 453 additions and 773 deletions

1208
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -25,11 +25,10 @@ serde_derive = "1.0"
serde = { version = "1.0", features = ["derive"] }
gumdrop = "0.8.0"
gumdrop_derive = "0.8.0"
dirs = "3.0.1"
tokio-xmpp = "3.0.0"
dirs = "4.0.0"
tokio-xmpp = { version = "3.2.0", default-features = false, features = ["tls-rust"] }
tokio = { version = "1", features = ["net", "rt", "rt-multi-thread", "macros", "io-util", "io-std"] }
tokio-tls = { package = "tokio-native-tls", version = "0.3" }
xmpp-parsers = "0.18"
xmpp-parsers = "0.19"
die = "0.2.0"
anyhow = "1.0"
env_logger = "0.9"

View File

@ -10,14 +10,13 @@ use gumdrop::Options;
use serde_derive::Deserialize;
use std::process::{Command, Stdio};
use tokio_xmpp::{xmpp_stream, SimpleClient as Client};
use tokio_xmpp::{SimpleClient as Client};
use xmpp_parsers::message::{Body, Message, MessageType};
use xmpp_parsers::muc::Muc;
use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType};
use xmpp_parsers::{BareJid, Element, FullJid, Jid};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio_tls::TlsStream;
use anyhow::{anyhow, bail, Result};
@ -121,19 +120,13 @@ async fn main() {
// can paste this to test: <message xmlns="jabber:client" to="travis@burtrum.org" type="chat"><body>woot</body></message>
pub struct OpenClient {
pub stream: xmpp_stream::XMPPStream<TlsStream<tokio::net::TcpStream>>,
}
let client: OpenClient = unsafe { std::mem::transmute(client) };
let mut open_client = client.stream.stream.try_lock().die("could not lock client stream");
let open_client = open_client.get_mut();
let mut open_client = client.into_inner().into_inner();
let mut rd_buf = [0u8; 256]; // todo: proper buffer size?
let mut stdin_buf = rd_buf.clone();
let mut stdin = tokio::io::stdin();
let mut stdout = tokio::io::stdout();
loop {
tokio::select! {
n = open_client.read(&mut rd_buf) => {