Mercurial > emacs
annotate lisp/net/net-utils.el @ 92134:ce1187e14779
(iwconfig-program, iwconfig-program-options): Add :version.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 23 Feb 2008 20:02:45 +0000 |
parents | 7c818ca7aedb |
children | f991f10f15ec |
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 (eval-when-compile | |
50 (require 'comint)) | |
51 | |
52 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
53 ;; Customization Variables | |
54 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
55 | |
56 (defgroup net-utils nil | |
57 "Network utility functions." | |
58 :prefix "net-utils-" | |
59 :group 'comm | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
60 :version "20.3") |
28210 | 61 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
62 (defcustom net-utils-remove-ctl-m |
28210 | 63 (member system-type (list 'windows-nt 'msdos)) |
64 "If non-nil, remove control-Ms from output." | |
65 :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
|
66 :type 'boolean) |
28210 | 67 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
68 (defcustom traceroute-program |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
69 (if (eq system-type 'windows-nt) |
28210 | 70 "tracert" |
71 "traceroute") | |
72 "Program to trace network hops to a destination." | |
73 :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
|
74 :type 'string) |
28210 | 75 |
76 (defcustom traceroute-program-options nil | |
77 "Options for the traceroute program." | |
78 :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
|
79 :type '(repeat string)) |
28210 | 80 |
81 (defcustom ping-program "ping" | |
82 "Program to send network test packets to a host." | |
83 :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
|
84 :type 'string) |
28210 | 85 |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
86 ;; On GNU/Linux and Irix, the system's ping program seems to send packets |
28210 | 87 ;; indefinitely unless told otherwise |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
88 (defcustom ping-program-options |
28210 | 89 (and (memq system-type (list 'linux 'gnu/linux 'irix)) |
90 (list "-c" "4")) | |
91 "Options for the ping program. | |
92 These options can be used to limit how many ICMP packets are emitted." | |
93 :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
|
94 :type '(repeat string)) |
28210 | 95 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
96 (defcustom ipconfig-program |
28210 | 97 (if (eq system-type 'windows-nt) |
98 "ipconfig" | |
99 "ifconfig") | |
100 "Program to print network configuration information." | |
101 :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
|
102 :type 'string) |
28210 | 103 |
104 (defcustom ipconfig-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")) |
28210 | 108 "Options for ipconfig-program." |
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 |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
119 "Options for `iwconfig-program'." |
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 |
28210 | 124 (defcustom netstat-program "netstat" |
125 "Program to print network statistics." | |
126 :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
|
127 :type 'string) |
28210 | 128 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
129 (defcustom netstat-program-options |
28210 | 130 (list "-a") |
131 "Options for netstat-program." | |
132 :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
|
133 :type '(repeat string)) |
28210 | 134 |
135 (defcustom arp-program "arp" | |
136 "Program to print IP to address translation tables." | |
137 :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
|
138 :type 'string) |
28210 | 139 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
140 (defcustom arp-program-options |
28210 | 141 (list "-a") |
142 "Options for arp-program." | |
143 :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
|
144 :type '(repeat string)) |
28210 | 145 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
146 (defcustom route-program |
28210 | 147 (if (eq system-type 'windows-nt) |
148 "route" | |
149 "netstat") | |
150 "Program to print routing tables." | |
151 :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
|
152 :type 'string) |
28210 | 153 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
154 (defcustom route-program-options |
28210 | 155 (if (eq system-type 'windows-nt) |
156 (list "print") | |
157 (list "-r")) | |
158 "Options for route-program." | |
159 :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
|
160 :type '(repeat string)) |
28210 | 161 |
162 (defcustom nslookup-program "nslookup" | |
163 "Program to interactively query DNS information." | |
164 :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
|
165 :type 'string) |
28210 | 166 |
167 (defcustom nslookup-program-options nil | |
168 "List of options to pass to the nslookup program." | |
169 :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
|
170 :type '(repeat string)) |
28210 | 171 |
172 (defcustom nslookup-prompt-regexp "^> " | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
173 "Regexp to match the nslookup prompt. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
174 |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
175 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
|
176 `comint-use-prompt-regexp' is non-nil." |
28210 | 177 :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
|
178 :type 'regexp) |
28210 | 179 |
180 (defcustom dig-program "dig" | |
181 "Program to query DNS information." | |
182 :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
|
183 :type 'string) |
28210 | 184 |
185 (defcustom ftp-program "ftp" | |
186 "Progam to run to do FTP transfers." | |
187 :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
|
188 :type 'string) |
28210 | 189 |
190 (defcustom ftp-program-options nil | |
191 "List of options to pass to the FTP program." | |
192 :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
|
193 :type '(repeat string)) |
28210 | 194 |
195 (defcustom ftp-prompt-regexp "^ftp>" | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
196 "Regexp which matches the FTP program's prompt. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
197 |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
198 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
|
199 `comint-use-prompt-regexp' is non-nil." |
28210 | 200 :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
|
201 :type 'regexp) |
28210 | 202 |
203 (defcustom smbclient-program "smbclient" | |
204 "Smbclient program." | |
205 :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
|
206 :type 'string) |
28210 | 207 |
208 (defcustom smbclient-program-options nil | |
209 "List of options to pass to the smbclient program." | |
210 :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
|
211 :type '(repeat string)) |
28210 | 212 |
213 (defcustom smbclient-prompt-regexp "^smb: \>" | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
214 "Regexp which matches the smbclient program's prompt. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
215 |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
216 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
|
217 `comint-use-prompt-regexp' is non-nil." |
28210 | 218 :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
|
219 :type 'regexp) |
28210 | 220 |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
221 (defcustom dns-lookup-program "host" |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
222 "Program to interactively query DNS information." |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
223 :group 'net-utils |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
224 :type 'string |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
225 ) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
226 |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
227 (defcustom dns-lookup-program-options nil |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
228 "List of options to pass to the dns-lookup program." |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
229 :group 'net-utils |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
230 :type '(repeat string) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
231 ) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
232 |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
233 ;; Internal variables |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
234 (defvar network-connection-service nil) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
235 (defvar network-connection-host nil) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
236 |
28210 | 237 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
238 ;; Nslookup goodies | |
239 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
240 | |
241 (defconst nslookup-font-lock-keywords | |
32158
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
242 (progn |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
243 (defvar font-lock-type-face) |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
244 (defvar font-lock-keyword-face) |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
245 (defvar font-lock-variable-name-face) |
32158
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
246 (require 'font-lock) |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
247 (list |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
248 (list "^[A-Za-z0-9 _]+:" 0 font-lock-type-face) |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
249 (list "\\<\\(SOA\\|NS\\|MX\\|A\\|CNAME\\)\\>" |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
250 1 font-lock-keyword-face) |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
251 ;; Dotted quads |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
252 (list |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
253 (mapconcat 'identity |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
254 (make-list 4 "[0-9]+") |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
255 "\\.") |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
256 0 font-lock-variable-name-face) |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
257 ;; Host names |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
258 (list |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
259 (let ((host-expression "[-A-Za-z0-9]+")) |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
260 (concat |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
261 (mapconcat 'identity |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
262 (make-list 2 host-expression) |
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
263 "\\.") |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
264 "\\(\\." host-expression "\\)*")) |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
265 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
|
266 "Expressions to font-lock for nslookup.") |
28210 | 267 |
268 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
269 ;; Utility functions | |
270 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
271 | |
272 ;; Simplified versions of some at-point functions from ffap.el. | |
273 ;; It's not worth loading all of ffap just for these. | |
274 (defun net-utils-machine-at-point () | |
275 (let ((pt (point))) | |
276 (buffer-substring-no-properties | |
277 (save-excursion | |
278 (skip-chars-backward "-a-zA-Z0-9.") | |
279 (point)) | |
280 (save-excursion | |
281 (skip-chars-forward "-a-zA-Z0-9.") | |
282 (skip-chars-backward "." pt) | |
283 (point))))) | |
284 | |
285 (defun net-utils-url-at-point () | |
286 (let ((pt (point))) | |
287 (buffer-substring-no-properties | |
288 (save-excursion | |
289 (skip-chars-backward "--:=&?$+@-Z_a-z~#,%") | |
290 (skip-chars-forward "^A-Za-z0-9" pt) | |
291 (point)) | |
292 (save-excursion | |
293 (skip-chars-forward "--:=&?$+@-Z_a-z~#,%") | |
294 (skip-chars-backward ":;.,!?" pt) | |
295 (point))))) | |
296 | |
297 | |
298 (defun net-utils-remove-ctrl-m-filter (process output-string) | |
299 "Remove trailing control Ms." | |
300 (let ((old-buffer (current-buffer)) | |
301 (filtered-string output-string)) | |
302 (unwind-protect | |
303 (let ((moving)) | |
304 (set-buffer (process-buffer process)) | |
305 (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
|
306 |
28210 | 307 (while (string-match "\r" filtered-string) |
308 (setq filtered-string | |
309 (replace-match "" nil nil filtered-string))) | |
310 | |
311 (save-excursion | |
312 ;; Insert the text, moving the process-marker. | |
313 (goto-char (process-mark process)) | |
314 (insert filtered-string) | |
315 (set-marker (process-mark process) (point))) | |
316 (if moving (goto-char (process-mark process)))) | |
317 (set-buffer old-buffer)))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
318 |
28210 | 319 (defmacro net-utils-run-program (name header program &rest args) |
320 "Run a network information program." | |
321 ` (let ((buf (get-buffer-create (concat "*" ,name "*")))) | |
322 (set-buffer buf) | |
323 (erase-buffer) | |
324 (insert ,header "\n") | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
325 (set-process-filter |
28210 | 326 (apply 'start-process ,name buf ,program ,@args) |
327 'net-utils-remove-ctrl-m-filter) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
328 (display-buffer buf) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
329 buf)) |
28210 | 330 |
331 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
332 ;; Wrappers for external network programs | |
333 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
334 | |
335 ;;;###autoload | |
336 (defun traceroute (target) | |
337 "Run traceroute program for TARGET." | |
338 (interactive "sTarget: ") | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
339 (let ((options |
28210 | 340 (if traceroute-program-options |
341 (append traceroute-program-options (list target)) | |
342 (list target)))) | |
343 (net-utils-run-program | |
344 (concat "Traceroute" " " target) | |
345 (concat "** Traceroute ** " traceroute-program " ** " target) | |
346 traceroute-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
347 options))) |
28210 | 348 |
349 ;;;###autoload | |
350 (defun ping (host) | |
351 "Ping HOST. | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
352 If your system's ping continues until interrupted, you can try setting |
28210 | 353 `ping-program-options'." |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
354 (interactive |
28210 | 355 (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
|
356 (let ((options |
28210 | 357 (if ping-program-options |
358 (append ping-program-options (list host)) | |
359 (list host)))) | |
360 (net-utils-run-program | |
361 (concat "Ping" " " host) | |
362 (concat "** Ping ** " ping-program " ** " host) | |
363 ping-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
364 options))) |
28210 | 365 |
366 ;;;###autoload | |
367 (defun ipconfig () | |
368 "Run ipconfig program." | |
369 (interactive) | |
370 (net-utils-run-program | |
371 "Ipconfig" | |
372 (concat "** Ipconfig ** " ipconfig-program " ** ") | |
373 ipconfig-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
374 ipconfig-program-options)) |
28210 | 375 |
376 ;; This is the normal name on most Unixes. | |
377 ;;;###autoload | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
378 (defalias 'ifconfig 'ipconfig) |
28210 | 379 |
380 ;;;###autoload | |
92133
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
381 (defun iwconfig () |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
382 "Run iwconfig program." |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
383 (interactive) |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
384 (net-utils-run-program |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
385 "Iwconfig" |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
386 (concat "** Iwconfig ** " iwconfig-program " ** ") |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
387 iwconfig-program |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
388 iwconfig-program-options)) |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
389 |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
390 ;;;###autoload |
28210 | 391 (defun netstat () |
392 "Run netstat program." | |
393 (interactive) | |
394 (net-utils-run-program | |
395 "Netstat" | |
396 (concat "** Netstat ** " netstat-program " ** ") | |
397 netstat-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
398 netstat-program-options)) |
28210 | 399 |
400 ;;;###autoload | |
401 (defun arp () | |
402 "Run the arp program." | |
403 (interactive) | |
404 (net-utils-run-program | |
405 "Arp" | |
406 (concat "** Arp ** " arp-program " ** ") | |
407 arp-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
408 arp-program-options)) |
28210 | 409 |
410 ;;;###autoload | |
411 (defun route () | |
412 "Run the route program." | |
413 (interactive) | |
414 (net-utils-run-program | |
415 "Route" | |
416 (concat "** Route ** " route-program " ** ") | |
417 route-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
418 route-program-options)) |
28210 | 419 |
420 ;; FIXME -- Needs to be a process filter | |
421 ;; (defun netstat-with-filter (filter) | |
422 ;; "Run netstat program." | |
423 ;; (interactive "sFilter: ") | |
424 ;; (netstat) | |
425 ;; (set-buffer (get-buffer "*Netstat*")) | |
426 ;; (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
|
427 ;; (delete-matching-lines filter)) |
28210 | 428 |
429 ;;;###autoload | |
430 (defun nslookup-host (host) | |
431 "Lookup the DNS information for HOST." | |
432 (interactive | |
433 (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
|
434 (let ((options |
28210 | 435 (if nslookup-program-options |
436 (append nslookup-program-options (list host)) | |
437 (list host)))) | |
438 (net-utils-run-program | |
439 "Nslookup" | |
440 (concat "** " | |
441 (mapconcat 'identity | |
442 (list "Nslookup" host nslookup-program) | |
443 " ** ")) | |
444 nslookup-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
445 options))) |
28210 | 446 |
447 ;;;###autoload | |
448 (defun nslookup () | |
449 "Run nslookup program." | |
450 (interactive) | |
451 (require 'comint) | |
452 (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
|
453 (nslookup-mode)) |
28210 | 454 |
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 |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
482 options |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
483 ))) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
484 |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
485 ;;;###autoload |
64805
9612798470fd
(run-dig): Renamed from `dig'.
Richard M. Stallman <rms@gnu.org>
parents:
64701
diff
changeset
|
486 (defun run-dig (host) |
28210 | 487 "Run dig program." |
488 (interactive | |
489 (list | |
490 (progn | |
491 (require 'ffap) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
492 (read-from-minibuffer |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
493 "Lookup host: " |
62316
2a4f6c0559af
(dig): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
61875
diff
changeset
|
494 (with-no-warnings |
2a4f6c0559af
(dig): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
61875
diff
changeset
|
495 (or (ffap-string-at-point 'machine) "")))))) |
28210 | 496 (net-utils-run-program |
497 "Dig" | |
498 (concat "** " | |
499 (mapconcat 'identity | |
500 (list "Dig" host dig-program) | |
501 " ** ")) | |
502 dig-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
503 (list host))) |
28210 | 504 |
505 ;; This is a lot less than ange-ftp, but much simpler. | |
506 ;;;###autoload | |
507 (defun ftp (host) | |
508 "Run ftp program." | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
509 (interactive |
28210 | 510 (list |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
511 (read-from-minibuffer |
28210 | 512 "Ftp to Host: " (net-utils-machine-at-point)))) |
513 (require 'comint) | |
514 (let ((buf (get-buffer-create (concat "*ftp [" host "]*")))) | |
515 (set-buffer buf) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
516 (ftp-mode) |
28210 | 517 (comint-exec buf (concat "ftp-" host) ftp-program nil |
518 (if ftp-program-options | |
519 (append (list host) ftp-program-options) | |
520 (list host))) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
521 (pop-to-buffer buf))) |
28210 | 522 |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
523 (define-derived-mode ftp-mode comint-mode "FTP" |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
524 "Major mode for interacting with the ftp program." |
28210 | 525 (setq comint-prompt-regexp ftp-prompt-regexp) |
526 (setq comint-input-autoexpand t) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
527 ;; 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
|
528 ;; 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
|
529 ;; 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
|
530 ;; password prompts will probably immediately follow the initial |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
531 ;; 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
|
532 ;; same password. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
533 (unless (memq 'comint-watch-for-password-prompt |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
534 (default-value 'comint-output-filter-functions)) |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
535 (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
|
536 nil t))) |
28210 | 537 |
538 ;; Occasionally useful | |
539 (define-key ftp-mode-map "\t" 'comint-dynamic-complete) | |
540 | |
541 (defun smbclient (host service) | |
542 "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
|
543 (interactive |
28210 | 544 (list |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
545 (read-from-minibuffer |
28210 | 546 "Connect to Host: " (net-utils-machine-at-point)) |
547 (read-from-minibuffer "SMB Service: "))) | |
548 (require 'comint) | |
549 (let* ((name (format "smbclient [%s\\%s]" host service)) | |
550 (buf (get-buffer-create (concat "*" name "*"))) | |
551 (service-name (concat "\\\\" host "\\" service))) | |
552 (set-buffer buf) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
553 (smbclient-mode) |
28210 | 554 (comint-exec buf name smbclient-program nil |
555 (if smbclient-program-options | |
556 (append (list service-name) smbclient-program-options) | |
557 (list service-name))) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
558 (pop-to-buffer buf))) |
28210 | 559 |
560 (defun smbclient-list-shares (host) | |
561 "List services on HOST." | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
562 (interactive |
28210 | 563 (list |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
564 (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
|
565 "Connect to Host: " (net-utils-machine-at-point)))) |
28210 | 566 (let ((buf (get-buffer-create (format "*SMB Shares on %s*" host)))) |
567 (set-buffer buf) | |
568 (smbclient-mode) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
569 (comint-exec buf "smbclient-list-shares" |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
570 smbclient-program nil (list "-L" host)) |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
571 (pop-to-buffer buf))) |
28210 | 572 |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
573 (define-derived-mode smbclient-mode comint-mode "smbclient" |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
574 "Major mode for interacting with the smbclient program." |
28210 | 575 (setq comint-prompt-regexp smbclient-prompt-regexp) |
576 (setq comint-input-autoexpand t) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
577 ;; 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
|
578 ;; 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
|
579 ;; 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
|
580 ;; password prompts will probably immediately follow the initial |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
581 ;; 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
|
582 ;; same password. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
583 (unless (memq 'comint-watch-for-password-prompt |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
584 (default-value 'comint-output-filter-functions)) |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
585 (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
|
586 nil t))) |
28210 | 587 |
588 | |
589 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
590 ;; Network Connections | |
591 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
592 | |
593 ;; Full list is available at: | |
57161 | 594 ;; 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
|
595 (defvar network-connection-service-alist |
28210 | 596 (list |
597 (cons 'echo 7) | |
598 (cons 'active-users 11) | |
599 (cons 'daytime 13) | |
600 (cons 'chargen 19) | |
601 (cons 'ftp 21) | |
602 (cons 'telnet 23) | |
603 (cons 'smtp 25) | |
604 (cons 'time 37) | |
605 (cons 'whois 43) | |
606 (cons 'gopher 70) | |
607 (cons 'finger 79) | |
608 (cons 'www 80) | |
609 (cons 'pop2 109) | |
610 (cons 'pop3 110) | |
611 (cons 'sun-rpc 111) | |
612 (cons 'nntp 119) | |
613 (cons 'ntp 123) | |
614 (cons 'netbios-name 137) | |
615 (cons 'netbios-data 139) | |
616 (cons 'irc 194) | |
617 (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
|
618 (cons 'rlogin 513)) |
28210 | 619 "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
|
620 This list is not complete.") |
0605a90581d4
(network-connection-service-abbrev-alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
621 |
28210 | 622 ;; Workhorse macro |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
623 (defmacro run-network-program (process-name host port |
28210 | 624 &optional initial-string) |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
625 `(let ((tcp-connection) |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
626 (buf)) |
28210 | 627 (setq buf (get-buffer-create (concat "*" ,process-name "*"))) |
628 (set-buffer buf) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
629 (or |
28210 | 630 (setq tcp-connection |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
631 (open-network-stream |
28210 | 632 ,process-name |
633 buf | |
634 ,host | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
635 ,port)) |
28210 | 636 (error "Could not open connection to %s" ,host)) |
637 (erase-buffer) | |
638 (set-marker (process-mark tcp-connection) (point-min)) | |
639 (set-process-filter tcp-connection 'net-utils-remove-ctrl-m-filter) | |
640 (and ,initial-string | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
641 (process-send-string tcp-connection |
28210 | 642 (concat ,initial-string "\r\n"))) |
643 (display-buffer buf))) | |
644 | |
645 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
646 ;; Simple protocols | |
647 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
648 | |
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
649 (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
|
650 "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
|
651 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
|
652 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
|
653 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
|
654 :group 'net-utils |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
655 :type '(repeat regexp) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
656 :version "21.1") |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
657 |
28210 | 658 ;; Finger protocol |
659 ;;;###autoload | |
660 (defun finger (user host) | |
661 "Finger USER on HOST." | |
662 ;; One of those great interactive statements that's actually | |
663 ;; longer than the function call! The idea is that if the user | |
664 ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the | |
665 ;; host name. If we don't see an "@", we'll prompt for the host. | |
666 (interactive | |
667 (let* ((answer (read-from-minibuffer "Finger User: " | |
668 (net-utils-url-at-point))) | |
669 (index (string-match (regexp-quote "@") answer))) | |
670 (if index | |
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
671 (list (substring answer 0 index) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
672 (substring answer (1+ index))) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
673 (list answer |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
674 (read-from-minibuffer "At Host: " |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
675 (net-utils-machine-at-point)))))) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
676 (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
|
677 (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
|
678 (regexps finger-X.500-host-regexps) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
679 found) |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
680 (and regexps |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
681 (while (not (string-match (car regexps) host)) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
682 (setq regexps (cdr regexps))) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
683 (when regexps |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
684 (setq user-and-host user))) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
685 (run-network-program |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
686 process-name |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
687 host |
28210 | 688 (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
|
689 user-and-host))) |
28210 | 690 |
691 (defcustom whois-server-name "rs.internic.net" | |
692 "Default host name for the whois service." | |
693 :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
|
694 :type 'string) |
28210 | 695 |
696 (defcustom whois-server-list | |
697 '(("whois.arin.net") ; Networks, ASN's, and related POC's (numbers) | |
698 ("rs.internic.net") ; domain related info | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
699 ("whois.publicinterestregistry.net") |
28210 | 700 ("whois.abuse.net") |
701 ("whois.apnic.net") | |
702 ("nic.ddn.mil") | |
703 ("whois.nic.mil") | |
704 ("whois.nic.gov") | |
705 ("whois.ripe.net")) | |
706 "A list of whois servers that can be queried." | |
707 :group 'net-utils | |
708 :type '(repeat (list string))) | |
709 | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
710 ;; 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
|
711 ;; 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
|
712 ;; will DTRT anyway... -rfr |
28210 | 713 (defcustom whois-server-tld |
714 '(("rs.internic.net" . "com") | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
715 ("whois.publicinterestregistry.net" . "org") |
28210 | 716 ("whois.ripe.net" . "be") |
717 ("whois.ripe.net" . "de") | |
718 ("whois.ripe.net" . "dk") | |
719 ("whois.ripe.net" . "it") | |
720 ("whois.ripe.net" . "fi") | |
721 ("whois.ripe.net" . "fr") | |
722 ("whois.ripe.net" . "uk") | |
723 ("whois.apnic.net" . "au") | |
724 ("whois.apnic.net" . "ch") | |
725 ("whois.apnic.net" . "hk") | |
726 ("whois.apnic.net" . "jp") | |
727 ("whois.nic.gov" . "gov") | |
728 ("whois.nic.mil" . "mil")) | |
729 "Alist to map top level domains to whois servers." | |
730 :group 'net-utils | |
731 :type '(repeat (cons string string))) | |
732 | |
733 (defcustom whois-guess-server t | |
734 "If non-nil then whois will try to deduce the appropriate whois | |
735 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
|
736 then the server named by `whois-server-name' is used." |
28210 | 737 :group 'net-utils |
738 :type 'boolean) | |
739 | |
740 (defun whois-get-tld (host) | |
741 "Return the top level domain of `host', or nil if it isn't a domain name." | |
742 (let ((i (1- (length host))) | |
743 (max-len (- (length host) 5))) | |
744 (while (not (or (= i max-len) (char-equal (aref host i) ?.))) | |
745 (setq i (1- i))) | |
746 (if (= i max-len) | |
747 nil | |
748 (substring host (1+ i))))) | |
749 | |
750 ;; Whois protocol | |
751 ;;;###autoload | |
752 (defun whois (arg search-string) | |
753 "Send SEARCH-STRING to server defined by the `whois-server-name' variable. | |
754 If `whois-guess-server' is non-nil, then try to deduce the correct server | |
755 from SEARCH-STRING. With argument, prompt for whois server." | |
756 (interactive "P\nsWhois: ") | |
757 (let* ((whois-apropos-host (if whois-guess-server | |
758 (rassoc (whois-get-tld search-string) | |
759 whois-server-tld) | |
760 nil)) | |
761 (server-name (if whois-apropos-host | |
762 (car whois-apropos-host) | |
763 whois-server-name)) | |
764 (host | |
765 (if arg | |
766 (completing-read "Whois server name: " | |
767 whois-server-list nil nil "whois.") | |
768 server-name))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
769 (run-network-program |
28210 | 770 "Whois" |
771 host | |
772 (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
|
773 search-string))) |
28210 | 774 |
775 (defcustom whois-reverse-lookup-server "whois.arin.net" | |
776 "Server which provides inverse DNS mapping." | |
777 :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
|
778 :type 'string) |
28210 | 779 |
780 ;;;###autoload | |
781 (defun whois-reverse-lookup () | |
782 (interactive) | |
783 (let ((whois-server-name whois-reverse-lookup-server)) | |
784 (call-interactively 'whois))) | |
785 | |
786 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
787 ;;; General Network connection | |
788 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
789 | |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
790 ;; 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
|
791 (define-derived-mode |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
792 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
|
793 "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
|
794 |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
795 (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
|
796 (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
|
797 (setq network-connection-host host) |
c5ddbcd62234
(ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents:
41257
diff
changeset
|
798 (make-local-variable 'network-connection-service) |
42310 | 799 (setq network-connection-service service)) |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
800 |
28210 | 801 ;;;###autoload |
802 (defun network-connection-to-service (host service) | |
803 "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
|
804 (interactive |
28210 | 805 (list |
806 (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
|
807 (completing-read "Service: " |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
808 (mapcar |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
809 (function |
28210 | 810 (lambda (elt) |
811 (list (symbol-name (car elt))))) | |
812 network-connection-service-alist)))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
813 (network-connection |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
814 host |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
815 (cdr (assoc (intern service) network-connection-service-alist)))) |
28210 | 816 |
817 ;;;###autoload | |
818 (defun network-connection (host port) | |
819 "Open a network connection to HOST on PORT." | |
820 (interactive "sHost: \nnPort: ") | |
821 (network-service-connection host (number-to-string port))) | |
822 | |
823 (defun network-service-connection (host service) | |
824 "Open a network connection to SERVICE on HOST." | |
825 (require 'comint) | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
826 (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
|
827 (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
|
828 (buf (get-buffer-create (concat "*" process-name "*")))) |
28210 | 829 (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
|
830 (make-comint |
28210 | 831 process-name |
832 (cons host service)) | |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
833 (set-buffer buf) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
834 (network-connection-mode) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
835 (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
|
836 (pop-to-buffer buf))) |
28210 | 837 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
838 (defun network-connection-reconnect () |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
839 "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
|
840 (interactive) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
841 (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
|
842 (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
|
843 (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
|
844 (service network-connection-service)) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
845 (if (not (or (not proc) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
846 (eq (process-status proc) 'closed))) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
847 (message "Still connected") |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
848 (goto-char (point-max)) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
849 (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
|
850 (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
|
851 (if (numberp service) |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
852 service |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
853 (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
|
854 (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
|
855 (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
|
856 |
28210 | 857 (provide 'net-utils) |
858 | |
52401 | 859 ;;; arch-tag: 97119e91-9edb-4376-838b-bf7058fa1314 |
28210 | 860 ;;; net-utils.el ends here |