OpenVPN ccd: try to adapt changes to latest next branch.
authorAlexander Marx <amarx@ipfire.org>
Mon, 26 Nov 2012 04:45:07 +0000 (05:45 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 26 Nov 2012 09:31:47 +0000 (10:31 +0100)
html/cgi-bin/ovpnmain.cgi
langs/de/cgi-bin/de.pl
langs/en/cgi-bin/en.pl

index 9dd901138cf2c8ca51014cb59c9e0ea6425a6510..3c090b080da5ba9e68741a66b90fa5c38c983ac2 100755 (executable)
@@ -2579,6 +2579,8 @@ END
        if ($cgiparams{'ACTION'} eq 'editsave'){
                my ($a,$b) =split (/\|/,$cgiparams{'ccdname'});
                if ( $a ne $b){ &modccdnet($a,$b);}
+               $cgiparams{'ccdname'}='';
+               $cgiparams{'ccdsubnet'}='';
        }
        
        if ($cgiparams{'ACTION'} eq $Lang::tr{'ccd add'}) {
@@ -2633,6 +2635,11 @@ END
        &Header::closebox();
 }
        &Header::openbox('100%', 'LEFT',$Lang::tr{'ccd net'} );
+       if ( -e "/var/run/openvpn.pid"){
+               print "<b>$Lang::tr{'attention'}:</b><br>";
+               print "$Lang::tr{'ccd noaddnet'}<br><hr>";
+       }
+       
        print <<END
     <table width='100%' border='0'  cellpadding='0' cellspacing='1'>
     <tr>
@@ -3303,6 +3310,8 @@ if ($cgiparams{'TYPE'} eq 'host') {
        my @temp=();
        my %ccdroutehash=();
        my $keypoint=0;
+       my $ip;
+       my $cidr;
        if ($cgiparams{'IR'} ne ''){
                @temp = split("\n",$cgiparams{'IR'});
                &General::readhasharray("${General::swroot}/ovpn/ccdroute", \%ccdroutehash);
@@ -3321,19 +3330,32 @@ if ($cgiparams{'TYPE'} eq 'host') {
                foreach $val (@temp){
                        chomp($val);
                        $val=~s/\s*$//g; 
-                       my($ip,$cidr) = split(/\//,$val);
-                       $ip=&General::getnetworkip($ip,&General::iporsubtocidr($cidr));
-                       $cidr=&General::iporsubtodec($cidr);
-                       
-                       #check if iroute exists in ccdroute
+                       #check if iroute exists in ccdroute or if new iroute is part of an existing one
                        foreach my $key (keys %ccdroutehash) {
                                foreach my $oldiroute ( 1 .. $#{$ccdroutehash{$key}}){
-                                       if ($ccdroutehash{$key}[$oldiroute] eq "$ip/$cidr") {
-                                               $errormessage=$Lang::tr{'ccd err irouteexist'};
-                                               goto VPNCONF_ERROR;
-                                       }
+                                               if ($ccdroutehash{$key}[$oldiroute] eq "$val") {
+                                                       $errormessage=$errormessage.$Lang::tr{'ccd err irouteexist'};
+                                                       goto VPNCONF_ERROR;
+                                               }
+                                               my ($ip1,$cidr1) = split (/\//, $val);
+                                               my ($ip2,$cidr2) = split (/\//, $ccdroutehash{$key}[$oldiroute]);
+                                               if (&General::IpInSubnet ($ip1,$ip2,$cidr2)){
+                                                       $errormessage=$errormessage.$Lang::tr{'ccd err irouteexist'};
+                                                       goto VPNCONF_ERROR;
+                                               } 
+                                                                       
                                }
                        }
+                       if (!&General::validipandmask($val)){
+                               $errormessage=$errormessage."Route ".$Lang::tr{'ccd invalid'}." ($val)";
+                               goto VPNCONF_ERROR;
+                       }else{
+                               ($ip,$cidr) = split(/\//,$val);
+                               $ip=&General::getnetworkip($ip,&General::iporsubtocidr($cidr));
+                               $cidr=&General::iporsubtodec($cidr);
+                               $ccdroutehash{$keypoint}[$i] = $ip."/".$cidr;
+                       
+                       }
                                                                                                                                        
                        #check for existing network IP's
                        if (&General::IpInSubnet ($ip,$netsettings{GREEN_NETADDRESS},$netsettings{GREEN_NETMASK}) && $netsettings{GREEN_NETADDRESS} ne '0.0.0.0')
index 7fe336c13197019317e9abccccac71f8fa8de6a8..1c32fb628346b520e301a707e626a521c8036ea2 100644 (file)
 'ccd modify' => 'Netzwerk ändern',
 'ccd name' => 'Name',
 'ccd net' => 'Statische IP-Adressen-Pools',
+'ccd noaddnet' => 'Neue statische Netze können erst erstellt werden, wenn der openVPN Server gestoppt wurde.',
 'ccd none' => 'Keine',
 'ccd routes' => 'Routen:',
 'ccd subnet' => 'Subnetz',
index 4a2f73eef0c42ad09ee4381b0332f312cd3890b8..0a387505082cdeb2d5caaaf5a137602a25366c0a 100644 (file)
 'ccd modify' => 'Change network',
 'ccd name' => 'Name',
 'ccd net' => 'Static IP address pools',
+'ccd noaddnet' => 'You can only add new static networks when OpenVPN server is stopped.',
 'ccd none' => 'None',
 'ccd routes' => 'Routing:',
 'ccd subnet' => 'Subnet',