erc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Erc-commit] [commit][emacs22] Don't attempt to reconnect if user is ban


From: mwolson
Subject: [Erc-commit] [commit][emacs22] Don't attempt to reconnect if user is banned from server.
Date: Sun, 14 Oct 2007 00:48:26 -0400

commit 84e1cb87d7ee5eb3e58b616294c20aea9e842b07
Author: Diane Murray <address@hidden>
Date:   Mon Aug 14 16:43:32 2006 +0000

    Don't attempt to reconnect if user is banned from server.
    
    * erc-backend.el (erc-server-banned): New variable.
    (erc-server-connect): Set `erc-server-banned' to nil.
    (erc-process-sentinel-1): Use `erc-server-reconnect-p'.
    (erc-server-reconnect-p): New function.  Return non-nil if the
    user wants automatic reconnects and if the user has not been
    banned from the server.  This should fix a bug where ERC gets into
    a loop trying to reconnect with no way to stop it when the user is
    denied access to the server due to a server ban.  It might also
    help when Tor users are blocked from freenode if freenode servers
    send the 465 message before disconnecting.
    (465): Handle "banned from server" error notices.
    
    * ChangeLog: Added changes.
    git-archimport-id: address@hidden/erc--main--0--patch-42

diff --git a/ChangeLog b/ChangeLog
index c9b852a..83edaed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2006-08-14  Diane Murray  <address@hidden>
+
+       * erc-backend.el (erc-server-banned): New variable.
+       (erc-server-connect): Set `erc-server-banned' to nil.
+       (erc-process-sentinel-1): Use `erc-server-reconnect-p'.
+       (erc-server-reconnect-p): New function.  Return non-nil if the
+       user wants automatic reconnects and if the user has not been
+       banned from the server.  This should fix a bug where ERC gets into
+       a loop trying to reconnect with no way to stop it when the user is
+       denied access to the server due to a server ban.  It might also
+       help when Tor users are blocked from freenode if freenode servers
+       send the 465 message before disconnecting.
+       (465): Handle "banned from server" error notices.
+
 2006-08-13  Michael Olson  <address@hidden>
 
        * erc-backend.el (erc-server-timed-out): New variable that
diff --git a/erc-backend.el b/erc-backend.el
index a4a038b..3ce2600 100644
--- a/erc-backend.el
+++ b/erc-backend.el
@@ -190,6 +190,10 @@ This variable is buffer-local.")
   "Non-nil if the IRC server failed to respond to a ping.")
 (make-variable-buffer-local 'erc-server-timed-out)
 
+(defvar erc-server-banned nil
+  "Non-nil if the user is denied access because of a server ban.")
+(make-variable-buffer-local 'erc-server-banned)
+
 (defvar erc-server-lines-sent nil
   "Line counter.")
 (make-variable-buffer-local 'erc-server-lines-sent)
@@ -463,6 +467,7 @@ We will store server variables in the current buffer."
   ;; Misc server variables
   (setq erc-server-quitting nil)
   (setq erc-server-timed-out nil)
+  (setq erc-server-banned nil)
   (let ((time (erc-current-time)))
     (setq erc-server-last-sent-time time)
     (setq erc-server-last-ping-time time)
@@ -531,14 +536,14 @@ action."
           (kill-buffer (current-buffer))))
     ;; unexpected disconnect
     (erc-display-message nil 'error (current-buffer)
-                         (if erc-server-auto-reconnect
+                         (if (erc-server-reconnect-p)
                              'disconnected
                            'disconnected-noreconnect))
     (erc-update-mode-line)
     (erc-set-active-buffer (current-buffer))
     (setq erc-server-last-sent-time 0)
     (setq erc-server-lines-sent 0)
-    (if (and erc-server-auto-reconnect
+    (if (and (erc-server-reconnect-p)
              (or erc-server-timed-out
                  (not (string-match "^deleted" event)))
              ;; open-network-stream-nowait error for connection refused
@@ -551,6 +556,10 @@ action."
       (erc-display-message nil 'error (current-buffer)
                            'terminated ?e event))))
 
+(defun erc-server-reconnect-p ()
+  "Return non-nil if ERC should attempt to reconnect automatically."
+  (and erc-server-auto-reconnect (not erc-server-banned)))
+
 (defun erc-process-sentinel (cproc event)
   "Sentinel function for ERC process."
   (with-current-buffer (process-buffer cproc)
@@ -1736,6 +1745,14 @@ See `erc-display-server-message'." nil
                        ?c (second (erc-response.command-args parsed))
                        ?m (erc-response.contents parsed)))
 
+(define-erc-response-handler (465)
+  "You are banned from this server." nil
+  (setq erc-server-banned t)
+  ;; show the server's message, as a reason might be provided
+  (erc-display-error-notice
+   parsed
+   (erc-response.contents parsed)))
+
 (define-erc-response-handler (474)
   "Banned from channel errors" nil
   (erc-display-message parsed '(notice error) nil
@@ -1769,7 +1786,7 @@ See `erc-display-server-message'." nil
     (erc-display-message parsed '(error notice) 'active 's482
                          ?c channel ?m message)))
 
-(define-erc-response-handler (431 445 446 451 462 463 464 465 481 483 484 485
+(define-erc-response-handler (431 445 446 451 462 463 464 481 483 484 485
                                   491 501 502)
   ;; 431 - No nickname given
   ;; 445 - SUMMON has been disabled
@@ -1778,7 +1795,6 @@ See `erc-display-server-message'." nil
   ;; 462 - Unauthorized command (already registered)
   ;; 463 - Your host isn't among the privileged
   ;; 464 - Password incorrect
-  ;; 465 - You are banned from this server
   ;; 481 - Need IRCop privileges
   ;; 483 - You can't kill a server!
   ;; 484 - Your connection is restricted!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]