]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/forwardfw.cgi
Forward Firewall: New Version 0.9.8.2
[people/teissler/ipfire-2.x.git] / html / cgi-bin / forwardfw.cgi
index b93557d8375870a9dbf326f63d1450bdec6d9bbe..fb0ef590023885739a5262da877620ee8566bc65 100755 (executable)
@@ -74,6 +74,7 @@ my %ipsecsettings=();
 my %aliases=();
 my %optionsfw=();
 
+my $VERSION='0.9.8.2';
 my $color;
 my $confignet          = "${General::swroot}/fwhosts/customnetworks";
 my $confighost         = "${General::swroot}/fwhosts/customhosts";
@@ -95,7 +96,7 @@ my $hint='';
 my $ipgrp="${General::swroot}/outgoing/groups";
 my $tdcolor='';
 my $checkorange='';
-
+my @protocols;
 &General::readhash("${General::swroot}/forward/settings", \%fwdfwsettings);
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
@@ -574,7 +575,9 @@ END
        print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='outgoing' /></tr>";
        print "</table></form>";
        &Header::closebox();
+       print "<br><br><div align='right'><font size='1' color='grey'>Version: $VERSION</font></div>";
 }
+
 sub changerule
 {
        my $oldchain=shift;
@@ -1026,32 +1029,32 @@ print<<END;
                <table width='100%' border='0'>
                <tr><td width='50%' valign='top'>
                <table width='100%' border='0'>
-               <tr><td width='1%'><input type='radio' name='$grp' value='std_net_$srctgt' $checked{$grp}{'std_net_'.$srctgt}></td><td>$Lang::tr{'fwhost stdnet'}</td><td><select name='std_net_$srctgt' style='min-width:185px;'>
+               <tr><td width='1%'><input type='radio' name='$grp' value='std_net_$srctgt' $checked{$grp}{'std_net_'.$srctgt}></td><td>$Lang::tr{'fwhost stdnet'}</td><td align='right'><select name='std_net_$srctgt' style='width:200px;'>
 END
        foreach my $network (sort keys %defaultNetworks)
                {
-                       next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
-                       next if($defaultNetworks{$network}{'NAME'} eq "RED");
+                       next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
+                       next if($defaultNetworks{$network}{'NAME'} eq "IPFire" && $srctgt eq 'tgt');
                        print "<option value='$defaultNetworks{$network}{'NAME'}'";
                        print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
                        print ">$network</option>";
                }
        print"</select></td></tr>";
        #custom networks
-       if (! -z $confignet){
-               print"<tr><td><input type='radio' name='$grp' value='cust_net_$srctgt' $checked{$grp}{'cust_net_'.$srctgt}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_$srctgt' style='min-width:185px;'>";
+       if (! -z $confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
+               print"<tr><td><input type='radio' name='$grp' value='cust_net_$srctgt' $checked{$grp}{'cust_net_'.$srctgt}></td><td>$Lang::tr{'fwhost cust net'}</td><td align='right'><select name='cust_net_$srctgt' style='width:200px;'>";
                &fillselect(\%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
                print"</select></td>";
        }
        #custom hosts
-       if (! -z $confighost){
-               print"<tr><td><input type='radio' name='$grp' value='cust_host_$srctgt' $checked{$grp}{'cust_host_'.$srctgt}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_$srctgt' style='min-width:185px;'>";
+       if (! -z $confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
+               print"<tr><td><input type='radio' name='$grp' value='cust_host_$srctgt' $checked{$grp}{'cust_host_'.$srctgt}></td><td>$Lang::tr{'fwhost cust addr'}</td><td align='right'><select name='cust_host_$srctgt' style='width:200px;'>";
                &fillselect(\%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
                print"</select></td>";
        }
        #custom groups
-       if (! -z $configgrp){
-               print"<tr><td valign='top'><input type='radio' name='$grp' value='cust_grp_$srctgt' $checked{$grp}{'cust_grp_'.$srctgt}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_$srctgt' style='min-width:185px;'>";
+       if (! -z $configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
+               print"<tr><td valign='top'><input type='radio' name='$grp' value='cust_grp_$srctgt' $checked{$grp}{'cust_grp_'.$srctgt}></td><td >$Lang::tr{'fwhost cust grp'}</td><td align='right'><select name='cust_grp_$srctgt' style='width:200px;'>";
                foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
                        if($helper ne $customgrp{$key}[0]){
                                print"<option ";
@@ -1065,43 +1068,52 @@ END
        #End left table. start right table (vpn)
        print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
        # CCD networks
-       if( ! -z $configccdnet){
-               print"<td width='1%'><input type='radio' name='$grp' value='ovpn_net_$srctgt'  $checked{$grp}{'ovpn_net_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_$srctgt' style='min-width:185px;'>";
+       if( ! -z $configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
+               print"<td width='1%'><input type='radio' name='$grp' value='ovpn_net_$srctgt'  $checked{$grp}{'ovpn_net_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_net_$srctgt' style='width:200px;'>";
                &fillselect(\%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
                print"</select></td></tr>";
        }
        #OVPN CCD Hosts
        foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
-               if ($ccdhost{$key}[33] ne ''){
-                       print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_host_$srctgt' $checked{$grp}{'ovpn_host_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_$srctgt' style='min-width:185px;'>" if ($show eq '');
+               if ($ccdhost{$key}[33] ne '' ){
+                       print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_host_$srctgt' $checked{$grp}{'ovpn_host_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_host_$srctgt' style='width:200px;'>" if ($show eq '');
                        $show='1';
                        print "<option value='$ccdhost{$key}[1]'";
                        print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
                        print ">$ccdhost{$key}[1]</option>";
                }
        }
+       if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
+               print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_host_$srctgt' $checked{$grp}{'ovpn_host_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_host_$srctgt' style='width:200px;'></select></td></tr>" ;
+       }
        if ($show eq '1'){$show='';print"</select></td></tr>";}
        #OVPN N2N
        foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
                if ($ccdhost{$key}[3] eq 'net'){
-                       print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_n2n_$srctgt' $checked{$grp}{'ovpn_n2n_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_n2n_$srctgt' style='min-width:185px;'>" if ($show eq '');
-                       my $show='1';
+                       print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_n2n_$srctgt' $checked{$grp}{'ovpn_n2n_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ovpn_n2n'}:</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_n2n_$srctgt' style='width:200px;'>" if ($show eq '');
+                       $show='1';
                        print "<option value='$ccdhost{$key}[1]'";
                        print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
                        print ">$ccdhost{$key}[1]</option>";
                }
        }
+       if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
+               print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_n2n_$srctgt' $checked{$grp}{'ovpn_n2n_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ovpn_n2n'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_n2n_$srctgt' style='width:200px;'></select></td></tr>" ;
+       }
        if ($show eq '1'){$show='';print"</select></td></tr>";}
        #IPsec netze
        foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
-               if ($ipsecconf{$key}[3] eq 'net'){
-                       print"<tr><td valign='top'><input type='radio' name='$grp' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_$srctgt' style='min-width:185px;'>" if ($show eq '');
+               if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
+                       print"<tr><td valign='top'><input type='radio' name='$grp' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'>" if ($show eq '');
                        $show='1';
                        print "<option ";
                        print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
                        print ">$ipsecconf{$key}[1]</option>";
                }
        }
+       if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
+               print"<tr><td valign='top'><input type='radio' name='$grp' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'><select></td></tr>";
+       }
        if ($show eq '1'){$show='';print"</select></td></tr>";}
        
        print"</tr></table>";
@@ -1211,13 +1223,14 @@ sub get_serviceports
        my $name=shift;
        &General::readhasharray("$configsrv", \%customservice);
        &General::readhasharray("$configsrvgrp", \%customservicegrp);
-       my $protocols;
        my $tcp;
        my $udp;
+       my $icmp;
+       @protocols=();
        if($type eq 'service'){
                foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
                        if ($customservice{$key}[0] eq $name){
-                               $protocols=$customservice{$key}[2];
+                               push (@protocols,$customservice{$key}[2]);
                        }
                }
        }elsif($type eq 'group'){
@@ -1225,16 +1238,32 @@ sub get_serviceports
                        if ($customservicegrp{$key}[0] eq $name){
                                foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
                                        if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
-                                               if($customservice{$key1}[2] eq 'TCP'){$tcp='TCP';}else{$udp='UDP';}
+                                               if($customservice{$key1}[2] eq 'TCP'){
+                                                       $tcp='TCP';
+                                               }elsif($customservice{$key1}[2] eq 'ICMP'){
+                                                       $icmp='ICMP';
+                                               }elsif($customservice{$key1}[2] eq 'UDP'){
+                                                       $udp='UDP';
+                                               }
                                        }
                                }
                        }
                }
        }
-       if($tcp && $udp){$protocols="TCP,UDP";
-       }elsif($tcp){$protocols.="TCP";
-       }elsif($udp){$protocols.="UDP";}
-       return $protocols;
+       if($tcp && $udp && $icmp){
+               push (@protocols,"All");
+               return @protocols;
+       }
+       if($tcp){
+               push (@protocols,"TCP");
+       }
+       if($udp){
+               push (@protocols,"UDP");
+       }
+       if($icmp){
+               push (@protocols,"ICMP");
+       }
+       return @protocols;
 }
 sub getcolor
 {
@@ -1525,7 +1554,7 @@ END
                &Header::openbox('100%', 'left', $Lang::tr{'fwdfw target'});
                print<<END;
                <table width='100%' border='0'> 
-               <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr'  checked></td><td colspan='2'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16'><td><input type='radio' name='grp2' value='ipfire'  $checked{'grp2'}{'ipfire'}></td><td><b>IPFire ($Lang::tr{'external access'})</b></td><td align='right'><select name='ipfire' style='min-width:185px;'>
+               <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr'  checked></td><td colspan='2'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16'><td><input type='radio' name='grp2' value='ipfire'  $checked{'grp2'}{'ipfire'}></td><td><b>IPFire ($Lang::tr{'external access'})</b></td><td align='right'><select name='ipfire' style='width:200px;'>
 END
                print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
 
@@ -2047,8 +2076,6 @@ sub viewtablenew
                                                $$hash{$key}[2]='';
                                        }
                                }
