54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1 ;;; url-gw.el --- Gateway munging for URL loading
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
2 ;; Author: Bill Perry <wmperry@gnu.org>
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
3 ;; Keywords: comm, data, processes
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
4
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
6 ;;; Copyright (c) 1997, 1998 Free Software Foundation, Inc.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
7 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8 ;;; This file is part of GNU Emacs.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
9 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
10 ;;; GNU Emacs is free software; you can redistribute it and/or modify
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
11 ;;; it under the terms of the GNU General Public License as published by
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12 ;;; the Free Software Foundation; either version 2, or (at your option)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
13 ;;; any later version.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
14 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15 ;;; GNU Emacs is distributed in the hope that it will be useful,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18 ;;; GNU General Public License for more details.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20 ;;; You should have received a copy of the GNU General Public License
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
22 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23 ;;; Boston, MA 02111-1307, USA.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25 (eval-when-compile (require 'cl))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
26 (require 'url-vars)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
27
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
28 ;; Fixme: support SSH explicitly or via a url-gateway-rlogin-program?
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
29
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
30 (autoload 'socks-open-network-stream "socks")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
31 (autoload 'open-ssl-stream "ssl")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 (defgroup url-gateway nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34 "URL gateway variables"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 :group 'url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
36
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 (defcustom url-gateway-local-host-regexp nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 "*A regular expression specifying local hostnames/machines."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39 :type '(choice (const nil) regexp)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
40 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
41
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
42 (defcustom url-gateway-prompt-pattern
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
43 "^[^#$%>;]*[#$%>;] *" ;; "bash\\|\$ *\r?$\\|> *\r?"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
44 "*A regular expression matching a shell prompt."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
45 :type 'regexp
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
46 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
47
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
48 (defcustom url-gateway-rlogin-host nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
49 "*What hostname to actually rlog into before doing a telnet."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
50 :type '(choice (const nil) string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
51 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
52
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
53 (defcustom url-gateway-rlogin-user-name nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
54 "*Username to log into the remote machine with when using rlogin."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55 :type '(choice (const nil) string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
57
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
58 (defcustom url-gateway-rlogin-parameters '("telnet" "-8")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
59 "*Parameters to `url-open-rlogin'.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
60 This list will be used as the parameter list given to rsh."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61 :type '(repeat string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 (defcustom url-gateway-telnet-host nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 "*What hostname to actually login to before doing a telnet."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 :type '(choice (const nil) string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
67 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69 (defcustom url-gateway-telnet-parameters '("exec" "telnet" "-8")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
70 "*Parameters to `url-open-telnet'.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
71 This list will be executed as a command after logging in via telnet."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
72 :type '(repeat string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
74
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 (defcustom url-gateway-telnet-login-prompt "^\r*.?login:"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
76 "*Prompt that tells us we should send our username when loggin in w/telnet."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
77 :type 'regexp
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
78 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
79
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
80 (defcustom url-gateway-telnet-password-prompt "^\r*.?password:"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
81 "*Prompt that tells us we should send our password when loggin in w/telnet."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
82 :type 'regexp
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
83 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
84
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
85 (defcustom url-gateway-telnet-user-name nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
86 "User name to log in via telnet with."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
87 :type '(choice (const nil) string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
88 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
89
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
90 (defcustom url-gateway-telnet-password nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
91 "Password to use to log in via telnet with."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
92 :type '(choice (const nil) string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
93 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
94
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
95 (defcustom url-gateway-broken-resolution nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
96 "*Whether to use nslookup to resolve hostnames.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
97 This should be used when your version of Emacs cannot correctly use DNS,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
98 but your machine can. This usually happens if you are running a statically
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
99 linked Emacs under SunOS 4.x"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
100 :type 'boolean
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
101 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
102
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
103 (defcustom url-gateway-nslookup-program "nslookup"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
104 "*If non-NIL then a string naming nslookup program."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
105 :type '(choice (const :tag "None" :value nil) string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 :group 'url-gateway)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
107
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
108 ;; Stolen from ange-ftp
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
109 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
110 (defun url-gateway-nslookup-host (host)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
111 "Attempt to resolve the given HOST using nslookup if possible."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
112 (interactive "sHost: ")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
113 (if url-gateway-nslookup-program
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
114 (let ((proc (start-process " *nslookup*" " *nslookup*"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
115 url-gateway-nslookup-program host))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
116 (res host))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
117 (process-kill-without-query proc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
118 (save-excursion
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
119 (set-buffer (process-buffer proc))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 (while (memq (process-status proc) '(run open))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
121 (accept-process-output proc))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
122 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
123 (if (re-search-forward "Name:.*\nAddress: *\\(.*\\)$" nil t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
124 (setq res (buffer-substring (match-beginning 1)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
125 (match-end 1))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
126 (kill-buffer (current-buffer)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
127 res)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
128 host))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
129
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
130 ;; Stolen from red gnus nntp.el
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
131 (defun url-wait-for-string (regexp proc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
132 "Wait until string matching REGEXP arrives in process PROC's buffer."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
133 (let ((buf (current-buffer)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
134 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
135 (while (not (re-search-forward regexp nil t))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
136 (accept-process-output proc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
137 (set-buffer buf)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
138 (goto-char (point-min)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
139
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
140 ;; Stolen from red gnus nntp.el
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
141 (defun url-open-rlogin (name buffer host service)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
142 "Open a connection using rsh."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
143 (if (not (stringp service))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
144 (setq service (int-to-string service)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
145 (let ((proc (if url-gateway-rlogin-user-name
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
146 (start-process
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
147 name buffer "rsh"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
148 url-gateway-rlogin-host "-l" url-gateway-rlogin-user-name
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
149 (mapconcat 'identity
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
150 (append url-gateway-rlogin-parameters
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151 (list host service)) " "))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
152 (start-process
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
153 name buffer "rsh" url-gateway-rlogin-host
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154 (mapconcat 'identity
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
155 (append url-gateway-rlogin-parameters
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
156 (list host service))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
157 " ")))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
158 (set-buffer buffer)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
159 (url-wait-for-string "^\r*200" proc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
160 (beginning-of-line)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
161 (delete-region (point-min) (point))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
162 proc))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
163
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
164 ;; Stolen from red gnus nntp.el
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
165 (defun url-open-telnet (name buffer host service)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
166 (if (not (stringp service))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
167 (setq service (int-to-string service)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
168 (save-excursion
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
169 (set-buffer (get-buffer-create buffer))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
170 (erase-buffer)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
171 (let ((proc (start-process name buffer "telnet" "-8"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
172 (case-fold-search t))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
173 (when (memq (process-status proc) '(open run))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
174 (process-send-string proc "set escape \^X\n")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
175 (process-send-string proc (concat
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
176 "open " url-gateway-telnet-host "\n"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
177 (url-wait-for-string url-gateway-telnet-login-prompt proc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
178 (process-send-string
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
179 proc (concat
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
180 (or url-gateway-telnet-user-name
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
181 (setq url-gateway-telnet-user-name (read-string "login: ")))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
182 "\n"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
183 (url-wait-for-string url-gateway-telnet-password-prompt proc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
184 (process-send-string
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
185 proc (concat
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
186 (or url-gateway-telnet-password
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
187 (setq url-gateway-telnet-password
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
188 (funcall url-passwd-entry-func "Password: ")))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
189 "\n"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
190 (erase-buffer)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
191 (url-wait-for-string url-gateway-prompt-pattern proc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
192 (process-send-string
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
193 proc (concat (mapconcat 'identity
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
194 (append url-gateway-telnet-parameters
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
195 (list host service)) " ") "\n"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
196 (url-wait-for-string "^\r*Escape character.*\r*\n+" proc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
197 (delete-region (point-min) (match-end 0))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
198 (process-send-string proc "\^]\n")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
199 (url-wait-for-string "^telnet" proc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
200 (process-send-string proc "mode character\n")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
201 (accept-process-output proc 1)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
202 (sit-for 1)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
203 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
204 (forward-line 1)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
205 (delete-region (point) (point-max)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
206 proc)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
207
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
208 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
209 (defun url-open-stream (name buffer host service)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
210 "Open a stream to HOST, possibly via a gateway.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
211 Args per `open-network-stream'.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
212 Will not make a connexion if `url-gateway-unplugged' is non-nil."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
213 (unless url-gateway-unplugged
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
214 (let ((gw-method (if (and url-gateway-local-host-regexp
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
215 (not (eq 'ssl url-gateway-method))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
216 (string-match
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
217 url-gateway-local-host-regexp
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
218 host))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
219 'native
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
220 url-gateway-method))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
221 ;;; ;; This hack is for OS/2 Emacs so that it will not do bogus CRLF
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
222 ;;; ;; conversions while trying to be 'helpful'
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
223 ;;; (tcp-binary-process-output-services (if (stringp service)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
224 ;;; (list service)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
225 ;;; (list service
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
226 ;;; (int-to-string service))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
227
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
228 ;; An attempt to deal with denied connections, and attempt
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
229 ;; to reconnect
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
230 (cur-retries 0)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
231 (retry t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
232 (errobj nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
233 (conn nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
234
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
235 ;; If the user told us to do DNS for them, do it.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
236 (if url-gateway-broken-resolution
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
237 (setq host (url-gateway-nslookup-host host)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
238
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
239 (condition-case errobj
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
240 ;; This is a clean way to ensure the new process inherits the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
241 ;; right coding systems in both Emacs and XEmacs.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
242 (let ((coding-system-for-read 'binary)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
243 (coding-system-for-write 'binary))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
244 (setq conn (case gw-method
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
245 (ssl
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
246 (open-ssl-stream name buffer host service))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
247 ((native)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
248 (open-network-stream name buffer host service))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
249 (socks
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
250 (socks-open-network-stream name buffer host service))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
251 (telnet
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
252 (url-open-telnet name buffer host service))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
253 (rlogin
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
254 (url-open-rlogin name buffer host service))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
255 (otherwise
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
256 (error "Bad setting of url-gateway-method: %s"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
257 url-gateway-method)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
258 (error
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
259 (setq conn nil)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
260 conn)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
261
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
262 (provide 'url-gw)
|
54699
|
263
|
|
264 ;;; arch-tag: 1c4c0317-6d03-45b8-b3f3-838bd8f9d838
|