3 ### Adverbial modifier conferring AUTHINFO GENERIC support on NNTP clients
5 ### (c) 2016 Mark Wooding
8 ###----- Licensing notice ---------------------------------------------------
10 ### This program is free software; you can redistribute it and/or modify
11 ### it under the terms of the GNU General Public License as published by
12 ### the Free Software Foundation; either version 2 of the License, or
13 ### (at your option) any later version.
15 ### This program is distributed in the hope that it will be useful,
16 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ### GNU General Public License for more details.
20 ### You should have received a copy of the GNU General Public License
21 ### along with this program; if not, write to the Free Software Foundation,
22 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 my $VERSION = "0.1.0~unfinished";
32 ###--------------------------------------------------------------------------
35 ## Included batteries.
38 use Getopt::Long qw(:config gnu_compat bundling
39 require_order no_getopt_compat);
40 use POSIX qw(:errno_h :fcntl_h :sys_wait_h);
41 use Socket qw(/^[AP]F_/ /^SOCK_/ /^sockaddr_/
42 getaddrinfo /^AI_/ /^EAI_/
46 ## External batteries.
49 ###--------------------------------------------------------------------------
50 ### Configuration variables.
52 ## The global configuration.
57 ## The per-server configuration.
59 my %SPARAM = map { $_ => 1 }
60 "local", "nntpauth", "remote", "sshbind", "via";
62 ## Various facts we might discover.
63 my $HOME = $ENV{"HOME"};
64 (my $PROG = $0) =~ s:^.*/::;
70 ## Other bits of useful state.
76 my $CLIENTKID = undef;
78 ###--------------------------------------------------------------------------
85 print STDERR "$PROG: $msg\n";
107 print STDERR "$PROG: ;; $msg\n" if $VERBOSE;
118 defined $HOME or fail "no home directory set";
122 sub ensure_dir_exists ($$) {
123 my ($dir, $mode) = @_;
124 mkdir $dir, $mode or $! == EEXIST or
125 sysfail "failed to create directory `$dir': $!";
133 unless (opendir $d, $f) {
134 moan "failed to open directory `$d': $!";
138 defined (my $b = readdir $d) or last ENTRY;
139 next ENTRY if grep { $b eq $_ } ".", "..";
143 rmdir $f or $! == ENOENT or moan "failed to zap directory `$f': $!";
145 unlink $f or $! == ENOENT or moan "failed to zap file thing `$f': $!";
149 sub set_cloexec ($) {
151 my $f = fcntl $fh, F_GETFD, 0 or sysfail "failed to get per-fd flags: $!";
152 fcntl $fh, F_SETFD, $f | FD_CLOEXEC or
153 sysfail "failed to set close-on-exec: $!";
158 my $l = new File::FcntlLock;
159 $l->lock($f, F_GETLK) or sysfail "couldn't read locking for `$f': $!";
160 return $l->l_type != F_UNLCK;
166 if (defined $kid && !$kid) { $INKIDP = 1; }
171 sub sequence () { return $SEQ++; }
173 ###--------------------------------------------------------------------------
174 ### Setting up the configuration.
176 sub set_global_param ($$) {
177 my ($param, $value) = @_;
178 exists $C{$param} or fail "unknown global parameter `$param'";
182 sub notice_server ($$) {
183 my ($server, $where) = @_;
184 inform "found server `$server' $where";
188 sub set_server_param ($$$) {
189 my ($server, $param, $value) = @_;
190 $S{$server} or bad "unknown server `$param'";
191 $SPARAM{$param} or bad "unknown server parameter `$param'";
192 $S{$server}{$param} = $value;
195 sub chew_cli_server_configs (\@) {
200 last ARG unless @$args;
201 my $arg = shift @$args;
202 if ($arg eq "+") { last ARG; }
203 elsif ($arg =~ /^\+/) {
204 $server = substr $arg, 1;
205 notice_server $server, "on command line";
207 elsif (!defined $server or $arg !~ /^([^=]+)=(.*)$/)
208 { unshift @$args, $arg; last ARG; }
209 else { set_server_param $server, $1, $2; }
213 sub parse_config_file () {
215 ## If we already know what we're doing then forbid a configuration file as
218 return unless defined $CONF;
219 fail "servers defined on command-line; won't read config file too";
222 ## Search about to find a suitable configuration file.
225 ($ENV{"XDG_CONFIG_HOME"} // ensure_home . "/.config",
226 split /:/, $ENV{"XDG_CONFIG_DIRS"} // "/etc/xdg");
227 inform "searching for a configuration file with tag `$TAG'...";
228 PATH: for my $dir (@confpath) {
229 for my $base ($TAG, "\@default") {
230 my $f = "$dir/with-authinfo-kludge/$base.conf";
231 if (open $cf, "<", $f) {
232 inform " found `$f'; search over";
233 $CONF = $f; last PATH;
234 } elsif ($! != ENOENT) {
235 bad "couldn't open `$f' for reading: $!";
237 inform " `$f' not found; search continues";
242 ## If we still don't have a configuration file then synthesize one from the
243 ## `$NNTPSERVER' variable.
245 my $server = $ENV{"NNTPSERVER"};
246 defined $server or fail "no `NNTPSERVER' defined in the environment";
247 inform "no config file found; synthesizing default";
248 notice_server $server, "in environment";
252 ## Work through the configuration file setting up servers.
253 my $set_param = \&set_global_param;
255 next if /^\s*([#;]|$)/;
256 if (/^\s*\[(.+)\]\s*$/) {
258 if ($head eq "\@GLOBAL") { $set_param = \&set_global_param; }
260 notice_server $head, "in config file";
261 $set_param = sub { set_server_param $head, $_[0], $_[1]; };
263 } elsif (/^([^=]+)=(.*)$/) { $set_param->(trim $1, trim $2); }
264 else { bad "$CONF:$.: couldn't parse configuration file line"; }
266 (!$cf->error and close $cf)
267 or sysfail "error reading configuration file `$CONF': $!";
270 sub format_value ($);
271 sub format_value ($) {
273 if (!defined $value) { return "<undef>"; }
274 elsif (my $r = ref $value) {
276 return "[" . join(", ", map { format_value $_ } @$value) . "]";
277 } elsif ($r eq "HASH") {
279 join(", ", map { format_value $_ . " => " .
280 format_value $value->{$_} } sort keys %$value) .
285 } else { return "`$value'"; }
288 sub inform_param ($$) {
289 my ($param, $value) = @_;
290 inform " $param = " . format_value $value;
293 sub dump_configuration () {
294 inform "Global parameters...";
295 for my $p (sort keys %C) { inform_param $p, $C{$p}; }
297 for my $s (sort keys %S) {
298 inform "Server `$s' parameters...";
299 for my $p (sort keys %{$S{$s}}) { inform_param $p, $S{$s}{$p}; }
303 ###--------------------------------------------------------------------------
304 ### Managing the runtime directory.
306 ### Truly told, this bit is probably the trickiest part of the program.
308 ## How long we allow for a new server directory to be set up.
313 ## Maybe we've done all of this already.
314 defined $RUNDIR and return;
316 ## Find a suitable place to put things.
318 inform "searching for a suitable runtime directory...";
320 ## Maybe the user's configured a directory explicitly. (Maybe we still
321 ## have to arrange for this to exist.)
322 if (defined ($RUNDIR = $C{"rundir"})) {
323 inform "using runtime directory from configuration";
327 ## First attempt: use `$XDG_RUNTIME_DIR'.
328 if (defined (my $runhome = $ENV{"XDG_RUNTIME_DIR"})) {
329 inform "setting runtime directory from `XDG_RUNTIME_DIR'";
330 $RUNDIR = "$runhome/with-authinfo-kludge";
334 ## Second attempt: let's use /tmp, or whatever `$TMPDIR' is set.
335 my $tmpdir = $ENV{"TMPDIR"} // "/tmp";
336 inform "investigating putting runtime directory under tmpdir `$tmpdir'";
337 my $dir = "$tmpdir/with-authinfo-kludge-$>";
339 if (!$st && $! == ENOENT) {
340 mkdir $dir, 0700 or sysfail "failed to create directory `$dir': $!";
342 inform "created `$dir'";
344 if (!-d $st) { inform "alas, `$dir' isn't a directory"; }
345 elsif ($st->uid != $>) { inform "alas, we don't own `$dir'"; }
346 elsif ($st->mode & 0077) { inform "alas, `$dir' has liberal perms"; }
348 inform "accepting `$dir' as runtime directory";
353 ## Third attempt: we'll use the XDG cache directory.
354 my $cachehome = $ENV{"XDG_CACHE_HOME"} // ensure_home . "/.cache";
355 ensure_dir_exists $cachehome, 0777;
357 $RUNDIR = "$cachehome/with-authinfo-kludge.$host";
358 inform "last ditch: using `$RUNDIR' as runtime directory";
361 ## Make the runtime directory if it doesn't exist. Be paranoid here; users
362 ## can override if they really want. (Note that noip(1) is untweakably
363 ## picky about its socket directories, so this is less generous than it
365 ensure_dir_exists $RUNDIR, 0700;
366 for my $d ("junk", "new") { ensure_dir_exists "$RUNDIR/$d", 0777; }
369 sub junk_rundir_thing ($$) {
371 inform "junking $what `$f'";
373 ## Find a name to rename it to under the `junk' directory. Anyone can put
374 ## things in the `junk' directory, and anyone is allowed to delete them;
375 ## the only tricky bit is making sure the names don't collide.
378 my $r = int rand 1000000;
379 $junk = "$RUNDIR/junk/j.$r";
381 ## It'll be OK if this fails because someone else has junked the file (in
382 ## which case we end happy), or if the target exists (in which case we
383 ## pick another and try again).
384 if (rename $f, $junk or ($! == ENOENT && !-e $f)) { last NAME; }
385 elsif ($! != EEXIST) { sysfail "couldn't rename `$f' to `$junk': $!"; }
391 sub clean_up_rundir () {
392 inform "cleaning up stale things from runtime directory";
394 ## Work through the things in the directory, making sure they're meant to
396 opendir my $dh, $RUNDIR or
397 sysfail "failed to open directory `$RUNDIR': $!";
399 defined (my $base = readdir $dh) or last ENTRY;
400 next ENTRY if grep { $base eq $_ } ".", "..";
401 my $f = "$RUNDIR/$base";
403 ## If this thing isn't a directory then it shouldn't be there. Maybe a
404 ## later version of us put it there.
406 inform "found unexpected thing `$f' in runtime directory";
410 ## Maybe it's a standard thing that's meant to be here. We'll clean
412 next ENTRY if grep { $base eq $_ } "junk", "new";
414 ## If the name doesn't have a `.' in it, then it's some other special
415 ## thing which we don't understand.
416 if ($base !~ /^s.*\.\d+/) {
417 inform "found unexpected special directory `$f' in runtime directory";
421 ## Otherwise, it's a session directory. If its lockfile isn't locked
422 ## then it's fair game.
424 if (open my $fh, "<", $lk) {
425 my $ownedp = lockedp $fh;
426 close $fh or sysfail "couldn't close file, what's up with that?: $!";
427 if (!$ownedp) { junk_rundir_thing $f, "stale session dir"; }
428 } elsif ($! == ENOENT) {
429 junk_rundir_thing $f, "session dir without `lock' file";
431 moan "couldn't open `$lk' (found in runtime dir) for reading: $!";
432 inform "leaving `$f' alone";
437 ## Work through the things in the `new' directory.
438 my $thresh = time - $BIRTHTIME;
439 my $newdir = "$RUNDIR/new";
440 opendir $dh, $newdir or
441 sysfail "failed to open directory `$newdir': $!";
443 defined (my $base = readdir $dh) or last NEW;
444 next NEW if grep { $base eq $_ } ".", "..";
445 my $f = "$newdir/$base";
447 inform "found unexepected nondirectory thing `$f' in nursery";
450 if ($base !~ /^n\.(\d+)\./) {
451 inform "found directory with unexpected name `$f' in nursery";
455 $stamp >= $thresh or junk_rundir_thing $f, "stillborn session directory";
459 ## Work through the things in the `junk' directory. Anyone can put things
460 ## in the `junk' directory, and anyone is allowed to delete them.
461 ## Therefore we can just zap everything in here. The `zap' function is
462 ## (somewhat) careful not to screw up if someone else is also zapping the
464 my $junkdir = "$RUNDIR/junk";
465 opendir $dh, $junkdir or
466 sysfail "failed to open directory `$junkdir': $!";
468 defined (my $base = readdir $dh) or last NEW;
469 next NEW if grep { $base eq $_ } ".", "..";
470 my $f = "$junkdir/$base";
476 sub make_session_dir () {
477 inform "making session directory for `$TAG'";
479 ## Make a new directory in the nursery. Only the creator of a nursery
480 ## directory is allowed to put things in it.
481 my $newdir = "$RUNDIR/new";
485 my $r = int rand 1000000;
486 $n = "$newdir/n.$now.$$.$r";
487 if (mkdir $n, 0777) { last NAME; }
488 elsif ($! != EEXIST) { sysfail "failed to create `$n': $!"; }
491 ## Create the lockfile, and take out a lock.
492 open my $fh, ">", "$n/lock";
494 my $l = File::FcntlLock->new(l_type => F_WRLCK,
495 l_whence => SEEK_SET,
498 $l->lock($fh, F_SETLK) or sysfail "failed to lock `$n/lock: $!";
500 ## Rename the directory into its proper place. We have already cleaned out
501 ## stale directories, and the target name has our PID in it, so it can't
502 ## exist any more unless something unfortunate has happened.
503 $SESSDIR = "$RUNDIR/s.$TAG.$$";
504 rename $n, $SESSDIR or sysfail "failed to rename `$n' to `$SESSDIR': $!";
506 ## Create some necessary things.
507 ensure_dir_exists "$SESSDIR/noip-client", 0700;
511 zap junk_rundir_thing $SESSDIR, "cleanup on exit"
512 if !$INKIDP && defined $SESSDIR;
515 ###--------------------------------------------------------------------------
516 ### Setting up a session.
518 sub parse_address ($;$) {
519 my ($addr, $defport) = @_;
520 inform "parsing address `$addr'...";
523 if ($addr =~ /^\[([^]]*)\]:(\d+)$/ || $addr =~ /^([^:]+):(\d+)$/)
524 { $host = $1; $port = $2; }
525 elsif (defined $defport) { $host = $addr; $port = $defport; }
526 else { fail "invalid address `$addr': missing port number"; }
527 inform " host = `$host'; port = $port";
528 return ($host, $port);
531 sub format_address ($$) {
532 my ($host, $port) = @_;
533 $host =~ /:/ and $host = "[$host]";
534 return "$host:$port";
537 sub canonify_address ($;$) {
538 my ($addr, $defport) = @_;
539 my ($host, $port) = parse_address $addr, $defport;
540 return format_address $host, $port;
543 sub resolve_parsed_address ($$) {
544 my ($host, $port) = @_;
545 inform "resolving host `$host', port $port";
547 my ($err, @a) = getaddrinfo $host, $port, { flags => AI_NUMERICSERV };
548 $err and fail "failed to resolve `$host': $err";
553 ($err, $host, $port) =
554 getnameinfo $a->{addr}, NI_NUMERICHOST | NI_NUMERICSERV;
555 $err and sysfail "unexpectedly failed to convert addr to text: $err";
556 inform " resolved to $host $port";
557 my $r = format_address $host, $port;
558 unless ($seen{$r}) { push @res, $r; $seen{$r} = 1; }
564 sub resolve_address ($;$) {
565 my ($addr, $defport) = @_;
566 my ($host, $port) = parse_address $addr, $defport;
567 return resolve_parsed_address $host, $port;
570 sub fix_server_config ($) {
574 ## Keep the name. This is useful for diagnostics, but it's also important
575 ## for finding the right socket directory if we're doing SSH forwarding.
576 $s->{"_name"} = $server;
578 ## Sort out the various addresses.
580 ($host, $port) = parse_address($s->{"local"} // $server, 119);
581 $s->{"local"} = format_address $host, $port;
582 $s->{"_laddrs"} = [resolve_parsed_address $host, $port];
583 $s->{"remote"} = canonify_address($s->{"remote"} // $server, 119);
584 ($host, $port) = parse_address($s->{"sshbind"} // "127.1.0.1", 1119);
585 $s->{"sshbind"} = format_address $host, $port;
586 $s->{"_sshaddrs"} = [resolve_parsed_address $host, $port];
588 ## Initialize other settings.
589 $s->{"_proxy_noip"} = undef;
590 $s->{"_proxy_sockdir"} = undef;
591 $s->{"_proxy_server"} = defined $s->{"via"} ?
592 $s->{"sshbind"} : $s->{"remote"};
593 $s->{"_proxy_server"} =~ s/:119$//;
594 $s->{"_proxy_server"} =~ s/^\[(.*)\]$/$1/;
595 $s->{"_sshkid"} = undef;
596 $s->{"_ssh_master"} = undef;
599 sub hack_noip_envvar ($$) {
600 my ($var, $val) = @_;
601 inform " hack env for noip: $var = `$val'";
605 sub hack_noip_env ($$) {
606 my ($vars, $dir) = @_;
609 hack_noip_envvar "LD_PRELOAD",
611 (exists $ENV{"LD_PRELOAD"} ? ":" . $ENV{"LD_PRELOAD"} : "");
612 for my $k (keys %ENV) { delete $ENV{$k} if $k =~ /^NOIP_/; }
613 hack_noip_envvar "NOIP_CONFIG", "$RUNDIR/noip.conf.notexist";
614 hack_noip_envvar "NOIP_SOCKETDIR", $dir;
615 hack_noip_envvar "NOIP_DEBUG", $VERBOSE;
616 for my $acl ("REALBIND", "REALCONNECT") {
617 hack_noip_envvar "NOIP_$acl",
618 join ",", @{$vars->{$acl} // []}, "+any";
622 sub server_listen ($) {
626 ## Set up the listening sockets for this server's addresses.
627 inform "set up sockets for `$server'";
628 for my $a (@{$s->{"_laddrs"}}) {
629 socket my $sk, PF_UNIX, SOCK_STREAM, 0
630 or sysfail "failed to make Unix-domain socket: $!";
632 my $sa = "$SESSDIR/noip-client/$a";
633 bind $sk, sockaddr_un $sa
634 or sysfail "failed to bind Unix-domain socket to `$sa': $!";
635 listen $sk, 5 or sysfail "failed to listen on Unix-domain socket: $!";
636 $SERVMAP{fileno $sk} = [$s, $a, $sk];
637 inform " listening on $a";
638 push @{$CLIENT_NOIP{"REALCONNECT"}}, "-$a";
641 ## If we're forwarding via SSH then set that up too.
642 if (defined (my $via = $s->{"via"})) {
643 inform "set up SSH tunnel to `$server' via $via...";
645 my $sockdir = "$SESSDIR/noip-ssh.$server";
646 ensure_dir_exists $sockdir, 0700;
647 my $sshbind = $s->{"sshbind"};
648 my $remote = $s->{"remote"};
649 for my $a (@{$s->{"_sshaddrs"}}) {
650 push @{$ssh_noip{"REALBIND"}}, "-$a";
651 inform " listening on $a";
652 push @{$s->{"_proxy_noip"}{"REALCONNECT"}}, "-$a";
654 $s->{"_proxy_sockdir"} = $sockdir;
656 ## This is quite awful. The `-L' option sets up the tunnel that we
657 ## actually wanted. The `-v' makes SSH spew stuff to stdout, which might
658 ## be useful if you're debugging. The `-S' has two effects: firstly, it
659 ## detaches OpenSSH from any other control master things which might be
660 ## going on, because they tend to interfere with forwarding (and,
661 ## besides, the existing master won't be under the same noip
662 ## configuration); and, secondly, it causes OpenSSH to make a socket in a
663 ## place we know, so we can tell when it's actually ready. The `cat'
664 ## will keep the tunnel open until we close our end, which we don't do
666 inform " starting SSH tunnel";
667 my @sshargs = ("ssh", "-L$sshbind:$remote");
668 $VERBOSE and push @sshargs, "-v";
669 my $master = "$SESSDIR/ssh-master." . sequence;
670 push @sshargs, "-S$master", "-M";
671 $s->{"_ssh_master"} = $master;
672 push @sshargs, $via, "cat";
673 pipe my $rfd, my $wfd or sysfail "failed to create pipe: $!";
675 defined (my $kid = myfork) or sysfail "failed to fork: $!";
677 open STDIN, "<&", $rfd or sysfail "failed to dup pipe to stdin: $!";
678 open STDOUT, ">", "/dev/null"
679 or sysfail "failed to redirect stdout to /dev/null: $!";
680 hack_noip_env \%ssh_noip, $sockdir;
681 exec @sshargs or sysfail "failed to exec SSH: $!";
684 $s->{"_sshkid"} = $kid;
685 $s->{"_ssh_pipe"} = $wfd;
686 $KIDMAP{$kid} = [$s, "SSH tunnel"];
690 sub wait_for_ssh () {
691 inform "waiting for SSH tunnels to start...";
698 KID: for my $kid (keys %KIDMAP) {
699 my ($s, $what) = @{$KIDMAP{$kid}};
700 next KID unless $kid == $s->{"_sshkid"};
701 if (-S $s->{"_ssh_master"}) {
702 inform " found socket from `$s->{_name}'";
704 inform " no socket yet from `$s->{_name}'";
709 inform " all present and correct!";
713 inform " bored now; giving up";
716 inform "waiting ${delay}s for stuff to happen...";
717 select undef, undef, undef, $delay;
724 defined (my $kid = waitpid -1, WNOHANG)
725 or sysfail "failed to reap child: $!";
726 last KID if $kid <= 0;
729 $how = "exited successfully";
731 } elsif ($? & 0xff) {
733 $how = "killed by signal $sig";
734 $how .= " (core dumped)" if $? & 0x80;
738 $how = "exited with status $rc";
740 if ($kid == $CLIENTKID) {
741 inform "client kid $how; shutting down";
743 } elsif (exists $KIDMAP{$kid}) {
744 my ($s, $what) = @{$KIDMAP{$kid}};
745 inform "$what for server `$s->{_name}' collapsed ($how)";
746 delete $KIDMAP{$kid};
748 inform "unrecognized child $kid $how";
756 inform "starting client";
757 defined (my $kid = myfork) or sysfail "failed to fork: $!";
759 hack_noip_env \%CLIENT_NOIP, "$SESSDIR/noip-client";
761 exec @args or sysfail "failed to exec `$prog': $!";
768 for my $fd (keys %SERVMAP) { vec($rfd_in, $fd, 1) = 1; }
770 my ($n, $t) = select my $rfd_out = $rfd_in, undef, undef, undef;
772 elsif ($! == EINTR) { next SELECT; }
773 else { sysfail "select failed: $!"; }
774 FD: for my $fd (keys %SERVMAP) {
775 next FD unless vec $rfd_out, $fd, 1;
776 my ($s, $a, $sk) = @{$SERVMAP{$fd}};
778 unless (accept $nsk, $sk) {
779 moan "failed to accept new connection: $!";
783 inform "incoming connection `$s->{_name}' to $a; starting proxy...";
784 defined (my $kid = myfork) or sysfail "failed to fork: $!";
786 $ENV{"NNTPAUTH"} = $s->{"nntpauth"} if exists $s->{"nntpauth"};
787 hack_noip_env $s->{"_proxy_noip"}, $s->{"_proxy_sockdir"};
788 open STDIN, "<&", $nsk
789 or sysfail "failed to dup socket to kid stdin: $!";
790 open STDOUT, ">&", $nsk
791 or sysfail "failed to dup socket to kid stdin: $!";
792 inform "running proxy to `$s->{_proxy_server}'";
793 exec "authinfo-kludge", $s->{"_proxy_server"}
794 or sysfail "failed to exec `authinfo-kludge': $!";
796 $KIDMAP{$kid} = [$s, "proxy"];
801 ###--------------------------------------------------------------------------
806 print $fh "$PROG, version $VERSION\n";
812 usage: $PROG [-v] [-d DIR] [-f CONF] [-t TAG]
813 [ [+SERVER] [PARAM=VALUE ...] ...] [+]
824 Command-line options:
825 -h, --help Show this help text.
826 -d, --rundir=DIR Use DIR to store runtime state.
827 -f, --config=FILE Read configuration from FILE.
828 -t, --tag=TAG Use TAG to identify this session.
829 -v, --verbose Emit running commentary to stderr.
831 Server parameter summary:
832 local=ADDRESS Listen on ADDRESS for client connections.
833 nntpauth=AUTH-METHOD Set authentication method and arguments.
834 remote=ADDRESS Connect to server at ADDRESS.
835 sshbind=ADDRESS Use ADDRESS for local SSH tunnel endpoint.
836 via=SSH-HOST Use SSH to connect to remote server.
838 See the manual page for full details.
844 "h|help" => sub { help; exit 0; },
845 "version" => sub { version *STDOUT; exit 0; },
846 "d|rundir=s" => \$RUNDIR,
847 "f|config=s" => \$CONF,
849 "v|verbose" => \$VERBOSE
851 chew_cli_server_configs @ARGV;
853 (my $cmd = $ARGV[0]) =~ s:^.*/::;
858 if ($BAD) { usage *STDERR; exit 1; }
860 for my $server (keys %S) { fix_server_config $server; }
861 dump_configuration if $VERBOSE;
865 for my $server (keys %S) { server_listen $server; }
873 ###----- That's all, folks --------------------------------------------------