Mercurial > emacs
annotate lisp/net/net-utils.el @ 92982:afa7a7913261
* tramp.el (tramp-root-regexp): New defconst.
(tramp-completion-file-name-regexp-unified)
(tramp-completion-file-name-regexp-separate)
(tramp-completion-file-name-regexp-url): Use it.
(tramp-do-copy-or-rename-file-via-buffer): Set
`enable-multibyte-characters' to nil. Set `jka-compr-inhibit' to
t for `insert-file-contents-literally'.
(tramp-drop-volume-letter): Rewrite, using `tramp-root-regexp'.
Autoload it.
(tramp-completion-file-name-handler-post-function): New defconst.
(tramp-completion-file-name-handler): Use it.
(tramp-maybe-open-connection): Update calls to
`tramp-flush-connection-property' for removed 2nd argument.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Sat, 15 Mar 2008 21:54:02 +0000 |
parents | 9f968e893cca |
children | 1e3a407766b9 |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36225
diff
changeset
|
1 ;;; net-utils.el --- network functions |
28210 | 2 |
64701
34bd8e434dd7
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
79714 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
36225 | 5 |
28210 | 6 ;; Author: Peter Breton <pbreton@cs.umb.edu> |
7 ;; Created: Sun Mar 16 1997 | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
8 ;; Keywords: network comm |
28210 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
78230
84cf1e2214c5
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
76162
diff
changeset
|
14 ;; the Free Software Foundation; either version 3, or (at your option) |
28210 | 15 ;; any later version. |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
28210 | 26 |
27 ;;; Commentary: | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
28 |
28210 | 29 ;; |
30 ;; There are three main areas of functionality: | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
31 ;; |
28210 | 32 ;; * Wrap common network utility programs (ping, traceroute, netstat, |
33 ;; nslookup, arp, route). Note that these wrappers are of the diagnostic | |
34 ;; functions of these programs only. | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
35 ;; |
28210 | 36 ;; * Implement some very basic protocols in Emacs Lisp (finger and whois) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
37 ;; |
28210 | 38 ;; * Support connections to HOST/PORT, generally for debugging and the like. |
39 ;; In other words, for doing much the same thing as "telnet HOST PORT", and | |
40 ;; then typing commands. | |
41 ;; | |
42 ;; PATHS | |
43 ;; | |
44 ;; On some systems, some of these programs are not in normal user path, | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
45 ;; but rather in /sbin, /usr/sbin, and so on. |
28210 | 46 |
47 | |
48 ;;; Code: | |
49 | |
50 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
51 ;; Customization Variables | |
52 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
53 | |
54 (defgroup net-utils nil | |
55 "Network utility functions." | |
56 :prefix "net-utils-" | |
57 :group 'comm | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
58 :version "20.3") |
28210 | 59 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
60 (defcustom net-utils-remove-ctl-m |
28210 | 61 (member system-type (list 'windows-nt 'msdos)) |
62 "If non-nil, remove control-Ms from output." | |
63 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
64 :type 'boolean) |
28210 | 65 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
66 (defcustom traceroute-program |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
67 (if (eq system-type 'windows-nt) |
28210 | 68 "tracert" |
69 "traceroute") | |
70 "Program to trace network hops to a destination." | |
71 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
72 :type 'string) |
28210 | 73 |
74 (defcustom traceroute-program-options nil | |
75 "Options for the traceroute program." | |
76 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
77 :type '(repeat string)) |
28210 | 78 |
79 (defcustom ping-program "ping" | |
80 "Program to send network test packets to a host." | |
81 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
82 :type 'string) |
28210 | 83 |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
84 ;; On GNU/Linux and Irix, the system's ping program seems to send packets |
28210 | 85 ;; indefinitely unless told otherwise |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
86 (defcustom ping-program-options |
28210 | 87 (and (memq system-type (list 'linux 'gnu/linux 'irix)) |
88 (list "-c" "4")) | |
89 "Options for the ping program. | |
90 These options can be used to limit how many ICMP packets are emitted." | |
91 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
92 :type '(repeat string)) |
28210 | 93 |
80077
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
94 (defcustom ifconfig-program |
28210 | 95 (if (eq system-type 'windows-nt) |
96 "ipconfig" | |
97 "ifconfig") | |
98 "Program to print network configuration information." | |
99 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
100 :type 'string) |
28210 | 101 |
80081
b0ced9a93377
(ipconfig-program, ipconfig-program-options): Add obsolete aliases to
Glenn Morris <rgm@gnu.org>
parents:
80077
diff
changeset
|
102 (define-obsolete-variable-alias 'ipconfig-program 'ifconfig-program "22.2") |
b0ced9a93377
(ipconfig-program, ipconfig-program-options): Add obsolete aliases to
Glenn Morris <rgm@gnu.org>
parents:
80077
diff
changeset
|
103 |
80077
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
104 (defcustom ifconfig-program-options |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
105 (list |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
106 (if (eq system-type 'windows-nt) |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
107 "/all" "-a")) |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
108 "Options for the ifconfig program." |
28210 | 109 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
110 :type '(repeat string)) |
28210 | 111 |
92133
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
112 (defcustom iwconfig-program "iwconfig" |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
113 "Program to print wireless network configuration information." |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
114 :group 'net-utils |
92134
ce1187e14779
(iwconfig-program, iwconfig-program-options): Add :version.
Glenn Morris <rgm@gnu.org>
parents:
92133
diff
changeset
|
115 :type 'string |
ce1187e14779
(iwconfig-program, iwconfig-program-options): Add :version.
Glenn Morris <rgm@gnu.org>
parents:
92133
diff
changeset
|
116 :version "23.1") |
92133
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
117 |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
118 (defcustom iwconfig-program-options nil |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
119 "Options for the iwconfig program." |
92133
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
120 :group 'net-utils |
92134
ce1187e14779
(iwconfig-program, iwconfig-program-options): Add :version.
Glenn Morris <rgm@gnu.org>
parents:
92133
diff
changeset
|
121 :type '(repeat string) |
ce1187e14779
(iwconfig-program, iwconfig-program-options): Add :version.
Glenn Morris <rgm@gnu.org>
parents:
92133
diff
changeset
|
122 :version "23.1") |
92133
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
123 |
80081
b0ced9a93377
(ipconfig-program, ipconfig-program-options): Add obsolete aliases to
Glenn Morris <rgm@gnu.org>
parents:
80077
diff
changeset
|
124 (define-obsolete-variable-alias 'ipconfig-program-options |
b0ced9a93377
(ipconfig-program, ipconfig-program-options): Add obsolete aliases to
Glenn Morris <rgm@gnu.org>
parents:
80077
diff
changeset
|
125 'ifconfig-program-options "22.2") |
b0ced9a93377
(ipconfig-program, ipconfig-program-options): Add obsolete aliases to
Glenn Morris <rgm@gnu.org>
parents:
80077
diff
changeset
|
126 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
127 (defcustom netstat-program "netstat" |
28210 | 128 "Program to print network statistics." |
129 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
130 :type 'string) |
28210 | 131 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
132 (defcustom netstat-program-options |
28210 | 133 (list "-a") |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
134 "Options for the netstat program." |
28210 | 135 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
136 :type '(repeat string)) |
28210 | 137 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
138 (defcustom arp-program "arp" |
28210 | 139 "Program to print IP to address translation tables." |
140 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
141 :type 'string) |
28210 | 142 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
143 (defcustom arp-program-options |
28210 | 144 (list "-a") |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
145 "Options for the arp program." |
28210 | 146 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
147 :type '(repeat string)) |
28210 | 148 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
149 (defcustom route-program |
28210 | 150 (if (eq system-type 'windows-nt) |
151 "route" | |
152 "netstat") | |
153 "Program to print routing tables." | |
154 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
155 :type 'string) |
28210 | 156 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
157 (defcustom route-program-options |
28210 | 158 (if (eq system-type 'windows-nt) |
159 (list "print") | |
160 (list "-r")) | |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
161 "Options for the route program." |
28210 | 162 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
163 :type '(repeat string)) |
28210 | 164 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
165 (defcustom nslookup-program "nslookup" |
28210 | 166 "Program to interactively query DNS information." |
167 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
168 :type 'string) |
28210 | 169 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
170 (defcustom nslookup-program-options nil |
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
171 "Options for the nslookup program." |
28210 | 172 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
173 :type '(repeat string)) |
28210 | 174 |
175 (defcustom nslookup-prompt-regexp "^> " | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
176 "Regexp to match the nslookup prompt. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
177 |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
178 This variable is only used if the variable |
61875
cff214e628c2
(nslookup-prompt-regexp, ftp-prompt-regexp, smbclient-prompt-regexp):
Luc Teirlinck <teirllm@auburn.edu>
parents:
57161
diff
changeset
|
179 `comint-use-prompt-regexp' is non-nil." |
28210 | 180 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
181 :type 'regexp) |
28210 | 182 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
183 (defcustom dig-program "dig" |
28210 | 184 "Program to query DNS information." |
185 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
186 :type 'string) |
28210 | 187 |
188 (defcustom ftp-program "ftp" | |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
189 "Program to run to do FTP transfers." |
28210 | 190 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
191 :type 'string) |
28210 | 192 |
193 (defcustom ftp-program-options nil | |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
194 "Options for the ftp program." |
28210 | 195 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
196 :type '(repeat string)) |
28210 | 197 |
198 (defcustom ftp-prompt-regexp "^ftp>" | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
199 "Regexp which matches the FTP program's prompt. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
200 |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
201 This variable is only used if the variable |
61875
cff214e628c2
(nslookup-prompt-regexp, ftp-prompt-regexp, smbclient-prompt-regexp):
Luc Teirlinck <teirllm@auburn.edu>
parents:
57161
diff
changeset
|
202 `comint-use-prompt-regexp' is non-nil." |
28210 | 203 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
204 :type 'regexp) |
28210 | 205 |
206 (defcustom smbclient-program "smbclient" | |
207 "Smbclient program." | |
208 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
209 :type 'string) |
28210 | 210 |
211 (defcustom smbclient-program-options nil | |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
212 "Options for the smbclient program." |
28210 | 213 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
214 :type '(repeat string)) |
28210 | 215 |
216 (defcustom smbclient-prompt-regexp "^smb: \>" | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
217 "Regexp which matches the smbclient program's prompt. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
218 |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
219 This variable is only used if the variable |
61875
cff214e628c2
(nslookup-prompt-regexp, ftp-prompt-regexp, smbclient-prompt-regexp):
Luc Teirlinck <teirllm@auburn.edu>
parents:
57161
diff
changeset
|
220 `comint-use-prompt-regexp' is non-nil." |
28210 | 221 :group 'net-utils |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
222 :type 'regexp) |
28210 | 223 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
224 (defcustom dns-lookup-program "host" |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
225 "Program to interactively query DNS information." |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
226 :group 'net-utils |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
227 :type 'string) |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
228 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
229 (defcustom dns-lookup-program-options nil |
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
230 "Options for the dns-lookup program." |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
231 :group 'net-utils |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
232 :type '(repeat string)) |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
233 |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
234 ;; Internal variables |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
235 (defvar network-connection-service nil) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
236 (defvar network-connection-host nil) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
237 |
28210 | 238 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
239 ;; Nslookup goodies | |
240 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
241 | |
242 (defconst nslookup-font-lock-keywords | |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
243 (list |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
244 (list "^[A-Za-z0-9 _]+:" 0 'font-lock-type-face) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
245 (list "\\<\\(SOA\\|NS\\|MX\\|A\\|CNAME\\)\\>" |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
246 1 'font-lock-keyword-face) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
247 ;; Dotted quads |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
248 (list |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
249 (mapconcat 'identity |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
250 (make-list 4 "[0-9]+") |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
251 "\\.") |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
252 0 'font-lock-variable-name-face) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
253 ;; Host names |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
254 (list |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
255 (let ((host-expression "[-A-Za-z0-9]+")) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
256 (concat |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
257 (mapconcat 'identity |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
258 (make-list 2 host-expression) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
259 "\\.") |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
260 "\\(\\." host-expression "\\)*")) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
261 0 'font-lock-variable-name-face)) |
32158
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
262 "Expressions to font-lock for nslookup.") |
28210 | 263 |
264 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
265 ;; Utility functions | |
266 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
267 | |
268 ;; Simplified versions of some at-point functions from ffap.el. | |
269 ;; It's not worth loading all of ffap just for these. | |
270 (defun net-utils-machine-at-point () | |
271 (let ((pt (point))) | |
272 (buffer-substring-no-properties | |
273 (save-excursion | |
274 (skip-chars-backward "-a-zA-Z0-9.") | |
275 (point)) | |
276 (save-excursion | |
277 (skip-chars-forward "-a-zA-Z0-9.") | |
278 (skip-chars-backward "." pt) | |
279 (point))))) | |
280 | |
281 (defun net-utils-url-at-point () | |
282 (let ((pt (point))) | |
283 (buffer-substring-no-properties | |
284 (save-excursion | |
285 (skip-chars-backward "--:=&?$+@-Z_a-z~#,%") | |
286 (skip-chars-forward "^A-Za-z0-9" pt) | |
287 (point)) | |
288 (save-excursion | |
289 (skip-chars-forward "--:=&?$+@-Z_a-z~#,%") | |
290 (skip-chars-backward ":;.,!?" pt) | |
291 (point))))) | |
292 | |
293 | |
294 (defun net-utils-remove-ctrl-m-filter (process output-string) | |
295 "Remove trailing control Ms." | |
296 (let ((old-buffer (current-buffer)) | |
297 (filtered-string output-string)) | |
298 (unwind-protect | |
299 (let ((moving)) | |
300 (set-buffer (process-buffer process)) | |
301 (setq moving (= (point) (process-mark process))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
302 |
28210 | 303 (while (string-match "\r" filtered-string) |
304 (setq filtered-string | |
305 (replace-match "" nil nil filtered-string))) | |
306 | |
307 (save-excursion | |
308 ;; Insert the text, moving the process-marker. | |
309 (goto-char (process-mark process)) | |
310 (insert filtered-string) | |
311 (set-marker (process-mark process) (point))) | |
312 (if moving (goto-char (process-mark process)))) | |
313 (set-buffer old-buffer)))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
314 |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
315 (defun net-utils-run-program (name header program args) |
28210 | 316 "Run a network information program." |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
317 (let ((buf (get-buffer-create (concat "*" name "*")))) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
318 (set-buffer buf) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
319 (erase-buffer) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
320 (insert header "\n") |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
321 (set-process-filter |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
322 (apply 'start-process name buf program args) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
323 'net-utils-remove-ctrl-m-filter) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
324 (display-buffer buf) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
325 buf)) |
28210 | 326 |
327 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
328 ;; Wrappers for external network programs | |
329 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
330 | |
331 ;;;###autoload | |
332 (defun traceroute (target) | |
333 "Run traceroute program for TARGET." | |
334 (interactive "sTarget: ") | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
335 (let ((options |
28210 | 336 (if traceroute-program-options |
337 (append traceroute-program-options (list target)) | |
338 (list target)))) | |
339 (net-utils-run-program | |
340 (concat "Traceroute" " " target) | |
341 (concat "** Traceroute ** " traceroute-program " ** " target) | |
342 traceroute-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
343 options))) |
28210 | 344 |
345 ;;;###autoload | |
346 (defun ping (host) | |
347 "Ping HOST. | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
348 If your system's ping continues until interrupted, you can try setting |
28210 | 349 `ping-program-options'." |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
350 (interactive |
28210 | 351 (list (read-from-minibuffer "Ping host: " (net-utils-machine-at-point)))) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
352 (let ((options |
28210 | 353 (if ping-program-options |
354 (append ping-program-options (list host)) | |
355 (list host)))) | |
356 (net-utils-run-program | |
357 (concat "Ping" " " host) | |
358 (concat "** Ping ** " ping-program " ** " host) | |
359 ping-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
360 options))) |
28210 | 361 |
362 ;;;###autoload | |
80077
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
363 (defun ifconfig () |
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
364 "Run ifconfig program." |
28210 | 365 (interactive) |
366 (net-utils-run-program | |
80077
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
367 "Ifconfig" |
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
368 (concat "** Ifconfig ** " ifconfig-program " ** ") |
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
369 ifconfig-program |
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
370 ifconfig-program-options)) |
28210 | 371 |
80077
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
372 ;; Windows uses this name. |
28210 | 373 ;;;###autoload |
80077
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
374 (defalias 'ipconfig 'ifconfig) |
28210 | 375 |
376 ;;;###autoload | |
92133
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
377 (defun iwconfig () |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
378 "Run iwconfig program." |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
379 (interactive) |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
380 (net-utils-run-program |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
381 "Iwconfig" |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
382 (concat "** Iwconfig ** " iwconfig-program " ** ") |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
383 iwconfig-program |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
384 iwconfig-program-options)) |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
385 |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
386 ;;;###autoload |
28210 | 387 (defun netstat () |
388 "Run netstat program." | |
389 (interactive) | |
390 (net-utils-run-program | |
391 "Netstat" | |
392 (concat "** Netstat ** " netstat-program " ** ") | |
393 netstat-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
394 netstat-program-options)) |
28210 | 395 |
396 ;;;###autoload | |
397 (defun arp () | |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
398 "Run arp program." |
28210 | 399 (interactive) |
400 (net-utils-run-program | |
401 "Arp" | |
402 (concat "** Arp ** " arp-program " ** ") | |
403 arp-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
404 arp-program-options)) |
28210 | 405 |
406 ;;;###autoload | |
407 (defun route () | |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
408 "Run route program." |
28210 | 409 (interactive) |
410 (net-utils-run-program | |
411 "Route" | |
412 (concat "** Route ** " route-program " ** ") | |
413 route-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
414 route-program-options)) |
28210 | 415 |
416 ;; FIXME -- Needs to be a process filter | |
417 ;; (defun netstat-with-filter (filter) | |
418 ;; "Run netstat program." | |
419 ;; (interactive "sFilter: ") | |
420 ;; (netstat) | |
421 ;; (set-buffer (get-buffer "*Netstat*")) | |
422 ;; (goto-char (point-min)) | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
423 ;; (delete-matching-lines filter)) |
28210 | 424 |
425 ;;;###autoload | |
426 (defun nslookup-host (host) | |
427 "Lookup the DNS information for HOST." | |
428 (interactive | |
429 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point)))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
430 (let ((options |
28210 | 431 (if nslookup-program-options |
432 (append nslookup-program-options (list host)) | |
433 (list host)))) | |
434 (net-utils-run-program | |
435 "Nslookup" | |
436 (concat "** " | |
437 (mapconcat 'identity | |
438 (list "Nslookup" host nslookup-program) | |
439 " ** ")) | |
440 nslookup-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
441 options))) |
28210 | 442 |
443 ;;;###autoload | |
444 (defun nslookup () | |
445 "Run nslookup program." | |
446 (interactive) | |
447 (comint-run nslookup-program) | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
448 (nslookup-mode)) |
28210 | 449 |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
450 (defvar comint-prompt-regexp) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
451 (defvar comint-input-autoexpand) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
452 |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
453 (autoload 'comint-mode "comint" nil t) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
454 |
28210 | 455 ;; Using a derived mode gives us keymaps, hooks, etc. |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
456 (define-derived-mode nslookup-mode comint-mode "Nslookup" |
28210 | 457 "Major mode for interacting with the nslookup program." |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
458 (set |
28210 | 459 (make-local-variable 'font-lock-defaults) |
460 '((nslookup-font-lock-keywords))) | |
461 (setq comint-prompt-regexp nslookup-prompt-regexp) | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
462 (setq comint-input-autoexpand t)) |
28210 | 463 |
464 (define-key nslookup-mode-map "\t" 'comint-dynamic-complete) | |
465 | |
466 ;;;###autoload | |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
467 (defun dns-lookup-host (host) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
468 "Lookup the DNS information for HOST (name or IP address)." |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
469 (interactive |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
470 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point)))) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
471 (let ((options |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
472 (if dns-lookup-program-options |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
473 (append dns-lookup-program-options (list host)) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
474 (list host)))) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
475 (net-utils-run-program |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
476 (concat "DNS Lookup [" host "]") |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
477 (concat "** " |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
478 (mapconcat 'identity |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
479 (list "DNS Lookup" host dns-lookup-program) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
480 " ** ")) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
481 dns-lookup-program |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
482 options))) |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
483 |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
484 (autoload 'ffap-string-at-point "ffap") |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
485 |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
486 ;;;###autoload |
64805
9612798470fd
(run-dig): Renamed from `dig'.
Richard M. Stallman <rms@gnu.org>
parents:
64701
diff
changeset
|
487 (defun run-dig (host) |
28210 | 488 "Run dig program." |
489 (interactive | |
490 (list | |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
491 (read-from-minibuffer "Lookup host: " |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
492 (or (ffap-string-at-point 'machine) "")))) |
28210 | 493 (net-utils-run-program |
494 "Dig" | |
495 (concat "** " | |
496 (mapconcat 'identity | |
497 (list "Dig" host dig-program) | |
498 " ** ")) | |
499 dig-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
500 (list host))) |
28210 | 501 |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
502 (autoload 'comint-exec "comint") |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
503 |
28210 | 504 ;; This is a lot less than ange-ftp, but much simpler. |
505 ;;;###autoload | |
506 (defun ftp (host) | |
507 "Run ftp program." | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
508 (interactive |
28210 | 509 (list |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
510 (read-from-minibuffer |
28210 | 511 "Ftp to Host: " (net-utils-machine-at-point)))) |
512 (let ((buf (get-buffer-create (concat "*ftp [" host "]*")))) | |
513 (set-buffer buf) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
514 (ftp-mode) |
28210 | 515 (comint-exec buf (concat "ftp-" host) ftp-program nil |
516 (if ftp-program-options | |
517 (append (list host) ftp-program-options) | |
518 (list host))) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
519 (pop-to-buffer buf))) |
28210 | 520 |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
521 (define-derived-mode ftp-mode comint-mode "FTP" |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
522 "Major mode for interacting with the ftp program." |
28210 | 523 (setq comint-prompt-regexp ftp-prompt-regexp) |
524 (setq comint-input-autoexpand t) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
525 ;; Only add the password-prompting hook if it's not already in the |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
526 ;; global hook list. This stands a small chance of losing, if it's |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
527 ;; later removed from the global list (very small, since any |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
528 ;; password prompts will probably immediately follow the initial |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
529 ;; connection), but it's better than getting prompted twice for the |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
530 ;; same password. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
531 (unless (memq 'comint-watch-for-password-prompt |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
532 (default-value 'comint-output-filter-functions)) |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
533 (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
534 nil t))) |
28210 | 535 |
536 ;; Occasionally useful | |
537 (define-key ftp-mode-map "\t" 'comint-dynamic-complete) | |
538 | |
539 (defun smbclient (host service) | |
540 "Connect to SERVICE on HOST via SMB." | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
541 (interactive |
28210 | 542 (list |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
543 (read-from-minibuffer |
28210 | 544 "Connect to Host: " (net-utils-machine-at-point)) |
545 (read-from-minibuffer "SMB Service: "))) | |
546 (let* ((name (format "smbclient [%s\\%s]" host service)) | |
547 (buf (get-buffer-create (concat "*" name "*"))) | |
548 (service-name (concat "\\\\" host "\\" service))) | |
549 (set-buffer buf) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
550 (smbclient-mode) |
28210 | 551 (comint-exec buf name smbclient-program nil |
552 (if smbclient-program-options | |
553 (append (list service-name) smbclient-program-options) | |
554 (list service-name))) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
555 (pop-to-buffer buf))) |
28210 | 556 |
557 (defun smbclient-list-shares (host) | |
558 "List services on HOST." | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
559 (interactive |
28210 | 560 (list |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
561 (read-from-minibuffer |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
562 "Connect to Host: " (net-utils-machine-at-point)))) |
28210 | 563 (let ((buf (get-buffer-create (format "*SMB Shares on %s*" host)))) |
564 (set-buffer buf) | |
565 (smbclient-mode) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
566 (comint-exec buf "smbclient-list-shares" |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
567 smbclient-program nil (list "-L" host)) |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
568 (pop-to-buffer buf))) |
28210 | 569 |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
570 (define-derived-mode smbclient-mode comint-mode "smbclient" |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
571 "Major mode for interacting with the smbclient program." |
28210 | 572 (setq comint-prompt-regexp smbclient-prompt-regexp) |
573 (setq comint-input-autoexpand t) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
574 ;; Only add the password-prompting hook if it's not already in the |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
575 ;; global hook list. This stands a small chance of losing, if it's |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
576 ;; later removed from the global list (very small, since any |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
577 ;; password prompts will probably immediately follow the initial |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
578 ;; connection), but it's better than getting prompted twice for the |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
579 ;; same password. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
580 (unless (memq 'comint-watch-for-password-prompt |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
581 (default-value 'comint-output-filter-functions)) |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
582 (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
583 nil t))) |
28210 | 584 |
585 | |
586 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
587 ;; Network Connections | |
588 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
589 | |
590 ;; Full list is available at: | |
57161 | 591 ;; http://www.iana.org/assignments/port-numbers |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
592 (defvar network-connection-service-alist |
28210 | 593 (list |
594 (cons 'echo 7) | |
595 (cons 'active-users 11) | |
596 (cons 'daytime 13) | |
597 (cons 'chargen 19) | |
598 (cons 'ftp 21) | |
599 (cons 'telnet 23) | |
600 (cons 'smtp 25) | |
601 (cons 'time 37) | |
602 (cons 'whois 43) | |
603 (cons 'gopher 70) | |
604 (cons 'finger 79) | |
605 (cons 'www 80) | |
606 (cons 'pop2 109) | |
607 (cons 'pop3 110) | |
608 (cons 'sun-rpc 111) | |
609 (cons 'nntp 119) | |
610 (cons 'ntp 123) | |
611 (cons 'netbios-name 137) | |
612 (cons 'netbios-data 139) | |
613 (cons 'irc 194) | |
614 (cons 'https 443) | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
615 (cons 'rlogin 513)) |
28210 | 616 "Alist of services and associated TCP port numbers. |
41257
0605a90581d4
(network-connection-service-abbrev-alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
617 This list is not complete.") |
0605a90581d4
(network-connection-service-abbrev-alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
618 |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
619 ;; Workhorse routine |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
620 (defun run-network-program (process-name host port &optional initial-string) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
621 (let ((tcp-connection) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
622 (buf)) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
623 (setq buf (get-buffer-create (concat "*" process-name "*"))) |
28210 | 624 (set-buffer buf) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
625 (or |
28210 | 626 (setq tcp-connection |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
627 (open-network-stream process-name buf host port)) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
628 (error "Could not open connection to %s" host)) |
28210 | 629 (erase-buffer) |
630 (set-marker (process-mark tcp-connection) (point-min)) | |
631 (set-process-filter tcp-connection 'net-utils-remove-ctrl-m-filter) | |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
632 (and initial-string |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
633 (process-send-string tcp-connection |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
634 (concat initial-string "\r\n"))) |
28210 | 635 (display-buffer buf))) |
636 | |
637 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
638 ;; Simple protocols | |
639 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
640 | |
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
641 (defcustom finger-X.500-host-regexps nil |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
642 "A list of regular expressions matching host names. |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
643 If a host name passed to `finger' matches one of these regular |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
644 expressions, it is assumed to be a host that doesn't accept |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
645 queries of the form USER@HOST, and wants a query containing USER only." |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
646 :group 'net-utils |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
647 :type '(repeat regexp) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
648 :version "21.1") |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
649 |
28210 | 650 ;; Finger protocol |
651 ;;;###autoload | |
652 (defun finger (user host) | |
653 "Finger USER on HOST." | |
654 ;; One of those great interactive statements that's actually | |
655 ;; longer than the function call! The idea is that if the user | |
656 ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the | |
657 ;; host name. If we don't see an "@", we'll prompt for the host. | |
658 (interactive | |
659 (let* ((answer (read-from-minibuffer "Finger User: " | |
660 (net-utils-url-at-point))) | |
661 (index (string-match (regexp-quote "@") answer))) | |
662 (if index | |
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
663 (list (substring answer 0 index) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
664 (substring answer (1+ index))) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
665 (list answer |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
666 (read-from-minibuffer "At Host: " |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
667 (net-utils-machine-at-point)))))) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
668 (let* ((user-and-host (concat user "@" host)) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
669 (process-name (concat "Finger [" user-and-host "]")) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
670 (regexps finger-X.500-host-regexps) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
671 found) |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
672 (and regexps |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
673 (while (not (string-match (car regexps) host)) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
674 (setq regexps (cdr regexps))) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
675 (when regexps |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
676 (setq user-and-host user))) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
677 (run-network-program |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
678 process-name |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
679 host |
28210 | 680 (cdr (assoc 'finger network-connection-service-alist)) |
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
681 user-and-host))) |
28210 | 682 |
683 (defcustom whois-server-name "rs.internic.net" | |
684 "Default host name for the whois service." | |
685 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
686 :type 'string) |
28210 | 687 |
688 (defcustom whois-server-list | |
689 '(("whois.arin.net") ; Networks, ASN's, and related POC's (numbers) | |
690 ("rs.internic.net") ; domain related info | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
691 ("whois.publicinterestregistry.net") |
28210 | 692 ("whois.abuse.net") |
693 ("whois.apnic.net") | |
694 ("nic.ddn.mil") | |
695 ("whois.nic.mil") | |
696 ("whois.nic.gov") | |
697 ("whois.ripe.net")) | |
698 "A list of whois servers that can be queried." | |
699 :group 'net-utils | |
700 :type '(repeat (list string))) | |
701 | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
702 ;; FIXME: modern whois clients include a much better tld <-> whois server |
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
703 ;; list, Emacs should probably avoid specifying the server as the client |
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
704 ;; will DTRT anyway... -rfr |
28210 | 705 (defcustom whois-server-tld |
706 '(("rs.internic.net" . "com") | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
707 ("whois.publicinterestregistry.net" . "org") |
28210 | 708 ("whois.ripe.net" . "be") |
709 ("whois.ripe.net" . "de") | |
710 ("whois.ripe.net" . "dk") | |
711 ("whois.ripe.net" . "it") | |
712 ("whois.ripe.net" . "fi") | |
713 ("whois.ripe.net" . "fr") | |
714 ("whois.ripe.net" . "uk") | |
715 ("whois.apnic.net" . "au") | |
716 ("whois.apnic.net" . "ch") | |
717 ("whois.apnic.net" . "hk") | |
718 ("whois.apnic.net" . "jp") | |
719 ("whois.nic.gov" . "gov") | |
720 ("whois.nic.mil" . "mil")) | |
721 "Alist to map top level domains to whois servers." | |
722 :group 'net-utils | |
723 :type '(repeat (cons string string))) | |
724 | |
725 (defcustom whois-guess-server t | |
726 "If non-nil then whois will try to deduce the appropriate whois | |
727 server from the query. If the query doesn't look like a domain or hostname | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
728 then the server named by `whois-server-name' is used." |
28210 | 729 :group 'net-utils |
730 :type 'boolean) | |
731 | |
732 (defun whois-get-tld (host) | |
733 "Return the top level domain of `host', or nil if it isn't a domain name." | |
734 (let ((i (1- (length host))) | |
735 (max-len (- (length host) 5))) | |
736 (while (not (or (= i max-len) (char-equal (aref host i) ?.))) | |
737 (setq i (1- i))) | |
738 (if (= i max-len) | |
739 nil | |
740 (substring host (1+ i))))) | |
741 | |
742 ;; Whois protocol | |
743 ;;;###autoload | |
744 (defun whois (arg search-string) | |
745 "Send SEARCH-STRING to server defined by the `whois-server-name' variable. | |
746 If `whois-guess-server' is non-nil, then try to deduce the correct server | |
747 from SEARCH-STRING. With argument, prompt for whois server." | |
748 (interactive "P\nsWhois: ") | |
749 (let* ((whois-apropos-host (if whois-guess-server | |
750 (rassoc (whois-get-tld search-string) | |
751 whois-server-tld) | |
752 nil)) | |
753 (server-name (if whois-apropos-host | |
754 (car whois-apropos-host) | |
755 whois-server-name)) | |
756 (host | |
757 (if arg | |
758 (completing-read "Whois server name: " | |
759 whois-server-list nil nil "whois.") | |
760 server-name))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
761 (run-network-program |
28210 | 762 "Whois" |
763 host | |
764 (cdr (assoc 'whois network-connection-service-alist)) | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
765 search-string))) |
28210 | 766 |
767 (defcustom whois-reverse-lookup-server "whois.arin.net" | |
768 "Server which provides inverse DNS mapping." | |
769 :group 'net-utils | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
770 :type 'string) |
28210 | 771 |
772 ;;;###autoload | |
773 (defun whois-reverse-lookup () | |
774 (interactive) | |
775 (let ((whois-server-name whois-reverse-lookup-server)) | |
776 (call-interactively 'whois))) | |
777 | |
778 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
779 ;;; General Network connection | |
780 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
781 | |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
782 ;; Using a derived mode gives us keymaps, hooks, etc. |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
783 (define-derived-mode |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
784 network-connection-mode comint-mode "Network-Connection" |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
785 "Major mode for interacting with the network-connection program.") |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
786 |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
787 (defun network-connection-mode-setup (host service) |
42303
c5ddbcd62234
(ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents:
41257
diff
changeset
|
788 (make-local-variable 'network-connection-host) |
c5ddbcd62234
(ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents:
41257
diff
changeset
|
789 (setq network-connection-host host) |
c5ddbcd62234
(ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents:
41257
diff
changeset
|
790 (make-local-variable 'network-connection-service) |
42310 | 791 (setq network-connection-service service)) |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
792 |
28210 | 793 ;;;###autoload |
794 (defun network-connection-to-service (host service) | |
795 "Open a network connection to SERVICE on HOST." | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
796 (interactive |
28210 | 797 (list |
798 (read-from-minibuffer "Host: " (net-utils-machine-at-point)) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
799 (completing-read "Service: " |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
800 (mapcar |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
801 (function |
28210 | 802 (lambda (elt) |
803 (list (symbol-name (car elt))))) | |
804 network-connection-service-alist)))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
805 (network-connection |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
806 host |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
807 (cdr (assoc (intern service) network-connection-service-alist)))) |
28210 | 808 |
809 ;;;###autoload | |
810 (defun network-connection (host port) | |
811 "Open a network connection to HOST on PORT." | |
812 (interactive "sHost: \nnPort: ") | |
813 (network-service-connection host (number-to-string port))) | |
814 | |
815 (defun network-service-connection (host service) | |
816 "Open a network connection to SERVICE on HOST." | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
817 (let* ((process-name (concat "Network Connection [" host " " service "]")) |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
818 (portnum (string-to-number service)) |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
819 (buf (get-buffer-create (concat "*" process-name "*")))) |
28210 | 820 (or (zerop portnum) (setq service portnum)) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
821 (make-comint |
28210 | 822 process-name |
823 (cons host service)) | |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
824 (set-buffer buf) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
825 (network-connection-mode) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
826 (network-connection-mode-setup host service) |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
827 (pop-to-buffer buf))) |
28210 | 828 |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
829 (defvar comint-input-ring) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
830 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
831 (defun network-connection-reconnect () |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
832 "Reconnect a network connection, preserving the old input ring." |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
833 (interactive) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
834 (let ((proc (get-buffer-process (current-buffer))) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
835 (old-comint-input-ring comint-input-ring) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
836 (host network-connection-host) |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
837 (service network-connection-service)) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
838 (if (not (or (not proc) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
839 (eq (process-status proc) 'closed))) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
840 (message "Still connected") |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
841 (goto-char (point-max)) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
842 (insert (format "Reopening connection to %s\n" host)) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
843 (network-connection host |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
844 (if (numberp service) |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
845 service |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
846 (cdr (assoc service network-connection-service-alist)))) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
847 (and old-comint-input-ring |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
848 (setq comint-input-ring old-comint-input-ring))))) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
849 |
28210 | 850 (provide 'net-utils) |
851 | |
52401 | 852 ;;; arch-tag: 97119e91-9edb-4376-838b-bf7058fa1314 |
28210 | 853 ;;; net-utils.el ends here |