Remove patches from repo
This commit is contained in:
parent
9eaf050b6a
commit
f57e65d588
|
@ -1,724 +0,0 @@
|
|||
From c8ef14f76841b6db95ce74d20351b1192732e0aa Mon Sep 17 00:00:00 2001
|
||||
From: famfo <famfo@protonmail.com>
|
||||
Date: Thu, 11 Nov 2021 09:18:50 +0100
|
||||
Subject: [PATCH] Moved commands to seperate file, fixed ping issue, added
|
||||
authors, bumped version number
|
||||
|
||||
---
|
||||
Cargo.lock | 2 +-
|
||||
Cargo.toml | 3 +-
|
||||
src/commands.rs | 200 +++++++++++++++++++++++++++++++++
|
||||
src/lib.rs | 289 ++++++++++--------------------------------------
|
||||
src/main.rs | 2 +-
|
||||
5 files changed, 262 insertions(+), 234 deletions(-)
|
||||
create mode 100644 src/commands.rs
|
||||
|
||||
diff --git a/Cargo.lock b/Cargo.lock
|
||||
index ef780e2..177eafa 100644
|
||||
--- a/Cargo.lock
|
||||
+++ b/Cargo.lock
|
||||
@@ -28,7 +28,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "circe"
|
||||
-version = "0.1.2"
|
||||
+version = "0.1.3"
|
||||
dependencies = [
|
||||
"native-tls",
|
||||
"serde",
|
||||
diff --git a/Cargo.toml b/Cargo.toml
|
||||
index d1a6ec8..2f551bc 100644
|
||||
--- a/Cargo.toml
|
||||
+++ b/Cargo.toml
|
||||
@@ -1,6 +1,7 @@
|
||||
[package]
|
||||
+authors = ["famfo", "karx"]
|
||||
name = "circe"
|
||||
-version = "0.1.2"
|
||||
+version = "0.1.3"
|
||||
edition = "2021"
|
||||
license = "Unlicense"
|
||||
description = "IRC crate in Rust"
|
||||
diff --git a/src/commands.rs b/src/commands.rs
|
||||
new file mode 100644
|
||||
index 0000000..4532969
|
||||
--- /dev/null
|
||||
+++ b/src/commands.rs
|
||||
@@ -0,0 +1,200 @@
|
||||
+#[doc(hidden)]
|
||||
+#[derive(Debug)]
|
||||
+pub enum CapMode {
|
||||
+ LS,
|
||||
+ END,
|
||||
+}
|
||||
+
|
||||
+/// IRC commands
|
||||
+#[derive(Debug)]
|
||||
+pub enum Command {
|
||||
+ // TODO:
|
||||
+ // SERVICE <nickname> <reserved> <distribution> <type> <reserved> <info>
|
||||
+ // SQUIT <server> <comment>
|
||||
+ //
|
||||
+ /// Gets information about the admin of the IRC server.
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*;
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.admin("192.168.178.100")?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ ADMIN(
|
||||
+ /// Target
|
||||
+ String,
|
||||
+ ),
|
||||
+ /// Sets the user status to AWAY
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*;
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.away("AFK")?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ AWAY(
|
||||
+ /// Message
|
||||
+ String,
|
||||
+ ),
|
||||
+ #[doc(hidden)]
|
||||
+ CAP(CapMode),
|
||||
+ /// Invite user to channel
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*;
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.invite("liblirc", "#circe")?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ INVITE(
|
||||
+ /// User
|
||||
+ String,
|
||||
+ /// Channel
|
||||
+ String,
|
||||
+ ),
|
||||
+ /// Joins a channel
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*;
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.join("#main")?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ JOIN(
|
||||
+ /// Channel
|
||||
+ String,
|
||||
+ ),
|
||||
+ /// Lists all channels and their topics
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*;
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.list(None, None)?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ LIST(
|
||||
+ /// Channel
|
||||
+ Option<String>,
|
||||
+ /// Server to foreward request to
|
||||
+ Option<String>,
|
||||
+ ),
|
||||
+ /// Sets the mode of the user
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*;
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.mode("test", Some("+B"))?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ /// If the MODE is not given (e.g. None), then the client will send "MODE target"
|
||||
+ MODE(
|
||||
+ /// Channel
|
||||
+ String,
|
||||
+ /// Mode
|
||||
+ Option<String>,
|
||||
+ ),
|
||||
+ /// List all nicknames visiable to the Client
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*;
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.names("#main,#circe", None)?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ NAMES(
|
||||
+ /// Channel
|
||||
+ String,
|
||||
+ /// Server to foreward request to
|
||||
+ Option<String>,
|
||||
+ ),
|
||||
+ #[doc(hidden)]
|
||||
+ NICK(String),
|
||||
+ /// Attempts to identify as a channel operator
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*;
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.oper("circe", "foo")?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ OPER(
|
||||
+ /// Username
|
||||
+ String,
|
||||
+ /// Password
|
||||
+ String,
|
||||
+ ),
|
||||
+ /// Everything that is not a command
|
||||
+ OTHER(String),
|
||||
+ /// Leave a channel
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.part("#main")?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ PART(
|
||||
+ /// Target
|
||||
+ String,
|
||||
+ ),
|
||||
+ #[doc(hidden)]
|
||||
+ PASS(String),
|
||||
+ #[doc(hidden)]
|
||||
+ PING(String),
|
||||
+ #[doc(hidden)]
|
||||
+ PONG(String),
|
||||
+ /// Sends a message in a channel
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*;
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.privmsg("This is an example message")?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ PRIVMSG(
|
||||
+ /// Channel
|
||||
+ String,
|
||||
+ /// Message
|
||||
+ String,
|
||||
+ ),
|
||||
+ /// Leaves the IRC
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.quit(Some("Leaving..."))?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ QUIT(
|
||||
+ /// Leave message
|
||||
+ String,
|
||||
+ ),
|
||||
+ /// Sets or gets the topic of a channel
|
||||
+ /// ```no_run
|
||||
+ /// # use circe::*
|
||||
+ /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
+ /// client.topic("#main", Some("main channel"))?;
|
||||
+ /// # Ok::<(), std::io::Error>(())
|
||||
+ /// ```
|
||||
+ TOPIC(
|
||||
+ /// Channel
|
||||
+ String,
|
||||
+ /// Topic
|
||||
+ Option<String>,
|
||||
+ ),
|
||||
+ #[doc(hidden)]
|
||||
+ USER(String, String, String, String),
|
||||
+}
|
||||
+
|
||||
+impl Command {
|
||||
+ /// Performs the conversion
|
||||
+ pub fn from_str(s: &str) -> Self {
|
||||
+ let new = s.trim();
|
||||
+ let parts: Vec<&str> = new.split_whitespace().collect();
|
||||
+
|
||||
+ if parts[0] == "PING" {
|
||||
+ let command = parts[1].to_string();
|
||||
+ return Self::PONG(command);
|
||||
+ } else if parts[1] == "PRIVMSG" {
|
||||
+ let target = parts[2];
|
||||
+ let mut builder = String::new();
|
||||
+
|
||||
+ for part in parts[3..].to_vec() {
|
||||
+ builder.push_str(&format!("{} ", part));
|
||||
+ }
|
||||
+
|
||||
+ return Self::PRIVMSG(target.to_string(), (&builder[1..]).to_string());
|
||||
+ }
|
||||
+
|
||||
+ Self::OTHER(new.to_string())
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/lib.rs b/src/lib.rs
|
||||
index 99452e0..607fce0 100644
|
||||
--- a/src/lib.rs
|
||||
+++ b/src/lib.rs
|
||||
@@ -31,6 +31,9 @@ use std::path::Path;
|
||||
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
+/// IRC comamnds
|
||||
+pub mod commands;
|
||||
+
|
||||
/// An IRC client
|
||||
pub struct Client {
|
||||
config: Config,
|
||||
@@ -50,206 +53,6 @@ pub struct Config {
|
||||
username: String,
|
||||
}
|
||||
|
||||
-#[doc(hidden)]
|
||||
-#[derive(Debug)]
|
||||
-pub enum CapMode {
|
||||
- LS,
|
||||
- END,
|
||||
-}
|
||||
-
|
||||
-/// IRC commands
|
||||
-#[derive(Debug)]
|
||||
-pub enum Command {
|
||||
- // TODO:
|
||||
- // SERVICE <nickname> <reserved> <distribution> <type> <reserved> <info>
|
||||
- // SQUIT <server> <comment>
|
||||
- //
|
||||
- /// Gets information about the admin of the IRC server.
|
||||
- /// ```no_run
|
||||
- /// # use circe::*;
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.admin("192.168.178.100")?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- ADMIN(
|
||||
- /// Target
|
||||
- String,
|
||||
- ),
|
||||
- /// Sets the user status to AWAY
|
||||
- /// ```no_run
|
||||
- /// # use circe::*;
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.away("AFK")?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- AWAY(
|
||||
- /// Message
|
||||
- String,
|
||||
- ),
|
||||
- #[doc(hidden)]
|
||||
- CAP(CapMode),
|
||||
- /// Invite user to channel
|
||||
- /// ```no_run
|
||||
- /// # use circe::*;
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.invite("liblirc", "#circe")?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- INVITE(
|
||||
- /// User
|
||||
- String,
|
||||
- /// Channel
|
||||
- String,
|
||||
- ),
|
||||
- /// Joins a channel
|
||||
- /// ```no_run
|
||||
- /// # use circe::*;
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.join("#main")?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- JOIN(
|
||||
- /// Channel
|
||||
- String,
|
||||
- ),
|
||||
- /// Lists all channels and their topics
|
||||
- /// ```no_run
|
||||
- /// # use circe::*;
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.list(None, None)?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- LIST(
|
||||
- /// Channel
|
||||
- Option<String>,
|
||||
- // Server
|
||||
- Option<String>,
|
||||
- ),
|
||||
- /// Sets the mode of the user
|
||||
- /// ```no_run
|
||||
- /// # use circe::*;
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.mode("test", Some("+B"))?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- /// If the MODE is not given (e.g. None), then the client will send "MODE target"
|
||||
- MODE(
|
||||
- /// Channel
|
||||
- String,
|
||||
- /// Mode
|
||||
- Option<String>,
|
||||
- ),
|
||||
- /// List all nicknames visiable to the Client
|
||||
- /// ```no_run
|
||||
- /// # use circe::*;
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.names("#main,#circe", None)?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- NAMES(
|
||||
- /// Channel
|
||||
- String,
|
||||
- /// Server to foreward request to
|
||||
- Option<String>,
|
||||
- ),
|
||||
- #[doc(hidden)]
|
||||
- NICK(String),
|
||||
- /// Attempts to identify as a channel operator
|
||||
- /// ```no_run
|
||||
- /// # use circe::*;
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.oper("circe", "foo")?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- OPER(
|
||||
- /// Username
|
||||
- String,
|
||||
- /// Password
|
||||
- String,
|
||||
- ),
|
||||
- /// Everything that is not a command
|
||||
- OTHER(String),
|
||||
- /// Leave a channel
|
||||
- /// ```no_run
|
||||
- /// # use circe::*
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.part("#main")?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- PART(
|
||||
- /// Target
|
||||
- String,
|
||||
- ),
|
||||
- #[doc(hidden)]
|
||||
- PASS(String),
|
||||
- #[doc(hidden)]
|
||||
- PING(String),
|
||||
- #[doc(hidden)]
|
||||
- PONG(String),
|
||||
- /// Sends a message in a channel
|
||||
- /// ```no_run
|
||||
- /// # use circe::*;
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.privmsg("This is an example message")?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- PRIVMSG(
|
||||
- /// Channel
|
||||
- String,
|
||||
- /// Message
|
||||
- String,
|
||||
- ),
|
||||
- /// Leaves the IRC
|
||||
- /// ```no_run
|
||||
- /// # use circe::*
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.quit(Some("Leaving..."))?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- QUIT(
|
||||
- /// Leave message
|
||||
- String,
|
||||
- ),
|
||||
- /// Sets or gets the topic of a channel
|
||||
- /// ```no_run
|
||||
- /// # use circe::*
|
||||
- /// # let mut client = Client::new(Config::from_toml("config.toml")?)?;
|
||||
- /// client.topic("#main", Some("main channel"))?;
|
||||
- /// # Ok::<(), std::io::Error>(())
|
||||
- /// ```
|
||||
- TOPIC(
|
||||
- /// Channel
|
||||
- String,
|
||||
- /// Topic
|
||||
- Option<String>,
|
||||
- ),
|
||||
- #[doc(hidden)]
|
||||
- USER(String, String, String, String),
|
||||
-}
|
||||
-
|
||||
-impl Command {
|
||||
- fn from_str(s: &str) -> Self {
|
||||
- let new = s.trim();
|
||||
-
|
||||
- if new.starts_with("PING") {
|
||||
- let command = new.split_whitespace().collect::<Vec<&str>>()[1].to_string();
|
||||
- return Self::PONG(command);
|
||||
- } else if new.contains("PRIVMSG") {
|
||||
- let parts: Vec<&str> = new.split_whitespace().collect();
|
||||
- let target = parts[2];
|
||||
- let mut builder = String::new();
|
||||
-
|
||||
- for part in parts[3..].to_vec() {
|
||||
- builder.push_str(&format!("{} ", part));
|
||||
- }
|
||||
-
|
||||
- return Self::PRIVMSG(target.to_string(), (&builder[1..]).to_string());
|
||||
- }
|
||||
-
|
||||
- Self::OTHER(new.to_string())
|
||||
- }
|
||||
-}
|
||||
-
|
||||
impl Client {
|
||||
/// Creates a new client with a given [`Config`].
|
||||
/// ```no_run
|
||||
@@ -291,8 +94,10 @@ impl Client {
|
||||
/// ```
|
||||
/// Returns error if the client could not write to the stream.
|
||||
pub fn identify(&mut self) -> Result<(), Error> {
|
||||
- self.write_command(Command::CAP(CapMode::END))?;
|
||||
- self.write_command(Command::USER(
|
||||
+ self.write_command(commands::Command::CAP(commands::CapMode::LS))?;
|
||||
+ self.write_command(commands::Command::CAP(commands::CapMode::END))?;
|
||||
+
|
||||
+ self.write_command(commands::Command::USER(
|
||||
self.config.username.clone(),
|
||||
"*".into(),
|
||||
"*".into(),
|
||||
@@ -300,19 +105,19 @@ impl Client {
|
||||
))?;
|
||||
|
||||
if let Some(nick) = self.config.nickname.clone() {
|
||||
- self.write_command(Command::NICK(nick.to_string()))?;
|
||||
+ self.write_command(commands::Command::NICK(nick.to_string()))?;
|
||||
} else {
|
||||
- self.write_command(Command::NICK(self.config.username.clone()))?;
|
||||
+ self.write_command(commands::Command::NICK(self.config.username.clone()))?;
|
||||
}
|
||||
|
||||
loop {
|
||||
if let Ok(ref command) = self.read() {
|
||||
match command {
|
||||
- Command::PING(code) => {
|
||||
+ commands::Command::PING(code) => {
|
||||
println!("{}", code);
|
||||
- self.write_command(Command::PONG(code.to_string()))?;
|
||||
+ self.write_command(commands::Command::PONG(code.to_string()))?;
|
||||
}
|
||||
- Command::OTHER(line) => {
|
||||
+ commands::Command::OTHER(line) => {
|
||||
print!("{}", line);
|
||||
if line.contains("001") {
|
||||
break;
|
||||
@@ -324,9 +129,9 @@ impl Client {
|
||||
}
|
||||
|
||||
let config = self.config.clone();
|
||||
- self.write_command(Command::MODE(config.username, config.mode))?;
|
||||
+ self.write_command(commands::Command::MODE(config.username, config.mode))?;
|
||||
for channel in config.channels.iter() {
|
||||
- self.write_command(Command::JOIN(channel.to_string()))?;
|
||||
+ self.write_command(commands::Command::JOIN(channel.to_string()))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -350,7 +155,7 @@ impl Client {
|
||||
Some(String::from_utf8_lossy(&buffer).into())
|
||||
}
|
||||
|
||||
- /// Read data coming from the IRC as a [`Command`].
|
||||
+ /// Read data coming from the IRC as a [`commands::Command`].
|
||||
/// ```no_run
|
||||
/// # use circe::*;
|
||||
/// # fn main() -> Result<(), std::io::Error> {
|
||||
@@ -365,9 +170,18 @@ impl Client {
|
||||
/// # }
|
||||
/// ```
|
||||
/// Returns error if there are no new messages. This should not be taken as an actual error, because nothing went wrong.
|
||||
- pub fn read(&mut self) -> Result<Command, ()> {
|
||||
+ pub fn read(&mut self) -> Result<commands::Command, ()> {
|
||||
if let Some(string) = self.read_string() {
|
||||
- return Ok(Command::from_str(&string));
|
||||
+ let command = commands::Command::from_str(&string);
|
||||
+
|
||||
+ if let commands::Command::PONG(command) = command {
|
||||
+ if let Err(_e) = self.write_command(commands::Command::PONG(command)) {
|
||||
+ return Err(());
|
||||
+ }
|
||||
+ return Ok(commands::Command::PONG("".to_string()));
|
||||
+ }
|
||||
+
|
||||
+ return Ok(command);
|
||||
}
|
||||
|
||||
Err(())
|
||||
@@ -394,7 +208,7 @@ impl Client {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
- /// Send a [`Command`] to the IRC.<br>
|
||||
+ /// Send a [`commands::Command`] to the IRC.<br>
|
||||
/// Not reccomended to use, use the helper functions instead.
|
||||
/// ```no_run
|
||||
/// # use circe::*;
|
||||
@@ -403,8 +217,8 @@ impl Client {
|
||||
/// # Ok::<(), std::io::Error>(())
|
||||
/// ```
|
||||
/// Returns error if the client could not write to the stream.
|
||||
- pub fn write_command(&mut self, command: Command) -> Result<(), Error> {
|
||||
- use Command::*;
|
||||
+ pub fn write_command(&mut self, command: commands::Command) -> Result<(), Error> {
|
||||
+ use commands::Command::*;
|
||||
let computed = match command {
|
||||
ADMIN(target) => {
|
||||
let formatted = format!("ADMIN {}", target);
|
||||
@@ -415,7 +229,7 @@ impl Client {
|
||||
Cow::Owned(formatted) as Cow<str>
|
||||
}
|
||||
CAP(mode) => {
|
||||
- use CapMode::*;
|
||||
+ use commands::CapMode::*;
|
||||
Cow::Borrowed(match mode {
|
||||
LS => "CAP LS 302",
|
||||
END => "CAP END",
|
||||
@@ -487,6 +301,7 @@ impl Client {
|
||||
}
|
||||
PONG(code) => {
|
||||
let formatted = format!("PONG {}", code);
|
||||
+ println!("formatted\nPONG {}", formatted);
|
||||
Cow::Owned(formatted) as Cow<str>
|
||||
}
|
||||
PRIVMSG(target, message) => {
|
||||
@@ -527,7 +342,7 @@ impl Client {
|
||||
/// # Ok::<(), std::io::Error>(())
|
||||
/// ```
|
||||
pub fn admin(&mut self, target: &str) -> Result<(), Error> {
|
||||
- self.write_command(Command::ADMIN(target.to_string()))?;
|
||||
+ self.write_command(commands::Command::ADMIN(target.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -539,7 +354,7 @@ impl Client {
|
||||
/// # Ok::<(), std::io::Error>(())
|
||||
/// ```
|
||||
pub fn away(&mut self, message: &str) -> Result<(), Error> {
|
||||
- self.write_command(Command::AWAY(message.to_string()))?;
|
||||
+ self.write_command(commands::Command::AWAY(message.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -551,7 +366,10 @@ impl Client {
|
||||
/// # Ok::<(), std::io::Error>(())
|
||||
/// ```
|
||||
pub fn privmsg(&mut self, channel: &str, message: &str) -> Result<(), Error> {
|
||||
- self.write_command(Command::PRIVMSG(channel.to_string(), message.to_string()))?;
|
||||
+ self.write_command(commands::Command::PRIVMSG(
|
||||
+ channel.to_string(),
|
||||
+ message.to_string(),
|
||||
+ ))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -563,7 +381,10 @@ impl Client {
|
||||
/// # Ok::<(), std::io::Error>(())
|
||||
/// ```
|
||||
pub fn invite(&mut self, username: &str, channel: &str) -> Result<(), Error> {
|
||||
- self.write_command(Command::INVITE(username.to_string(), channel.to_string()))?;
|
||||
+ self.write_command(commands::Command::INVITE(
|
||||
+ username.to_string(),
|
||||
+ channel.to_string(),
|
||||
+ ))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -575,7 +396,7 @@ impl Client {
|
||||
/// # Ok::<(), std::io::Error>(())
|
||||
/// ```
|
||||
pub fn join(&mut self, channel: &str) -> Result<(), Error> {
|
||||
- self.write_command(Command::JOIN(channel.to_string()))?;
|
||||
+ self.write_command(commands::Command::JOIN(channel.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -601,7 +422,7 @@ impl Client {
|
||||
None
|
||||
}
|
||||
};
|
||||
- self.write_command(Command::LIST(channel_config, server_config))?;
|
||||
+ self.write_command(commands::Command::LIST(channel_config, server_config))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -614,12 +435,12 @@ impl Client {
|
||||
/// ```
|
||||
pub fn names(&mut self, channel: &str, server: Option<&str>) -> Result<(), Error> {
|
||||
if let Some(server) = server {
|
||||
- self.write_command(Command::NAMES(
|
||||
+ self.write_command(commands::Command::NAMES(
|
||||
channel.to_string(),
|
||||
Some(server.to_string()),
|
||||
))?;
|
||||
} else {
|
||||
- self.write_command(Command::NAMES(channel.to_string(), None))?;
|
||||
+ self.write_command(commands::Command::NAMES(channel.to_string(), None))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -633,9 +454,12 @@ impl Client {
|
||||
/// ```
|
||||
pub fn mode(&mut self, target: &str, mode: Option<&str>) -> Result<(), Error> {
|
||||
if let Some(mode) = mode {
|
||||
- self.write_command(Command::MODE(target.to_string(), Some(mode.to_string())))?;
|
||||
+ self.write_command(commands::Command::MODE(
|
||||
+ target.to_string(),
|
||||
+ Some(mode.to_string()),
|
||||
+ ))?;
|
||||
} else {
|
||||
- self.write_command(Command::MODE(target.to_string(), None))?;
|
||||
+ self.write_command(commands::Command::MODE(target.to_string(), None))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -648,7 +472,7 @@ impl Client {
|
||||
/// # Ok::<(), std::io::Error>(())
|
||||
/// ```
|
||||
pub fn part(&mut self, target: &str) -> Result<(), Error> {
|
||||
- self.write_command(Command::PART(target.to_string()))?;
|
||||
+ self.write_command(commands::Command::PART(target.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -661,9 +485,12 @@ impl Client {
|
||||
/// ```
|
||||
pub fn topic(&mut self, channel: &str, topic: Option<&str>) -> Result<(), Error> {
|
||||
if let Some(topic) = topic {
|
||||
- self.write_command(Command::TOPIC(channel.to_string(), Some(topic.to_string())))?;
|
||||
+ self.write_command(commands::Command::TOPIC(
|
||||
+ channel.to_string(),
|
||||
+ Some(topic.to_string()),
|
||||
+ ))?;
|
||||
} else {
|
||||
- self.write_command(Command::TOPIC(channel.to_string(), None))?;
|
||||
+ self.write_command(commands::Command::TOPIC(channel.to_string(), None))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -677,9 +504,9 @@ impl Client {
|
||||
/// ```
|
||||
pub fn quit(&mut self, message: Option<&str>) -> Result<(), Error> {
|
||||
if let Some(message) = message {
|
||||
- self.write_command(Command::QUIT(message.to_string()))?;
|
||||
+ self.write_command(commands::Command::QUIT(message.to_string()))?;
|
||||
} else {
|
||||
- self.write_command(Command::QUIT(format!(
|
||||
+ self.write_command(commands::Command::QUIT(format!(
|
||||
"circe {} (https://crates.io/crates/circe)",
|
||||
env!("CARGO_PKG_VERSION")
|
||||
)))?;
|
||||
diff --git a/src/main.rs b/src/main.rs
|
||||
index 0f63a35..d0d84dd 100644
|
||||
--- a/src/main.rs
|
||||
+++ b/src/main.rs
|
||||
@@ -1,4 +1,4 @@
|
||||
-use circe::{Client, Command, Config};
|
||||
+use circe::{commands::Command, Client, Config};
|
||||
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! loop_n {
|
||||
--
|
||||
2.33.1
|
||||
|
|
@ -1,425 +0,0 @@
|
|||
From 2b0c2a3a698f737d87cd0dad6814d8bb1e164d22 Mon Sep 17 00:00:00 2001
|
||||
From: famfo <famfo@protonmail.com>
|
||||
Date: Tue, 9 Nov 2021 16:22:10 +0100
|
||||
Subject: [PATCH] Switched to native-tls, altered the authentification
|
||||
|
||||
---
|
||||
Cargo.lock | 212 +++++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
Cargo.toml | 3 +-
|
||||
config.toml | 3 +-
|
||||
src/lib.rs | 29 +++++--
|
||||
src/main.rs | 4 +-
|
||||
5 files changed, 229 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/Cargo.lock b/Cargo.lock
|
||||
index 6c064b1..ef780e2 100644
|
||||
--- a/Cargo.lock
|
||||
+++ b/Cargo.lock
|
||||
@@ -30,13 +30,28 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
name = "circe"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
- "openssl",
|
||||
- "openssl-sys",
|
||||
+ "native-tls",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"toml",
|
||||
]
|
||||
|
||||
+[[package]]
|
||||
+name = "core-foundation"
|
||||
+version = "0.9.2"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3"
|
||||
+dependencies = [
|
||||
+ "core-foundation-sys",
|
||||
+ "libc",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "core-foundation-sys"
|
||||
+version = "0.8.3"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
||||
+
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
@@ -52,12 +67,56 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
+[[package]]
|
||||
+name = "getrandom"
|
||||
+version = "0.2.3"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
|
||||
+dependencies = [
|
||||
+ "cfg-if",
|
||||
+ "libc",
|
||||
+ "wasi",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "lazy_static"
|
||||
+version = "1.4.0"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
+
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219"
|
||||
|
||||
+[[package]]
|
||||
+name = "log"
|
||||
+version = "0.4.14"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
+dependencies = [
|
||||
+ "cfg-if",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "native-tls"
|
||||
+version = "0.2.8"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d"
|
||||
+dependencies = [
|
||||
+ "lazy_static",
|
||||
+ "libc",
|
||||
+ "log",
|
||||
+ "openssl",
|
||||
+ "openssl-probe",
|
||||
+ "openssl-sys",
|
||||
+ "schannel",
|
||||
+ "security-framework",
|
||||
+ "security-framework-sys",
|
||||
+ "tempfile",
|
||||
+]
|
||||
+
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.8.0"
|
||||
@@ -79,13 +138,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
-name = "openssl-src"
|
||||
-version = "300.0.2+3.0.0"
|
||||
+name = "openssl-probe"
|
||||
+version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
-checksum = "14a760a11390b1a5daf72074d4f6ff1a6e772534ae191f999f57e9ee8146d1fb"
|
||||
-dependencies = [
|
||||
- "cc",
|
||||
-]
|
||||
+checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
@@ -96,7 +152,6 @@ dependencies = [
|
||||
"autocfg",
|
||||
"cc",
|
||||
"libc",
|
||||
- "openssl-src",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
@@ -107,6 +162,12 @@ version = "0.3.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f"
|
||||
|
||||
+[[package]]
|
||||
+name = "ppv-lite86"
|
||||
+version = "0.2.15"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba"
|
||||
+
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.32"
|
||||
@@ -125,6 +186,97 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
+[[package]]
|
||||
+name = "rand"
|
||||
+version = "0.8.4"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
|
||||
+dependencies = [
|
||||
+ "libc",
|
||||
+ "rand_chacha",
|
||||
+ "rand_core",
|
||||
+ "rand_hc",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "rand_chacha"
|
||||
+version = "0.3.1"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
+dependencies = [
|
||||
+ "ppv-lite86",
|
||||
+ "rand_core",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "rand_core"
|
||||
+version = "0.6.3"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
|
||||
+dependencies = [
|
||||
+ "getrandom",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "rand_hc"
|
||||
+version = "0.3.1"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
|
||||
+dependencies = [
|
||||
+ "rand_core",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "redox_syscall"
|
||||
+version = "0.2.10"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
|
||||
+dependencies = [
|
||||
+ "bitflags",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "remove_dir_all"
|
||||
+version = "0.5.3"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
|
||||
+dependencies = [
|
||||
+ "winapi",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "schannel"
|
||||
+version = "0.1.19"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
|
||||
+dependencies = [
|
||||
+ "lazy_static",
|
||||
+ "winapi",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "security-framework"
|
||||
+version = "2.4.2"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87"
|
||||
+dependencies = [
|
||||
+ "bitflags",
|
||||
+ "core-foundation",
|
||||
+ "core-foundation-sys",
|
||||
+ "libc",
|
||||
+ "security-framework-sys",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "security-framework-sys"
|
||||
+version = "2.4.2"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e"
|
||||
+dependencies = [
|
||||
+ "core-foundation-sys",
|
||||
+ "libc",
|
||||
+]
|
||||
+
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.130"
|
||||
@@ -153,6 +305,20 @@ dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
+[[package]]
|
||||
+name = "tempfile"
|
||||
+version = "3.2.0"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
|
||||
+dependencies = [
|
||||
+ "cfg-if",
|
||||
+ "libc",
|
||||
+ "rand",
|
||||
+ "redox_syscall",
|
||||
+ "remove_dir_all",
|
||||
+ "winapi",
|
||||
+]
|
||||
+
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.8"
|
||||
@@ -173,3 +339,31 @@ name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
+
|
||||
+[[package]]
|
||||
+name = "wasi"
|
||||
+version = "0.10.2+wasi-snapshot-preview1"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
+
|
||||
+[[package]]
|
||||
+name = "winapi"
|
||||
+version = "0.3.9"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
+dependencies = [
|
||||
+ "winapi-i686-pc-windows-gnu",
|
||||
+ "winapi-x86_64-pc-windows-gnu",
|
||||
+]
|
||||
+
|
||||
+[[package]]
|
||||
+name = "winapi-i686-pc-windows-gnu"
|
||||
+version = "0.4.0"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
+
|
||||
+[[package]]
|
||||
+name = "winapi-x86_64-pc-windows-gnu"
|
||||
+version = "0.4.0"
|
||||
+source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
diff --git a/Cargo.toml b/Cargo.toml
|
||||
index 8344465..d1a6ec8 100644
|
||||
--- a/Cargo.toml
|
||||
+++ b/Cargo.toml
|
||||
@@ -14,5 +14,4 @@ exclude = ["src/main.rs", "config.toml"]
|
||||
toml = "0.5"
|
||||
serde_derive = "1.0"
|
||||
serde = "1.0"
|
||||
-openssl = { version = "0.10", features = ["vendored"] }
|
||||
-openssl-sys = "0.9"
|
||||
+native-tls = "0.2"
|
||||
diff --git a/config.toml b/config.toml
|
||||
index 218d06a..ac31732 100644
|
||||
--- a/config.toml
|
||||
+++ b/config.toml
|
||||
@@ -1,6 +1,7 @@
|
||||
channels = ["#main", "#circe"]
|
||||
-host = "192.168.1.28"
|
||||
+host = "192.168.178.100"
|
||||
mode = "+B"
|
||||
nickname = "circe"
|
||||
port = 6667
|
||||
username = "circe"
|
||||
+ssl = false
|
||||
diff --git a/src/lib.rs b/src/lib.rs
|
||||
index 6cf2a0d..6fd0178 100644
|
||||
--- a/src/lib.rs
|
||||
+++ b/src/lib.rs
|
||||
@@ -21,7 +21,8 @@
|
||||
//! }
|
||||
|
||||
#![warn(missing_docs)]
|
||||
-use openssl::ssl::{SslConnector, SslMethod};
|
||||
+use native_tls::TlsConnector;
|
||||
+
|
||||
use std::borrow::Cow;
|
||||
use std::fs::File;
|
||||
use std::io::{Error, Read, Write};
|
||||
@@ -34,7 +35,7 @@ use serde_derive::Deserialize;
|
||||
pub struct Client {
|
||||
config: Config,
|
||||
stream: Option<TcpStream>,
|
||||
- sslstream: Option<openssl::ssl::SslStream<TcpStream>>,
|
||||
+ sslstream: Option<native_tls::TlsStream<TcpStream>>,
|
||||
}
|
||||
|
||||
/// Config for the IRC client
|
||||
@@ -261,11 +262,12 @@ impl Client {
|
||||
/// Returns error if the client could not connect to the host.
|
||||
pub fn new(config: Config) -> Result<Self, Error> {
|
||||
let stream = TcpStream::connect(format!("{}:{}", config.host, config.port))?;
|
||||
- let sslstream: openssl::ssl::SslStream<TcpStream>;
|
||||
+ let sslstream: native_tls::TlsStream<TcpStream>;
|
||||
|
||||
if config.ssl {
|
||||
- let connector = SslConnector::builder(SslMethod::tls())?.build();
|
||||
+ let connector = TlsConnector::new().unwrap();
|
||||
sslstream = connector.connect(config.host.as_str(), stream).unwrap();
|
||||
+
|
||||
return Ok(Self {
|
||||
config,
|
||||
stream: None,
|
||||
@@ -289,7 +291,8 @@ impl Client {
|
||||
/// ```
|
||||
/// Returns error if the client could not write to the stream.
|
||||
pub fn identify(&mut self) -> Result<(), Error> {
|
||||
- self.write_command(Command::CAP(CapMode::END))?;
|
||||
+ self.write_command(Command::CAP(CapMode::LS))?;
|
||||
+
|
||||
self.write_command(Command::USER(
|
||||
self.config.username.clone(),
|
||||
"*".into(),
|
||||
@@ -303,11 +306,17 @@ impl Client {
|
||||
self.write_command(Command::NICK(self.config.username.clone()))?;
|
||||
}
|
||||
|
||||
+ self.write_command(Command::CAP(CapMode::END))?;
|
||||
+
|
||||
loop {
|
||||
if let Ok(ref command) = self.read() {
|
||||
match command {
|
||||
- Command::PING(code) => self.write_command(Command::PONG(code.to_string()))?,
|
||||
+ Command::PING(code) => {
|
||||
+ println!("{}", code);
|
||||
+ self.write_command(Command::PONG(code.to_string()))?;
|
||||
+ }
|
||||
Command::OTHER(line) => {
|
||||
+ print!("{}", line);
|
||||
if line.contains("001") {
|
||||
break;
|
||||
}
|
||||
@@ -376,7 +385,8 @@ impl Client {
|
||||
self.sslstream
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
- .write(formatted.as_bytes())?;
|
||||
+ .write(formatted.as_bytes())
|
||||
+ .unwrap();
|
||||
} else {
|
||||
self.stream.as_mut().unwrap().write(formatted.as_bytes())?;
|
||||
}
|
||||
@@ -677,7 +687,10 @@ impl Client {
|
||||
if self.config.ssl {
|
||||
self.sslstream.as_mut().unwrap().shutdown().unwrap();
|
||||
} else {
|
||||
- self.stream.as_mut().unwrap().shutdown(std::net::Shutdown::Both)?;
|
||||
+ self.stream
|
||||
+ .as_mut()
|
||||
+ .unwrap()
|
||||
+ .shutdown(std::net::Shutdown::Both)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
diff --git a/src/main.rs b/src/main.rs
|
||||
index d440be5..0f63a35 100644
|
||||
--- a/src/main.rs
|
||||
+++ b/src/main.rs
|
||||
@@ -20,8 +20,8 @@ fn main() -> Result<(), std::io::Error> {
|
||||
true,
|
||||
"circe",
|
||||
);
|
||||
- let mut client = Client::new(config)?;
|
||||
- client.identify()?;
|
||||
+ let mut client = Client::new(config).unwrap();
|
||||
+ client.identify().unwrap();
|
||||
|
||||
loop {
|
||||
if let Ok(ref command) = client.read() {
|
||||
--
|
||||
2.33.1
|
||||
|
Loading…
Reference in a new issue