]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/firewall.cgi
Firewall: When using custom hosts and not having BLUE or ORANGE, the Ruletable took...
[people/teissler/ipfire-2.x.git] / html / cgi-bin / firewall.cgi
index b7639a27ff6f7390d5319fff5125fda2047c21dc..cf94c8f8bccccefe6692c56b5af0aa8530f9e237 100644 (file)
@@ -101,7 +101,7 @@ my @protocols;
 &General::readhasharray("$configipsec", \%ipsecconf);
 &Header::showhttpheaders();
 &Header::getcgihash(\%fwdfwsettings);
-&Header::openpage($Lang::tr{'fwdfw menu'}, 1, '');
+&Header::openpage($Lang::tr{'firewall rules'}, 1, '');
 &Header::openbigbox('100%', 'center',$errormessage);
 #### JAVA SCRIPT ####
 print<<END;
@@ -1260,10 +1260,8 @@ sub get_serviceports
        my $name=shift;
        &General::readhasharray("$configsrv", \%customservice);
        &General::readhasharray("$configsrvgrp", \%customservicegrp);
-       my $tcp;
-       my $udp;
-       my $icmp;
        @protocols=();
+       my @specprot=("IPIP","IPV6","IGMP","GRE","AH","ESP");
        if($type eq 'service'){
                foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
                        if ($customservice{$key}[0] eq $name){
@@ -1273,33 +1271,23 @@ sub get_serviceports
        }elsif($type eq 'group'){
                foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
                        if ($customservicegrp{$key}[0] eq $name){
-                               foreach my $key1 (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
-                                       if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
-                                               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 ($customservicegrp{$key}[2] ~~ @specprot){
+                                       push (@protocols," ".$customservicegrp{$key}[2]);
+                               }else{
+                                       foreach my $key1 (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
+                                               if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
+                                                       if (!grep(/$customservice{$key1}[2]/, @protocols)){
+                                                               push (@protocols,$customservice{$key1}[2]);}
                                                }
                                        }
                                }
                        }
                }
        }
-       if($tcp && $udp && $icmp){
-               push (@protocols,"TCP,UDP, <br>ICMP");
-               return @protocols;
-       }
-       if($tcp){
-               push (@protocols,"TCP");
-       }
-       if($udp){
-               push (@protocols,"UDP");
-       }
-       if($icmp){
-               push (@protocols,"ICMP");
-       }
+
+       # Sort protocols alphabetically.
+       @protocols = sort(@protocols);
+
        return @protocols;
 }
 sub getcolor
@@ -1346,7 +1334,7 @@ sub getcolor
                        return;
                }elsif($val =~ /^(.*?)\/(.*?)$/){
                        my ($sip,$scidr) = split ("/",$val);
-                       if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
+                       if ( &Header::orange_used() && &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
                                $tdcolor="style='background-color: $Header::colourorange;color:white;'";
                                return;
                        }
@@ -1354,7 +1342,7 @@ sub getcolor
                                $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
                                return;
                        }
-                       if ( &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
+                       if ( &Header::blue_used() && &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
                                $tdcolor="style='background-color: $Header::colourblue;color:white;'";
                                return;
                        }
@@ -1551,6 +1539,7 @@ sub newrule
                                $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
                                $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
                                $selected{'dnat'}{$fwdfwsettings{'dnat'}}                               ='selected';
+                               $selected{'snat'}{$fwdfwsettings{'snat'}}                               ='selected';
                        }
                }
                $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
@@ -1613,7 +1602,7 @@ END
                if (! -z "${General::swroot}/ethernet/aliases"){
                        foreach my $alias (sort keys %aliases)
                        {
-                               print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
+                               print "<option value='$alias' $selected{'ipfire_src'}{$alias}>$alias</option>";
                        }
                }
                print<<END;
@@ -2311,8 +2300,8 @@ sub viewtablerule
        &General::readhash("/var/ipfire/ethernet/settings", \%netsettings);
 
        &viewtablenew(\%configfwdfw, $configfwdfw, $Lang::tr{'firewall rules'});
-       &viewtablenew(\%configinputfw, $configinput, $Lang::tr{'external access'});
-       &viewtablenew(\%configoutgoingfw, $configoutgoing, $Lang::tr{'outgoing firewall'});
+       &viewtablenew(\%configinputfw, $configinput, $Lang::tr{'incoming firewall access'});
+       &viewtablenew(\%configoutgoingfw, $configoutgoing, $Lang::tr{'outgoing firewall access'});
 }
 sub viewtablenew
 {
@@ -2486,7 +2475,7 @@ END
                                push (@protocols,$Lang::tr{'all'});
                        }
 
-                       my $protz=join(",",@protocols);
+                       my $protz=join(", ",@protocols);
                        if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
                                &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
                                foreach my $keyicmp (sort { ncmp($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
@@ -2495,6 +2484,8 @@ END
                                                last;
                                        }
                                }
+                       }elsif($#protocols gt '3'){
+                               print"<td align='center'><span title='$protz'>$Lang::tr{'fwdfw many'}</span></td>";
                        }else{
                                print"<td align='center'>$protz</td>";
                        }
@@ -2571,11 +2562,11 @@ END
                                                push (@nat_ifaces,&fwlib::get_nat_address($$hash{$key}[29],$val));
                                        }
                                        @nat_ifaces=&del_double(@nat_ifaces);
-                                       $natstring = join(', ', @nat_ifaces);
+                                       $natstring = "";
                                }else{
-                                       $natstring = $$hash{$key}[29];
+                                       $natstring = "($$hash{$key}[29])";
                                }
-                               print "$Lang::tr{'firewall'} ($natstring)";
+                               print "$Lang::tr{'firewall'} $natstring";
                                if($$hash{$key}[30] ne ''){
                                        $$hash{$key}[30]=~ tr/|/,/;
                                        print": $$hash{$key}[30]";