Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] rewrite of the nntp-open-connection functions
@ 2001-07-04 10:10 Didier Verna
  0 siblings, 0 replies; only message in thread
From: Didier Verna @ 2001-07-04 10:10 UTC (permalink / raw)


NOTE: This patch has been committed.

		Dear folks,

	I've rewrote the nntp-open-connection-function methods and wrote a new
one. The old ones are still there for backward compatibility, but are not
documented anymore. The important features of the new set of functions are:

- a better, more consistent and more explicit naming scheme for these
  functions and related variables. In particular, all indirect methods are
  called `nntp-open-via-<something>', and all related variables also use the
  `via' middle-fix.
- a more consistent usage of certain related variables. For instance,
  `nntp-address' *always* designates the real nntp server, *never* the
  intermediate host.
- this provides, in particular, a proper authinfo negociation, which was not
  the case before.
- a new method `nntp-open-telnet-stream' which allows to connect to the nntp
  server through a telnet connection rather than through a native one.
- some more parameters. In particular, the `nntp-pre-command' variable lets
  you wrap your connections, which is useful in situations like living behind
  a firewall and using a socksifying wrapper.

        Everything is properly documented at the usual place in the manual.


I use the new method daily with no problem. The two indirect methods are a bit
less tested since I don't use them. Please report any problem you encounter
with these methods (not occuring with the old ones).



texi/ChangeLog addition:

2001-07-04  Didier Verna  <didier@lrde.epita.fr>

	* gnus.texi (Example Methods): use the new nntp-open-connection
	methods in the examples.
	* gnus.texi (NNTP): update for the new nntp-open-connection methods.
	* gnus.texi (Direct Functions): new node.
	* gnus.texi (Indirect Functions): new node.
	* gnus.texi (Common Variables): new node.

lisp/ChangeLog addition:

2001-07-04  Didier Verna  <didier@lrde.epita.fr>

	* nntp.el (nntp-open-connection-function): doc update.
	* nntp.el (nntp-pre-command): New.
	* nntp.el (nntp-via-rlogin-command): New.
	* nntp.el (nntp-via-telnet-command): New.
	* nntp.el (nntp-via-telnet-switches): New.
	* nntp.el (nntp-via-user-name): New.
	* nntp.el (nntp-via-user-password): New.
	* nntp.el (nntp-via-address): New.
	* nntp.el (nntp-via-envuser): New.
	* nntp.el (nntp-via-shell-prompt): New.
	* nntp.el (nntp-open-telnet-stream): New.
	* nntp.el (nntp-open-via-rlogin-and-telnet): New.
	* nntp.el (nntp-open-via-telnet-and-telnet): New.
	* nntp.el (nntp-wait-for): check for possibly echo'ed commands.
	* nntp.el (nntp-send-command): ditto.
	* nntp.el (nntp-send-command-nodelete): ditto.
	* nntp.el (nntp-send-command-and-decode): ditto.


Gnus Patch (runsocks cvs -q diff -u -t -b -B -w lisp/nntp.el texi/gnus.texi):

Index: lisp/nntp.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/nntp.el,v
retrieving revision 6.8
diff -u -u -t -b -B -w -r6.8 nntp.el
--- lisp/nntp.el	2001/04/30 21:39:59	6.8
+++ lisp/nntp.el	2001/07/04 09:44:36
@@ -65,58 +65,71 @@
 
 (defvoo nntp-open-connection-function 'nntp-open-network-stream
   "*Function used for connecting to a remote system.
-It will be called with the buffer to output in.
+It will be called with the buffer to output in as argument.
 
-Two pre-made functions are `nntp-open-network-stream', which is the
-default, and simply connects to some port or other on the remote
-system (see nntp-port-number).  The other are `nntp-open-rlogin',
-which does an rlogin on the remote system, and then does a telnet to
-the NNTP server available there (see nntp-rlogin-parameters) and
-`nntp-open-telnet' which telnets to a remote system, logs in and does
-the same.")
+Currently, five such functions are provided (please refer to their
+respective doc string for more information), three of them establishing
+direct connections to the nntp server, and two of them using an indirect
+host.
+
+Direct connections:
+- `nntp-open-network-stream' (the default),
+- `nntp-open-ssl-stream',
+- `nntp-open-telnet-stream'.
+
+Indirect connections:
+- `nntp-open-via-rlogin-and-telnet',
+- `nntp-open-via-telnet-and-telnet'.")
+
+(defvoo nntp-pre-command nil
+  "*Pre-command to use with the various nntp-open-via-* methods.
+This is where you would put \"runsocks\" or stuff like that.")
 
-(defvoo nntp-rlogin-program "rsh"
-  "*Program used to log in on remote machines.
-The default is \"rsh\", but \"ssh\" is a popular alternative.")
-
-(defvoo nntp-rlogin-parameters '("telnet" "-8" "${NNTPSERVER:=news}" "nntp")
-  "*Parameters to `nntp-open-rlogin'.
-That function may be used as `nntp-open-connection-function'.  In that
-case, this list will be used as the parameter list given to rsh.")
-
-(defvoo nntp-rlogin-user-name nil
-  "*User name on remote system when using the rlogin connect method.")
-
-(defvoo nntp-telnet-parameters
-    '("exec" "telnet" "-8" "${NNTPSERVER:=news}" "nntp")
-  "*Parameters to `nntp-open-telnet'.
-That function may be used as `nntp-open-connection-function'.  In that
-case, this list will be executed as a command after logging in
-via telnet.")
-
-(defvoo nntp-telnet-user-name nil
-  "User name to log in via telnet with.")
-
-(defvoo nntp-telnet-passwd nil
-  "Password to use to log in via telnet with.")
-
-(defvoo nntp-open-telnet-envuser nil
-  "*If non-nil, telnet session (client and server both) will support the ENVIRON option and not prompt for login name.")
-
-(defvoo nntp-telnet-shell-prompt "bash\\|\$ *\r?$\\|> *\r?"
-  "*Regular expression to match the shell prompt on the remote machine.")
-
 (defvoo nntp-telnet-command "telnet"
-  "Command used to start telnet.")
+  "*Telnet command used to connect to the nntp server.
+This command is used by the various nntp-open-via-* methods.")
 
 (defvoo nntp-telnet-switches '("-8")
-  "Switches given to the telnet command.")
+  "*Switches given to the telnet command `nntp-telnet-command'.")
 
 (defvoo nntp-end-of-line "\r\n"
-  "String to use on the end of lines when talking to the NNTP server.
+  "*String to use on the end of lines when talking to the NNTP server.
 This is \"\\r\\n\" by default, but should be \"\\n\" when
-using rlogin or telnet to communicate with the server.")
+using and indirect connection method (nntp-open-via-*).")
 
+(defvoo nntp-via-rlogin-command "rsh"
+  "*Rlogin command used to connect to an intermediate host.
+This command is used by the `nntp-open-via-rlogin-and-telnet' method.
+The default is \"rsh\", but \"ssh\" is a popular alternative.")
+
+(defvoo nntp-via-telnet-command "telnet"
+  "*Telnet command used to connect to an intermediate host.
+This command is used by the `nntp-open-via-telnet-and-telnet' method.")
+
+(defvoo nntp-via-telnet-switches '("-8")
+  "*Switches given to the telnet command `nntp-via-telnet-command'.")
+
+(defvoo nntp-via-user-name nil
+  "*User name to log in on an intermediate host with.
+This variable is used by the `nntp-open-via-telnet-and-telnet' method.")
+
+(defvoo nntp-via-user-password nil
+  "*Password to use to log in on an intermediate host with.
+This variable is used by the `nntp-open-via-telnet-and-telnet' method.")
+
+(defvoo nntp-via-address nil
+  "*Address of an intermediate host to connect to.
+This variable is used by the `nntp-open-via-rlogin-and-telnet' and
+`nntp-open-via-telnet-and-telnet' methods.")
+
+(defvoo nntp-via-envuser nil
+  "*Whether both telnet client and server support the ENVIRON option.
+If non-nil, there will be no prompt for a login name.")
+
+(defvoo nntp-via-shell-prompt "bash\\|\$ *\r?$\\|> *\r?"
+  "*Regular expression to match the shell prompt on an intermediate host.
+This variable is used by the `nntp-open-via-telnet-and-telnet' method.")
+
 (defvoo nntp-large-newsgroup 50
   "*The number of the articles which indicates a large newsgroup.
 If the number of the articles is greater than the value, verbose
@@ -262,6 +275,8 @@
                 (memq (process-status process) '(open run)))
       (when (looking-at "480")
         (nntp-handle-authinfo process))
+      (when (looking-at "^.*\n")
+        (delete-region (point) (progn (forward-line 1) (point))))
       (nntp-accept-process-output process)
       (goto-char (point-min)))
     (prog1
@@ -365,17 +380,43 @@
     (save-excursion
       (set-buffer nntp-server-buffer)
       (erase-buffer)))
-  (nntp-retrieve-data
-   (mapconcat 'identity strings " ")
+  (let* ((command (mapconcat 'identity strings " "))
+         (buffer (process-buffer (nntp-find-connection nntp-server-buffer)))
+         (pos (point buffer)))
+    (prog1
+        (nntp-retrieve-data command
    nntp-address nntp-port-number nntp-server-buffer
-   wait-for nnheader-callback-function))
+                            wait-for nnheader-callback-function)
+      ;; If nothing to wait for, still remove possibly echo'ed commands
+      (unless wait-for
+        (nntp-accept-response)
+        (save-excursion
+          (set-buffer buffer)
+          (goto-char pos)
+          (if (looking-at (regexp-quote command))
+              (delete-region pos (progn (forward-line 1) (point-at-bol))))
+          )))
+    ))
 
 (defun nntp-send-command-nodelete (wait-for &rest strings)
   "Send STRINGS to server and wait until WAIT-FOR returns."
-  (nntp-retrieve-data
-   (mapconcat 'identity strings " ")
+  (let* ((command (mapconcat 'identity strings " "))
+         (buffer (process-buffer (nntp-find-connection nntp-server-buffer)))
+         (pos (point buffer)))
+    (prog1
+        (nntp-retrieve-data command
    nntp-address nntp-port-number nntp-server-buffer
-   wait-for nnheader-callback-function))
+                            wait-for nnheader-callback-function)
+      ;; If nothing to wait for, still remove possibly echo'ed commands
+      (unless wait-for
+        (nntp-accept-response)
+        (save-excursion
+          (set-buffer buffer)
+          (goto-char pos)
+          (if (looking-at (regexp-quote command))
+              (delete-region pos (progn (forward-line 1) (point-at-bol))))
+          )))
+    ))
 
 (defun nntp-send-command-and-decode (wait-for &rest strings)
   "Send STRINGS to server and wait until WAIT-FOR returns."
@@ -384,11 +425,25 @@
     (save-excursion
       (set-buffer nntp-server-buffer)
       (erase-buffer)))
-  (nntp-retrieve-data
-   (mapconcat 'identity strings " ")
+  (let* ((command (mapconcat 'identity strings " "))
+         (buffer (process-buffer (nntp-find-connection nntp-server-buffer)))
+         (pos (point buffer)))
+    (prog1
+        (nntp-retrieve-data command
    nntp-address nntp-port-number nntp-server-buffer
-   wait-for nnheader-callback-function t))
+                            wait-for nnheader-callback-function t)
+      ;; If nothing to wait for, still remove possibly echo'ed commands
+      (unless wait-for
+        (nntp-accept-response)
+        (save-excursion
+          (set-buffer buffer)
+          (goto-char pos)
+          (if (looking-at (regexp-quote command))
+              (delete-region pos (progn (forward-line 1) (point-at-bol))))
+          )))
+    ))
 
+
 (defun nntp-send-buffer (wait-for)
   "Send the current buffer to server and wait until WAIT-FOR returns."
   (when (and (not nnheader-callback-function)
@@ -1275,7 +1330,44 @@
             (setq nntp-server-xover nil)))
         nntp-server-xover))))
 
-;;; Alternative connection methods.
+(defun nntp-find-group-and-number ()
+  (save-excursion
+    (save-restriction
+      (set-buffer nntp-server-buffer)
+      (narrow-to-region (goto-char (point-min))
+                        (or (search-forward "\n\n" nil t) (point-max)))
+      (goto-char (point-min))
+      ;; We first find the number by looking at the status line.
+      (let ((number (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ")
+                         (string-to-int
+                          (buffer-substring (match-beginning 1)
+                                            (match-end 1)))))
+            group newsgroups xref)
+        (and number (zerop number) (setq number nil))
+        ;; Then we find the group name.
+        (setq group
+              (cond
+               ;; If there is only one group in the Newsgroups header,
+               ;; then it seems quite likely that this article comes
+               ;; from that group, I'd say.
+               ((and (setq newsgroups (mail-fetch-field "newsgroups"))
+                     (not (string-match "," newsgroups)))
+                newsgroups)
+               ;; If there is more than one group in the Newsgroups
+               ;; header, then the Xref header should be filled out.
+               ;; We hazard a guess that the group that has this
+               ;; article number in the Xref header is the one we are
+               ;; looking for.  This might very well be wrong if this
+               ;; article happens to have the same number in several
+               ;; groups, but that's life.
+               ((and (setq xref (mail-fetch-field "xref"))
+                     number
+                     (string-match (format "\\([^ :]+\\):%d" number) xref))
+                (substring xref (match-beginning 1) (match-end 1)))
+               (t "")))
+        (when (string-match "\r" group)
+          (setq group (substring group 0 (match-beginning 0))))
+        (cons group number)))))
 
 (defun nntp-wait-for-string (regexp)
   "Wait until string arrives in the buffer."
@@ -1286,6 +1378,42 @@
       (set-buffer buf)
       (goto-char (point-min)))))
 
+
+;; ==========================================================================
+;; Obsolete nntp-open-* connection methods -- drv
+;; ==========================================================================
+
+(defvoo nntp-open-telnet-envuser nil
+  "*If non-nil, telnet session (client and server both) will support the ENVIRON option and not prompt for login name.")
+
+(defvoo nntp-telnet-shell-prompt "bash\\|\$ *\r?$\\|> *\r?"
+  "*Regular expression to match the shell prompt on the remote machine.")
+
+(defvoo nntp-rlogin-program "rsh"
+  "*Program used to log in on remote machines.
+The default is \"rsh\", but \"ssh\" is a popular alternative.")
+
+(defvoo nntp-rlogin-parameters '("telnet" "-8" "${NNTPSERVER:=news}" "nntp")
+  "*Parameters to `nntp-open-rlogin'.
+That function may be used as `nntp-open-connection-function'.  In that
+case, this list will be used as the parameter list given to rsh.")
+
+(defvoo nntp-rlogin-user-name nil
+  "*User name on remote system when using the rlogin connect method.")
+
+(defvoo nntp-telnet-parameters
+    '("exec" "telnet" "-8" "${NNTPSERVER:=news}" "nntp")
+  "*Parameters to `nntp-open-telnet'.
+That function may be used as `nntp-open-connection-function'.  In that
+case, this list will be executed as a command after logging in
+via telnet.")
+
+(defvoo nntp-telnet-user-name nil
+  "User name to log in via telnet with.")
+
+(defvoo nntp-telnet-passwd nil
+  "Password to use to log in via telnet with.")
+
 (defun nntp-open-telnet (buffer)
   (save-excursion
     (set-buffer buffer)
@@ -1351,44 +1479,143 @@
       (delete-region (point-min) (point))
       proc)))
 
-(defun nntp-find-group-and-number ()
+
+;; ==========================================================================
+;; Replacements for the nntp-open-* functions -- drv
+;; ==========================================================================
+
+(defun nntp-open-telnet-stream (buffer)
+  "Open a nntp connection by telnet'ing the news server.
+
+Please refer to the following variables to customize the connection:
+- `nntp-pre-command',
+- `nntp-telnet-command',
+- `nntp-telnet-switches',
+- `nntp-address',
+- `nntp-port-number',
+- `nntp-end-of-line'."
+  (let ((command `(,nntp-telnet-command
+                   ,@nntp-telnet-switches
+                   ,nntp-address ,nntp-port-number))
+        proc)
+    (and nntp-pre-command
+         (push nntp-pre-command command))
+    (setq proc (apply 'start-process "nntpd" buffer command))
   (save-excursion
-    (save-restriction
-      (set-buffer nntp-server-buffer)
-      (narrow-to-region (goto-char (point-min))
-                        (or (search-forward "\n\n" nil t) (point-max)))
-      (goto-char (point-min))
-      ;; We first find the number by looking at the status line.
-      (let ((number (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ")
-                         (string-to-int
-                          (buffer-substring (match-beginning 1)
-                                            (match-end 1)))))
-            group newsgroups xref)
-        (and number (zerop number) (setq number nil))
-        ;; Then we find the group name.
-        (setq group
+      (set-buffer buffer)
+      (nntp-wait-for-string "^\r*20[01]")
+      (beginning-of-line)
+      (delete-region (point-min) (point))
+      proc)))
+
+(defun nntp-open-via-rlogin-and-telnet (buffer)
+  "Open a connection to an nntp server through an intermediate host.
+First rlogin to the remote host, and then telnet the real news server
+from there.
+
+Please refer to the following variables to customize the connection:
+- `nntp-pre-command',
+- `nntp-via-rlogin-command',
+- `nntp-via-user-name',
+- `nntp-via-address',
+- `nntp-telnet-command',
+- `nntp-telnet-switches',
+- `nntp-address',
+- `nntp-port-number',
+- `nntp-end-of-line'."
+  (let ((command `(,nntp-via-address
+                   ,nntp-telnet-command
+                   ,@nntp-telnet-switches
+                   ,nntp-address ,nntp-port-number))
+        proc)
+    (and nntp-via-user-name
+         (setq command `("-l" ,nntp-via-user-name ,@command)))
+    (push nntp-via-rlogin-command command)
+    (and nntp-pre-command
+         (push nntp-pre-command command))
+    (setq proc (apply 'start-process "nntpd" buffer command))
+    (save-excursion
+      (set-buffer buffer)
+      (nntp-wait-for-string "^\r*20[01]")
+      (beginning-of-line)
+      (delete-region (point-min) (point))
+      proc)))
+
+(defun nntp-open-via-telnet-and-telnet (buffer)
+  "Open a connection to an nntp server through an intermediate host.
+First telnet the remote host, and then telnet the real news server
+from there.
+
+Please refer to the following variables to customize the connection:
+- `nntp-pre-command',
+- `nntp-via-telnet-command',
+- `nntp-via-telnet-switches',
+- `nntp-via-address',
+- `nntp-via-envuser',
+- `nntp-via-user-name',
+- `nntp-via-user-password',
+- `nntp-via-shell-prompt',
+- `nntp-telnet-command',
+- `nntp-telnet-switches',
+- `nntp-address',
+- `nntp-port-number',
+- `nntp-end-of-line'."
+  (save-excursion
+    (set-buffer buffer)
+    (erase-buffer)
+    (let ((command `(,nntp-via-telnet-command ,@nntp-via-telnet-switches))
+          (case-fold-search t)
+          proc)
+      (and nntp-pre-command (push nntp-pre-command command))
+      (setq proc (apply 'start-process "nntpd" buffer command))
+      (when (memq (process-status proc) '(open run))
+        (nntp-wait-for-string "^r?telnet")
+        (process-send-string proc "set escape \^X\n")
               (cond
-               ;; If there is only one group in the Newsgroups header,
-               ;; then it seems quite likely that this article comes
-               ;; from that group, I'd say.
-               ((and (setq newsgroups (mail-fetch-field "newsgroups"))
-                     (not (string-match "," newsgroups)))
-                newsgroups)
-               ;; If there is more than one group in the Newsgroups
-               ;; header, then the Xref header should be filled out.
-               ;; We hazard a guess that the group that has this
-               ;; article number in the Xref header is the one we are
-               ;; looking for.  This might very well be wrong if this
-               ;; article happens to have the same number in several
-               ;; groups, but that's life.
-               ((and (setq xref (mail-fetch-field "xref"))
-                     number
-                     (string-match (format "\\([^ :]+\\):%d" number) xref))
-                (substring xref (match-beginning 1) (match-end 1)))
-               (t "")))
-        (when (string-match "\r" group)
-          (setq group (substring group 0 (match-beginning 0))))
-        (cons group number)))))
+         ((and nntp-via-envuser nntp-via-user-name)
+          (process-send-string proc (concat "open " "-l" nntp-via-user-name
+                                            nntp-via-address "\n")))
+         (t
+          (process-send-string proc (concat "open " nntp-via-address
+                                            "\n"))))
+        (when (not nntp-via-envuser)
+          (nntp-wait-for-string "^\r*.?login:")
+          (process-send-string proc
+                               (concat
+                                (or nntp-via-user-name
+                                    (setq nntp-via-user-name
+                                          (read-string "login: ")))
+                                "\n")))
+        (nntp-wait-for-string "^\r*.?password:")
+        (process-send-string proc
+                             (concat
+                              (or nntp-via-user-password
+                                  (setq nntp-via-user-password
+                                        (mail-source-read-passwd
+                                         "Password: ")))
+                              "\n"))
+        (nntp-wait-for-string nntp-via-shell-prompt)
+        (let ((real-telnet-command `("exec"
+                                     ,nntp-telnet-command
+                                     ,@nntp-telnet-switches
+                                     ,nntp-address
+                                     ,nntp-port-number)))
+          (process-send-string proc
+                               (concat (mapconcat 'identity
+                                                  real-telnet-command " ")
+                                       "\n")))
+        (nntp-wait-for-string "^\r*20[01]")
+        (beginning-of-line)
+        (delete-region (point-min) (point))
+        (process-send-string proc "\^]")
+        (nntp-wait-for-string "^r?telnet")
+        (process-send-string proc "mode character\n")
+        (accept-process-output proc 1)
+        (sit-for 1)
+        (goto-char (point-min))
+        (forward-line 1)
+        (delete-region (point) (point-max)))
+      proc)))
 
 (provide 'nntp)
 
Index: texi/gnus.texi
===================================================================
RCS file: /usr/local/cvsroot/gnus/texi/gnus.texi,v
retrieving revision 6.92
diff -u -u -t -b -B -w -r6.92 gnus.texi
--- texi/gnus.texi	2001/06/27 17:25:06	6.92
+++ texi/gnus.texi	2001/07/04 09:44:49
@@ -10538,27 +10538,32 @@
 
 @lisp
 (nntp "firewall"
-      (nntp-address "the.firewall.machine")
-      (nntp-open-connection-function nntp-open-rlogin)
-      (nntp-end-of-line "\n")
-      (nntp-rlogin-parameters
-       ("telnet" "the.real.nntp.host" "nntp")))
+      (nntp-open-connection-function nntp-open-via-rlogin-and-telnet)
+      (nntp-via-address "the.firewall.machine")
+      (nntp-address "the.real.nntp.host")
+      (nntp-end-of-line "\n"))
 @end lisp
 
 If you want to use the wonderful @code{ssh} program to provide a
-compressed connection over the modem line, you could create a virtual
-server that would look something like this:
+compressed connection over the modem line, you could add the following
+configuration to the example above:
 
 @lisp
-(nntp "news"
-       (nntp-address "copper.uio.no")
-       (nntp-rlogin-program "ssh")
-       (nntp-open-connection-function nntp-open-rlogin)
-       (nntp-end-of-line "\n")
-       (nntp-rlogin-parameters
-        ("telnet" "news.uio.no" "nntp")))
+      (nntp-via-rlogin-command "ssh")
 @end lisp
 
+If you're behind a firewall, but have direct access to the outside world
+through a wrapper command like "runsocks", you could open a socksified
+telnet connection to the news server as follows:
+
+@lisp
+(nntp "outside"
+      (nntp-pre-command "runsocks")
+      (nntp-open-connection-function nntp-open-via-telnet)
+      (nntp-address "the.news.server")
+      (nntp-end-of-line "\n"))
+@end lisp
+
 This means that you have to have set up @code{ssh-agent} correctly to
 provide automatic authorization, of course.  And to get a compressed
 connection, you have to have the @samp{Compression} option in the
@@ -10882,127 +10887,6 @@
 This hook is run as the last step when connecting to an @sc{nntp}
 server.
 
-@findex nntp-open-rlogin
-@findex nntp-open-telnet
-@findex nntp-open-network-stream
-@item nntp-open-connection-function
-@vindex nntp-open-connection-function
-This function is used to connect to the remote system.  Four pre-made
-functions are supplied:
-
-@table @code
-@item nntp-open-network-stream
-This is the default, and simply connects to some port or other on the
-remote system.
-
-@item nntp-open-rlogin
-Does an @samp{rlogin} on the
-remote system, and then does a @samp{telnet} to the @sc{nntp} server
-available there.
-
-@code{nntp-open-rlogin}-related variables:
-
-@table @code
-
-@item nntp-rlogin-program
-@vindex nntp-rlogin-program
-Program used to log in on remote machines.  The default is @samp{rsh},
-but @samp{ssh} is a popular alternative.
-
-@item nntp-rlogin-parameters
-@vindex nntp-rlogin-parameters
-This list will be used as the parameter list given to @code{rsh}.
-
-@item nntp-rlogin-user-name
-@vindex nntp-rlogin-user-name
-User name on the remote system.
-
-@end table
-
-@item nntp-open-telnet
-Does a @samp{telnet} to the remote system and then another @samp{telnet}
-to get to the @sc{nntp} server.
-
-@code{nntp-open-telnet}-related variables:
-
-@table @code
-@item nntp-telnet-command
-@vindex nntp-telnet-command
-Command used to start @code{telnet}.
-
-@item nntp-telnet-switches
-@vindex nntp-telnet-switches
-List of strings to be used as the switches to the @code{telnet} command.
-
-@item nntp-telnet-user-name
-@vindex nntp-telnet-user-name
-User name for log in on the remote system.
-
-@item nntp-telnet-passwd
-@vindex nntp-telnet-passwd
-Password to use when logging in.
-
-@item nntp-telnet-parameters
-@vindex nntp-telnet-parameters
-A list of strings executed as a command after logging in
-via @code{telnet}.
-
-@item nntp-telnet-shell-prompt
-@vindex nntp-telnet-shell-prompt
-Regexp matching the shell prompt on the remote machine.  The default is
-@samp{bash\\|\$ *\r?$\\|> *\r?}.
-
-@item nntp-open-telnet-envuser
-@vindex nntp-open-telnet-envuser
-If non-@code{nil}, the @code{telnet} session (client and server both)
-will support the @code{ENVIRON} option and not prompt for login name.
-This works for Solaris @code{telnet}, for instance.
-
-@end table
-
-@findex nntp-open-ssl-stream
-@item nntp-open-ssl-stream
-Opens a connection to a server over a @dfn{secure} channel.  To use this
-you must have SSLay installed
-(@uref{ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL}, and you also need
-@file{ssl.el} (from the W3 distribution, for instance).  You then
-define a server as follows:
-
-@lisp
-;; Type `C-c C-c' after you've finished editing.
-;;
-;; "snews" is port 563 and is predefined 
-;; in our /etc/services
-;;
-(nntp "snews.bar.com"
-      (nntp-open-connection-function 
-        nntp-open-ssl-stream)
-      (nntp-port-number "snews")
-      (nntp-address "snews.bar.com"))
-@end lisp
-
-@end table
-
-@item nntp-end-of-line
-@vindex nntp-end-of-line
-String to use as end-of-line marker when talking to the @sc{nntp}
-server.  This is @samp{\r\n} by default, but should be @samp{\n} when
-using @code{rlogin} to talk to the server.
-
-@item nntp-rlogin-user-name
-@vindex nntp-rlogin-user-name
-User name on the remote system when using the @code{rlogin} connect
-function.
-
-@item nntp-address
-@vindex nntp-address
-The address of the remote system running the @sc{nntp} server.
-
-@item nntp-port-number
-@vindex nntp-port-number
-Port number to connect to when using the @code{nntp-open-network-stream}
-connect function.
-
 @item nntp-buggy-select
 @vindex nntp-buggy-select
 Set this to non-@code{nil} if your select routine is buggy.
@@ -11050,6 +10934,200 @@
 buffer.  This is useful if you are debugging a Gnus/@sc{nntp} connection
 that doesn't seem to work.
 
+@item nntp-open-connection-function
+@vindex nntp-open-connection-function
+It is possible to customize how the connection to the nntp server will
+be opened.  If you specify an @code{nntp-open-connection-function}
+parameter, Gnus will use that function to establish the connection.
+Five pre-made functions are supplied.  These functions can be grouped in
+two categories: direct connection functions (three pre-made), and
+indirect ones (two pre-made).
+@end table
+
+@menu
+* Direct Functions::   Connecting directly to the server.
+* Indirect Functions:: Connecting indirectly to the server.
+* Common Variables::   Understood by several connection functions.
+@end menu
+
+
+@node Direct Functions
+@subsubsection Direct Functions
+@cindex direct connection functions
+
+These functions are called direct because they open a direct connection
+between your machine and the @sc{nntp} server.  The behavior of these
+functions is also affected by commonly understood variables
+(@pxref{Common Variables}).
+
+@table @code
+@findex nntp-open-network-stream
+@item nntp-open-network-stream
+This is the default, and simply connects to some port or other on the
+remote system.
+
+@findex nntp-open-ssl-stream
+@item nntp-open-ssl-stream
+Opens a connection to a server over a @dfn{secure} channel.  To use this
+you must have SSLay installed
+(@uref{ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL}, and you also need
+@file{ssl.el} (from the W3 distribution, for instance).  You then
+define a server as follows:
+
+@lisp
+;; Type `C-c C-c' after you've finished editing.
+;;
+;; "snews" is port 563 and is predefined in our /etc/services
+;;
+(nntp "snews.bar.com"
+      (nntp-open-connection-function nntp-open-ssl-stream)
+      (nntp-port-number "snews")
+      (nntp-address "snews.bar.com"))
+@end lisp
+
+@findex nntp-open-telnet-stream
+@item nntp-open-telnet-stream
+Opens a connection to an @sc{nntp} server by simply @samp{telnet}'ing
+it.  You might wonder why this function exists, since we have the
+default @code{nntp-open-network-stream} which would do the job.  (One
+of) the reason(s) is that if you are behind a firewall but have direct
+connections to the outside world thanks to a command wrapper like
+@code{runsocks}, you can use it like this:
+
+@lisp
+(nntp "socksified"
+      (nntp-pre-command "runsocks")
+      (nntp-open-connection-function nntp-open-telnet-stream)
+      (nntp-address "the.news.server"))
+@end lisp
+
+With the default method, you would need to wrap your whole Emacs
+session, which is not a good idea.
+@end table
+
+
+@node Indirect Functions
+@subsubsection Indirect Functions
+@cindex indirect connection functions
+
+These functions are called indirect because they connect to an
+intermediate host before actually connecting to the @sc{nntp} server.
+All of these functions and related variables are also said to belong to
+the "via" family of connection: they're all prefixed with "via" to make
+things cleaner.  The behavior of these functions is also affected by
+commonly understood variables (@pxref{Common Variables}).
+
+@table @code
+@item nntp-open-via-rlogin-and-telnet
+@findex nntp-open-via-rlogin-and-telnet
+Does an @samp{rlogin} on a remote system, and then does a @samp{telnet}
+to the real @sc{nntp} server from there.  This is useful for instance if
+you need to connect to a firewall machine first.
+
+@code{nntp-open-via-rlogin-and-telnet}-specific variables:
+
+@table @code
+@item nntp-via-rlogin-command
+@vindex nntp-via-rlogin-command
+Command used to log in on the intermediate host.  The default is
+@samp{rsh}, but @samp{ssh} is a popular alternative.
+@end table
+
+@item nntp-open-via-telnet-and-telnet
+@findex nntp-open-via-telnet-and-telnet
+Does essentially the same, but uses @samp{telnet} instead of
+@samp{rlogin} to connect to the intermediate host.
+
+@code{nntp-open-via-telnet-and-telnet}-specific variables:
+
+@table @code
+@item nntp-via-telnet-command
+@vindex nntp-via-telnet-command
+Command used to @code{telnet} the intermediate host.  The default is
+@samp{telnet}.
+
+@item nntp-via-telnet-switches
+@vindex nntp-via-telnet-switches
+List of strings to be used as the switches to the
+@code{nntp-via-telnet-command} command.  The default is @samp{("-8")}.
+
+@item nntp-via-user-password
+@vindex nntp-via-user-password
+Password to use when logging in on the intermediate host.
+
+@item nntp-via-envuser
+@vindex nntp-via-envuser
+If non-@code{nil}, the intermediate @code{telnet} session (client and
+server both) will support the @code{ENVIRON} option and not prompt for
+login name. This works for Solaris @code{telnet}, for instance.
+
+@item nntp-via-shell-prompt
+@vindex nntp-via-shell-prompt
+Regexp matching the shell prompt on the intermediate host.  The default
+is @samp{bash\\|\$ *\r?$\\|> *\r?}.
+
+@end table
+
+@end table
+
+
+Here are some additional variables that are understood by all the above
+functions:
+
+@table @code
+
+@item nntp-via-user-name
+@vindex nntp-via-user-name
+User name to use when connecting to the intermediate host.
+
+@item nntp-via-address
+@vindex nntp-via-address
+Address of the intermediate host to connect to.
+
+@end table
+
+
+@node Common Variables
+@subsubsection Common Variables
+
+The following variables affect the behavior of all, or several of the
+pre-made connection functions. When not specified, all functions are
+affected.
+
+@table @code
+
+@item nntp-pre-command
+@vindex nntp-pre-command
+A command wrapper to use when connecting through a non native connection
+function (all except @code{nntp-open-network-stream} and
+@code{nntp-open-ssl-stream}.  This is where you would put a @samp{SOCKS}
+wrapper for instance.
+
+@item nntp-address
+@vindex nntp-address
+The address of the @sc{nntp} server.
+
+@item nntp-port-number
+@vindex nntp-port-number
+Port number to connect to the @sc{nntp} server.  The default is @samp{nntp}.
+
+@item nntp-end-of-line
+@vindex nntp-end-of-line
+String to use as end-of-line marker when talking to the @sc{nntp}
+server.  This is @samp{\r\n} by default, but should be @samp{\n} when
+using a non native connection function.
+
+@item nntp-telnet-command
+@vindex nntp-telnet-command
+Command to use when connecting to the @sc{nntp} server through
+@samp{telnet}.  This is NOT for an intermediate host.  This is just for
+the real @sc{nntp} server.  The default is @samp{telnet}.
+
+@item nntp-telnet-switches
+@vindex nntp-telnet-switches
+A list of switches to pass to @code{nntp-telnet-command}.  The default
+is @samp{("-8")}.
+
 @end table
 
 
@@ -13216,7 +13294,7 @@
 @item nnslashdot-active-url
 @vindex nnslashdot-active-url
 The @sc{url} format string that will be used to fetch the information on
-news articles and comments.  Default:
+news articles and comments.  The default is
 @samp{http://slashdot.org/search.pl?section=&min=%d}.
 
 @item nnslashdot-comments-url

-- 
Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 53 14 59 47
94276 Le Kremlin-Bicêtre, France   Fax.+33 (1) 44 08 01 99   didier@xemacs.org


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-07-04 10:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-04 10:10 [PATCH] rewrite of the nntp-open-connection functions Didier Verna

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).