diff options
| author | Max Audron <me@audron.dev> | 2025-12-14 02:28:05 +0100 |
|---|---|---|
| committer | Max Audron <me@audron.dev> | 2025-12-14 02:28:05 +0100 |
| commit | b6a17af38a5aba43bb5767cb082fd46cdf34c0a0 (patch) | |
| tree | a0fa5940bb7faf564d1ce5d9bc22a411e83ffc98 | |
| parent | fix readme badge links (diff) | |
fix non-sasl connection registration
| -rw-r--r-- | Cargo.lock | 13 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/lib.rs | 24 | ||||
| -rw-r--r-- | src/main.rs | 5 |
4 files changed, 35 insertions, 9 deletions
@@ -923,6 +923,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" [[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] name = "memchr" version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1976,10 +1985,14 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ + "matchers", "nu-ansi-term", + "once_cell", + "regex-automata", "sharded-slab", "smallvec", "thread_local", + "tracing", "tracing-core", "tracing-log", ] @@ -38,7 +38,7 @@ futures = "0.3" tokio = { version = "1", features = ["full", "rt-multi-thread"] } tracing = "0.1" -tracing-subscriber = "0.3" +tracing-subscriber = { version = "0.3", features = [ "env-filter" ] } tracing-futures = "0.2" regex = "1" @@ -74,7 +74,11 @@ impl Bot { if bot.config.server.sasl && bot.config.user.password.is_some() { tracing::info!("initializing sasl"); - bot.sasl_init().await.unwrap() + bot.sasl_init().unwrap() + } else if let Some(password) = bot.config.server.password.as_ref() { + tracing::info!("sending server password"); + bot.irc_client.send(Command::PASS(password.clone()))?; + bot.register_connection()?; } Ok(bot) @@ -86,18 +90,24 @@ impl Bot { &self.figment } - /// Initialize a sasl connection, you usually don't need - /// to run this yourself as it is done during [Bot::new]. - pub async fn sasl_init(&self) -> Result<()> { - self.irc_client - .send_cap_req(&vec![irc::client::prelude::Capability::Sasl])?; + pub fn register_connection(&self) -> Result<()> { self.irc_client .send(Command::NICK(self.config.user.nickname.clone()))?; self.irc_client.send(Command::USER( - self.config.user.nickname.clone(), + self.config.user.username.clone(), "0".to_owned(), self.config.user.realname.clone(), ))?; + + Ok(()) + } + + /// Initialize a sasl connection, you usually don't need + /// to run this yourself as it is done during [Bot::new]. + pub fn sasl_init(&self) -> Result<()> { + self.irc_client + .send_cap_req(&[irc::client::prelude::Capability::Sasl])?; + self.register_connection()?; self.irc_client.send_sasl_plain()?; Ok(()) diff --git a/src/main.rs b/src/main.rs index ef32078..e4c65d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,10 @@ async fn main() { use catinator::catinator; - tracing_subscriber::fmt::init(); + tracing_subscriber::fmt() + .with_max_level(tracing::Level::TRACE) + // .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .init(); rustls::crypto::CryptoProvider::install_default(rustls::crypto::aws_lc_rs::default_provider()) .unwrap(); |
