Browse Source

Comments SASL support. Quit message shows caller hungup.

Steve Thielemann 3 years ago
parent
commit
0cc8108ceb
2 changed files with 17 additions and 14 deletions
  1. 6 1
      input.cpp
  2. 11 13
      irc.cpp

+ 6 - 1
input.cpp

@@ -249,7 +249,12 @@ bool check_for_input(door::Door &door, ircClient &irc) {
         // handle timeout/hangup/out of time
         if (c < -1) {
           if (!has_quit) {
-            irc.write("QUIT");
+            std::string quit = "QUIT :";
+            if (c == -2)
+              quit += "BBS User Dropped Connection";
+            if (c == -3)
+              quit += "BBS User Out of time";
+            irc.write(quit);
             has_quit = true;
           }
         }

+ 11 - 13
irc.cpp

@@ -568,6 +568,9 @@ void ircClient::receive(std::string &text) {
       // Possibly a CTCP request.  Let's see
       std::string message = msg;
       if ((message[0] == '\x01') and (message[message.size() - 1] == '\x01')) {
+        // CTCP handler
+        // NOTE:  When sent to a channel, the response is sent to the sender.
+
         // CTCP MESSAGE FOUND  strip \x01's
         message.erase(0, 1);
         message.erase(message.size() - 1);
@@ -628,9 +631,6 @@ void ircClient::receive(std::string &text) {
     }
   }
 
-  // CTCP handler
-  // NOTE:  When sent to a channel, the response is sent to the sender.
-
   if (!registered) {
     // We're not registered yet
     if (parts[1] == "433") {
@@ -651,9 +651,11 @@ void ircClient::receive(std::string &text) {
       }
     }
 
+    // SASL Authentication
     if ((parts[1] == "CAP") and (parts[3] == "ACK")) {
       write("AUTHENTICATE PLAIN");
     }
+
     if ((parts[0] == "AUTHENTICATE") and (parts[1] == "+")) {
       std::string userpass;
       userpass.append(1, 0);
@@ -673,6 +675,7 @@ void ircClient::receive(std::string &text) {
     if (parts[1] == "904") {
       // SASL failed
       write("CAP END");
+      // Should we close the connection if we can't authenticate?
     }
 
     if ((parts[1] == "376") or (parts[1] == "422")) {
@@ -686,16 +689,7 @@ void ircClient::receive(std::string &text) {
     }
   }
 
-  if (parts[0] == "ERROR") {
-    // we're outta here.  :O
-    // std::cout << "BANG!" << std::endl;
-  }
-
   message_append(ms);
-
-  // :FROM command TO :rest and ':' is optional
-
-  // std::cout << text << "\n";
 }
 
 /**
@@ -723,12 +717,16 @@ void ircClient::find_max_nick_length(void) {
 
 std::string ircClient::registration(void) {
   std::string text;
+
+  // Initiate SASL authentication
   if (!sasl_plain_password.empty()) {
     text = "CAP REQ :sasl\r\n";
   }
+
   if (!server_password.empty()) {
     text += "PASS " + server_password + "\r\n";
   }
+
   text += "NICK " + nick + "\r\n" + "USER " + username + " 0 * :" + realname +
           "\r\n";
   return text;
@@ -747,4 +745,4 @@ std::string base64encode(const std::string &str) {
   std::string base64(it_base64_t(str.begin()), it_base64_t(str.end()));
   base64.append(writePaddChars, '=');
   return base64;
-}
+}