1 ;;; erc-identd.el --- RFC1413 (identd authentication protocol) server
3 ;; Copyright (C) 2003, 2006, 2007 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 3, or (at your option)
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.
27 ;; This module allows you to run a local identd server on port 8113.
28 ;; You will need to set up DNAT to bind 113->8113, or use a proxy.
30 ;; To use this module, add identd to `erc-modules' and run
31 ;; `erc-update-modules'.
33 ;; Here is an example /etc/inetd.conf rule that forwards identd
34 ;; traffic to port 8113. You will need simpleproxy installed for it
37 ;; 113 stream tcp nowait nobody /usr/sbin/tcpd /usr/bin/simpleproxy simpleproxy -i -R 127.0.0.1:8113
43 (defvar erc-identd-process nil
)
45 (defgroup erc-identd nil
46 "Run a local identd server."
49 (defcustom erc-identd-port
8113
50 "Port to run the identd server on if not specified in the argument for
53 This can be either a string or a number."
55 :type
'(choice (const :tag
"None" nil
)
56 (integer :tag
"Port number")
57 (string :tag
"Port string")))
59 ;;;###autoload (autoload 'erc-identd-mode "erc-identd")
60 (define-erc-module identd nil
61 "This mode launches an identd server on port 8113."
62 ((add-hook 'erc-connect-pre-hook
'erc-identd-quickstart
)
63 (add-hook 'erc-disconnected-hook
'erc-identd-stop
))
64 ((remove-hook 'erc-connect-pre-hook
'erc-identd-quickstart
)
65 (remove-hook 'erc-disconnected-hook
'erc-identd-stop
)))
67 (defun erc-identd-filter (proc string
)
68 "This filter implements RFC1413 (identd authentication protocol)."
69 (let ((erc-identd-process proc
))
70 (when (string-match "\\([0-9]+\\)\\s-*,\\s-*\\([0-9]+\\)" string
)
71 (let ((port-on-server (match-string 1 string
))
72 (port-on-client (match-string 2 string
)))
73 (send-string erc-identd-process
74 (format "%s, %s : USERID : %s : %s\n"
75 port-on-server port-on-client
76 system-type
(user-login-name)))
77 (stop-process erc-identd-process
)
78 (delete-process proc
)))))
81 (defun erc-identd-start (&optional port
)
82 "Start an identd server listening to port 8113.
83 Port 113 (auth) will need to be redirected to port 8113 on your
84 machine -- using iptables, or a program like redir which can be
85 run from inetd. The idea is to provide a simple identd server
86 when you need one, without having to install one globally on your
88 (interactive (list (read-string "Serve identd requests on port: " "8113")))
89 (unless port
(setq port erc-identd-port
))
91 (setq port
(string-to-number port
)))
92 (when erc-identd-process
93 (delete-process erc-identd-process
))
94 (setq erc-identd-process
95 (make-network-process :name
"identd"
97 :host
'local
:service port
98 :server t
:noquery t
:nowait t
99 :filter
'erc-identd-filter
))
100 (set-process-query-on-exit-flag erc-identd-process nil
))
102 (defun erc-identd-quickstart (&rest ignored
)
103 "Start the identd server with the default port.
104 The default port is specified by `erc-identd-port'."
108 (defun erc-identd-stop (&rest ignore
)
110 (when erc-identd-process
111 (delete-process erc-identd-process
)
112 (setq erc-identd-process nil
)))
114 (provide 'erc-identd
)
116 ;;; erc-identd.el ends here
119 ;; indent-tabs-mode: t
123 ;; arch-tag: e0b5f926-0f35-40b9-8ddb-ca06b62a7544