GNU bug report logs - #8772
[PATCH] rcirc: support TLS/SSL and arbitrary connection method

Previous Next

Package: emacs;

Reported by: Marco Pessotto <melmothx <at> gmail.com>

Date: Tue, 31 May 2011 08:45:02 UTC

Severity: wishlist

Tags: patch

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8772 in the body.
You can then email your comments to 8772 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8772; Package emacs. (Tue, 31 May 2011 08:45:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Marco Pessotto <melmothx <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 31 May 2011 08:45:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Marco Pessotto <melmothx <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] rcirc: support TLS/SSL and arbitrary connection method
Date: Tue, 31 May 2011 10:43:59 +0200
[Message part 1 (text/plain, inline)]
From emacs-devel:

Hello there.

I'm writing you to submit a patch for rcirc.el to give it support for
SSL connections. 

For example, the following 2 servers will connect with SSL, one using a
custom function (which can be anything, and re-implements this idea
https://github.com/nealey/rcirc/wiki ), one simply adding :use-tls t.

(setq rcirc-server-alist '(("irc.freenode.net" 
			    :nick "nick"
			    :user-name "username"
			    :port 6697
                            ;; use open-tls-stream as function to connect
			    :custom-connect-function open-tls-stream 
			    :channels ("#rcirc" "#emacs"))
			   ("irc.otherserver.org" 
			    :nick "nick"
			    :username "username"
                            ;; just say use-tls, more intuitive
                            ;; also prompted when C-u M-x rcirc
			    :use-tls t
			    :port 7000
			    :channels ("#channel1" "#channel 2"))))


The last 2 chunks of the patch are meant to strip the IRC colors. Not
really part of the "connection" patch, but IMHO useful.

The patch is meant to be applied to the latest revision published on
github by rcy:

https://github.com/rcy/rcirc

In case you're interested, I signed the emacs papers some years ago.

Bests

        Marco

