darkrenaissance/darkfi

darkirc: empty IRC messages causes server disconnect

Closed this issue · 1 comments

An empty IRC message causes the darkirc server to disconnect.

From https://www.rfc-editor.org/rfc/rfc1459

2.3.1 Message format in 'pseudo' BNF

[…] Empty messages are silently ignored, which permits use of the sequence CR-LF between messages without extra problems. […]

The following patch seems to work. Untested with an encrypted TLS connection to darkirc:

diff --git a/bin/darkirc/src/irc/client.rs b/bin/darkirc/src/irc/client.rs
index d54621427..854887410 100644
--- a/bin/darkirc/src/irc/client.rs
+++ b/bin/darkirc/src/irc/client.rs
@@ -317,7 +317,14 @@ impl Client {
         W: AsyncWrite + Unpin,
     {
         if line.is_empty() || line == "\n" || line == "\r\n" {
-            return Err(Error::ParseFailed("Line is empty"))
+            //            return Err(Error::ParseFailed("Line is empty"))
+            // <https://www.rfc-editor.org/rfc/rfc1459> sez 
+            // "2.3.1 Message format in 'pseudo' BNF
+            //
+            // "[…] Empty messages are silently ignored, which permits use
+            // of the sequence CR-LF between messages without extra
+            // problems. […]"
+            return Ok(None); 
         }
 
         let mut line = line.to_string();

Issue fixed in commit 2d805ac