From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/72396 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.gnus.general Subject: Re: nnimap ports and protocols Date: Fri, 01 Oct 2010 09:52:40 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87wrq2x8w7.fsf@lifelogs.com> References: <87r5gaiv6q.fsf@rimspace.net> <87k4m2yqnh.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1285944850 28245 80.91.229.12 (1 Oct 2010 14:54:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 1 Oct 2010 14:54:10 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M20768@lists.math.uh.edu Fri Oct 01 16:54:06 2010 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P1gzp-0006Rv-DO for ding-account@gmane.org; Fri, 01 Oct 2010 16:54:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1P1gz2-0004xS-9d; Fri, 01 Oct 2010 09:53:12 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1P1gz0-0004xE-Ne for ding@lists.math.uh.edu; Fri, 01 Oct 2010 09:53:10 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1P1gyv-0008JP-47 for ding@lists.math.uh.edu; Fri, 01 Oct 2010 09:53:10 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1P1gyu-0003vB-00 for ; Fri, 01 Oct 2010 16:53:04 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P1gyr-00069X-Lk for ding@gnus.org; Fri, 01 Oct 2010 16:53:01 +0200 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Oct 2010 16:53:01 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Oct 2010 16:53:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 145 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6;d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:5gaDyLnROkmkEdnregpGEFcaumc= X-Spam-Score: -0.7 (/) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:72396 Archived-At: --=-=-= Content-Type: text/plain On Fri, 01 Oct 2010 08:43:46 -0500 Ted Zlatanov wrote: TZ> On Fri, 01 Oct 2010 11:00:13 +1000 Daniel Pittman wrote: DP> Lars Magne Ingebrigtsen writes: >>> In the absence of user-specified ports and protocols, would it make sense >>> just to try the likely ones? DP> You wouldn't be the first person to do it, but watch out for firewalls that DP> eat the SYN packet silently: having Gnus hang for a significant timeout on the DP> first connection attempt would suck. Doing that every time... TZ> The nnimap stream parameter should be a list the user can customize, TZ> attempted in order. The default can be what Lars listed. TZ> Then Gnus can ask the user if they want to customize the nnimap stream TZ> parameter when a connection fails. Attached is a patch that: 1) has FIXMEs all over 2) removes the dependency on nnimap-shell-program in favor of a more structured nnimap-stream 3) makes nnimap-stream an alist of (stream . helper) where the helper is currently only meaningful for the 'shell stream. I plan to use it for GnuTLS as well. 4) provides a default nnimap-stream that tries ssl, then network, then shell I'm sure this can be done better, but wanted to show how I thought streams should work for nnimap. Ted --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=nnimap-stream.patch diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 70aa573..89fcff2 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -54,10 +54,17 @@ If nnimap-stream is `ssl', this will default to `imaps'. If not, it will default to `imap'.") -(defvoo nnimap-stream 'ssl +(defvoo nnimap-stream '((ssl . "") + (network . "") + (shell . (if (boundp 'imap-shell-program) + (if (listp imap-shell-program) + (car imap-shell-program) + imap-shell-program) + "ssh %s imapd"))) "How nnimap will talk to the IMAP server. Values are `ssl', `network', `starttls' or `shell'.") +;; FIXME: remove this in favor of nnimap-stream parameters (defvoo nnimap-shell-program (if (boundp 'imap-shell-program) (if (listp imap-shell-program) (car imap-shell-program) @@ -245,12 +252,12 @@ textual parts.") (push (current-buffer) nnimap-process-buffers) (current-buffer))) -(defun nnimap-open-shell-stream (name buffer host port) +(defun nnimap-open-shell-stream (name buffer host port program) (let ((process-connection-type nil)) (start-process name buffer shell-file-name shell-command-switch (format-spec - nnimap-shell-program + program (format-spec-make ?s host ?p port))))) @@ -293,9 +300,13 @@ textual parts.") (let* ((coding-system-for-read 'binary) (coding-system-for-write 'binary) (port nil) + ;; FIXME: this should cycle through the streams and if one fails, offer to customize them + (stream-struct (or (car-safe nnimap-stream) '(starttls . ""))) + (stream (car stream-struct)) + (stream-helper (cdr stream-struct)) (ports (cond - ((eq nnimap-stream 'network) + ((eq stream 'network) (open-network-stream "*nnimap*" (current-buffer) nnimap-address (setq port @@ -304,19 +315,20 @@ textual parts.") "imap" "143")))) '("143" "imap")) - ((eq nnimap-stream 'shell) + ((eq stream 'shell) (nnimap-open-shell-stream "*nnimap*" (current-buffer) nnimap-address - (setq port (or nnimap-server-port "imap"))) + (setq port (or nnimap-server-port "imap")) + stream-helper) '("imap")) - ((eq nnimap-stream 'starttls) + ((eq stream 'starttls) (let ((tls-program (nnimap-extend-tls-programs))) (open-tls-stream "*nnimap*" (current-buffer) nnimap-address (setq port (or nnimap-server-port "imap")) 'starttls)) '("imap")) - ((eq nnimap-stream 'ssl) + ((eq stream 'ssl) (open-tls-stream "*nnimap*" (current-buffer) nnimap-address (setq port @@ -332,7 +344,7 @@ textual parts.") (memq (process-status (nnimap-process nnimap-object)) '(open run)))) (nnheader-report 'nnimap "Unable to contact %s:%s via %s" - nnimap-address port nnimap-stream) + nnimap-address port stream) (gnus-set-process-query-on-exit-flag (nnimap-process nnimap-object) nil) (if (not (setq connection-result (nnimap-wait-for-connection))) (nnheader-report 'nnimap @@ -352,9 +364,9 @@ textual parts.") (push (format "%s" nnimap-server-port) ports)) ;; If this is a STARTTLS-capable server, then sever the ;; connection and start a STARTTLS connection instead. - (when (and (eq nnimap-stream 'network) + (when (and (eq stream 'network) (member "STARTTLS" (nnimap-capabilities nnimap-object))) - (let ((nnimap-stream 'starttls)) + (let ((nnimap-stream '(starttls))) ; FIXME, should be handled with the right nnimap-stream to begin with (let ((tls-process (nnimap-open-connection buffer))) ;; If the STARTTLS connection was successful, we --=-=-=--