public inbox for ipfire-scm@lists.ipfire.org
 help / color / mirror / Atom feed
From: git@ipfire.org
To: ipfire-scm@lists.ipfire.org
Subject: [git.ipfire.org] IPFire 2.x development tree branch, next, updated. e81be1e1edb0df7e11c305938838caa6c776ae8c
Date: Tue, 20 Nov 2012 17:11:27 +0100	[thread overview]
Message-ID: <20121120161128.B8A05203A4@argus.ipfire.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 6800 bytes --]

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPFire 2.x development tree".

The branch, next has been updated
       via  e81be1e1edb0df7e11c305938838caa6c776ae8c (commit)
      from  a66e24bbfd09b2ab2345ece2079d7143348a3980 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e81be1e1edb0df7e11c305938838caa6c776ae8c
Author: Alexander Marx <amarx(a)ipfire.org>
Date:   Tue Nov 20 16:23:01 2012 +0100

    openvpn ccd: Minor fixes.
    
    some bugfixes, client advanced options no more visible under net-2-net config, blue network is recognized,
    Fixed the bug with wrong ip address in ccd file.

-----------------------------------------------------------------------

Summary of changes:
 config/cfgroot/general-functions.pl | 55 ++++++++++++++++++++++++-------------
 html/cgi-bin/ovpnmain.cgi           | 23 +++++++++-------
 src/scripts/ovpn-ccd-convert        |  2 +-
 3 files changed, 50 insertions(+), 30 deletions(-)

Difference in files:
diff --git a/config/cfgroot/general-functions.pl b/config/cfgroot/general-functions.pl
index c6a6a7c..6026173 100644
--- a/config/cfgroot/general-functions.pl
+++ b/config/cfgroot/general-functions.pl
@@ -325,30 +325,47 @@ sub getccdbc
 	my $broadcast_address  = inet_ntoa( $ip_address_binary | ~$netmask_binary );
 	return $broadcast_address;
 }
+
+sub ip2dec 
+{
+    my $ip_num;
+    my $ip=$_[0];
+    if ( $ip =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/ ) {
+        $ip_num = (($1*256**3) + ($2*256**2) + ($3*256) + $4);
+    } else {
+        $ip_num = -1;
+    }
+    $ip_num = (($1*256**3) + ($2*256**2) + ($3*256) + $4);
+    return($ip_num);
+}
+
+sub dec2ip 
+{
+    my $ip;
+    my $ip_num=$_[0];
+	my $o1=$ip_num%256;
+	$ip_num=int($ip_num/256);
+	my $o2=$ip_num%256;
+	$ip_num=int($ip_num/256);
+	my $o3=$ip_num%256;
+	$ip_num=int($ip_num/256);
+	my $o4=$ip_num%256;
+	$ip="$o4.$o3.$o2.$o1";
+    return ($ip);
+}
+
 sub getnextip
 {
-	my ($byte1,$byte2,$byte3,$byte4) = split (/\./,$_[0]);
-	my $step=$_[1];
-	for (my $x=1;$x<=$step;$x++){
-		$byte4++;
-		if($byte4==255){ $byte4=0;$byte3++;}
-			if($byte3==255){$byte3=0;$byte2++;}
-				if ($byte2==255){$byte2=0;$byte1++}
-	
-	}
-	return "$byte1.$byte2.$byte3.$byte4";
+	my $decip=&ip2dec($_[0]);
+	$decip=$decip+4;
+	return &dec2ip($decip);
 }
+
 sub getlastip
 {
-	my ($byte1,$byte2,$byte3,$byte4) = split (/\./,$_[0]);
-	my $step=$_[1];
-	for (my $x=$step;$x>=1;$x--){
-		$byte4--;
-		if($byte4==0){ $byte4=255;$byte3--;}
-			if($byte3==0){$byte3=255;$byte2--;}
-				if ($byte2==0){$byte2=255;$byte1--}
-	}
-	return "$byte1.$byte2.$byte3.$byte4";
+	my $decip=&ip2dec($_[0]);
+	$decip--;
+	return &dec2ip($decip);
 }
 
 sub validipandmask
diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
index 9dd8272..9ae2a5f 100755
--- a/html/cgi-bin/ovpnmain.cgi
+++ b/html/cgi-bin/ovpnmain.cgi
@@ -50,6 +50,9 @@ my %mainsettings = ();
 ###
 ### Initialize variables
 ###
+my %ccdconfhash=();
+my %ccdroutehash=();
+my %ccdroute2hash=();
 my %netsettings=();
 my %cgiparams=();
 my %vpnsettings=();
@@ -2202,7 +2205,7 @@ else
 	{
 		unlink "${General::swroot}/ovpn/ccd/$confighash{$cgiparams{'KEY'}}[2]";
 	}
