chiark / gitweb /
peerdb/peers.in, svc/connect.8.in: Tweak dead-peer-detection parameters.
[tripe] / svc / connect.8.in
CommitLineData
a62f8e8a
MW
1.\" -*-nroff-*-
2.\".
3.\" Manual for the connect 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.\"--------------------------------------------------------------------------
d64ce4ae 30.TH connect 8 "11 December 2007" "Straylight/Edgeware" "TrIPE: Trivial IP Encryption"
a62f8e8a
MW
31.
32.\"--------------------------------------------------------------------------
33.SH "NAME"
34.
d64ce4ae 35connect \- tripe service to handle addition and removal of peers
a62f8e8a
MW
36.
37.\"--------------------------------------------------------------------------
38.SH "SYNOPSIS"
39.
40.B connect
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 connect
d64ce4ae
MW
58service tracks associations with peers and performs various actions at
59appropriate stages in the assocations' lifecycles. It also registers
60new peers with the
a62f8e8a 61.BR tripe (8)
d64ce4ae
MW
62server on demand.
63.PP
64For example:
65.hP \*o
66When a peer is added, it arranges to configure the corresponding network
67interface correctly, and (if necessary) to initiate a dynamic
68connection.
69.hP \*o
70When a peer is removed, it arranges to bring down the network interface.
71.hP \*o
72While the peer is known, it
73.BR PING s
74it at regular intervals. If the peer fails to respond, it can be
75removed or reconnected.
a62f8e8a
MW
76.PP
77A peer may participate
78.I actively
79or
80.I passively
81in a connection. A peer participating actively (an
82.IR "active peer" )
83must already know its peer's connection details \(en its server's IP
84address and port. Active connection is suitable when the peer is a
85well-known server with stable details.
86.PP
87A server participating passively (a
88.IR "passive peer" )
89waits to be contacted by its peer, and discovers the peer's IP address
90and port as a result of a simple protocol described below. Passive
91connection is suitable when the peer's IP address or port can vary over
92time \(en e.g., if its IP address is assigned dynamically by DHCP or
93PPP, or if it is hidden behind a NAT firewall.
94.PP
95If both peers are active, we say that they establish an
96.IR "static connection" ;
97if one is passive, we say that they establish a
98.IR "dynamic connection" .
99At least one of the peers must be active; it is not possible to
100establish a connection if both peers are passive.
101.SS "Command line"
102In addition to the standard options described in
103.BR tripe-service (7),
104the following command-line options are recognized.
105.TP
106.BI "\-p, \-\-peerdb=" file
107Use
108.I file
109as the (CDB format) peer database. In the absence of this option, the
110file named by the
111.B TRIPEPEERDB
112environment variable is used; if that's not set either, then the default
113default of
114.B peers.cdb
115in the current working directory is used instead.
d64ce4ae
MW
116.
117.\"--------------------------------------------------------------------------
118.SH "BEHAVIOUR"
119.
120.SS "Adoption"
121The
122.B connect
123service maintains a list of peers which it has adopted. A peer is
124.I eligible for adoption
125if it has a record in the peer database
126.BR peers.cdb (5)
127in which the
128.B watch
129key is assigned the value
130.BR t ,
131.BR true ,
132.BR y ,
133.BR yes ,
134or
135.BR on .
136.PP
137The service pings adopted peers periodically in order to ensure that
138they are alive, and takes appropriate action if no replies are received.
a62f8e8a 139.PP
d64ce4ae
MW
140A peer is said to be
141.I adopted
142when it is added to this list, and
143.I disowned
144when it removed.
145.
146.SS "Configuring interfaces"
147The
148.B connect
149service configures network interfaces by invoking an
150.B ifup
151script. The script is invoked as
152.IP
153.I script
154.IR args ...
155.I peer
156.I ifname
157.IR addr ...
158.PP
159where the elements are as described below.
160.TP
161.IR script " and " args
162The peer's database record is retrieved; the value assigned to the
163.B ifup
164key is split into words (quoting is allowed; see
165.BR tripe-admin (5)
166for details). The first word is the
167.IR script ;
168subsequent words are gathered to form the
169.IR args .
170.TP
171.I peer
172The name of the peer.
173.TP
174.I ifname
175The name of the network interface associated with the peer, as returned
176by the
177.B IFNAME
178administration command (see
179.BR tripe-admin (5)).
180.TP
181.I addr
182The network address of the peer's TrIPE server, in the form output by
183the
184.B ADDR
185administration command (see
186.BR tripe-admin (5)).
187The first word of
188.I addr
189is therefore a network address family, e.g.,
190.BR INET .
191.PP
192The
193.B connect
194service deconfigures interfaces by invoking an
195.B ifdown
196script, in a similar manner. The script is invoked as
197.IP
198.I script
199.IR args ...
200.I peer
201.PP
202where the elements are as above, except that
203.I script
204and
205.I args
206are formed by splitting the value associated with the peer record's
207.B ifdown
208key.
209.PP
210In both of the above cases, if the relevant key (either
211.B ifup
212or
213.BR ifdown )
214is absent, no action is taken.
215.PP
216The key/value pairs in the peer's database record and the server's
217response to the
218.B ALGS
219administration command (see
220.BR tripe-admin (5))
221are passed to the
222.B ifup
223and
224.B ifdown
225scripts as environment variables. The environment variable name
226corresponding to a key is determined as follows:
227.hP \*o
228Convert all letters to upper-case.
229.hP \*o Convert all sequences of one or more non-alphanumeric characters
230to an underscore
231.RB ` _ '.
232.hP \*o Prefix the resulting name by
233.RB ` P_ '
234or
235.RB ` A_ '
236depending on whether it came from the peer's database record or the
237.B ALGS
238output respectively.
239.PP
240For example,
241.B ifname
242becomes
243.BR P_IFNAME ;
244and
245.B cipher-blksz
246becomes
247.BR A_CIPHER_BLKSZ .
248.
249.SS "Dynamic connection"
250If a peer's database record assigns a value to the
251.B connect
252key, then the
253.B connect
254service will attempt to establish a connection dynamically with the
255peer. The value of the
256.B connect
257key is invoked as a Bourne shell command, i.e.,
258.IP
259.B /bin/sh \-c
260.I connect
261.PP
262is executed. The command is expected to contact the remote server and
263report, on standard output, a challenge string, typically by issuing
264a
265.B passive
266command to the instance of the
267.B connect
268service running on the peer. The
269.B connect
270service reads this challenge, and submits the command
271.IP
272.B GREET
273.I peer
274.I challenge
275.PP
276Typically, the
277.B connect
278command will issue a command such as
279.IP
280.B SVCSUBMIT connect passive
281.I our-name
282.PP
283where
284.I our-name
285is the remote peer's name for this host.
286.PP
287Similarly, if the database record has a
288.B disconnect
289entry, then
290.B connect
291will use this to give the peer explicit notification that its services
292are no longer needed. The value of the
293.B disconnect
294key is invoked as a Bourne shell command. This ought to result in a
295.B KILL
296command being issued to the peer's server.
297.PP
298In detail, the protocol for passive connection works as follows.
a62f8e8a
MW
299.hP 1.
300The active peer
301.BR ADD s
302its partner, typically using the
303.B \-cork
304option to suppress the key-exchange message which the server usually
305sends immediately, since otherwise the passive peer will warn about it.
306.hP 2.
d64ce4ae 307The active peer issues the command
a62f8e8a
MW
308.RS
309.IP
310.B SVCSUBMIT connect passive
311.I user
312.PP
313to the passive peer's server. (Here,
314.I user
d64ce4ae
MW
315is a name identifying the active peer; see below.) Doing this is the
316responsibility of the
317.B connect
318command.
a62f8e8a
MW
319.RE
320.hP 3.
321The
322.B connect
323service on the passive peer responds with a
324.I challenge
325\(en a short Base64-encoded string. Somehow this challenge is sent back
326to the passive peer without being intercepted.
327.hP 4.
328The active peer sends a
329.BR GREET ing
330containing the challenge to its passive partner. The passive server
331announces the arrival of this message, and the originating address and
332port.
333.hP 5.
334The
335.B connect
336service running on the passive host receives the notification, matches
337it up with the
338.I user
339from the initial connection request, and
340.BR ADD s
341the appropriate peer, with the address from the
342.BR GREET ing.
d64ce4ae
MW
343.
344.SS "Operation"
345On startup,
346.B connect
347requests a list of current peers from the
348.BR tripe (8)
349server, and adopts any eligible peers. If the
350.B \-\-startup
351flag was passed on the command line, the newly adopted peers have their
352interfaces configured and connection attempts are made.
a62f8e8a 353.PP
d64ce4ae
MW
354Adopted peers are pinged at regular intervals (using the
355.B PING
356administrative command; see
357.BR tripe-admin (5)).
358This process can be configured by assigning values to keys in the peer's
359database record. Some of these parameters are time intervals,
360expressed as a nonnegative integer followed optionally by
361.BR d ,
362.BR h ,
363.BR m ,
364or
365.B s
366for days, hours, minutes, or seconds, respectively; if no suffix is
367given, seconds are assumed.
368.PP
369The parameters are as follows.
370.TP
371.B every
372A time interval: how often to ping the peer to ensure that it's still
02c99524
MW
373alive. The default is 30 seconds for active dynamic peers, and 5
374minutes for passive peers.
375.IP
376The period for dynamic peers should be no longer than
377.I timeout
378\(mu
379.RI ( retries
380\- 1). Consider an idle mobile peer which has its IP address changed
381just before its passive peer begins pinging. The static peer's pings
382will go to the old address until it receives a ping back from the mobile
383peer. Therefore, the static peer has to keep pinging until it would
384definitely have received an unsolicited ping from the mobile peer, and
385therefore be informed of the change of address. And it's no use
386learning about the change of address just after sending the last ping to
387the old address, so the last retry doesn't count for the purposes of
388this calculation.
389.IP
390Besides, the consequences of failed pinging differ between dynamic and
391passive peers. In the former case, a failure provokes a reconnection
392attempt, after which (hopefully) things will work again: it's probably a
393good thing to check frequently and fail fast. In the latter case, the
394dynamic peer will certainly have to notice that it's been abandoned and
395arrange to retry, causing a communication failure where maybe there
396wasn't really one before.
d64ce4ae
MW
397.TP
398.B timeout
399A time interval: how long to wait for a reply before retrying or giving
400up. The default is 10 seconds.
401.TP
402.B retries
403An integer: how many failed attempts to make before deciding that the
404peer is unreachable and taking action. The default is 5 attempts.
405.PP
406The algorithm is as follows. Send up to
407.I retries
408pings; if a reply is received before the
409.I timeout
410then the peer is alive; wait
411.I every
412and check again. If no reply is received within the
413.IR timeout ,
414then try again up to
415.I retries
416times. If no attempt succeeds, the peer is declared unreachable. If
417the peer has a
418.B connect
419command (i.e., it connects dynamically) then another connection attempt
420is made. Otherwise the peer is killed.
a62f8e8a
MW
421.
422.\"--------------------------------------------------------------------------
423.SH "SERVICE COMMAND REFERENCE"
424.
425.\"* 10 Service commands
426The commands provided by the service are as follows.
427.SP
428.BI "active " peer
429Make an active connection to the named
430.IR peer .
431The service will submit the command
432.RS
433.IP
434.B ADD
435.RB [ \-cork ]
436.RB [ \-keepalive
437.IR time ]
48b84569
MW
438.RB [ \-key
439.IR tag ]
d64ce4ae
MW
440.RB [ \-priv
441.IR tag ]
6411163d 442.RB [ \-mobile ]
a62f8e8a
MW
443.RB [ \-tunnel
444.IR driver ]
445.I address
446.PP
447Specifically:
448.hP \*o
449The option
450.B \-cork
451is provided if the peer's database record assigns the
452.B cork
453key one of the values
454.BR t ,
455.BR true ,
456.BR y ,
457.BR yes,
458or
459.BR on .
460.hP \*o
461The option
462.B \-keepalive
463.I time
464is provided if the database record assigns a value
465.I time
466to the
467.B keepalive
468key.
469.hP \*o
470The option
48b84569
MW
471.B \-key
472.I tag
473is provided if the database record assigns a value
474.I tag
475to the
476.B key
477key.
478.hP \*o
479The option
d64ce4ae
MW
480.B \-priv
481.I tag
482is provided if the database record assigns a value
483.I tag
484to the
485.B priv
486key.
487.hP \*o
488The option
6411163d
MW
489.B \-mobile
490is provided if the peer's database record assigns the
491.B mobile
492key one of the values
493.BR t ,
494.BR true ,
495.BR y ,
496.BR yes,
497or
498.BR on .
499.hP \*o
500The option
a62f8e8a
MW
501.B \-tunnel
502.I driver
503is provided if the database record assigns a value
504.I driver
505to the
506.B tunnel
507key.
508.hP \*o
509The
510.I address
511is the value assigned to the
512.B peer
513key in the database record.
514.RE
515.SP
d64ce4ae
MW
516.B adopted
517For each peer being tracked by the
518.B connect
519service, write a line
520.B INFO
521.IR name .
522(Compatibility note: it's possible that further information will be
523provided about each peer, in the form of subsequent tokens. Clients
524should be prepared to ignore such tokens.)
525.SP
a62f8e8a
MW
526.BI "info " peer
527Lists the database record for the named
528.IR peer .
529For each key/value pair, a line
530.RS
531.IP
532.B INFO
533.IB key = value
534.PP
535is output. The key/value pairs are output in an arbitrary order.
536.RE
d64ce4ae
MW
537.SP
538.BI "kick " peer
539If
540.I peer
541is currently added, and its record in the peer database contains a
542.B connect
543key (see
544.BR peers.in )
545then force a reconnection attempt. See
546.BR "Dynamic connection" .
547.SP
548.B "list-active"
a62f8e8a
MW
549Output a list of peers in the database. For each peer name
550.IR peer ,
551a line
552.RS
553.IP
554.B INFO
555.I peer
556.PP
557is output.
558.RE
559.SP
560.BI "passive \fR[" options "\fR]\fP " user
561If the database contains a user record mapping
562.I user
563to some
564.I peer
565then an
566.B INFO
567line is written containing a freshly chosen challenge string. If the
568server receives a
569.BR GREET ing
570message quoting this challenge within 30 seconds, the
571.B connect
572service will issue an
573.B ADD
574request for the peer, as for the
575.B active
576command, except that the origin of the
577.BR GREET ing
578packet is used as the peer's address.
579.RS
580.\"+opts
581.PP
582The following option is recognized.
583.TP
584.BI "\-timeout " time
585Wait for
586.I time
587instead of 30 seconds. The
588.I time
589is expressed as a non-negative integer followed by
590.BR d ,
591.BR h ,
592.BR m ,
593or
594.B s
595for days, hours, minutes or seconds respectively; if no suffix is given,
596seconds are assumed.
597.\"-opts
598.RE
d3731285
MW
599.SP
600.BI "userpeer " user
601Output a single
602.B INFO
603line identifying the peer corresponding to the
604.I user
605name.
a62f8e8a
MW
606.
607.\"--------------------------------------------------------------------------
d64ce4ae 608.SH "NOTIFICATIONS"
a62f8e8a 609.
d64ce4ae
MW
610.\"* 30 Notification broadcasts (NOTE codes)
611All notifications issued by
612.B connect
613begin with the tokens
614.BR "USER connect" .
a62f8e8a 615.SP
d64ce4ae
MW
616.B "USER connect peerdb-update"
617The peer database has changed. Other interested clients should reopen
618the database.
a62f8e8a 619.SP
d64ce4ae
MW
620.BI "USER connect ping-failed " peer " " error\fR...
621An attempt to
622.B PING
623the named
a62f8e8a 624.I peer
d64ce4ae
MW
625failed; the server replied
626.B FAIL
627.IR error ...
a62f8e8a 628.SP
d64ce4ae 629.BI "USER connect " process\fR... " stdout " line
a62f8e8a 630The
d64ce4ae
MW
631.I process
632spawned by the
633.B connect
634service unexpectedly wrote
635.I line
636to its standard output.
a62f8e8a
MW
637.
638.\"--------------------------------------------------------------------------
639.SH "WARNINGS"
640.
641.\"* 40 Warning broadcasts (WARN codes)
642All warnings issued by
643.B connect
644begin with the tokens
645.BR "USER connect" .
646.SP
647.BI "USER connect auto-add-failed " name " " error\fR...
648The attempt to add the peer
649.I name
650automatically failed: the
651.B ADD
652command reported
653.B FAIL
654.IR error ...
d64ce4ae
MW
655.SP
656.BI "USER connect ping-ok " peer
657A reply was received to a
658.B PING
659sent to the
660.IR peer ,
661though earlier attempts had failed.
662.SP
663.BI "USER connect ping-timeout " peer " attempt " i " of " n
664No reply was received to a
665.B PING
666sent to the
667.IR peer .
668So far,
669.I i
670.BR PING s
671have been sent; if a total of
672.I n
673consecutive attempts time out, the
674.B connect
675service will take further action.
676.SP
677.B "USER connect reconnecting " peer
678The dynamically connected
679.I peer
680seems to be unresponsive. The
681.B connect
682service will attempt to reconnect.
683.SP
684.BI "USER connect " process\fR... " stderr " line
685The
686.I process
687spawned by the
688.B connect
689service wrote
690.I line
691to its standard error.
692.SP
693.BI "USER connect " process\fR... " exit-nonzero " code
694The
695.I process
696spawned by the
697.B connect
698service exited with the nonzero status
699.IR code .
700.SP
701.BI "USER connect " process\fR... " exit-signal S" code
702The
703.I process
704spawned by the
705.B connect
706service was killed by signal
707.IR code .
708Here,
709.I code
710is the numeric value of the fatal signal.
711.SP
712.BI "USER connect " process\fR... " exit-unknown " status
713The
714.I process
715spawned by the
716.B connect
717service exited with an unknown
718.IR status .
719Here,
720.I status
721is the raw exit status, as returned by
722.BR waitpid (2),
723in hexadecimal.
724.
725.\"--------------------------------------------------------------------------
726.SH "CHILD PROCESS IDENTIFIERS"
727.
728.\"* 50 Child process identifiers
729Some of the warnings and notifications refer to processes spawned by
730.B connect
731under various circumstances. The process identifiers are as follows.
732.SP
733.BI "connect " peer
734A child spawned in order to establish a dynamic connection with
735.IR peer .
736.SP
737.BI "disconnect " peer
738A child spawned in order to shut down a dynamic connection with
739.IR peer .
740.SP
741.BI "ifdown " peer
742A child spawned to deconfigure the network interface for
743.IR peer .
744.SP
745.BI "ifup " peer
746A child spawned to configure the network interface for
747.IR peer .
a62f8e8a
MW
748.
749.\"--------------------------------------------------------------------------
750.SH "SUMMARY"
751.
752.\"= summary
753.
754.\"--------------------------------------------------------------------------
755.SH "SEE ALSO"
756.
757.BR tripe-service (7),
758.BR peers.in (5),
a62f8e8a
MW
759.BR tripe (8).
760.
761.\"--------------------------------------------------------------------------
762.SH "AUTHOR"
763.
764Mark Wooding, <mdw@distorted.org.uk>
765.
766.\"----- That's all, folks --------------------------------------------------