tunneldigger-0.10/0000755000175000017500000000000010033741436013454 5ustar kaikai00000000000000tunneldigger-0.10/lib/0000755000175000017500000000000010033741437014223 5ustar kaikai00000000000000tunneldigger-0.10/lib/CA.global0000644000175000017500000000035107770401173015673 0ustar kaikai00000000000000# per-CA global OpenVPN config comp-lzo dev-node /dev/net/tun dh /usr/share/doc/openvpn/examples/sample-keys/dh1024.pem mlock mtu-disc yes no-replay persist-key persist-local-ip persist-remote-ip persist-tun ping 60 ping-restart 300 tunneldigger-0.10/lib/thisuser.pl0000755000175000017500000000176707770362472016460 0ustar kaikai00000000000000#! /usr/bin/perl -w # thisuser.pl - get email address for current user # # Copyright (C) 2003 Kai Henningsen # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use strict; my @data = getpwuid($<); my @name = split /,/, $data[6]; my $host = `hostname -f`; chomp $host; print "$name[0] <$data[0]\@$host>\n"; tunneldigger-0.10/lib/confgen.pl0000755000175000017500000000511010033741351016172 0ustar kaikai00000000000000#! /usr/bin/perl -w # confgen.pl - parses per-link data into config files # # Copyright (C) 2003 Kai Henningsen # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use strict; use Data::Dumper; $Data::Dumper::Useqq = 1; our (%ep1, %ep2); require $ARGV[1]; my ($a1, $p1, $a2, $p2) = ($ep1{eadr}, $ep1{eport}, $ep2{eadr}, $ep2{eport}); my ($ad1, $ad2, $pd1, $pd2); if ($a1 =~ m/(.*)\/dyn$/) { $ad1 = 1; $a1 = $1; } elsif ($a1 eq 'dyn') { $ad1 = 1; $a1 = ''; } if ($p1 eq 'dyn') { $pd1 = 1; $p1 = ''; } if ($a2 =~ m/(.*)\/dyn$/) { $ad2 = 1; $a2 = $1; } elsif ($a2 eq 'dyn') { $ad2 = 1; $a2 = ''; } if ($p2 eq 'dyn') { $pd2 = 1; $p2 = ''; } my $cf = $ARGV[0]; my $cft = $cf.'.tmp'; open CONF, '>', $cft or die "$cft: $!"; print CONF "config \"/etc/openvpn/$ARGV[0].local\"\n"; print CONF "config \"/etc/openvpn/$ARGV[2].global\"\n"; print CONF "ca $ARGV[2].crt\n"; print CONF "cert $ep1{name}.crt\n"; print CONF "daemon \"openvpn-$ep2{name}\"\n"; print CONF "dev $ep1{dev}\n" if $ep1{dev}; print CONF "float\n" if $ad2 or $pd2; print CONF "ifconfig $ep1{iadr}[0] $ep2{iadr}[0]\n" if @{$ep1{iadr}} and @{$ep2{iadr}}; print CONF "key $ep1{name}.key\n"; print CONF "local $a1\n" unless $ad1; print CONF "lport $p1\n" if $p1; #print CONF "nobind\n" if $ad1; print CONF "remote $a2\n" if $a2; print CONF "replay-persist $cf.persist\n"; print CONF "rport $p2\n" if $p2; #print CONF "single-session\n" unless $ad2 or $pd2; print CONF "tls-client\n" if $ep1{tls} eq 'C'; print CONF "tls-server\n" if $ep1{tls} eq 'S'; print CONF "tls-verify \"/usr/share/openvpn/verify-cn $ep2{name}\"\n"; print CONF "up \"/usr/lib/tunneldigger/td-up $ep2{name} '", join(' ', @{$ep1{iadr}}), "' '", join(' ', @{$ep2{nets}}), "'\"\n"; print CONF "hand-window 600\n"; close CONF or die "$cft: $!"; &move_if_changed($cft, $cf); sub move_if_changed { my ($tmp, $fin) = @_; system("cmp -s $tmp $fin || mv -v $tmp $fin"); unlink $tmp; } tunneldigger-0.10/lib/keygen.sh0000755000175000017500000000405307770377267016072 0ustar kaikai00000000000000#! /bin/bash # keygen.sh - generate CA and/or host keys # # Copyright (C) 2000-2002 Tommi Virtanen # Copyright (C) 2003 Kai Henningsen # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA umask 077 cfg=$1 shift if [ -z "$cfg" ] then echo "Need a cfg template" exit 1 fi caname=$1 shift if [ -z "$caname" ] then echo "Need a CA name" exit 1 fi casafename=` echo -n $caname | tr -c 0-9a-zA-Z. _ ` name=$1 shift if [ -z "$name" ] then echo "Need a host name" exit 1 fi safename=` echo -n $name | tr -c 0-9a-zA-Z _ ` ca=keys/ca mkdir -p $ca chmod 755 $ca [ -e $ca/index.txt ] || touch $ca/index.txt [ -e $ca/serial ] || echo 01 > $ca/serial cakey=$ca/$casafename.key cacert=$ca/$casafename.crt req_name="$caname" export req_name ca [ -e $cakey -a -e $cacert ] || openssl req -days 3650 -nodes -new -x509 -keyout $cakey -out $cacert -config $cfg chmod 644 $cacert hostkeydir=keys/host mkdir -p $hostkeydir chmod 700 $hostkeydir if [ "$name" == "CA only" ] then exit fi key=$hostkeydir/$safename.key csr=$hostkeydir/$safename.csr req_name="$name" [ -e $key -a -e $csr ] || openssl req -days 3650 -nodes -new -keyout $key -out $csr -config $cfg crt=$hostkeydir/$safename.crt [ -e $csr -a ! -e crt ] && openssl ca -batch -days 3650 -name CA_default -in $csr -out $crt -cert $cacert -keyfile $cakey -md sha1 -policy policy_match -outdir $ca -config $cfg tunneldigger-0.10/lib/makedeb0000755000175000017500000000406107770423776015563 0ustar kaikai00000000000000#! /bin/bash -e # makedeb - create a Debian archive to contain a number of config files # # Copyright (C) 2003 Kai Henningsen # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA umask 077 ca="$1" shift maint="$1" shift deb=$1 shift name=$( basename $deb .deb ) date=$( find "$@" -type f -printf "%TY-%Tm-%Td %TH:%TM:%TS\n" | env - sort | tail -n 1 ) date1=$( echo $date | tr -- " :" "--" ) date2=$( date -R -d "$date" ) rm -rf tmp mkdir -p tmp tmp/openvpn tmp/debian cp -a "$@" tmp/openvpn ( : enter build dir; cd tmp cat > debian/changelog < debian/compat < debian/control < debian/rules < # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA LIB := /usr/lib/tunneldigger ################################################ # # # You should only need to configure this part: # # # ################################################ CANAME = $(shell hostname -f ) MAINT = $(shell $(LIB)/thisuser.pl) ################################################ WORK := $(shell pwd) KEYS := $(WORK)/keys PATH := $(LIB):/usr/local/bin:/usr/bin:/bin HK = $(KEYS)/host CA = $(KEYS)/ca all: confess make.deps _OUTPUTS_ confess: @echo "CANAME='$(CANAME)' MAINT='$(MAINT)'" make.deps: config *.alloc $(LIB)/parseconfig.pl config . # dummy to get us started *.alloc: touch empty.alloc include make.deps %.conf: %.link $(LIB)/confgen.pl $@ $^ $(CANAME) %.conf.local: $(LIB)/LINK.local cp -avi $^ $@ $(CA)/$(CANAME).crt: $(LIB)/openssl.cnf $(LIB)/keygen.sh $^ "$(CANAME)" "CA only" $(CANAME).global: $(LIB)/CA.global cp -avi $^ $@ $(HK)/%.crt $(HK)/%.key: $(LIB)/openssl.cnf $(LIB)/keygen.sh $^ "$(CANAME)" $* %.deb: $(LIB)/makedeb "$(CANAME)" "$(MAINT)" $@ $^ tunneldigger-0.10/lib/parseconfig.pl0000755000175000017500000001040307770373574017102 0ustar kaikai00000000000000#! /usr/bin/perl -wT # parseconfig.pl - parse TunnelDigger config file into per-link fragments # and create dependencies # # Copyright (C) 2003 Kai Henningsen # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use strict; use Data::Dumper; $Data::Dumper::Useqq = 1; %ENV = (); $ENV{PATH} = "/usr/local/bin:/usr/bin:/bin"; die "usage: $0 configfile workingdir" unless @ARGV == 2; my $cf = shift; my $work = shift; $cf =~ m/(.*)/; $cf = $1; $work =~ m/(.*)/; $work = $1; mkdir $work; chdir $work or die "chdir $work: $!"; open CF, '<', $cf or die "$cf: $!"; my %dependencies; while () { tr/ \t\r\n//d; s/#.*//; next unless /./; my @f = split /;/, $_; die "need 13 fields: " . join(' ', @f) unless @f == 14; my %ep1 = &ep('S', @f[0 ... 6], $f[8]); my %ep2 = &ep('C', @f[7 ... 13], $f[1]); my $linkid = $ep1{name}.'-'.$ep2{name}; my $linkname = $linkid.'.link'; my $linktemp = $linkname . '.tmp'; open LINK, '>', $linktemp or die "$linktemp: $!"; print LINK Data::Dumper->Dump([\%ep1, \%ep2], [qw/ *ep1 *ep2 /]); close LINK or die "$linktemp: $!"; &move_if_changed($linktemp, $linkname); $dependencies{$ep1{name}.'.'.$ep1{sys}}->{$linkid.'.conf'}++; $dependencies{$ep1{name}.'.'.$ep1{sys}}->{$linkid.'.conf.local'}++; $linkid = $ep2{name}.'-'.$ep1{name}; $linkname = $linkid.'.link'; $linktemp = $linkname . '.tmp'; open LINK, '>', $linktemp or die "$linktemp: $!"; print LINK Data::Dumper->Dump([\%ep2, \%ep1], [qw/ *ep1 *ep2 /]); close LINK or die "$linktemp: $!"; &move_if_changed($linktemp, $linkname); $dependencies{$ep2{name}.'.'.$ep2{sys}}->{$linkid.'.conf'}++; $dependencies{$ep2{name}.'.'.$ep2{sys}}->{$linkid.'.conf.local'}++; } my $deps = 'make.deps'; open MAKE, '>', $deps or die "$deps: $!"; print MAKE "#! make\n\n"; for my $o (sort keys %dependencies) { print MAKE join(' ', $o, ':', sort keys %{$dependencies{$o}}), "\n"; } print MAKE "\n"; close MAKE; sub move_if_changed { my ($tmp, $fin) = @_; system("cmp -s $tmp $fin || mv -v $tmp $fin"); unlink $tmp; } sub ep { my ($tls, $sys, $name, $eadr, $eport, $dev, $iadr, $nets, $peer) = @_; ($name) = ($name =~ /^(\w+)$/); $dependencies{'_OUTPUTS_'}->{$name.'.'.$sys}++; $dependencies{$name.'.'.$sys}->{'$(HK)/'.$name.'.key'}++; $dependencies{$name.'.'.$sys}->{'$(HK)/'.$name.'.crt'}++; $dependencies{$name.'.'.$sys}->{'$(CA)/$(CANAME).crt'}++; $dependencies{$name.'.'.$sys}->{'$(CANAME).global'}++; my @iadr = split /,/, $iadr; my @nets = split /,/, $nets; if ($eport =~ m[^alloc/(\w+)$]) { #] my $aname = $name . '-' . $1 . '.alloc'; my ($first, $last, %alloc, %reverse) = (5000, 5999); sub firsttag() { '[first]' } sub lasttag() { '[last]' } if (open ALLOC, '<', $aname) { local $/ = undef; my $alloc = ; close ALLOC or die "$aname: $!"; ($alloc) = ($alloc =~ /^(.*)$/s); my @alloc = eval $alloc; %alloc = @alloc; $first = $alloc{firsttag()}; $last = $alloc{lasttag()}; delete $alloc{firsttag()}; delete $alloc{lasttag()}; %reverse = reverse %alloc; } if (not exists $alloc{$peer} or $alloc{$peer} < $first or $alloc{$peer} > $last) { my $p = $first; $p++ while exists $reverse{$p}; die "$aname: out of free ports" if $p > $last; $alloc{$peer} = $p; $alloc{firsttag()} = $first; $alloc{lasttag()} = $last; open ALLOC, '>', $aname or die "$aname: $!"; print ALLOC Data::Dumper->Dump([\%alloc], [qw/ *alloc /]); close ALLOC or die "$aname: $!"; } $eport = $alloc{$peer}; } return ( tls => $tls, sys => $sys, name => $name, eadr => $eadr, eport => $eport, dev => $dev, iadr => [ @iadr ], nets => [ @nets ], ); } tunneldigger-0.10/lib/openssl.cnf0000644000175000017500000000206307770357540016413 0ustar kaikai00000000000000# openssl.cnf - template config file # # Copyright (C) 2003 Kai Henningsen # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA [req] prompt = no default_bits = 1024 distinguished_name = req_distinguished_name [req_distinguished_name] commonName = $ENV::req_name [CA_default] database = $ENV::ca/index.txt serial = $ENV::ca/serial [policy_match] commonName = supplied tunneldigger-0.10/example/0000755000175000017500000000000007770363311015115 5ustar kaikai00000000000000tunneldigger-0.10/example/config0000644000175000017500000000074407770363265016322 0ustar kaikai00000000000000deb;router;router.dyndns.org/dyn;5101;;10.11.4.98;10.11.0.0/19;deb;home;home.dyndns.org/dyn;5000;;10.11.4.101;10.11.4.100/30 deb;router;router.dyndns.org/dyn;5101;;10.11.4.98;10.11.0.0/19;deb;web;web.company.com;5000;;10.11.8.6;10.11.8.6/32 deb;home;home.dyndns.org/dyn;5005;;10.22.192.2;10.22.192.0/24;deb;colo;colo.my.do.main;5001;;10.22.192.1;10.22.192.0/24 deb;web;web.company.com;alloc/stuff;;10.22.192.2;10.22.192.0/24;deb;colo;colo.my.do.main;5001;;10.22.192.1;10.22.192.0/24 tunneldigger-0.10/COPYING0000644000175000017500000004311006770226140014511 0ustar kaikai00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. tunneldigger-0.10/debian/0000755000175000017500000000000010033741437014677 5ustar kaikai00000000000000tunneldigger-0.10/debian/changelog0000644000175000017500000000414410033741412016545 0ustar kaikai00000000000000tunneldigger (0.10) unstable; urgency=low * adapt to newer OpenVPN * no single-session - doesn't seem to work * add hand-window of 600 (more reasonable than 60) -- Kai Henningsen Sun, 4 Apr 2004 10:10:24 +0200 tunneldigger (0.9) unstable; urgency=low * do not use nobind -- Kai Henningsen Fri, 19 Dec 2003 01:06:23 +0100 tunneldigger (0.8) unstable; urgency=low * really make makedeb not ask * need full path for config includes in confgen.pl -- Kai Henningsen Thu, 18 Dec 2003 23:42:31 +0100 tunneldigger (0.7) unstable; urgency=low * need an additional chmod on the .deb * need to have dev-node defined * can only rename interface while down * need to use new name for ifconfig -- Kai Henningsen Thu, 18 Dec 2003 23:15:09 +0100 tunneldigger (0.6) unstable; urgency=low * make sure keys are only accessible by user (and read-only on final host) -- Kai Henningsen Thu, 18 Dec 2003 20:25:09 +0100 tunneldigger (0.5) unstable; urgency=low * explain how to customize CANAME and MAINT * add path for td-up (confgen.pl) * name daemon after peer, not self (confgen.pl) -- Kai Henningsen Thu, 18 Dec 2003 20:18:19 +0100 tunneldigger (0.4) unstable; urgency=low * don't forget to erase the tmp directory before building a new package in it -- Kai Henningsen Thu, 18 Dec 2003 20:00:07 +0100 tunneldigger (0.3) unstable; urgency=low * need to protet $/ assignment with local in parseconfig.pl * don't ask before overwriting .deb in makedeb * need to alloc ports under peer's name in parseconfig.pl -- Kai Henningsen Thu, 18 Dec 2003 19:52:49 +0100 tunneldigger (0.2) unstable; urgency=low * clear environment in parseconfig.pl * add path to scripts in Makefile -- Kai Henningsen Thu, 18 Dec 2003 19:38:32 +0100 tunneldigger (0.1) unstable; urgency=low * Initial Release. -- Kai Henningsen Thu, 18 Dec 2003 17:04:04 +0100 tunneldigger-0.10/debian/compat0000644000175000017500000000000207770346371016111 0ustar kaikai000000000000004 tunneldigger-0.10/debian/tunneldigger.install0000644000175000017500000000011407770354414020763 0ustar kaikai00000000000000lib/* /usr/lib/tunneldigger example/* /usr/share/doc/tunneldigger/examples tunneldigger-0.10/debian/control0000644000175000017500000000203010033740717016275 0ustar kaikai00000000000000Source: tunneldigger Section: net Priority: optional Maintainer: Kai Henningsen Build-Depends-Indep: debhelper (>= 4.0.0) Standards-Version: 3.6.0 Package: tunneldigger Architecture: all Depends: make, openssl, fakeroot, debhelper, ${perl:Depends} Description: Configures OpenVPN tunnel networks TunnelDigger takes the approach of having a central administration directory somewhere, not necessarily on a host where OpenVPN actually runs. It creates a .deb for every OpenVPN-connected host under this administration containing all relevant config files, keys, and certificates (be careful how you transport these to the host to use them!). The hosts using these configurations will also need the tunneldigger-utils package. . For an alternate approach, see the carpaltunnel package. Package: tunneldigger-utils Architecture: all Depends: openvpn (>= 1.5.0-2), net-tools, iproute Description: Utilities for TunnelDigger-configured OpenVPN tunnels Currently, there is a PPP ip-up.d script, and a OpenVPN "up" script. tunneldigger-0.10/debian/copyright0000644000175000017500000000054507770366151016650 0ustar kaikai00000000000000TunnelDigger was written and packaged by Kai Henningsen . (Some code for the td-up script and the key generation was stolen from Tommi Virtanen 's carpaltunnel package, which is an alternate OpenVPN configurator using a different approach.) Copyright: GPL. On Debian systems, the GPL is at /usr/share/common-licenses/GPL. tunneldigger-0.10/debian/rules0000755000175000017500000000343207770365012015766 0ustar kaikai00000000000000#!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 CFLAGS = -Wall -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif configure: configure-stamp configure-stamp: dh_testdir # Add here commands to configure the package. touch configure-stamp build: build-stamp build-stamp: configure-stamp dh_testdir # Add here commands to compile the package. #$(MAKE) #/usr/bin/docbook-to-man debian/tunneldigger-utils.sgml > tunneldigger-utils.1 touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp configure-stamp # Add here commands to clean up after the build process. #-$(MAKE) clean dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/tunneldigger-utils. #$(MAKE) install DESTDIR=$(CURDIR)/debian/tunneldigger-utils # Build architecture-dependent files here. binary-arch: build install # We have nothing to do. # Build architecture-independent files here. binary-indep: build install dh_testdir dh_testroot dh_installchangelogs dh_installdocs dh_installexamples dh_install # dh_installmenu # dh_installdebconf # dh_installlogrotate # dh_installemacsen # dh_installpam # dh_installmime # dh_installinit # dh_installcron # dh_installinfo dh_installman dh_link dh_strip dh_compress dh_fixperms dh_perl usr/lib/tunneldigger # dh_python # dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure tunneldigger-0.10/debian/tunneldigger-utils.install0000644000175000017500000000012107770353671022123 0ustar kaikai00000000000000utils/99-tunneldigger-utils /etc/ppp/ip-up.d utils/td-up /usr/lib/tunneldigger tunneldigger-0.10/debian/tunneldigger.docs0000644000175000017500000000000707770366003020243 0ustar kaikai00000000000000README tunneldigger-0.10/README0000644000175000017500000000314507770375720014354 0ustar kaikai00000000000000This is TunnelDigger, a tool to configure a network of OpenVPN tunnels. To use it, make a directory somewhere, create a "config" file in it with one line per tunnel, and call `make -f /usr/lib/tunneldigger/Makefile'. Copy the resulting .debs to the hosts they are named after, and install them. (You'll also need openvpn and tunneldigger-utils on those hosts.) IMPORTANT: There are secret keys in those .debs. Be careful about where you put them and how you transport them! You might want to customize the CANAME and MAINT variables to something else, by giving them as parameters to the makefile, like `make -f /usr/lib/tunneldigger/Makefile CANAME=My_CA_Name MAINT="I am The Man "'. The format of the "config" file is simple: White space has no meaning Fields are separated by ';' Lists are separated by ',' Everything after # is a comment There are no continuation lines or other escapes Empty lines are ignored Fields are: 1. Endpoint 1 (TLS server) fields 2. Endpoint 2 (TLS client) fields Endpoint fields: 1. Kind of system (currently only deb) 2. Endpoint name ([_a-zA-Z0-9]{1,8}) 3. external endpoint address (address or name, name/dyn, or dyn) 4. external endpoint port (number or dyn or alloc/allocatorname) 5. interface (usually empty) 6. internal endpoint address(es) (address or name list) 7. subnets routed through the tunnel to this side (address/length list) name-allocatorname.alloc is a file with a Perl hash with name => port entries, with the special entries "[first]" and "[last]" (default 5000 and 5999) specifying the port range to use. (Entries outside the range will be reallocated.) tunneldigger-0.10/utils/0000755000175000017500000000000007770423441014623 5ustar kaikai00000000000000tunneldigger-0.10/utils/99-tunneldigger-utils0000755000175000017500000000161307770351317020640 0ustar kaikai00000000000000#!/bin/sh # TunnelDigger: send SIGUSR1 to openvpn # # Copyright (C) 2003 Kai Henningsen # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA for i in /var/run/openvpn*.pid do kill -USR1 `cat $i` done tunneldigger-0.10/utils/td-up0000755000175000017500000000245107770422656015613 0ustar kaikai00000000000000#! /bin/bash # TunnelDigger "up" command # # Copyright (C) 2000-2002 Tommi Virtanen # Copyright (C) 2003 Kai Henningsen # # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Parameters: # 1 peer name # 2 local interface addresses # 3 remote networks to route # 4 dev # 5 tunmtu # 6 udpmtu # 7 localip # 8 remoteip DEV="$(echo "td-$1"|cut -c -15)" ip li set dev "$4" down ip li set dev "$4" name "$DEV" || DEV="$4" ip li set dev "$DEV" up mtu "$5" ifconfig $DEV $7 pointopoint $8 mtu $5 for i in $2 do ip a add "$i"/32 scope host dev "$DEV" done for i in $3 do ip ro add "$i" dev "$DEV" done tunneldigger-0.10/openvpn.options0000644000175000017500000000426307764665131016601 0ustar kaikai00000000000000tun = routing tap = bridging mktun rmtun connection desription options single-session # no usurping local endpoint # if static, for binding (else all ifaces) remote endpoint # or wait for incoming packets resolv-retry secs # for local or remote DNS float # allow remote to change ip:port, dft if no remote lport # local port (dft 5000) rport # remote port (dft 5000) port # both ports nobind # use dynamic local port, needs to initiate tun-ipv6 ifconfig l r # and default MTU to 1300 udp-mtu nnn # dft 1300; 1472? tun-mtu nnn # 1500? mtu-disc no|maybe|yes mtu-dynamic # rarely useful inactive nnn # then exit ping nnn # if inactive ping-exit nnn # if none ping-restart nnn # SIGUSR1 ping-timer-rem # only when we have an addr comp-lzo comp-noadapt secret "file" # --genkey secret auth "alg" # SHA1|none cipher "alg" # BFCBC|none # --show-ciphers keysize nnn no-replay replay-persist "file" no-iv tls-server tls-client ca "file" # can have several dh "file" # DH params cert "file" # local, signed by ca key "file" # local private tls-cipher list tls-timeout list reneg-bytes nnn reneg-pkts nnn reneg-sec nnn # dft 3600 hand-window # dft 60 tran-window # dft 3600 tls-auth "file" # additional passphrase disable-occ local options ipchange "command" # "ip" "port" # when new remote dev tunX|tapX|null dev-type tun|tap dev-node "/dev/xxx" tun-mtu-extra nnn # tap: 64 shaper nnn # outgoing bandwidth persist-tun # silent SIGUSR1 (no device reopen or up/down script) persist-key persist-local-ip persist-remote-ip mlock up "command" # "dev" "tunmtu" "udpmtu" "localip" "remoteip" # ifconfig $1 10.4.0.1 pointopoint 10.4.0.2 mtu $2 # route add -net 10.0.0.0 netmask 255.255.255.0 gw $5 down "command" # "dev" "tunmtu" "udpmtu" "localip" "remoteip" user "uuu" group "ggg" cd "ddd" chroot "rrr" # after initialization daemon "syslogprogname" passtos inetd "syslogprogname" writepid "fff" nice nnn nice-work nnn # TLS thread verb nnn # verbosity 1-4 5-11 mute nnn # per-category messages askpass tls-verify "cmd" # "certificate_depth" "X509_NAME_oneline" other options config "file" # include gremlin SIGHUP/SIGUSR1 on local addr change (ppp/ip-up.d)