chiark / gitweb /
server/tests.at: Fix TRIPECTL_INTERACT argument order.
[tripe] / svc / watch.8.in
CommitLineData
a62f8e8a
MW
1.\" -*-nroff-*-
2.\".
3.\" Manual for the watch service
4.\"
5.\" (c) 2008 Straylight/Edgeware
6.\"
7.
8.\"----- Licensing notice ---------------------------------------------------
9.\"
10.\" This file is part of Trivial IP Encryption (TrIPE).
11.\"
12.\" TrIPE is free software; you can redistribute it and/or modify
13.\" it under the terms of the GNU General Public License as published by
14.\" the Free Software Foundation; either version 2 of the License, or
15.\" (at your option) any later version.
16.\"
17.\" TrIPE is distributed in the hope that it will be useful,
18.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
19.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20.\" GNU General Public License for more details.
21.\"
22.\" You should have received a copy of the GNU General Public License
23.\" along with TrIPE; if not, write to the Free Software Foundation,
24.\" Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25.
26.\"--------------------------------------------------------------------------
27.so ../defs.man.in \"@@@PRE@@@
28.
29.\"--------------------------------------------------------------------------
30.TH watch 8 "11 December 2007" "Straylight/Edgeware" "TrIPE: Trivial IP Encryption"
31.
32.\"--------------------------------------------------------------------------
33.SH "NAME"
34.
35watch \- tripe service handle addition and removal of peers
36.
37.\"--------------------------------------------------------------------------
38.SH "SYNOPSIS"
39.
40.B watch
41.RB [ \-a
42.IR socket ]
43.RB [ \-d
44.IR dir ]
45.RB [ \-p
46.IR file ]
47.br
48\& \c
49.RB [ \-\-daemon ]
50.RB [ \-\-debug ]
51.RB [ \-\-startup ]
52.
53.\"--------------------------------------------------------------------------
54.SH "DESCRIPTION"
55.
56The
57.B watch
58service tracks associations with peers and performs various actions at
59appropriate stages in the assocations' lifecycles.
60.PP
61For example:
62.hP \*o
63When a peer is added, it arranges to configure the corresponding network
64interface correctly, and (if necessary) to initiate a dynamic
65connection.
66.hP \*o
67When a peer is removed, it arranges to bring down the network interface.
68.hP \*o
69While the peer is known, it
70.BR PING s
71it at regular intervals. If the peer fails to respond, it can be
72removed or reconnected.
73.SS "Command line"
74In addition to the standard options described in
75.BR tripe-service (7),
76the following command-line options are recognized.
77.TP
78.BI "\-p, \-\-peerdb=" file
79Use
80.I file
81as the (CDB format) peer database. In the absence of this option, the
82file named by the
83.B TRIPEPEERDB
84environment variable is used; if that's not set either, then the default
85default of
86.B peers.cdb
87in the current working directory is used instead.
88.
89.\"--------------------------------------------------------------------------
90.SH "BEHAVIOUR"
91.
92.SS "Adoption"
93The
94.B watch
95service maintains a list of peers which it has adopted. A peer is
96.I eligible for adoption
97if it has a record in the peer database
98.BR peers.cdb (5)
99in which the
100.B watch
101key is assigned the value
102.BR t ,
103.BR true ,
104.BR y ,
105.BR yes ,
106or
107.BR on .
108.PP
109The service pings adopted peers periodically in order to ensure that
110they are alive, and takes appropriate action if no replies are received.
111.PP
112A peer is said to be
113.I adopted
114when it is added to this list, and
115.I disowned
116when it removed.
117.SS "Configuring interfaces"
118The
119.B watch
120service configures network interfaces by invoking an
121.B ifup
122script. The script is invoked as
123.IP
124.I script
125.IR args ...
126.I peer
127.I ifname
128.IR addr ...
129.PP
130where the elements are as described below.
131.TP
132.IR script " and " args
133The peer's database record is retrieved; the value assigned to the
134.B ifup
135key is split into words (quoting is allowed; see
136.BR tripe-admin (5)
137for details). The first word is the
138.IR script ;
139subsequent words are gathered to form the
140.IR args .
141.TP
142.I peer
143The name of the peer.
144.TP
145.I ifname
146The name of the network interface associated with the peer, as returned
147by the
148.B IFNAME
149administration command (see
150.BR tripe-admin (5)).
151.TP
152.I addr
153The network address of the peer's TrIPE server, in the form output by
154the
155.B ADDR
156administration command (see
157.BR tripe-admin (5)).
158The first word of
159.I addr
160is therefore a network address family, e.g.,
161.BR INET .
162.PP
163The
164.B watch
165service deconfigures interfaces by invoking an
166.B ifdown
167script, in a similar manner. The script is invoked as
168.IP
169.I script
170.IR args ...
171.I peer
172.PP
173where the elements are as above, except that
174.I script
175and
176.I args
177are formed by splitting the value associated with the peer record's
178.B ifdown
179key.
180.PP
181In both of the above cases, if the relevant key (either
182.B ifup
183or
184.BR ifdown )
185is absent, no action is taken.
186.PP
187The key/value pairs in the peer's database record and the server's
188response to the
189.B ALGS
190administration command (see
191.BR tripe-admin (5))
192are passed to the
193.B ifup
194and
195.B ifdown
196scripts as environment variables. The environment variable name
197corresponding to a key is determined as follows:
198.hP \*o
199Convert all letters to upper-case.
200.hP \*o Convert all sequences of one or more non-alphanumeric characters
201to an underscore
202.RB ` _ '.
203.hP \*o Prefix the resulting name by
204.RB ` P_ '
205or
206.RB ` A_ '
207depending on whether it came from the peer's database record or the
208.B ALGS
209output respectively.
210.PP
211For example,
212.B ifname
213becomes
214.BR P_IFNAME ;
215and
216.B cipher-blksz
217becomes
218.BR A_CIPHER_BLKSZ .
219.SS "Dynamic connection"
220If a peer's database record assigns a value to the
221.B connect
222key, then the
223.B watch
224service will attempt to establish a connection dynamically with the
225peer. The value of the
226.B connect
227key is invoked as a Bourne shell command, i.e.,
228.IP
229.B /bin/sh \-c
230.I connect
231.PP
232is executed. The command is expected to contact the remote server and
233report, on standard output, a challenge string. The
234.B watch
235service reads this challenge, and submits the command
236.IP
237.B GREET
238.I peer
239.I challenge
240.PP
241Typically, the
242.B connect
243command will issue a command such as
244.IP
245.B SVCSUBMIT connect passive
246.I our-name
247.PP
248where
249.I our-name
250is the remote peer's name for this host.
251.SS "Operation"
252On startup,
253.B watch
254requests a list of current peers from the
255.BR tripe (8)
256server, and adopts any eligible peers. If the
257.B \-\-startup
258flag was passed on the command line,
259the newly adopted peers have their interfaces configured and connection
260attempts are made.
261.PP
262Adopted peers are pinged at regular intervals (using the
263.B PING
264administrative command; see
265.BR tripe-admin (5)).
266This process can be configured by assigning values to keys in the peer's
267database record. Some of these parameters are time intervals,
268expressed as a nonnegative integer followed optionally by
269.BR d ,
270.BR h ,
271.BR m ,
272or
273.B s
274for days, hours, minutes, or seconds, respectively; if no suffix is
275given, seconds are assumed.
276.PP
277The parameters are as follows.
278.TP
279.B every
280A time interval: how often to ping the peer to ensure that it's still
281alive. The default is 2 minutes.
282.TP
283.B timeout
284A time interval: how long to wait for a reply before retrying or giving
285up. The default is 10 seconds.
286.TP
287.B retries
288An integer: how many failed attempts to make before deciding that the
289peer is unreachable and taking action. The default is 5 attempts.
290.PP
291The algorithm is as follows. Send up to
292.I retries
293pings; if a reply is received before the
294.I timeout
295then the peer is alive; wait
296.I every
297and check again. If no reply is received within the
298.IR timeout ,
299then try again up to
300.I retries
301times. If no attempt succeeds, the peer is declared unreachable. If
302the peer has a
303.B connect
304command (i.e., it connects dynamically) then another connection attempt
305is made. Otherwise the peer is killed.
306.
307.\"--------------------------------------------------------------------------
308.SH "SERVICE COMMAND REFERENCE"
309.
310.\"* 10 Service commands
311The commands provided by the service are as follows.
312.SP
313.B adopted
314For each peer being tracked by the
315.B watch
316service, write a line
317.B INFO
318.IR name .
319(Compatibility note: it's possible that further information will be
320provided about each peer, in the form of subsequent tokens. Clients
321should be prepared to ignore such tokens.)
322.SP
323.BI "kick " peer
324If
325.I peer
326is currently added, and its record in the peer database contains a
327.B connect
328key (see
329.BR peers.in )
330then force a reconnection attempt. See
331.BR "Dynamic connection" .
332.
333.\"--------------------------------------------------------------------------
334.SH "NOTIFICATIONS"
335.
336.\"* 30 Notification broadcasts (NOTE codes)
337All notifications issued by
338.B watch
339begin with the tokens
340.BR "USER watch" .
341.SP
342.B "USER watch peerdb-update"
343The peer database has changed. Other interested clients should reopen
344the database.
345.SP
346.BI "USER watch ping-failed " peer " " error\fR...
347An attempt to
348.B PING
349the named
350.I peer
351failed; the server replied
352.B FAIL
353.IR error ...
354.SP
355.BI "USER watch " process\fR... " stdout " line
356The
357.I process
358spawned by the
359.B watch
360service unexpectedly wrote
361.I line
362to its standard output.
363.
364.\"--------------------------------------------------------------------------
365.SH "WARNINGS"
366.
367.\"* 40 Warning broadcasts (WARN codes)
368All warnings issued by
369.B watch
370begin with the tokens
371.BR "USER watch" .
372.SP
373.BI "USER watch ping-ok " peer
374A reply was received to a
375.B PING
376sent to the
377.IR peer ,
378though earlier attempts had failed.
379.SP
380.BI "USER watch ping-timeout " peer " attempt " i " of " n
381No reply was received to a
382.B PING
383sent to the
384.IR peer .
385So far,
386.I i
387.BR PING s
388have been sent; if a total of
389.I n
390consecutive attempts time out, the
391.B watch
392service will take further action.
393.SP
394.B "USER watch reconnecting " peer
395The dynamically connected
396.I peer
397seems to be unresponsive. The
398.B watch
399service will attempt to reconnect.
400.SP
401.BI "USER watch " process\fR... " stderr " line
402The
403.I process
404spawned by the
405.B watch
406service wrote
407.I line
408to its standard error.
409.SP
410.BI "USER watch " process\fR... " exit-nonzero " code
411The
412.I process
413spawned by the
414.B watch
415service exited with the nonzero status
416.IR code .
417.SP
418.BI "USER watch " process\fR... " exit-signal S" code
419The
420.I process
421spawned by the
422.B watch
423service was killed by signal
424.IR code .
425Here,
426.I code
427is the numeric value of the fatal signal.
428.SP
429.BI "USER watch " process\fR... " exit-unknown " status
430The
431.I process
432spawned by the
433.B watch
434service exited with an unknown
435.IR status .
436Here,
437.I status
438is the raw exit status, as returned by
439.BR waitpid (2),
440in hexadecimal.
441.
442.\"--------------------------------------------------------------------------
443.SH "CHILD PROCESS IDENTIFIERS"
444.
445.\"* 50 Child process identifiers
446Some of the warnings and notifications refer to processes spawned by
447.B watch
448under various circumstances. The process identifiers are as follows.
449.SP
450.BI "connect " peer
451A child spawned in order to establish a dynamic connection with
452.IR peer .
453.SP
454.BI "ifdown " peer
455A child spawned to deconfigure the network interface for
456.IR peer .
457.SP
458.BI "ifup " peer
459A child spawned to configure the network interface for
460.IR peer .
461.
462.\"--------------------------------------------------------------------------
463.SH "SUMMARY"
464.
465.\"= summary
466.
467.\"--------------------------------------------------------------------------
468.SH "SEE ALSO"
469.
470.BR tripe-service (7),
471.BR peers.in (5),
472.BR connect (8),
473.BR tripe (8).
474.
475.\"--------------------------------------------------------------------------
476.SH "AUTHOR"
477.
478Mark Wooding, <mdw@distorted.org.uk>
479.
480.\"----- That's all, folks --------------------------------------------------