-                               #$$hash{$key}[3]='';
-                               #$$hash{$key}[5]='';
                        }
                        $$hash{'ACTIVE'}=$$hash{$key}[2];
                        $count++;
@@ -2119,17 +2146,19 @@ END
                        #Get Protocol
                        my $prot;
                        if ($$hash{$key}[12]){                  #target prot if manual
-                               $prot=$$hash{$key}[12];
+                               push (@protocols,$$hash{$key}[12]);
                        }elsif($$hash{$key}[8]){                #source prot if manual
-                               $prot=$$hash{$key}[8];
+                               push (@protocols,$$hash{$key}[8]);
                        }elsif($$hash{$key}[14] eq 'cust_srv'){ 
-                               $prot=&get_serviceports("service",$$hash{$key}[15]);
+                               &get_serviceports("service",$$hash{$key}[15]);
                        }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
-                               $prot=&get_serviceports("group",$$hash{$key}[15]);
+                               &get_serviceports("group",$$hash{$key}[15]);
                        }else{
-                               $prot=$Lang::tr{'all'};
+                               push (@protocols,$Lang::tr{'all'});
                        }
-                       print"<td align='center'>$prot</td>";
+                       my $protz=join(",",@protocols);
+                       print"<td align='center'>$protz</td>";
+                       @protocols=();
                        if ($$hash{$key}[18] eq 'ON'){
                                my @days=();
                                if($$hash{$key}[19] ne ''){push (@days,$Lang::tr{'fwdfw wd_mon'});}