Add support for using CertFP to auth to the IRC server, and document it.
[irker.git] / irkerd.xml
1 <!DOCTYPE refentry PUBLIC 
2    "-//OASIS//DTD DocBook XML V4.1.2//EN"
3    "docbook/docbookx.dtd">
4 <refentry id='irkerd.8'>
5 <refmeta>
6 <refentrytitle>irkerd</refentrytitle>
7 <manvolnum>8</manvolnum>
8 <refmiscinfo class='date'>Aug 27 2012</refmiscinfo>
9 <refmiscinfo class='source'>irker</refmiscinfo>
10 <refmiscinfo class='product'>irker</refmiscinfo>
11 <refmiscinfo class='manual'>Commands</refmiscinfo>
12 </refmeta>
13 <refnamediv id='name'>
14 <refname>irkerd</refname>
15 <refpurpose>relay for shipping notifications to IRC servers</refpurpose>
16 </refnamediv>
17 <refsynopsisdiv id='synopsis'>
18
19 <cmdsynopsis>
20   <command>irkerd</command>
21      <arg>-c <replaceable>ca-file</replaceable></arg>
22      <arg>-d <replaceable>debuglevel</replaceable></arg>
23      <arg>-e <replaceable>cert-file</replaceable></arg>
24      <arg>-l <replaceable>logfile</replaceable></arg>
25      <arg>-n <replaceable>nick</replaceable></arg>
26      <arg>-p <replaceable>password</replaceable></arg>
27      <arg>-i <replaceable>IRC-URL</replaceable></arg>
28      <arg>-V</arg>
29      <arg>-h</arg>
30      <arg choice='opt'><replaceable>message text</replaceable></arg>
31 </cmdsynopsis>
32 </refsynopsisdiv>
33
34 <refsect1 id='description'><title>DESCRIPTION</title>
35
36 <para><application>irkerd</application> is a specialized write-only IRC
37 client intended to be used for shipping notification messages to IRC
38 channels. The use case in mind when it was designed was broadcasting
39 notifications from commit hooks in version-control systems.</para>
40
41 <para>The main advantage of relaying through this daemon over
42 individual scripted sends from applications is that it can maintain
43 connection state for multiple channels, rather than producing obnoxious
44 join/leave channel spam on every message.</para>
45
46 <para><application>irkerd</application> is a socket server that
47 listens on for UDP or TCP packets on port 6659 for textual request
48 lines containing JSON objects and terminated by a newline. Each JSON
49 object must have two members: "to" specifying a destination or
50 destination list, and "privmsg" specifying the message text.
51 Examples:
52
53 <programlisting>
54 {"to":"irc://chat.freenode.net/git-ciabot", "privmsg":"Hello, world!"}
55 {"to":["irc://chat.freenode.net/#git-ciabot","irc://chat.freenode.net/#gpsd"],"privmsg":"Multichannel test"}
56 {"to":"irc://chat.hypothetical.net:6668/git-ciabot", "privmsg":"Hello, world!"}
57 {"to":"ircs://chat.hypothetical.net/git-private?key=topsecret", "privmsg":"Keyed channel test"}
58 {"to":"ircs://:topsecret@chat.example.net/git-private", "privmsg":"Password-protected server test"}
59 </programlisting></para>
60
61 <para>If the channel part of the URL does not have one of the prefix
62 characters <quote>#</quote>, <quote>&amp;</quote>, or
63 <quote>+</quote>, a <quote>#</quote> will be prepended to it before
64 shipping - <emphasis>unless</emphasis> the channel part has the suffix
65 ",isnick" (which is unconditionally removed).</para>
66
67 <para>The host part of the URL may have a port-number suffix separated by a
68 colon, as shown in the third example; otherwise
69 <application>irkerd</application> sends plaintext messages to the default
70 6667 IRC port of each server, and SSL/TLS messages to 6697.</para>
71
72 <para>The password for password-protected servers can be set using the
73 usual <quote>[{username}:{password}@]{host}:{port}</quote> defined in
74 RFC 3986, as shown in the fifth example.  Non-empty URL usernames
75 override the default <quote>irker</quote> username.</para>
76
77 <para>When the <quote>to</quote> URL uses the <quote>ircs</quote>
78 scheme (as shown in the fourth and fifth examples), the connection to
79 the IRC server is made via SSL/TLS (vs. a plaintext connection with the
80 <quote>irc</quote> scheme).  To connect via SSL/TLS with Python 2.x,
81 you need to explicitly declare the certificate authority file used to
82 verify server certificates.  For example, <quote>-c
83 /etc/ssl/certs/ca-certificates.crt</quote>.  In Python 3.2 and later,
84 you can still set this option to declare a custom CA file, but
85 <application>irkerd</application>; if you don't set it
86 <application>irkerd</application> will use OpenSSL's default file
87 (using Python's
88 <quote>ssl.SSLContext.set_default_verify_paths</quote>).  In Python
89 3.2 and later, <quote>ssl.match_hostname</quote> is used to ensure the
90 server certificate belongs to the intended host, as well as being
91 signed by a trusted CA.</para>
92
93 <para>To join password-protected (mode +k) channels, the channel part of the
94 URL may be followed with a query-string indicating the channel key, of the
95 form <quote>?secret</quote> or <quote>?key=secret</quote>, where
96 <quote>secret</quote> is the channel key.</para>
97
98 <para>An empty message is legal and will cause
99 <application>irkerd</application> to join or maintain a connection to
100 the target channels without actually emitting a message.  This may be
101 useful for advertising that an instance is up and running, or for
102 joining a channel to log its traffic.</para>
103 </refsect1>
104
105 <refsect1 id='options'><title>OPTIONS</title>
106
107 <para><application>irkerd</application> takes the following options:</para>
108
109 <variablelist>
110 <varlistentry>
111 <term>-d</term>
112 <listitem>
113   <para>
114     Takes a following value, setting the debugging level from it;
115     possible values are 'critical', 'error', 'warning', 'info',
116     'debug'. This option will generally only be of interest to
117     developers, as the logs are designed to help trace
118     <application>irkerd</application>'s internal state.  These tracing
119     logs are independent of the traffic logs controlled by
120     <quote>-l</quote>.
121   </para>
122   <para>
123     Logging will be to standard error (if
124     <application>irkerd</application> is running in the foreground) or
125     to <quote>/dev/syslog</quote> with facility "daemon" (if
126     <application>irkerd</application> is running in the background).
127     The background-ness of <application>irkerd</application> is
128     determined by comparing the process group id with the process
129     group associated with the terminal attached to stdout (with
130     non-matches for background processes).  We assume you aren't
131     running <application>irkerd</application> in Windows or another OS
132     that doesn't support <quote>os.getpgrp</quote> or
133     <quote>tcgetpgrp</quote>.  We assume that if stdout is attached to
134     a TTY associated with the same process group as
135     <application>irkerd</application>, you do intend to log to stderr
136     and not syslog.
137   </para>
138 </listitem>
139 </varlistentry>
140 <varlistentry>
141 <term>-e</term>
142 <listitem><para>Takes a following filename in pem format and uses it
143 to authenticate to the IRC server.  You must be connecting to the IRC server
144 over SSL for this to function properly.  This is commonly known as
145 <quote>CertFP.</quote>
146 </para></listitem>
147 </varlistentry>
148 <varlistentry>
149 <term>-e</term>
150 <listitem><para>Takes a following filename in pem format and uses it
151 to authenticate to the IRC server.  You must be connecting to the IRC server
152 over SSL for this to function properly.  This is commonly known as <quote>CertFP.</quote>
153 </para></listitem>
154 </varlistentry>
155 <varlistentry>
156 <term>-l</term>
157 <listitem><para>Takes a following filename, logs traffic to that file.
158 Each log line consists of three |-separated fields; a numeric
159 timestamp in Unix time, the FQDN of the sending server, and the
160 message data.</para></listitem>
161 </varlistentry>
162 <varlistentry>
163 <term>-n</term>
164 <listitem><para>Takes a following value, setting the nick
165 to be used. If the nick contains a numeric format element
166 (such as %03d) it is used to generate suffixed fallback names
167 in the event of a nick collision.</para></listitem>
168 </varlistentry>
169 <varlistentry>
170 <term>-p</term>
171 <listitem><para>Takes a following value, setting a nickserv
172 password to be used. If given, this password is shipped to
173 authenticate the nick on receipt of a welcome message.</para></listitem>
174 </varlistentry>
175 <varlistentry>
176 <term>-i</term>
177 <listitem><para>Immediate mode, to be run in foreground. Takes two
178 following values interpreted as a channel URL and a message
179 string. Sends the message, then quits.</para></listitem>
180 </varlistentry>
181 <varlistentry>
182 <term>-V</term>
183 <listitem><para>Write the program version to stdout and
184 terminate.</para></listitem>
185 </varlistentry>
186 <varlistentry>
187 <term>-h</term>
188 <listitem><para>Print usage instructions and terminate.</para></listitem>
189 </varlistentry>
190 </variablelist>
191 </refsect1>
192
193 <refsect1 id='limitations'><title>LIMITATIONS</title>
194 <para>Requests via UDP optimizes for lowest latency and network load
195 by avoiding TCP connection setup time; the cost is that delivery is
196 not reliable in the face of packet loss.</para>
197
198 <para>An <application>irkerd</application> instance with a
199 publicly-accessible request socket could complicate blocking of IRC
200 spam by making it easy for spammers to submit while hiding their IP
201 addresses; the better way to deploy, then, is on places like
202 project-hosting sites where the <application>irkerd</application>
203 socket can be visible from commit-hook code but not exposed to the
204 outside world. Priming your firewall with blocklists of IP addresses
205 known to spew spam is always a good idea.</para>
206
207 <para>The absence of any option to set the service port is deliberate.
208 If you think you need to do that, you have a problem better solved at
209 your firewall.</para>
210
211 <para>IRC has a message length limit of 510 bytes; generate your
212 privmsg attribute values with appropriate care.</para>
213
214 <para>IRC ignores any text after an embedded newline. Be aware that
215 <application>irkerd</application> will turn payload strings with
216 embedded newlines into multiple IRC sends to avoid having message data
217 discarded. </para>
218 </refsect1>
219
220 <refsect1 id='see_also'><title>SEE ALSO</title>
221 <para>
222 <citerefentry><refentrytitle>irkerhook</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
223 </para>
224 </refsect1>
225
226 <refsect1 id='authors'><title>AUTHOR</title>
227 <para>Eric S. Raymond <email>esr@snark.thyrsus.com</email>.  See the
228 project page at <ulink
229 url='http://www.catb.org/~esr/irker'>http://www.catb.org/~esr/irker</ulink>
230 for updates and other resources, including an installable repository
231 hook script.</para>
232 </refsect1>
233 </refentry>
234