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.
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
###
### Initialize variables
###
+my %ccdconfhash=();
+my %ccdroutehash=();
+my %ccdroute2hash=();
my %netsettings=();
my %cgiparams=();
my %vpnsettings=();
{
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]){
}
}
&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]){
}
undef @temp;
#check route field and convert it to decimal
- my %ccdroute2hash=();
+
my $val=0;
my $i=1;
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);
}
print "</table><br><br><hr><br><br>";
}
+}
# ccd end
&Header::closebox();
if ($cgiparams{'KEY'} && $cgiparams{'AUTH'} eq 'psk') {
&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%'>
$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;
}
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'}' />";
&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";