From: ian Date: Sun, 10 Dec 2000 22:03:40 +0000 (+0000) Subject: @@ -2,6 +2,8 @@ X-Git-Tag: mergepoint-1-2000-12-10-udptunnelconf~10 X-Git-Url: https://git.distorted.org.uk/~mdw/userv-utils/commitdiff_plain/2dba6494a0d65e88363b45056ae7503476d03f22 @@ -2,6 +2,8 @@ * service.c (userv ipif) /32 prefixes work properly now. + * udptunnelconf directory, embryonic + -- userv-utils (0.2.0) unstable; urgency=low --- diff --git a/changelog b/changelog index b834e3d..a7f5c32 100644 --- a/changelog +++ b/changelog @@ -2,6 +2,8 @@ userv-utils (0.2.1) unstable; urgency=low * service.c (userv ipif) /32 prefixes work properly now. + * udptunnelconf directory, embryonic + -- userv-utils (0.2.0) unstable; urgency=low diff --git a/ipif/udptunnel-reconf.pl b/ipif/udptunnel-reconf.pl new file mode 100755 index 0000000..383b553 --- /dev/null +++ b/ipif/udptunnel-reconf.pl @@ -0,0 +1,60 @@ +#!/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 []\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= ; + $/= "\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 $!; diff --git a/ipif/udptunnel-vpn-config.m4 b/ipif/udptunnel-vpn-config.m4 new file mode 100644 index 0000000..7092265 --- /dev/null +++ b/ipif/udptunnel-vpn-config.m4 @@ -0,0 +1,52 @@ +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) diff --git a/ipif/udptunnel-vpn-defaults b/ipif/udptunnel-vpn-defaults new file mode 100644 index 0000000..93427c9 --- /dev/null +++ b/ipif/udptunnel-vpn-defaults @@ -0,0 +1,41 @@ +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 + ])