aboutsummaryrefslogtreecommitdiff
path: root/doc/jumper.8in
blob: 77c8cdc080da616aee9a0605d4cdab0792c5fe2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
.\" This file is part of Jumper  -*- nroff -*-
.\" Copyright (C) 2013, 2017, 2020 Sergey Poznyakoff
.\"
.\" Jumper is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 3, or (at your option)
.\" any later version.
.\"
.\" Jumper is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with Jumper.  If not, see <http://www.gnu.org/licenses/>.
.so config.so
.TH JUMPER 8 "January 25, 2020" "JUMPER"
.SH NAME
jumper \- bring up network links on demand
.SH SYNOPSIS
\fBjumper\fR [\fB\-Edf\fR] [\fB\-P\fR \fIFILE\fR] [\fB\-l\fR \fIPRIO\fR]\
 [\fB\-D\fR \fISYMBOL\fR[\fB=\fIVALUE\fR]]\
 [\fB\-I\fR \fIDIR\fR]
       [\fB\-\-debug\fR] [\fB\-\-foreground\fR]\
 [\fB\-\-define=\fISYMBOL\fR[\fB=\fIVALUE\fR]]
       [\fB\-\-include\-directory=\fIDIR\fR]
       [\fB\-\-no\-preprocessor\fR] [\fB\-\-preprocessor=\fICOMMAND\fR]
       [\fB\-\-pidfile=\fIFILE\fR] [\fICONFIG\fR]