[ssl-custom-function.patch (text/x-diff, inline)]
diff --git a/rcirc.el b/rcirc.el
index 093892a..a0bcaf1 100644
--- a/rcirc.el
+++ b/rcirc.el
@@ -46,6 +46,7 @@
 (require 'ring)
 (require 'time-date)
 (eval-when-compile (require 'cl))
+(require 'tls)
 
 (defgroup rcirc nil
   "Simple IRC client."
@@ -76,6 +77,19 @@ for this connection.
 VALUE must be a number or string.  If absent,
 `rcirc-default-port' is used.
 
+`:use-tls'
+
+VALUE is a boolean. If true, the connection will be established
+using the tls.el library. If absent, `rcirc-default-use-tls' is
+used, which in turn default to nil (false).
+
+`:custom-connect-function'
+
+VALUE is a custom function to open the connection and must take
+the same arguments of `open-network-stream' If you set this,
+the :use-tls parameter is ignored (as you are supposed to set the
+connection by yourself)
+
 `:user-name'
 
 VALUE must be a string.  If absent, `rcirc-default-user-name' is
@@ -102,6 +116,8 @@ connected to automatically."
 					     (:user-name string)
 					     (:password string)
 					     (:full-name string)
+					     (:use-tls boolean)
+					     (:custom-connect-function function)
 					     (:channels (repeat string)))))
   :group 'rcirc)
 
@@ -110,6 +126,11 @@ connected to automatically."
   :type 'integer
   :group 'rcirc)
 
+(defcustom rcirc-default-use-tls nil
+  "Use SSL/TLS by default?"
+  :type 'boolean
+  :group 'rcirc)
+
 (defcustom rcirc-default-nick (user-login-name)
   "Your nick."
   :type 'string
@@ -409,6 +430,7 @@ If ARG is non-nil, instead prompt for connection parameters."
                                      'rcirc-user-name-history))
 	     (password (read-passwd "IRC Password: " nil
                                     (plist-get server-plist :password)))
+	     (use-tls (yes-or-no-p "Use SSL/TLS? "))
 	     (channels (split-string
 			(read-string "IRC Channels: "
 				     (mapconcat 'identity
@@ -418,7 +440,7 @@ If ARG is non-nil, instead prompt for connection parameters."
 			"[, ]+" t)))
 	(rcirc-connect server port nick user-name
 		       rcirc-default-full-name
-		       channels password))
+		       channels password use-tls))
     ;; connect to servers in `rcirc-server-alist'
     (let (connected-servers)
       (dolist (c rcirc-server-alist)
@@ -430,6 +452,9 @@ If ARG is non-nil, instead prompt for connection parameters."
 	      (full-name (or (plist-get (cdr c) :full-name)
 			     rcirc-default-full-name))
 	      (channels (plist-get (cdr c) :channels))
+	      (use-tls (or (plist-get (cdr c) :use-tls)
+		       rcirc-default-use-tls))
+	      (custom-connect-function (plist-get (cdr c) :custom-connect-function))
               (password (plist-get (cdr c) :password)))
 	  (when server
 	    (let (connected)
@@ -439,13 +464,15 @@ If ARG is non-nil, instead prompt for connection parameters."
 	      (if (not connected)
 		  (condition-case e
 		      (rcirc-connect server port nick user-name
-				     full-name channels password)
+				     full-name channels password use-tls
+				     custom-connect-function)
 		    (quit (message "Quit connecting to %s" server)))
 		(with-current-buffer (process-buffer connected)
+		  (if (process-contact (get-buffer-process
+					(current-buffer)) :host)
 		  (setq connected-servers
-			(cons (process-contact (get-buffer-process
-						(current-buffer)) :host)
-			      connected-servers))))))))
+			(cons (process-name connected)
+			      connected-servers)))))))))
       (when connected-servers
 	(message "Already connected to %s"
 		 (if (cdr connected-servers)
@@ -471,7 +498,8 @@ If ARG is non-nil, instead prompt for connection parameters."
 
 ;;;###autoload
 (defun rcirc-connect (server &optional port nick user-name
-                             full-name startup-channels password)
+                             full-name startup-channels password use-tls
+			     custom-connect-function)
   (save-excursion
     (message "Connecting to %s..." server)
     (let* ((inhibit-eol-conversion)
@@ -484,7 +512,16 @@ If ARG is non-nil, instead prompt for connection parameters."
 	   (user-name (or user-name rcirc-default-user-name))
 	   (full-name (or full-name rcirc-default-full-name))
 	   (startup-channels startup-channels)
-           (process (make-network-process :name server :host server :service port-number)))
+           (process))
+      (if (functionp custom-connect-function)
+	  (setq process (funcall custom-connect-function server nil server port-number))
+	(if use-tls
+	    (setq process (open-tls-stream server nil server port-number))
+	  (setq process (open-network-stream server nil server port-number))))
+      (unless process
+	(error (concat 
+	       (format "Couldn't connect to %s on %d " server port-number)
+	       (when use-tls "using TLS/SSL"))))
       ;; set up process
       (set-process-coding-system process 'raw-text 'raw-text)
       (switch-to-buffer (rcirc-generate-new-buffer-name process nil))
@@ -698,7 +735,7 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.")
   "Send PROCESS a STRING plus a newline."
   (let ((string (concat (encode-coding-string string rcirc-encode-coding-system)
                         "\n")))
-    (unless (eq (process-status process) 'open)
+    (unless (member (process-status process) '(open run))
       (error "Network connection to %s is not open"
              (process-name process)))
     (rcirc-debug process string)
@@ -1401,7 +1438,8 @@ Returns nil if the information is not recorded."
       (- rcirc-current-line last-activity-line))))
 
 (defvar rcirc-markup-text-functions
-  '(rcirc-markup-attributes
+  '(rcirc-markup-strip-irc-colors
+    rcirc-markup-attributes
     rcirc-markup-my-nick
     rcirc-markup-urls
     rcirc-markup-keywords
@@ -2302,6 +2340,10 @@ keywords when no KEYWORD is given."
   (insert (rcirc-facify (format-time-string rcirc-time-format)
 			'rcirc-timestamp)))
 
+(defun rcirc-markup-strip-irc-colors (sender response)
+  (while (re-search-forward "\C-c\\([0-9][0-9]?\\(,[0-9][0-9]?\\)?\\)?" nil t)
+    (delete-region (match-beginning 0) (match-end 0))))
+
 (defun rcirc-markup-attributes (sender response)
   (while (re-search-forward "\\([\C-b\C-_\C-v]\\).*?\\(\\1\\|\C-o\\)" nil t)
     (rcirc-add-face (match-beginning 0) (match-end 0)
[Message part 3 (text/plain, inline)]

-- 
Marco

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8772; Package emacs. (Tue, 31 May 2011 14:23:02 GMT) Full text and rfc822 format available.

Message #8 received at 8772 <at> debbugs.gnu.org (full text, mbox):

From: Marco Pessotto <melmothx <at> gmail.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: Julien Danjou <julien <at> danjou.info>, 8772 <at> debbugs.gnu.org, rcyeske <at> gmail.com,
	Deniz Dogan <deniz <at> dogan.se>, emacs-devel <at> gnu.org
Subject: Re: [PATCH] rcirc: support TLS/SSL and arbitrary connection method
Date: Tue, 31 May 2011 16:21:51 +0200
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:

>> I'm writing you to submit a patch for rcirc.el to give it support for
>> SSL connections.
>
> Thank you.  But I'm afraid you're just a few weeks late:
>
>    revno: 104199
>    committer: Stefan Monnier <monnier <at> iro.umontreal.ca>
>    branch nick: trunk
>    timestamp: Wed 2011-05-11 23:25:58 -0300

Yeah, I noticed, as you've probably seen:
http://lists.gnu.org/archive/html/emacs-devel/2011-05/msg01016.html

There was obviously a communication problem. 

I talked on the irc channel #rcirc about a SSL patch 2 months ago, but
apparently without waking a real interest from the maintainers.
The irc channel was obviously the wrong place to talk about this.

Also, I assumed that the place where the development was happening was
the rcy's git(hub) repo, but, again, I was wrong.

So what else can I say? Sorry for the noise. I patched rcirc because
I prefer to run a stable emacs, I like rcirc and I need the SSL
connection *now*.

Julien Danjou <julien <at> danjou.info> writes:

> On Tue, May 31 2011, Stefan Monnier wrote:
>
>>> The last 2 chunks of the patch are meant to strip the IRC colors.
>>> Not really part of the "connection" patch, but IMHO useful.
>>
>> Could you describe a bit more what this is about (I'm not a regular IRC
>> user)?  I can't remember seeing those C-c escape sequences, when do they
>> appear, what are they expected to do?  Should we really strip them, or
>> would it be even better to turn them into faces?
>
> C-c are escape code for colors. I think they came with mIRC first, but
> well, I don't know for sure.
>
> See: http://www.mirc.com/colors.html
>
> I don't think they should be stripped, but they should be rendered using
> faces as you suggest. And this probably be configurable with a
> defcustom.

I prefer to have the colors stripped out, because [IMHO] they are just
lame.

  "rcirc is a next generation IRC client. It blends seamlessly with the
  rest of emacs, it’s tight, fast, and doesn’t light up like a christmas
  tree." -- http://www.emacswiki.org/emacs/rcirc

I believe the colors are part of the christmas tree ;-)

Best wishes

-- 
Marco




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8772; Package emacs. (Tue, 31 May 2011 14:58:02 GMT) Full text and rfc822 format available.

Message #11 received at 8772 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Marco Pessotto <melmothx <at> gmail.com>
Cc: Julien Danjou <julien <at> danjou.info>, 8772 <at> debbugs.gnu.org, rcyeske <at> gmail.com,
	Deniz Dogan <deniz <at> dogan.se>, emacs-devel <at> gnu.org
Subject: Re: [PATCH] rcirc: support TLS/SSL and arbitrary connection method
Date: Tue, 31 May 2011 11:57:33 -0300
> I talked on the irc channel #rcirc about a SSL patch 2 months ago, but
> apparently without waking a real interest from the maintainers.
> The irc channel was obviously the wrong place to talk about this.

Not being a regular user of IRC, I'm basically never on #rcirc.

> Also, I assumed that the place where the development was happening was
> the rcy's git(hub) repo, but, again, I was wrong.

I didn't know Ryan kept a separate repository for it.  That could be
a problem if the two aren't kept in sync.  Of course, the other problem
is that I haven't heard from Ryan in a long while.

> So what else can I say? Sorry for the noise.

There's nothing to be sorry about.

> I prefer to have the colors stripped out, because [IMHO] they are just
> lame.

>   "rcirc is a next generation IRC client. It blends seamlessly with the
>   rest of emacs, it’s tight, fast, and doesn’t light up like a christmas
>   tree." -- http://www.emacswiki.org/emacs/rcirc

> I believe the colors are part of the christmas tree ;-)

I can relate to that.  Could you send a new patch relative to Emacs
trunk's version of rcirc.el?

Thanks for your contribution, in any case,


        Stefan




bug closed, send any further explanations to 8772 <at> debbugs.gnu.org and Marco Pessotto <melmothx <at> gmail.com> Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> debbugs.gnu.org. (Sun, 12 Jun 2011 22:46:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 11 Jul 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 346 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.