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