* xterm.h, xterm.c (x_uncatch_errors): Delete unneccessary
[emacs.git] / lisp / erc / erc-identd.el
blobe0ccfb4049796fed4cc5aec24f6ceb76d881c55f
1 ;;; erc-identd.el --- RFC1413 (identd authentication protocol) server
3 ;; Copyright (C) 2003, 2006 Free Software Foundation, Inc.
5 ;; Author: John Wiegley <johnw@gnu.org>
6 ;; Keywords: comm, processes
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
25 ;;; Commentary:
27 ;; You can have a local identd server (running on port 8113; I use DNAT
28 ;; to bind 113->8113) if you add this to .emacs.el:
30 ;; (add-hook 'erc-connect-pre-hook 'erc-identd-start)
31 ;; (add-hook 'erc-disconnected-hook 'erc-identd-stop)
33 ;;; Code:
35 (defvar erc-identd-process nil)
37 (defun erc-identd-filter (proc string)
38 "This filter implements RFC1413 (identd authentication protocol)."
39 (let ((erc-identd-process proc))
40 (when (string-match "\\([0-9]+\\)\\s-*,\\s-*\\([0-9]+\\)" string)
41 (let ((port-on-server (match-string 1 string))
42 (port-on-client (match-string 2 string)))
43 (send-string erc-identd-process
44 (format "%s, %s : USERID : %s : %s\n"
45 port-on-server port-on-client
46 system-type (user-login-name)))
47 (process-send-eof erc-identd-process)))))
49 (defun erc-identd-start (&optional port)
50 "Start an identd server listening to port 8113.
51 Port 113 (auth) will need to be redirected to port 8113 on your
52 machine -- using iptables, or a program like redir which can be
53 run from inetd. The idea is to provide a simple identd server
54 when you need one, without having to install one globally on your
55 system."
56 (interactive (list (read-string "Serve identd requests on port: " "8113")))
57 (if (null port)
58 (setq port 8113)
59 (if (stringp port)
60 (setq port (string-to-number port))))
61 (if erc-identd-process
62 (delete-process erc-identd-process))
63 (if (fboundp 'make-network-process)
64 (setq erc-identd-process
65 (make-network-process :name "identd"
66 :buffer (generate-new-buffer "identd")
67 :service port :server t :noquery t
68 :filter 'erc-identd-filter))
69 (open-network-stream-server "identd" (generate-new-buffer "identd")
70 port nil 'erc-identd-filter)))
72 (defun erc-identd-stop (&rest ignore)
73 (interactive)
74 (when erc-identd-process
75 (delete-process erc-identd-process)
76 (setq erc-identd-process nil)))
78 (provide 'erc-identd)
80 ;;; erc-identd.el ends here
82 ;; Local Variables:
83 ;; indent-tabs-mode: t
84 ;; tab-width: 8
85 ;; End:
87 ;; arch-tag: e0b5f926-0f35-40b9-8ddb-ca06b62a7544