chiark / gitweb /
mon/tripemon.in: Show per-peer crypto details in peer info sheet.
[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
373alive. The default is 2 minutes.
374.TP
375.B timeout
376A time interval: how long to wait for a reply before retrying or giving
377up. The default is 10 seconds.
378.TP
379.B retries
380An integer: how many failed attempts to make before deciding that the
381peer is unreachable and taking action. The default is 5 attempts.
382.PP
383The algorithm is as follows. Send up to
384.I retries
385pings; if a reply is received before the
386.I timeout
387then the peer is alive; wait
388.I every
389and check again. If no reply is received within the
390.IR timeout ,
391then try again up to
392.I retries
393times. If no attempt succeeds, the peer is declared unreachable. If
394the peer has a
395.B connect
396command (i.e., it connects dynamically) then another connection attempt
397is made. Otherwise the peer is killed.
a62f8e8a
MW
398.
399.\"--------------------------------------------------------------------------
400.SH "SERVICE COMMAND REFERENCE"
401.
402.\"* 10 Service commands
403The commands provided by the service are as follows.
404.SP
405.BI "active " peer
406Make an active connection to the named
407.IR peer .
408The service will submit the command
409.RS
410.IP
411.B ADD
412.RB [ \-cork ]
413.RB [ \-keepalive
414.IR time ]
48b84569
MW
415.RB [ \-key
416.IR tag ]
d64ce4ae
MW
417.RB [ \-priv
418.IR tag ]
6411163d 419.RB [ \-mobile ]
a62f8e8a
MW
420.RB [ \-tunnel
421.IR driver ]
422.I address
423.PP
424Specifically:
425.hP \*o
426The option
427.B \-cork
428is provided if the peer's database record assigns the
429.B cork
430key one of the values
431.BR t ,
432.BR true ,
433.BR y ,
434.BR yes,
435or
436.BR on .
437.hP \*o
438The option
439.B \-keepalive
440.I time
441is provided if the database record assigns a value
442.I time
443to the
444.B keepalive
445key.
446.hP \*o
447The option
48b84569
MW
448.B \-key
449.I tag
450is provided if the database record assigns a value
451.I tag
452to the
453.B key
454key.
455.hP \*o
456The option
d64ce4ae
MW
457.B \-priv
458.I tag
459is provided if the database record assigns a value
460.I tag
461to the
462.B priv
463key.
464.hP \*o
465The option
6411163d
MW
466.B \-mobile
467is provided if the peer's database record assigns the
468.B mobile
469key one of the values
470.BR t ,
471.BR true ,
472.BR y ,
473.BR yes,
474or
475.BR on .
476.hP \*o
477The option
a62f8e8a
MW
478.B \-tunnel
479.I driver
480is provided if the database record assigns a value
481.I driver
482to the
483.B tunnel
484key.
485.hP \*o
486The
487.I address
488is the value assigned to the
489.B peer
490key in the database record.
491.RE
492.SP
d64ce4ae
MW
493.B adopted
494For each peer being tracked by the
495.B connect
496service, write a line
497.B INFO
498.IR name .
499(Compatibility note: it's possible that further information will be
500provided about each peer, in the form of subsequent tokens. Clients
501should be prepared to ignore such tokens.)
502.SP
a62f8e8a
MW
503.BI "info " peer
504Lists the database record for the named
505.IR peer .
506For each key/value pair, a line
507.RS
508.IP
509.B INFO
510.IB key = value
511.PP
512is output. The key/value pairs are output in an arbitrary order.
513.RE
d64ce4ae
MW
514.SP
515.BI "kick " peer
516If
517.I peer
518is currently added, and its record in the peer database contains a
519.B connect
520key (see
521.BR peers.in )
522then force a reconnection attempt. See
523.BR "Dynamic connection" .
524.SP
525.B "list-active"
a62f8e8a
MW
526Output a list of peers in the database. For each peer name
527.IR peer ,
528a line
529.RS
530.IP
531.B INFO
532.I peer
533.PP
534is output.
535.RE
536.SP
537.BI "passive \fR[" options "\fR]\fP " user
538If the database contains a user record mapping
539.I user
540to some
541.I peer
542then an
543.B INFO
544line is written containing a freshly chosen challenge string. If the
545server receives a
546.BR GREET ing
547message quoting this challenge within 30 seconds, the
548.B connect
549service will issue an
550.B ADD
551request for the peer, as for the
552.B active
553command, except that the origin of the
554.BR GREET ing
555packet is used as the peer's address.
556.RS
557.\"+opts
558.PP
559The following option is recognized.
560.TP
561.BI "\-timeout " time
562Wait for
563.I time
564instead of 30 seconds. The
565.I time
566is expressed as a non-negative integer followed by
567.BR d ,
568.BR h ,
569.BR m ,
570or
571.B s
572for days, hours, minutes or seconds respectively; if no suffix is given,
573seconds are assumed.
574.\"-opts
575.RE
d3731285
MW
576.SP
577.BI "userpeer " user
578Output a single
579.B INFO
580line identifying the peer corresponding to the
581.I user
582name.
a62f8e8a
MW
583.
584.\"--------------------------------------------------------------------------
d64ce4ae 585.SH "NOTIFICATIONS"
a62f8e8a 586.
d64ce4ae
MW
587.\"* 30 Notification broadcasts (NOTE codes)
588All notifications issued by
589.B connect
590begin with the tokens
591.BR "USER connect" .
a62f8e8a 592.SP
d64ce4ae
MW
593.B "USER connect peerdb-update"
594The peer database has changed. Other interested clients should reopen
595the database.
a62f8e8a 596.SP
d64ce4ae
MW
597.BI "USER connect ping-failed " peer " " error\fR...
598An attempt to
599.B PING
600the named
a62f8e8a 601.I peer
d64ce4ae
MW
602failed; the server replied
603.B FAIL
604.IR error ...
a62f8e8a 605.SP
d64ce4ae 606.BI "USER connect " process\fR... " stdout " line
a62f8e8a 607The
d64ce4ae
MW
608.I process
609spawned by the
610.B connect
611service unexpectedly wrote
612.I line
613to its standard output.
a62f8e8a
MW
614.
615.\"--------------------------------------------------------------------------
616.SH "WARNINGS"
617.
618.\"* 40 Warning broadcasts (WARN codes)
619All warnings issued by
620.B connect
621begin with the tokens
622.BR "USER connect" .
623.SP
624.BI "USER connect auto-add-failed " name " " error\fR...
625The attempt to add the peer
626.I name
627automatically failed: the
628.B ADD
629command reported
630.B FAIL
631.IR error ...
d64ce4ae
MW
632.SP
633.BI "USER connect ping-ok " peer
634A reply was received to a
635.B PING
636sent to the
637.IR peer ,
638though earlier attempts had failed.
639.SP
640.BI "USER connect ping-timeout " peer " attempt " i " of " n
641No reply was received to a
642.B PING
643sent to the
644.IR peer .
645So far,
646.I i
647.BR PING s
648have been sent; if a total of
649.I n
650consecutive attempts time out, the
651.B connect
652service will take further action.
653.SP
654.B "USER connect reconnecting " peer
655The dynamically connected
656.I peer
657seems to be unresponsive. The
658.B connect
659service will attempt to reconnect.
660.SP
661.BI "USER connect " process\fR... " stderr " line
662The
663.I process
664spawned by the
665.B connect
666service wrote
667.I line
668to its standard error.
669.SP
670.BI "USER connect " process\fR... " exit-nonzero " code
671The
672.I process
673spawned by the
674.B connect
675service exited with the nonzero status
676.IR code .
677.SP
678.BI "USER connect " process\fR... " exit-signal S" code
679The
680.I process
681spawned by the
682.B connect
683service was killed by signal
684.IR code .
685Here,
686.I code
687is the numeric value of the fatal signal.
688.SP
689.BI "USER connect " process\fR... " exit-unknown " status
690The
691.I process
692spawned by the
693.B connect
694service exited with an unknown
695.IR status .
696Here,
697.I status
698is the raw exit status, as returned by
699.BR waitpid (2),
700in hexadecimal.
701.
702.\"--------------------------------------------------------------------------
703.SH "CHILD PROCESS IDENTIFIERS"
704.
705.\"* 50 Child process identifiers
706Some of the warnings and notifications refer to processes spawned by
707.B connect
708under various circumstances. The process identifiers are as follows.
709.SP
710.BI "connect " peer
711A child spawned in order to establish a dynamic connection with
712.IR peer .
713.SP
714.BI "disconnect " peer
715A child spawned in order to shut down a dynamic connection with
716.IR peer .
717.SP
718.BI "ifdown " peer
719A child spawned to deconfigure the network interface for
720.IR peer .
721.SP
722.BI "ifup " peer
723A child spawned to configure the network interface for
724.IR peer .
a62f8e8a
MW
725.
726.\"--------------------------------------------------------------------------
727.SH "SUMMARY"
728.
729.\"= summary
730.
731.\"--------------------------------------------------------------------------
732.SH "SEE ALSO"
733.
734.BR tripe-service (7),
735.BR peers.in (5),
a62f8e8a
MW
736.BR tripe (8).
737.
738.\"--------------------------------------------------------------------------
739.SH "AUTHOR"
740.
741Mark Wooding, <mdw@distorted.org.uk>
742.
743.\"----- That's all, folks --------------------------------------------------