.br
\fBjumper\fR [\fB\-HhV\fR] [\fB\-\-help\fR] [\fB\-\-version\fR] [\fB\-\-config\-help\fR]
.SH DESCRIPTION
.B Jumper
monitors network interfaces for certain kinds of traffic and starts
preconfigured external programs when such traffic is detected.  It is
designed mainly to bring up network links (such as VPN and the like)
on demand.
.PP
The configuration file tells the program on which interfaces to
listen, what packets to catch and what program to start when such
packets are detected.  The default location for the configuration file
is
.BR \*(ET/jumper.conf .
If the
.I CONFIG
argument is supplied, it names the configuration file to be read
instead of the default one.
.PP
See the section
.BR CONFIGURATION ,
for a detailed description of configuration file syntax.
.PP
Unless instructed otherwise,
.B jumper
uses
.BR m4 (1)
to preprocess its configuration file.  See the section
.B PREPROCESSOR
for a detailed discussion.
.PP
After successful parsing of the configuration file, the program
switches the configured interfaces to promiscuous mode, detaches
itself from the controlling terminal and begins listening on the
interfaces.
.PP
When a packet arrives that matches the specified conditions,
.B jumper
checks whether the program configured for this kind of packets is
already running.  If it is not, it will be started.  Thus, for
example, the following configuration fragment instructs the program to
start
.B openvpn
whenever a packet coming to any IP address from the network
10.0.1.0/24 is detected:
.PP
.EX
listen myvpn {
        interface eth1;
        match-destination 10.0.1.0/24;
        command "/usr/bin/openvpn /etc/openvpn.conf";
}
.EE
.PP
.SH OPTIONS
.TP
\fB\-D\fR, \fB\-\-define=\fISYMBOL\fR[\fB=\fIVALUE\fR]
Define preprocessor symbol.
.TP
\fB\-E\fR
Preprocess configuration file and exit.
.TP
\fB\-I\fR, \fB\-\-include\-directory=\fIDIR\fR
Add \fIDIR\fR to the list of preprocessor include directories.
.TP
\fB\-P \fIFILE\fR, \fB\-\-pidfile=\fIFILE\fR
Set PID file name.
.TP
.BR \-d , " \-\-debug"
Increase debugging level.  See the description of
.B debug
statement in
.BR "CONFIGURATION STATEMENTS" ,
for a detailed discussion of debugging levels and their effect on
the program output.
.TP
.BR \-f , " \-\-foreground"
Remain in foreground.
.TP
.BI \-l " PRIO"
When running in the foreground (see the \fB\-f\fR option above), log
messages with priority \fIPRIO\fR and higher to the stderr, as well as
to the syslog.  \fIPRIO\fR is one of the usual
.BR syslog.conf (8)
priorities:
.BR debug ,
.BR info ,
.BR notice ,
.BR warning ,
.BR err ,
.BR crit ,
.BR alert ,
.BR emerg ,
or
.BR none ,
which suppresses any output to standard error.

By default, all priorities are logged.
.TP
.B \-\-no\-preprocessor
Disable preprocessing of the configuration file.  Read it verbatim.
.TP
\fB\-\-preprocessor=\fICOMMAND\fR
Use \fICOMMAND\fR instead of the default preprocessor.
.PP
Informational options:
.TP
.BR \-h , " \-\-help"
Give a concise help summary.
.TP
.BR \-H , " \-\-config-help"
Show configuration file summary and exit.
.TP
.B \-\-usage
Print a short usage message.
.TP
.BR \-V , " \-\-version"
Print program version.
.SH CONFIGURATION
The configuration file consists of statements and comments.
.PP
There are three classes of lexical tokens: keywords, values, and
separators. Blanks, tabs, newlines and comments, collectively called
\fIwhite space\fR are ignored except as they serve to separate
tokens. Some white space is required to separate otherwise adjacent 
keywords and values.
.SS Comments
Comments may appear anywhere where white space may appear in the
configuration file.  There are two kinds of comments:
single-line and multi-line comments.  Single-line comments start
with
.B #
or
.B //
and continue to the end of the line:
.sp
.RS 4
.nf
# This is a comment
// This too is a comment
.fi
.RE
.PP
\fIMulti-line\fB or \fIC-style\fR comments start with the two
characters
.B /*
(slash, star) and continue until the first occurrence of
.B */
(star, slash).
.PP
Multi-line comments cannot be nested.  However, single-line comments
may well appear within multi-line ones.
.SS "Pragmatic Comments"
Pragmatic comments are similar to the usual single-line comments,
except that they cause some changes in the way the configuration is
parsed.  Pragmatic comments begin with a
.B #
sign and end with the next physical newline character.
.TP
.BI "#include <" "FILE" >
.PD 0
.TP
.BI "#include " "FILE"
.PD
Include the contents of the file \fIfile\fR.  Both forms are
equivalent.  The \fIFILE\fR must be an absolute file name.
.TP
.BI "#include_once <" "FILE" >
.PD 0
.TP
.BR "#include_once " "FILE"
.PD
Same as \fB#include\fR, except that, if the \fIFILE\fR has already
been included, it will not be included again.
.TP
.BI "#line " "num"
.PD 0
.TP
.BI "#line " "num" " \(dq" "FILE" "\(dq"
.PD
This line causes the parser to believe, for purposes of error
diagnostics, that the line number of the next source line
is given by \fInum\fR and the current input file is named by
\fIFILE\fR. If the latter is absent, the remembered file name
does not change.
.TP
.BI "# " "num" " \(dq" "FILE" "\(dq"
This is a special form of the \fB#line\fR statement, understood for
compatibility with the C preprocessor.
.SS "Simple statement"
A \fIsimple statement\fR consists of a keyword and value
separated by any amount of whitespace.  Simple statement is terminated
with a semicolon (\fB;\fR).
.PP
The following is a simple statement:
.sp
.RS 4
.nf
pidfile /var/run/jumper.pid;
.RE
.fi
.PP
A \fIvalue\fR can be one of the following:
.TP
.I number
A number is a sequence of decimal digits.
.TP
.I boolean
One of: \fByes\fR, \fBtrue\fR, \fBt\fR or \fB1\fR, meaning \fItrue\fR,
and \fBno\fR, \fBfalse\fR, \fBnil\fR, \fB0\fR meaning \fIfalse\fR.
.TP
.I unquoted string
Any sequence of letters, digits, and any of the
following characters: \fB_\fR, \fB\-\fR, \fB.\fR, \fB/\fR,
\fB@\fR, \fB*\fR, \fB:\fR is treated as a string.
.TP
.I quoted string
Any sequence of characters enclosed in
double-quotes (\fB\(dq\fR).  A backslash appearing within a quoted
string introduces an \fIescape sequence\fR, which is replaced
with a single character according to the following rules:
.sp
.nf
.ta 8n 18n 42n
.ul
	Sequence	Expansion	ASCII
	\fB\\\\\fR	\fB\\\fR	134
	\fB\\"\fR	\fB"\fR	042
	\fB\\a\fR	audible bell	007	
	\fB\\b\fR	backspace	010
	\fB\\f\fR	form-feed	014
	\fB\\n\fR	new line	012
	\fB\\r\fR	charriage return	015
	\fB\\t\fR	horizontal tabulation	011
	\fB\\v\fR	vertical tabulation	013
.fi

In addition, the sequence \fB\\\fInewline\fR is removed from
the string.  This allows to split long strings over several
physical lines, e.g.:
.sp
.nf
.in +4
"a long string may be\\
 split over several lines"
.in
.fi
.sp
If the character following a backslash is not one of those specified
above, the backslash is ignored and a warning is issued.

Two or more adjacent quoted strings are concatenated, which gives
another way to split long strings over several lines to improve
readability.  The following fragment produces the same result as the
example above:
.sp
.nf
.in +4
"a long string may be"
" split over several lines"
.in
.fi
.TP
.I Here-document
A \fIhere-document\fR is a special construct that allows to introduce
strings of text containing embedded newlines.  

The
.BI "<<" "word"
construct instructs the parser to read all the following lines up to
the line containing only \fIword\fR, with possible trailing blanks.
Any lines thus read are concatenated together into a single string.
For example: 
.sp
.nf
.in +4
<<EOT
A multiline
string
EOT
.in
.fi
.sp
The body of a here-document is interpreted the same way as a
double\-quoted string, unless \fIword\fR is preceded by a backslash
(e.g.  \fB<<\\EOT\fR) or enclosed in double\-quotes, in which case
the text is read as is, without interpretation of escape sequences.

If \fIword\fR is prefixed with \fB\-\fR (a dash), then all leading
tab characters are stripped from input lines and the line containing
\fIword\fR.  Furthermore, \fB\-\fR is followed by a single space,
all leading whitespace is stripped from them.  This allows to indent
here-documents in a natural fashion.  For example:
.sp
.nf
.in +4
<<\- TEXT
    The leading whitespace will be
    ignored when reading these lines.
TEXT
.in
.fi
.sp
It is important that the terminating delimiter be the only token on
its line.  The only exception to this rule is allowed if a
here-document appears as the last element of a statement.  In this
case a semicolon can be placed on the same line with its terminating 
delimiter, as in: 
.sp
.nf
.in +5
help\-text <<\-EOT
    A sample help text.
EOT;
.in
.fi
.TP
.I list
A comma-separated list of values, enclosed in parentheses.  The
following example shows a statement whose value is a list of strings:
.sp
.nf
.in +4
option (wait, stderr);
.in
.fi
.sp
In any context where a list is appropriate, a single value is allowed
without being a member of a list: it is equivalent to a list with a
single member.  This means that, e.g.
.sp
.nf
.in +4
option stderr;
.in
.fi
.sp
is equivalent to
.sp
.nf
.in +4
option (stderr);
.in
.fi
.SS "Block Statement"
A block statement introduces a logical group of 
statements.  It consists of a keyword, optionally followed by a value,
called a \fBtag\fR, and a sequence of statements enclosed in curly
braces, as shown in the example below:
.PP
.EX
listen vpn {
    interface eth0;
    match-destination 10.0.0.0/8;
    command "openvpn";
}
.EE
.PP
The closing curly brace may be followed by a semicolon, although
this is not required.
.SS MACRO EXPANSION
Arguments to certain statements undergo macro expansion before further
use.  During the macro expansion any occurrence of \fB${NAME}\fR is
replaced with the value of macro \fBNAME\fR.  Macro names follow the usual
convention: they begin with a letter and contain letters, digits and
underscores.  Curly braces around the \fBNAME\fR are optional.
They are required only if the macro reference is followed by a
character that is not to be interpreted as part of its name, as in
\fB${command}string\fR.
.PP
The sets of macro names available for expansion differs depending on
the configuration context and are discussed in detail below.
.SS CONFIGURATION STATEMENTS
.TP
\fBforeground\fR \fIBOOL\fB;\fR
If \fIBOOL\fR is \fBtrue\fR, do not detach
from the controlling terminal.
.TP
\fBpidfile\fR \fIFILE\fB;\fR
After successful startup, write the PID of the running process to
\fIFILE\fR.  The file will be removed before normal termination.
The default \fIFILE\fR is
.BR \*(ST/run/jumper.pid .
.TP
\fBdebug\fR \fINUMBER\fB;\fR
Set debugging level.  Implemented levels are:
.RS +7
.TP
.B 0
No debugging info.
.TP
.B 1
Additional information regarding process management.
.TP
.B 2
Log information about I/O redirection processes.
.TP
.B 3
Log captured IP packets.
.RE
.TP
\fBshutdown\-timeout\fR \fINUMBER\fB;\fR
When \fBjumper\fR is terminated, it shuts down all subprocesses
launched so far.  This statement sets the time to wait for them
to exit properly.  If any processes are left after \fINUMBER\fR
of seconds, \fBjumper\fR will terminate them forcefully, delivering
them the \fBSIGKILL\fR signal.  The default timeout is 15 seconds.
.TP
\fBlisten\fR \fINAME\fR \fB{ ... }\fR
Define a listener.  The \fINAME\fR is a unique string identifying
this listener in the configuration.  The following instructions are
available for use in the \fB{ ... }\fR block:
.TP
\fBinterface\fR \fIIFACE\fB;\fR
Listen on the specified interface.  This statement is mandatory.
.TP
\fBmatch\-source\fR \fICIDR-LIST\fB;\fR
Match only packets coming from one of the listed networks.
.TP
\fBmatch\-destination\fR \fICIDR-LIST\fB;\fR
Match only packets going to one of the listed networks.  This
statement must be present.

If both \fBmatch\-source\fR and \fBmatch\-destination\fR are supplied,
their conditions are joined by logical \fBAND\fR.
.TP
\fBcommand\fR \fICOMMAND\-LINE\fB;\fR
Run \fICOMMAND\-LINE\fR if the conditions are satisfied.  The argument
is parsed using the same algorithm as used by the shell.  It is
subject to macro expansion.  The following macro names are defined:
.RS +7
.TP
.B program
The program name (\fBjumper\fR).
.TP
.B file
Name of the configuration file where the \fBcommand\fR statement is
located.
.TP
.B line
Line number in that file.
.TP
.B src
Source IP address.
.TP
.B dst
Destination IP address.
.RE
.TP
\fBoption\fR \fIOPTION-LIST\fB;\fR
A list of additional options.  Currently the following options are defined:
.RS +7
.TP
.B stdout
Capture the standard output of the command and redirect it to the
\fBsyslog\fR with the \fBLOG_INFO\fR priority.
.TP
.B stderr
Capture the standard error of the command and redirect it to the
\fBsyslog\fR with the \fBLOG_ERR\fR priority.
.TP
.B nullin
Do not close standard input.  Redirect it from
.B /dev/null
instead.  Use this option with commands that require their standard
input to be open (e.g.
.BR "pppd nodetach" ).
.RE
.TP
\fBenviron\fR \fIENV\-SPEC\fR;
Modify command environment.  By default the command inherits the environment
of \fBjumper\fR augmented with the following variables:
.RS +7
.TP
.B JUMPER
Name of the program.
.TP
.B JUMPER_VERSION
Program version.
.TP
.B JUMPER_LOCUS
Location in the configuration file which caused execution of the
command (file name and line number separated with a colon).
.TP
.B JUMPER_EVENT
Name of the event that triggered the action; one of:
.BR cleanup ,
.BR exit ,
.BR heartbeat ,
.BR signal ,
.BR startup .
.BR
.B JUMPER_PID
PID of the running network management process.
.RE
.IP
The \fBenviron\fR statement allows for trimming the environment.  Its
argument is a list of one or more of the following environment modification
directives.  Before applying, the argument undergoes macro expansion
using the same set of macros as the \fBcommand\fR statement (which see).
.RS +10
.TP
.BR \- " (a single dash)"
Clear the inherited environment, but retain the variables added by
\fBjumper\fR.  The removed environment variables can be selectively
restored by the directives that follow.  This must be the first directive
in the list.
.TP
.BR \-\- " (double-dash)"
Clear the entire environment, including the variables added by
\fBjumper\fR.  This must be the first directive in the list.
.TP
.BI \- NAME
Unset the variable \fINAME\fR.
.TP
.BI \- NAME = VAL
Unset the environment variable \fINAME\fR only if its value is \fIVAL\fR.
.TP
.I NAME
Restore the environment variable \fINAME\fR.  This directive is useful
after \fB\-\fR or \fB\-\-\fR to retain some variables from the environment.
.TP
.BI "" NAME = VALUE
Define environment variable \fINAME\fR to the \fIVALUE\fR.  \fIVALUE\fR can
contain macro variables, which will be expanded prior to the assignment.
.TP
.BI "" NAME += VALUE
Retain the variable \fINAME\fR and append \fIVALUE\fR to its existing value.
If no such variable is present in the environment, it will be created and
assigned the \fBVALUE\fR.  If \fBVALUE\fR begins with a punctuation
character, this character is removed from it before the assignment.  This
is convenient  for using this construct with environment variables like
\fBPATH\fR, e.g.:
.RS
.sp
.nf
.in +4
PATH+=:/sbin
.in
.fi
.RE
.IP
In this example, if \fBPATH\fR exists, \fB:/sbin\fR will be appended
to it.  Otherwise, it will be created and assigned the value \fB/sbin\fR.
.IP
The \fIVALUE\fR can contain macro variables, which will be expanded prior
to the assignment. 
.TP
.BI ""  NAME =+ VALUE
Retain the variable \fINAME\fR and prepend \fIVALUE\fR to its existing value.
If no such variable is present in the environment, it will be created and
assigned the \fIVALUE\fR.  In this case, if \fIVALUE\fR ends with a
punctuation character, this character will be removed from it before
the assignment.
.IP
The \fIVALUE\fR can contain macro variables, which will be expanded prior
to the assignment.
.RE
.TP
\fBonevent\fR \fIEVLIST\fR \fB{ ... };\fR
This block statement instructs \fBjumper\fR to perform a specified
action when an event listed in \fIEVLIST\fR is detected.
\fIEVLIST\fR can be either a single event, or a whitespace separated
list of events, or a comma-separated list of events in parentheses.
Valid events are:
.RS +10
.TP
.B STARTUP
The action is run immediately after
.B jumper
starts up, before it begins listening on interfaces.  It can be used
to set up firewall rules, etc.
.TP
.B CLEANUP
The action is run before
.B jumper
terminates, right after termination of all commands.
.TP
Decimal number in range \fB0..127\fR
The action is performed when the command terminates with the given
code.
.TP
.BI EX+ N
The action is performed when the command terminates with the
code \fIN\fR.
.TP
Symbolic name of exit code from \fBsysexits.h\fR
The action is performed when the command terminates with the
given exit code.  Currently the following symbolic names are used:
\fBEX_OK\fR (0), \fBEX_USAGE\fR (64), \fBEX_DATAERR\fR (65),
\fBEX_NOINPUT\fR (66), \fBEX_NOUSER\fR (67), \fBEX_NOHOST\fR (68),
\fBEX_UNAVAILABLE\fR (69), \fBEX_SOFTWARE\fR (70), \fBEX_OSERR\fR
(71), \fBEX_OSFILE\fR (72), \fBEX_CANTCREAT\fR (73),
\fBEX_IOERR\fR (74), \fBEX_TEMPFAIL\fR (75), \fBEX_PROTOCOL\fR (76),
\fBEX_NOPERM\fR (77), and \fBEX_CONFIG\fR (78). 
.TP
.BI SIG+ N
The action is performed when the command
terminates on signal \fIN\fR (decimal number)
.TP
Symbolic signal name as defined in \fBsignal.h\fR
The action is performed when the command
terminates on this signal.
.RE

The following statements can be used within the block:
.TP
\fBcommand\fR \fICOMMAND\-LINE\fB;\fR
Run \fICOMMAND\-LINE\fR.  The following macros are expanded in the
argument prior to execution:
.RS +7
.TP
.B program
The program name (\fBjumper\fR).
.TP
.B file
Name of the configuration file where the \fBcommand\fR statement is
located.
.TP
.B line
Line number in that file.
.TP
.B event
Name of the event that triggered the action; one of:
.BR cleanup ,
.BR exit ,
.BR heartbeat ,
.BR signal ,
.BR startup .
.TP
.B status
Program termination status as returned by the
.BR waitpid (2)
call.
.TP
.B exitcode
Exit code returned by the program, or the number of the signal that
caused its termination.
.TP
.B pid
PID of the listener network management process.
.RE
.TP
\fBenviron\fR \fIENV\-SPEC\fR;
Modify command environment.  See the description of the \fBenviron\fR
statement above, for a detailed discussion.
.TP
\fBtimeout\fR \fINUMBER\fR
If the command does not exit within \fINUMBER\fR seconds from its
start, terminate it forcefully.  The default is 5 seconds.
.SH PREPROCESSOR
Prior to parsing, the configuration file is preprocessed using
.BR m4 (1).
.PP
The include path is set initially to the following two directories:
.PP
.B \*(VI
.br
.B \*(IN
.PP
It can be further modified using the
\fB\-I\fR (\fB\-\-include\-directory\fR) command line option.
.PP
If the file
.B pp-setup
is found in the include path, it is sourced before the configuration
file.  This can be used to provide macros and constants for the
configuration.
.PP
Additional definitions can also be provided from the command line
using the \fB\-D\fR (\fB\-\-define\fR) option.
.PP
To view preprocessed configuration, use the \fB\-E\fR option.  It
prints the preprocessed text on the standard output.
.PP
To disable preprocessing, use the \fB\-\-no\-preprocessor\fR option.
.SH SIGNALS
Delivering the \fBSIGHUP\fR signal causes \fBjumper\fR to re-read its
configuration file.  When doing so, it will not touch any running
processes started on behalf of listeners that underwent no changes,
compared to the previous configuration.  However, any command which
was started for a listener whose configuration did change will be
terminated prior to updating configuration.
.PP
If any errors are detected in the configuration file, the current
configuration will remain unchanged.
.PP
The \fBSIGALRM\fR and \fBSIGCHLD\fR signals are used internally.
.PP
The following signals cause normal program termination:
.BR SIGTERM ,
.BR SIGQUIT ,
.BR SIGINT .
.PP
The signals \fBSIGUSR1\fR and \fBSIGUSR2\fR are reserved for future
use.
.SH "EXIT CODE"
.IP 0
Successful termination.
.IP 64
Command line usage error.
.IP 70
Internal software error (unknown data link or the
like).
.IP 71
System error (can't fork, out of memory, etc.)
.IP 78
Configuration error.
.SH "EXAMPLES"
Run
.B openvpn
whenever a packet directed to one of the addresses from the 10.0.0.0/8
network is detected on the interface
.BR eth1 .
Redirect both its standard error and standard output to syslog:
.PP
.EX
listen vpn {
        interface eth0;
	match-destination (10.0.0.0/8);
	command "/usr/sbin/openvpn /etc/openvpn.conf";
	option (stderr, stdout);
}
.EE
.SH NOTES
When using
.B jumper
to start VPN, the usual operation sequence is as follows:
.PP
.nr step 1 1
.IP \n[step].
A client initiates connection to an IP address that should be provided
by the VPN which is currently not active.
.IP \n+[step].
.B Jumper
detects packets destined to that address and launches external program
that brings the VPN up.
.IP \n+[step].
Once the VPN is up, the client successfully connects to the required
IP.
.PP
To make this possible the following provisions should be made:
.PP
.nr step 1 1
.IP \n[step].
The
.BR iptables (8)
.B FORWARD
chain must initially contain a statement preventing packets for the IP
addresses covered by the VPN from reaching their destination, e.g.:

.EX
-A FORWARD -d 172.16.0.0/12 -j DROP
.EE
.IP \n+[step].
Upon successful startup, the VPN handler must insert to this chain a
rule allowing connections to that particular range of addresses.  This
rule must, of course, be inserted before the \fBDROP\fR rule.  As a
result, the \fBFORWARD\fR chain will contain something similar to:

.EX
-A FORWARD -d 172.16.0.0/12 -j ACCEPT
-A FORWARD -d 172.16.0.0/12 -j DROP
.EE

Exact ways of achieving this depend on the program used to establish
VPN connection.  For
.BR openvpn (8),
use the \fB\-\-client\-connect\fR option.  For
.BR vpnc (8),
modify the handling of \fBreason=connect\fR in the
.B /etc/vpnc/vpnc-script
file.
.IP \n+[step].
Upon VPN termination, that additional rule must be removed.  For
.BR openvpn (8),
use the \fB\-\-client\-disconnect\fR option.  For
.BR vpnc (8),
modify the handling of \fBreason=disconnect\fR in the
.B /etc/vpnc/vpnc-script
file.
.PP
Notice also, that you might have to specify additional \fBonevent\fR
rules to clean-up the firewall table in case of the hang-up or similar
conditions.  For example,
.BR vpnc (8)
fails to invoke the
.B /etc/vpnc/vpnc-script
if the connection is terminated by the server.  In that case it exits
with code 1.  If you modify the script so that it handles
\fBreason=cleanup\fR to clean up the firewall rules, add the following
to the \fBlisten\fR statement:
.PP
.EX
onevent 1 {
	command "/etc/vpnc/vpnc-script";
        environ "reason=cleanup";
}
.EE
.\" The MANCGI variable is set by man.cgi script on Ulysses.
.\" The download.inc file contains the default DOWNLOAD section
.\" for man-based doc pages.
.if "\V[MANCGI]"WEBDOC" \{\
.       ds package jumper
.       ds version 1.2
.       so download.inc
\}
.SH "SEE ALSO"
.BR m4 (1),
.BR cfpeek (1),
.BR ifalive (8).
.SH AUTHORS
Sergey Poznyakoff
.SH "BUG REPORTS"
Report bugs to <bug-jumper@gnu.org.ua>.
.SH COPYRIGHT
Copyright \(co 2013-2020 Sergey Poznyakoff
.br
.na
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
.br
.ad
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
.\" Local variables:
.\" eval: (add-hook 'write-file-hooks 'time-stamp)
.\" time-stamp-start: ".TH [A-Z_][A-Z0-9_.\\-]* [0-9] \""
.\" time-stamp-format: "%:B %:d, %:y"
.\" time-stamp-end: "\""
.\" time-stamp-line-limit: 20
.\" end:

Return to:

Send suggestions and report system problems to the System administrator.