-	my %ccdroutehash=();
+	
 	&General::readhasharray("${General::swroot}/ovpn/ccdroute", \%ccdroutehash);
 	foreach my $key (keys %ccdroutehash) {
 		if ($ccdroutehash{$key}[0] eq $confighash{$cgiparams{'KEY'}}[1]){
@@ -2210,7 +2213,7 @@ else
 		}
 	}
 	&General::writehasharray("${General::swroot}/ovpn/ccdroute", \%ccdroutehash);
-	my %ccdroute2hash=();
+	
 	&General::readhasharray("${General::swroot}/ovpn/ccdroute2", \%ccdroute2hash);
 	foreach my $key (keys %ccdroute2hash) {
 		if ($ccdroute2hash{$key}[0] eq $confighash{$cgiparams{'KEY'}}[1]){
@@ -3311,7 +3314,7 @@ if ($confighash{$cgiparams{'KEY'}}) {
 	}
 	undef @temp;
 	#check route field and convert it to decimal
-	my %ccdroute2hash=();
+	
 	my $val=0;
 	my $i=1;
 	
@@ -4194,11 +4197,8 @@ END
 
 		print"</tr></table><br><br>";
 #A.Marx CCD new client		
-	
+if ($cgiparams{'TYPE'} eq 'host') {	
 	    print "<table border='0' width='100%' cellspacing='1' cellpadding='0'><tr><td colspan='3'><hr><br><b>$Lang::tr{'ccd choose net'}</td></tr><tr><td height='20' colspan='3'></td></tr>";
-	    my %ccdconfhash=();
-	    my %ccdroutehash=();
-	    my %ccdroute2hash=();
 	    my %vpnnet=();
 	    my $vpnip;
 	    &General::readhash("${General::swroot}/ovpn/settings", \%vpnnet);
@@ -4227,6 +4227,7 @@ END
 		}
 		print "</table><br><br><hr><br><br>";
 	}
+}
 # ccd end
 	&Header::closebox();
 	if ($cgiparams{'KEY'} && $cgiparams{'AUTH'} eq 'psk') {
@@ -4338,10 +4339,12 @@ END
 	    &Header::closebox();
 	    
 	}
+
+#A.Marx CCD new client	
+if ($cgiparams{'TYPE'} eq 'host') {
 	    print"<br><br>";
 	    &Header::openbox('100%', 'LEFT', "$Lang::tr{'ccd client options'}:");
 
-#A.Marx CCD new client
 	
 	print <<END;
 	<table border='0' width='100%'>
@@ -4400,7 +4403,7 @@ END
 								$set=1;
 							}
 							if (&haveBlueNet()){
-								if($netsettings{'BLUE_NETADDRESS'}."/".&General::iporsubtodec($netsettings{'BLUE_NETMASK'} eq $ccdroute2hash{$key}[$i])) {
+								if($netsettings{'BLUE_NETADDRESS'}."/".&General::iporsubtodec($netsettings{'BLUE_NETMASK'}) eq $ccdroute2hash{$key}[$i]) {
 								$selblue=1;
 								
 								}
@@ -4425,7 +4428,7 @@ END
 END
 ;
      &Header::closebox();
-	
+}
 	print "<div align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' />";
 	if ($cgiparams{'KEY'}) {
 #	    print "<input type='submit' name='ACTION' value='$Lang::tr{'advanced'}' />";
diff --git a/src/scripts/ovpn-ccd-convert b/src/scripts/ovpn-ccd-convert
index 18c298c..a406211 100644
--- a/src/scripts/ovpn-ccd-convert
+++ b/src/scripts/ovpn-ccd-convert
@@ -27,7 +27,7 @@ open(FILE,"/var/ipfire/ovpn/server.conf");
 
 &General::readhasharray("/var/ipfire/ovpn/ovpnconfig", \%ovpnconfig);
 foreach my $key (keys %ovpnconfig){
-	if($ovpnconfig{$key}[32] eq ''){
+	if($ovpnconfig{$key}[32] eq '' && $ovpnconfig{$key}[3] eq 'host'){
 		open ( CCDRWCONF,'>',"/var/ipfire/ovpn/ccd/$ovpnconfig{$key}[2]") or die "Unable to create clientconfigfile $!";
 		print CCDRWCONF "# OpenVPN Clientconfig from CCD extension by Copymaster#\n\n";
 		print CCDRWCONF "#This client uses the dynamic pool\n\n";


hooks/post-receive
--
IPFire 2.x development tree

                 reply	other threads:[~2012-11-20 16:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121120161128.B8A05203A4@argus.ipfire.org \
    --to=git@ipfire.org \
    --cc=ipfire-scm@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox