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