}
}
if (!$errormessage){
- &checkcounter($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
- if ($fwdfwsettings{'nobase'} ne 'on'){
- &checkcounter($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
- }
- if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
- &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
- }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
- &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
- }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
- &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
- }
if($fwdfwsettings{'nosave2'} ne 'on'){
&saverule(\%configinputfw,$configinput);
}
}
#increase counters
if (!$errormessage){
- &checkcounter($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
- &checkcounter($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
- if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
- &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
- }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
- &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
- }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
- &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
- }
- if ($fwdfwsettings{'nobase'} eq 'on'){
- &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
- }
if ($fwdfwsettings{'nosave2'} ne 'on'){
&saverule(\%configoutgoingfw,$configoutgoing);
}
}
#increase counters
if (!$errormessage){
- &checkcounter($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
- &checkcounter($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
- if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
- &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
- }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
- &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
- }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
- &checkcounter($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
- }
- if ($fwdfwsettings{'nobase'} eq 'on'){
- &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
- }
if ($fwdfwsettings{'nosave2'} ne 'on'){
&saverule(\%configfwdfw,$configfwdfw);
}
{
&error;
- &Header::openbox('100%', 'left', $Lang::tr{'fwdfw menu'});
+ &Header::openbox('100%', 'left', "");
print <<END;
<form method="POST" action="">
<table border='0' width="100%">
<tr>
- <td>
+ <td align='center'>
<input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'>
- </td>
- <td align="right">
END
if (&General::firewall_needs_reload()) {
</table>
</form>
- <hr>
+ <br>
END
+
&Header::closebox();
&viewtablerule;
}
$fwdfwsettings{'config'}=$oldchain;
$fwdfwsettings{'nobase'}='on';
&deleterule;
- &checkcounter(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
- &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
}
sub checksource
{
}
}
}
- #When using source- or targetport, the protocol has to be TCP or UDP
- if (($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON') && ($fwdfwsettings{'SRC_PORT'} ne '' || $fwdfwsettings{'TGT_PORT'} ne '') && ($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP')){
- $errormessage.=$Lang::tr{'fwdfw err prot_port1'};
- return;
- }
- #when icmp selected, no targetport allowed
+ #when icmp selected, no source and targetport allowed
if (($fwdfwsettings{'PROT'} ne '' && $fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP' && $fwdfwsettings{'PROT'} ne 'template') && ($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON')){
$errormessage.=$Lang::tr{'fwdfw err prot_port'};
return;
$fwdfwsettings{'ICMP_TYPES'}='';
$fwdfwsettings{'USESRV'}='';
$fwdfwsettings{'TGT_PORT'}='';
- }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP' && $fwdfwsettings{'PROT'} ne 'ICMP'){
+ }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP'){
$fwdfwsettings{'ICMP_TYPES'}='';
- $fwdfwsettings{'PROT'} = '';
+ $fwdfwsettings{'SRC_PORT'}='';
+ $fwdfwsettings{'TGT_PORT'}='';
}elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
$fwdfwsettings{'ICMP_TYPES'}='';
}
}
-sub checkcounter
-{
- my ($base1,$val1,$base2,$val2) = @_;
-
- if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
- &dec_counter($confignet,\%customnetwork,$val1);
- }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
- &dec_counter($confighost,\%customhost,$val1);
- }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
- &dec_counter($configgrp,\%customgrp,$val1);
- }elsif($base1 eq 'cust_srv'){
- &dec_counter($configsrv,\%customservice,$val1);
- }elsif($base1 eq 'cust_srvgrp'){
- &dec_counter($configsrvgrp,\%customservicegrp,$val1);
- }
-
- if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
- &inc_counter($confignet,\%customnetwork,$val2);
- }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
- &inc_counter($confighost,\%customhost,$val2);
- }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
- &inc_counter($configgrp,\%customgrp,$val2);
- }elsif($base2 eq 'cust_srv'){
- &inc_counter($configsrv,\%customservice,$val2);
- }elsif($base2 eq 'cust_srvgrp'){
- &inc_counter($configsrvgrp,\%customservicegrp,$val2);
- }
-}
sub checkvpn
{
my $ip=shift;
my %delhash=();
&General::readhasharray($fwdfwsettings{'config'}, \%delhash);
foreach my $key (sort {$a <=> $b} keys %delhash){
- if ($key == $fwdfwsettings{'key'}){
- #check hosts/net and groups
- &checkcounter($delhash{$key}[3],$delhash{$key}[4],,);
- &checkcounter($delhash{$key}[5],$delhash{$key}[6],,);
- #check services and groups
- if ($delhash{$key}[11] eq 'ON'){
- &checkcounter($delhash{$key}[14],$delhash{$key}[15],,);
- }
- }
if ($key >= $fwdfwsettings{'key'}) {
my $next = $key + 1;
if (exists $delhash{$next}) {
&General::writehasharray("$configfwdfw", \%configfwdfw);
&General::firewall_config_changed();
}
-sub dec_counter
-{
- my $config=shift;
- my %hash=%{(shift)};
- my $val=shift;
- my $pos;
- &General::readhasharray($config, \%hash);
- foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
- if($hash{$key}[0] eq $val){
- $pos=$#{$hash{$key}};
- $hash{$key}[$pos] = $hash{$key}[$pos]-1;
- }
- }
- &General::writehasharray($config, \%hash);
-}
sub error
{
if ($errormessage) {
if ($show eq '1'){$show='';print"</select></td></tr>";}
#IPsec netze
foreach my $key (sort { ncmp($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
- if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
+ if ($ipsecconf{$key}[3] eq 'net' || ($optionsfw{'SHOWDROPDOWN'} eq 'on' && $ipsecconf{$key}[3] ne 'host')){
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 ";
}elsif ($val eq 'IPFire' ){
$tdcolor="style='background-color: $Header::colourred;color:white;'";
return;
+ }elsif ($val eq 'OpenVPN-Dyn' ){
+ $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
+ return;
+ }elsif ($val eq 'IPsec RW' ){
+ $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
+ return;
}elsif($val =~ /^(.*?)\/(.*?)$/){
my ($sip,$scidr) = split ("/",$val);
if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
&gen_dd_block('src','grp1');
print"<hr>";
&Header::closebox();
+
#---SNAT / DNAT ------------------------------------------------
&Header::openbox('100%', 'left', 'NAT');
print<<END;
<div class="NAT">
<table width='100%' border='0'>
<tr>
- <td colspan='2'></td>
- <td width='1%'>
- <input type='radio' name='nat' id='dnat' value='dnat' checked>
+ <td width='5%'></td>
+ <td width='40%'>
+ <label>
+ <input type='radio' name='nat' id='dnat' value='dnat' checked>
+ $Lang::tr{'fwdfw dnat'}
+ </label>
+ </td>
+END
+
+ if (%aliases) {
+ print <<END;
+ <td width='25%' align='right'>$Lang::tr{'dnat address'}:</td>
+ <td width='30%'>
+ <select name='dnat' style='width: 100%;'>
+ <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'default ip'} ($netsettings{'RED_ADDRESS'})</option>
+END
+ foreach my $alias (sort keys %aliases) {
+ print "<option value='$alias' $selected{'dnat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
+ }
+
+ print "</select>";
+ } else {
+ print <<END;
+ <td colspan="2" width='55%'>
+ <input type='hidden' name='dnat' value='Default IP'>
</td>
- <td width='50%'>$Lang::tr{'fwdfw dnat'}</td>
END
- print"<td width='8%'>Firewall: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
- print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
- print "<option value='Default IP' $selected{'dnat'}{'Default IP'}>Default IP</option>";
- foreach my $alias (sort keys %aliases)
- {
- print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
}
- print"</select></td></tr>";
+ print "</tr>";
+
#SNAT
- print"<tr><td colspan='2'></td><td width='1%'><input type='radio' name='nat' id='snat' value='snat' $checked{'nat'}{'snat'}></td><td width='20%'>$Lang::tr{'fwdfw snat'}</td>";
- print"<td width='8%'>Firewall: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
- foreach my $alias (sort keys %aliases)
- {
- print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
- }
- foreach my $network (sort keys %defaultNetworks)
- {
+ print <<END;
+ <tr>
+ <td width='5%'></td>
+ <td width='40%'>
+ <label>
+ <input type='radio' name='nat' id='snat' value='snat' $checked{'nat'}{'snat'}>
+ $Lang::tr{'fwdfw snat'}
+ </label>
+ </td>
+ <td width='25%' align='right'>$Lang::tr{'snat new source ip address'}:</td>
+ <td width='30%'>
+ <select name='snat' style='width: 100%;'>
+END
+
+ foreach my $alias (sort keys %aliases) {
+ print "<option value='$alias' $selected{'snat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
+ }
+
+ # XXX this is composed in a very ugly fashion
+ foreach my $network (sort keys %defaultNetworks) {
next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
next if($defaultNetworks{$network}{'NAME'} eq "ALL");
next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
+ next if($defaultNetworks{$network}{'NAME'} =~ /IPsec/i);
+
print "<option value='$defaultNetworks{$network}{'NAME'}'";
print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
- print ">$network</option>";
+ print ">$network ($defaultNetworks{$network}{'NET'})</option>";
}
- print"</select></td></tr></table>";
- print"</div>";
+
+ print <<END;
+ </select>
+ </td>
+ </tr>
+ </table>
+ </div>
+END
&Header::closebox();
+
#---TARGET------------------------------------------------------
&Header::openbox('100%', 'left', $Lang::tr{'fwdfw target'});
print<<END;
print"<hr>";
&Header::closebox;
#---PROTOCOL------------------------------------------------------
+ $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
+ $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
+ $fwdfwsettings{'dnatport'} =~ tr/|/,/;
+
+ # The dnatport may be empty, if it matches TGT_PORT
+ if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
+ $fwdfwsettings{'dnatport'} = "";
+ }
+
&Header::openbox('100%', 'left', $Lang::tr{'fwhost prot'});
#Fix Protocol for JQuery
if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
$fwdfwsettings{'PROT'} = 'template';
}
print<<END;
- <div id="prt">
- <table width='15%' border='0' style="float:left;">
+ <table width='100%' border='0'>
<tr>
- <td>
- <select name='PROT' id='protocol'>
+ <td width="25%">
+ <select name='PROT' id='protocol' style="width: 95px;">
END
print "<option value=\"\"";
if ($fwdfwsettings{'PROT'} eq '') {
print ">$_</option>";
}
}
+
print<<END;
</select>
</td>
- </tr>
- </table>
- </div>
-
- <div id="PROTOCOL_ICMP_TYPES">
- <table width='50%' border='0' style="float:left;">
- <tr>
- <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
- <td colspan='2'>
- <select name='ICMP_TYPES' style='min-width:230px;'>
+ <td width="75%">
+ <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES">
+ <tr>
+ <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
+ <td colspan='2'>
+ <select name='ICMP_TYPES' style='min-width:230px;'>
END
&General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
}
print <<END;
- </select>
- </td>
- </tr>
- </table>
- </div>
+ </select>
+ </td>
+ </tr>
+ </table>
+
+ <table width="100%" border="0" id="PROTOCOL_PORTS">
+ <tr>
+ <!-- #SOURCEPORT -->
+ <td>
+ $Lang::tr{'fwdfw use srcport'}
+ </td>
+ <td>
+ <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
+ </td>
+ <td width='10%'>
+ </td>
+
+ <!-- #TARGETPORT -->
+ <td>
+ $Lang::tr{'fwdfw use srv'}
+ </td>
+
+ <td>
+ <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
+ </td>
+ </tr>
+ <tr class="NAT">
+ <td colspan='3'></td>
+ <td>$Lang::tr{'fwdfw external port nat'}:</td>
+ <td>
+ <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
+ </td>
+ </tr>
+ </table>
+
+ <table width="100%" border="0" id="PROTOCOL_TEMPLATE">
+ <tr>
+ <td>
+ <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
+ $Lang::tr{'fwhost cust service'}
+ </td>
+ <td>
+ <select name='cust_srv' style='min-width: 230px;'>
END
- $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
- $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
- $fwdfwsettings{'dnatport'} =~ tr/|/,/;
-
- # The dnatport may be empty, if it matches TGT_PORT
- if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
- $fwdfwsettings{'dnatport'} = "";
- }
-
- print <<END;
-
- <div id="PROTOCOL_PORTS">
- <table border="0">
- <tr>
- <!-- #SOURCEPORT -->
- <td>
- $Lang::tr{'fwdfw use srcport'}
- </td>
- <td>
- <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
- </td>
- <td width='10%'>
- </td>
-
- <!-- #TARGETPORT -->
- <td>
- $Lang::tr{'fwdfw use srv'}
- </td>
-
- <td>
- <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
- </td>
- </tr>
- <tr class="NAT">
- <td colspan='3'></td>
- <td>$Lang::tr{'fwdfw external port nat'}:</td>
- <td>
- <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
- </td>
- </tr>
- </table>
- </div>
-
- <div id="PROTOCOL_TEMPLATE">
- <table border="0">
- <tr>
- <td>
- <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
- $Lang::tr{'fwhost cust service'}
- </td>
- <td>
- <select name='cust_srv' style='min-width: 230px;'>
-END
&General::readhasharray("$configsrv", \%customservice);
foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
print"<option ";
print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
}
- print<<END;
- </select>
- </td>
- </tr>
- <tr>
- <td>
- <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
- $Lang::tr{'fwhost cust srvgrp'}
- </td>
- <td>
- <select name='cust_srvgrp' style='min-width:230px;'>
+ print <<END;
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
+ $Lang::tr{'fwhost cust srvgrp'}
+ </td>
+ <td>
+ <select name='cust_srvgrp' style='min-width:230px;'>
END
&General::readhasharray("$configsrvgrp", \%customservicegrp);
print">$customservicegrp{$key}[0]</option>";
}
$helper=$customservicegrp{$key}[0];
- }
+ }
+
print<<END;
- </select>
+ </select>
+ </td>
+ </tr>
+ </table>
</td>
</tr>
</table>
- </div>
-
- <br><br><br>
END
&Header::closebox;
if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s]*$/) {
return 0;}
# First character can only be a letter or a digit
- if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
+ if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9(]*$/) {
return 0;}
# Last character can only be a letter or a digit
if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
sub viewtablerule
{
&General::readhash("/var/ipfire/ethernet/settings", \%netsettings);
- &viewtablenew(\%configfwdfw,$configfwdfw,"","Forward" );
- &viewtablenew(\%configinputfw,$configinput,"",$Lang::tr{'fwdfw xt access'} );
- &viewtablenew(\%configoutgoingfw,$configoutgoing,"","Outgoing" );
+
+ &viewtablenew(\%configfwdfw, $configfwdfw, $Lang::tr{'firewall rules'});
+ &viewtablenew(\%configinputfw, $configinput, $Lang::tr{'external access'});
+ &viewtablenew(\%configoutgoingfw, $configoutgoing, $Lang::tr{'outgoing firewall'});
}
sub viewtablenew
{
my $hash=shift;
my $config=shift;
my $title=shift;
- my $title1=shift;
my $go='';
+
+ my $show_box = (! -z $config) || ($optionsfw{'SHOWTABLES'} eq 'on');
+ return if (!$show_box);
+
&General::get_aliases(\%aliases);
&General::readhasharray("$confighost", \%customhost);
&General::readhasharray("$config", $hash);
&General::readhasharray("$configccdnet", \%ccdnet);
&General::readhasharray("$configccdhost", \%ccdhost);
- if( ! -z $config){
- &Header::openbox('100%', 'left',$title);
+
+ &Header::openbox('100%', 'left', $title);
+ print "<table width='100%' cellspacing='0' border='0'>";
+
+ if (! -z $config) {
my $count=0;
my ($gif,$log);
my $ruletype;
my $rulecolor;
my $tooltip;
my @tmpsrc=();
+ my @tmptgt=();
my $coloryellow='';
- print <<END;
- <b>$title1</b>
- <br>
- <table width='100%' cellspacing='0' border='0'>
+ print <<END;
<tr>
<th align='right' width='3%'>
#
<b>$Lang::tr{'fwdfw source'}</b>
</th>
<th align='center'>
- Log <!-- XXX UNTRANSLATED STRING -->
+ <b>$Lang::tr{'fwdfw log'}</b>
</th>
<th align='center' width='30%'>
<b>$Lang::tr{'fwdfw target'}</b>
foreach my $key (sort {$a <=> $b} keys %$hash){
$tdcolor='';
@tmpsrc=();
+ @tmptgt=();
#check if vpn hosts/nets have been deleted
if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
push (@tmpsrc,$$hash{$key}[4]);
}
if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
- push (@tmpsrc,$$hash{$key}[6]);
+ push (@tmptgt,$$hash{$key}[6]);
}
foreach my $host (@tmpsrc){
- if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
+ if($$hash{$key}[3] eq 'ipsec_net_src'){
if(&fwlib::get_ipsec_net_ip($host,11) eq ''){
$coloryellow='on';
&disable_rule($key);
$$hash{$key}[2]='';
}
- }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
+ }elsif($$hash{$key}[3] eq 'ovpn_net_src'){
if(&fwlib::get_ovpn_net_ip($host,1) eq ''){
$coloryellow='on';
&disable_rule($key);
$$hash{$key}[2]='';
}
- }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
+ }elsif($$hash{$key}[3] eq 'ovpn_n2n_src'){
if(&fwlib::get_ovpn_n2n_ip($host,27) eq ''){
$coloryellow='on';
&disable_rule($key);
$$hash{$key}[2]='';
}
- }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
+ }elsif($$hash{$key}[3] eq 'ovpn_host_src'){
+ if(&fwlib::get_ovpn_host_ip($host,33) eq ''){
+ $coloryellow='on';
+ &disable_rule($key);
+ $$hash{$key}[2]='';
+ }
+ }
+ }
+ foreach my $host (@tmptgt){
+ if($$hash{$key}[5] eq 'ipsec_net_tgt'){
+ if(&fwlib::get_ipsec_net_ip($host,11) eq ''){
+ $coloryellow='on';
+ &disable_rule($key);
+ $$hash{$key}[2]='';
+ }
+ }elsif($$hash{$key}[5] eq 'ovpn_net_tgt'){
+ if(&fwlib::get_ovpn_net_ip($host,1) eq ''){
+ $coloryellow='on';
+ &disable_rule($key);
+ $$hash{$key}[2]='';
+ }
+ }elsif($$hash{$key}[5] eq 'ovpn_n2n_tgt'){
+ if(&fwlib::get_ovpn_n2n_ip($host,27) eq ''){
+ $coloryellow='on';
+ &disable_rule($key);
+ $$hash{$key}[2]='';
+ }
+ }elsif($$hash{$key}[5] eq 'ovpn_host_tgt'){
if(&fwlib::get_ovpn_host_ip($host,33) eq ''){
$coloryellow='on';
&disable_rule($key);
$$hash{'ACTIVE'}=$$hash{$key}[2];
$count++;
if($coloryellow eq 'on'){
- print"<tr bgcolor='$color{'color14'}' >";
+ $color="$color{'color14'}";
$coloryellow='';
}elsif($coloryellow eq ''){
if ($count % 2){
#SOURCE
my $ipfireiface;
&getcolor($$hash{$key}[3],$$hash{$key}[4],\%customhost);
- print"<td align='center' width='160' $tdcolor>";
+ print"<td align='center' width='30%' $tdcolor>";
if ($$hash{$key}[3] eq 'ipfire_src'){
- $ipfireiface='Interface ';
+ $ipfireiface=$Lang::tr{'fwdfw iface'};
}
if ($$hash{$key}[3] eq 'std_net_src'){
print &get_name($$hash{$key}[4]);
}
}elsif ($$hash{$key}[4] eq 'RED1'){
print "$ipfireiface $Lang::tr{'fwdfw red'}";
+ }elsif ($$hash{$key}[4] eq 'ALL'){
+ print "$ipfireiface $Lang::tr{'all'}";
}else{
- print "$$hash{$key}[4]";
+ if ($$hash{$key}[4] eq 'GREEN' || $$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE' || $$hash{$key}[4] eq 'RED'){
+ print "$ipfireiface $Lang::tr{lc($$hash{$key}[4])}";
+ }else{
+ print "$ipfireiface $$hash{$key}[4]";
+ }
}
$tdcolor='';
#SOURCEPORT
}
print"<br>->";
}
- if ($$hash{$key}[5] eq 'ipfire'){
- $ipfireiface='Interface';
- }
- if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire' || $$hash{$key}[6] eq 'RED1' || $$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE' ){
+ if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire'){
if ($$hash{$key}[6] eq 'RED1'){
- print "$ipfireiface $Lang::tr{'red1'}";
- }elsif ($$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE'|| $$hash{$key}[6] eq 'ALL')
+ print "$Lang::tr{'red1'}";
+ }elsif ($$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE'|| $$hash{$key}[6] eq 'ALL' || $$hash{$key}[6] eq 'RED')
{
- print "$ipfireiface ".&get_name($$hash{$key}[6]);
+ print &get_name($$hash{$key}[6]);
}else{
print $$hash{$key}[6];
}
}
print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
}
- print"</table>";
- #SHOW FINAL RULE
- print "<table width='100%'rules='cols' border='1'>";
- my $col;
- if ($config eq '/var/ipfire/firewall/config'){
- my $pol='fwdfw '.$fwdfwsettings{'POLICY'};
- if ($fwdfwsettings{'POLICY'} eq 'MODE1'){
- $col="bgcolor='darkred'";
- }else{
- $col="bgcolor='green'";
- }
- &show_defaultrules($col,$pol);
- }elsif ($config eq '/var/ipfire/firewall/outgoing'){
- if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){
- $col="bgcolor='darkred'";
- print"<tr><td $col width='20%' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td $col align='center'><font color='#FFFFFF' >$Lang::tr{'fwdfw pol block'}</font></td></tr>";
- }else{
- $col="bgcolor='green'";
- print"<tr><td $col width='20%' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td $col align='center'><font color='#FFFFFF' >$Lang::tr{'fwdfw pol allow'}</font></td></tr>";
- }
- }else{
- print"<tr><td bgcolor='darkred' width='20%' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td bgcolor='darkred' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol block'}</font></td></tr>";
+ } elsif ($optionsfw{'SHOWTABLES'} eq 'on') {
+ print <<END;
+ <tr>
+ <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td>
+ </tr>
+END
+ }
+
+ #SHOW FINAL RULE
+ my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'};
+ my $colour = "bgcolor='green'";
+ if ($fwdfwsettings{'POLICY'} eq 'MODE1') {
+ $colour = "bgcolor='darkred'";
+ }
+
+ my $message;
+ if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) {
+ print <<END;
+ <tr>
+ <td colspan='13'> </td>
+ </tr>
+ <tr>
+ <td colspan='13'>
+ <table width="100%" border='1' rules="cols" cellspacing='0'>
+END
+
+ # GREEN
+ print <<END;
+ <tr>
+ <td align='center'>
+ <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
+ </td>
+ <td align='center'>
+ <font color="$Header::colourred">$Lang::tr{'red'}</font>
+ ($Lang::tr{'fwdfw pol allow'})
+ </td>
+END
+
+ if (&Header::orange_used()) {
+ print <<END;
+ <td align='center'>
+ <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
+ ($Lang::tr{'fwdfw pol allow'})
+ </td>
+END
}
- print"</table>";
- print "<hr>";
- print "<br><br>";
- &Header::closebox();
- }else{
- if ($optionsfw{'SHOWTABLES'} eq 'on'){
- print "<b>$title1</b><br>";
- print"<table width='100%' border='0' rules='none'><tr><td height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td></tr></table>";
- my $col;
- if ($config eq '/var/ipfire/firewall/config'){
- my $pol='fwdfw '.$fwdfwsettings{'POLICY'};
- if ($fwdfwsettings{'POLICY'} eq 'MODE1'){
- $col="bgcolor='darkred'";
- }else{
- $col="bgcolor='green'";
- }
- &show_defaultrules($col,$pol);
- }elsif ($config eq '/var/ipfire/firewall/outgoing'){
- print "<table width='100%' rules='cols' border='1'>";
- my $pol='fwdfw '.$fwdfwsettings{'POLICY1'};
- if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){
- $col="bgcolor='darkred'";
- print"<tr><td $col align='center' width='20%'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td $col align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol block'}</font></td></tr>";
- }else{
- $col="bgcolor='green'";
- print"<tr><td $col align='center' width='20%'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td $col align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol allow'}</font></td></tr>";
- }
- }else{
- print "<table width='100%' rules='cols' border='1'>";
- print"<tr><td bgcolor='darkred' align='center' width='20%'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td align='center' bgcolor='darkred'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol block'}</font></td></tr>";
- }
- print"</table><br><br>";
+
+ if (&Header::blue_used()) {
+ print <<END;
+ <td align='center'>
+ <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
+ ($Lang::tr{'fwdfw pol allow'})
+ </td>
+END
}
- }
-}
-&Header::closebigbox();
-&Header::closepage();
-sub show_defaultrules
-{
- my $col=shift;
- my $pol=shift;
- #STANDARD RULES (From WIKI)
- print"</table>";
- if ($col eq "bgcolor='green'"){
- print "<br><table width='100%' rules='cols' border='1' >";
- my $blue = "<font color=$Header::colourblue> $Lang::tr{'blue'}</font> ($Lang::tr{'fwdfw pol block'})" if (&Header::blue_used());
- my $orange = "<font color=$Header::colourorange> $Lang::tr{'orange'}</font> ($Lang::tr{'fwdfw pol block'})" if (&Header::orange_used());
- my $blue1 = "<font color=$Header::colourblue> $Lang::tr{'blue'}</font> ($Lang::tr{'fwdfw pol allow'})" if (&Header::blue_used());
- my $orange1 = "<font color=$Header::colourorange> $Lang::tr{'orange'}</font> ($Lang::tr{'fwdfw pol allow'})" if (&Header::orange_used());
- print"<tr><td align='center'><font color='#000000'>$Lang::tr{'green'}</td><td align='center'> <font color=$Header::colourred> $Lang::tr{'red'}</font> ($Lang::tr{'fwdfw pol allow'})</td>";
- print"<td align='center'>$orange1</td>" if (&Header::orange_used());
- print"<td align='center'>$blue1</td>" if (&Header::blue_used());
print"</tr>";
- if (&Header::orange_used()){
- print"<tr><td align='center' width='20%'><font color='#000000'>$Lang::tr{'orange'}</td><td align='center'> <font color=$Header::colourred> $Lang::tr{'red'}</font> ($Lang::tr{'fwdfw pol allow'})</td><td align='center'><font color=$Header::colourgreen> $Lang::tr{'green'}</font> ($Lang::tr{'fwdfw pol block'})</td>";
- print"<td align='center'>$blue</td>" if (&Header::blue_used());
+
+ # ORANGE
+ if (&Header::orange_used()) {
+ print <<END;
+ <tr>
+ <td align='center' width='20%'>
+ <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
+ </td>
+ <td align='center'>
+ <font color="$Header::colourred">$Lang::tr{'red'}</font>
+ ($Lang::tr{'fwdfw pol allow'})
+ </td>
+ <td align='center'>
+ <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
+ ($Lang::tr{'fwdfw pol block'})
+ </td>
+END
+
+ if (&Header::blue_used()) {
+ print <<END;
+ <td align='center'>
+ <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
+ ($Lang::tr{'fwdfw pol block'})
+ </td>
+END
+ }
+
print"</tr>";
}
- if (&Header::blue_used()){
- print"<tr><td align='center'><font color='#000000'>$Lang::tr{'blue'}</td><td align='center'> <font color=$Header::colourred> $Lang::tr{'red'}</font> ($Lang::tr{'fwdfw pol allow'})</td>";
- print"<td align='center'>$orange</td>" if (&Header::orange_used());
- print"<td align='center'><font color=$Header::colourgreen> $Lang::tr{'green'}</font> ($Lang::tr{'fwdfw pol block'})</td>";
+
+ if (&Header::blue_used()) {
+ print <<END;
+ <tr>
+ <td align='center'>
+ <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
+ </td>
+ <td align='center'>
+ <font color="$Header::colourred">$Lang::tr{'red'}</font>
+ ($Lang::tr{'fwdfw pol allow'})
+ </td>
+END
+
+ if (&Header::orange_used()) {
+ print <<END;
+ <td align='center'>
+ <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
+ ($Lang::tr{'fwdfw pol block'})
+ </td>
+ <td align='center'>
+ <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
+ ($Lang::tr{'fwdfw pol block'})
+ </td>
+END
+ }
+
print"</tr>";
}
- print"<tr><td $col align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'} </font></td><td $col colspan='3' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol allow'}</font></td></tr>";
- }elsif($col eq "bgcolor='darkred'"){
- print "<table width='100%' rules='cols' border='1' >";
- print"<tr><td $col width='20%' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td $col align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol block'}</font></td></tr>";
+
+ print <<END;
+ </table>
+ </td>
+ </tr>
+END
+
+ $message = $Lang::tr{'fwdfw pol allow'};
+
+ } elsif ($config eq '/var/ipfire/firewall/outgoing' && ($fwdfwsettings{'POLICY1'} ne 'MODE1')) {
+ $message = $Lang::tr{'fwdfw pol allow'};
+ $colour = "bgcolor='green'";
+ } else {
+ $message = $Lang::tr{'fwdfw pol block'};
+ $colour = "bgcolor='darkred'";
+ }
+
+ if ($message) {
+ print <<END;
+ <tr>
+ <td $colour align='center' colspan='13'>
+ <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font>
+ </td>
+ </tr>
+END
}
+
+ print "</table>";
+ print "<br>";
+
+ &Header::closebox();
}
+
+&Header::closebigbox();
+&Header::closepage();