* service.c (userv ipif) /32 prefixes work properly now.
+ * udptunnelconf directory, embryonic
+
--
userv-utils (0.2.0) unstable; urgency=low
* service.c (userv ipif) /32 prefixes work properly now.
+ * udptunnelconf directory, embryonic
+
--
userv-utils (0.2.0) unstable; urgency=low
--- /dev/null
+#!/usr/bin/perl
+
+#$sharedir= '/usr/local/share/userv/udptunnelconf';
+$sharedir= '/home/ian/things/userv-utils/udptunnelconf';
+$confdir= '/etc/udptunnel';
+
+sub badusage () { die "usage: udptunnel-reconf [<directory>]\n"; }
+$debug=0;
+
+while ($ARGV[0] =~ m/^-/) {
+ $_= shift @ARGV;
+ last if m/^--$/;
+ if (m/^-d$/) { $debug++; next; }
+ badusage();
+}
+
+if (@ARGV) { $confdir= shift @ARGV; }
+#badusage() if @ARGV;
+
+chdir $confdir or die "$0: $confdir: $!\n";
+
+sub run_m4 ($$$) {
+ my ($wanted, $site, $variable) = @_;
+ $x= "m4 -P -DWANTED=$wanted -DWHVARIABLE=V_$variable -DV_global=global ".
+ "-DV_site=$site ".
+ "-DV_defaults=$sharedir/defaults $sharedir/config.m4";
+ print STDERR $x,"\n" if $debug>=2;
+ open X, "$x |"
+ or die $!;
+ undef $/;
+ $m4out= <X>;
+ $/= "\n";
+ close X; $? and exit -1;
+ $m4out =~ s/^\s+//;
+ $m4out =~ s/\n+/\n/g;
+ $m4out =~ s/\s+$//;
+ print STDERR "$wanted/$variable($site) -> \`$m4out'\n" if $debug>=1;
+ return $m4out;
+}
+
+sub check_junk ($$) {
+ my ($emsg, $site) = @_;
+ $j= run_m4('JUNK',$site,'');
+ $j =~ s/^\# //g;
+ die "$0: $emsg: $j\n" if length $j;
+}
+
+check_junk("error in config",'');
+
+@actives= split /\s+/, run_m4('ACTIVES','','');
+@passives= split /\s+/, run_m4('PASSIVES','','');
+
+foreach $site (@actives, @passives) {
+ check_junk("error in config for site $site",$site);
+}
+
+$_= run_m4('VARIABLE','greenend','command');
+s/\\\n/ /g;
+s/\s+/\n/g;
+print $_,"\n" or die $!;
--- /dev/null
+m4_define(V_JUNK,1)m4_divert(V_JUNK)
+m4_define(V_VARIABLE,2)
+m4_define(V_ACTIVES,3)
+m4_define(V_PASSIVES,4)
+m4_changequote([,])
+
+m4_define(V_WARGS, [
+ m4_define([$1], [m4_ifelse($][#,$2,[$3],
+ [# ]m4___file__:m4___line__[: wrong number of args to $1])])])
+
+V_WARGS([SET], 2, [V_SET([V_$1], [$2])])
+m4_define(V_YES, [m4_define([V_SET],[m4_define($][@)])])
+m4_define(V_NO, [m4_define([V_SET], [])])
+
+m4_define(V_ACTPA, [
+ V_WARGS($1, 1, [m4_divert(V_$1S)$][1 m4_dnl
+ m4_divert(V_JUNK)m4_ifelse($][1,V_site,
+ [V_YES],
+ [V_NO]
+)])])
+
+m4_dnl V_WARGS(, 2, [m4_divert(V_PASSIVES)$1 m4_dnl
+m4_dnl m4_divert(V_JUNK)m4_ifelse([$1],V_site, [$2])])
+
+m4_divert(V_JUNK)
+
+V_YES
+m4_include(V_defaults)
+m4_include(V_global)
+
+V_WARGS(SITE, 1, [m4_ifelse([$1],V_site, [V_YES], [V_NO])])
+V_YES
+m4_include(V_sites)
+m4_undefine([SITE])
+
+V_ACTPA(ACTIVE)
+V_ACTPA(PASSIVE)
+V_YES
+m4_include(V_tunnels)
+
+m4_divert(V_VARIABLE)
+WHVARIABLE
+m4_divert(V_JUNK)
+
+m4_define(V_WANTED, V_[]WANTED)
+m4_divert(0)
+m4_undivert(V_WANTED)
+m4_divert(-1)
+m4_undivert(V_JUNK)
+m4_undivert(V_ACTIVES)
+m4_undivert(V_PASSIVES)
+m4_undivert(V_VARIABLE)
--- /dev/null
+SET( lcommand, [udptunnel])
+SET( crypto, [-e nonce -e timestamp/10/30 -e pkcs5/8 \
+ -e blowfish-cbcmac/128 -e blowfish-cbc/128])
+
+SET( lpublic, [`hostname`])
+SET( lport, [Any])
+m4_dnl rpublic -- usually set in sites
+SET( rport, [Command])
+m4_dnl lend -- usually set in global
+m4_dnl rend -- usually set in sites
+SET( mtu, [1000])
+SET( proto, [cslip])
+SET( to_poll, [30])
+SET( to_quit, [130])
+SET( to_report, [1800])
+SET( timeouts, [V_to_poll,V_to_quit,V_to_report])
+SET( lnets, [-])m4_dnl often overridden in global
+SET( rnets, [-])m4_dnl often overridden in sites
+
+SET( rcommandprefix, [])
+SET( rcommand, [V_rcommandprefix udptunnel])
+
+SET( sshopts, [-o 'ForwardAgent no' -o 'ForwardX11 no' \
+ -o 'BatchMode yes' -o 'ProtocolKeepAlives 300'])
+SET( ssh, [ssh -v V_sshopts])
+SET( sshdest, [V_rpublic])
+
+SET( sites, [sites])
+SET( tunnels, [tunnels])
+
+m4_dnl lgroup -- usually set in global
+
+SET( command, [ \
+ V_lcommand \
+ V_crypto \
+ V_lpublic,V_lport V_rpublic,V_rport \
+ V_lend,V_rend,V_mtu,V_proto \
+ V_timeouts \
+ V_rnets V_lnets \
+ V_ssh V_ruser@V_sshdest V_rcommand
+ ])