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