mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
bin/ircd: check on CRLF and LF in clean_input_line() & refactor PING
This commit is contained in:
@@ -173,12 +173,9 @@ impl IrcServerConnection {
|
||||
}
|
||||
}
|
||||
"PING" => {
|
||||
let line_clone = line.clone();
|
||||
let split_line: Vec<&str> = line_clone.split_whitespace().collect();
|
||||
if split_line.len() > 1 {
|
||||
let pong = format!("PONG {}\r\n", split_line[1]);
|
||||
self.reply(&pong).await?;
|
||||
}
|
||||
let pong = tokens.next().ok_or(Error::MalformedPacket)?;
|
||||
let pong = format!("PONG {}\r\n", pong);
|
||||
self.reply(&pong).await?;
|
||||
}
|
||||
"PRIVMSG" => {
|
||||
let channel = tokens.next().ok_or(Error::MalformedPacket)?;
|
||||
@@ -339,15 +336,17 @@ impl IrcServerConnection {
|
||||
return Err(Error::ChannelStopped)
|
||||
}
|
||||
|
||||
if &line[(line.len() - 2)..] != "\r\n" {
|
||||
if &line[(line.len() - 2)..] == "\r\n" {
|
||||
// Remove CRLF
|
||||
line.pop();
|
||||
line.pop();
|
||||
} else if &line[(line.len() - 1)..] == "\n" {
|
||||
line.pop();
|
||||
} else {
|
||||
warn!("Closing connection.");
|
||||
return Err(Error::ChannelStopped)
|
||||
}
|
||||
|
||||
// Remove CRLF
|
||||
line.pop();
|
||||
line.pop();
|
||||
|
||||
Ok(line.clone())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user