- | $Lang::tr{'fwdfw sourceip'} |
-
|
- | $Lang::tr{'fwhost stdnet'} | | | $Lang::tr{'fwhost ccdnet'} | |
+
| $Lang::tr{'fwdfw use srcport'} |
$Lang::tr{'fwdfw man port'} |
@@ -1271,7 +1577,7 @@ END
END
&General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
print"All ICMP-Types";
- foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
+ foreach my $key (sort { ncmp($icmptypes{$a}[0],$icmptypes{$b}[0]) } keys %icmptypes){
if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
print"$icmptypes{$key}[0] ($icmptypes{$key}[1])";
}else{
@@ -1287,119 +1593,43 @@ END
&Header::openbox('100%', 'left', $Lang::tr{'fwdfw target'});
print<
- | $Lang::tr{'fwdfw targetip'} | | IPFire ($Lang::tr{'external access'}) |
-END
- print "Default IP";
-
- foreach my $alias (sort keys %aliases)
- {
- print "$alias";
- }
-
- print< |
-
|
- | $Lang::tr{'fwhost stdnet'} |
-END
- foreach my $network (sort keys %defaultNetworks)
- {
- next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
- print "$network";
- }
- print< | | $Lang::tr{'fwhost ccdnet'} |
-END
- &fillselect(\%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
- print< |
- | $Lang::tr{'fwhost cust net'} |
-END
- &fillselect(\%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
- print< | | $Lang::tr{'fwhost ccdhost'} |
-END
- foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
- {
- if ($ccdhost{$key}[33] ne ''){
- print "$ccdhost{$key}[1]";
- }
- }
- print< |
- | $Lang::tr{'fwhost cust addr'} |
-END
- &fillselect(\%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
- print< | | $Lang::tr{'fwhost ovpn_n2n'} |
-END
- foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
- if($ccdhost{$key}[3] eq 'net'){
- print "$ccdhost{$key}[1]";
- }
- }
- print< |
- | $Lang::tr{'fwhost cust grp'} |
-END
- $helper='';
- foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
- if($helper ne $customgrp{$key}[0]){
- print"$customgrp{$key}[0]";
- }
- $helper=$customgrp{$key}[0];
- }
- print< |
- | $Lang::tr{'fwhost ipsec net'} |
+ | $Lang::tr{'fwdfw targetip'} | | Firewall |
END
- foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
- if ($ipsecconf{$key}[3] eq 'net'){
- print"$ipsecconf{$key}[1]";
+ print"";
+ print "$Lang::tr{'all'}";
+ print "$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})" if $ifaces{'GREEN_ADDRESS'};
+ print "$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})" if (&Header::orange_used());
+ print "$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})"if (&Header::blue_used());
+ print "$Lang::tr{'red1'} ($redip)" if ($redip);
+ if (! -z "${General::swroot}/ethernet/aliases"){
+ foreach my $alias (sort keys %aliases)
+ {
+ print "$alias";
}
}
print< |
+
| | |
END
-# | $Lang::tr{'fwhost ipsec host'} |
-#END
-# foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
-# if ($ipsecconf{$key}[3] eq 'host'){
-# print"$ipsecconf{$key}[1]";
-# }
-# }
+ &gen_dd_block('tgt','grp2');
print<
- $Lang::tr{'fwhost attention'}:
- $Lang::tr{'fwhost macwarn'}
-
+
- | $Lang::tr{'fwdfw use srv'} | | $Lang::tr{'fwhost cust service'} |
+ | $Lang::tr{'fwdfw use srv'} | | $Lang::tr{'fwhost cust service'} |
END
&General::readhasharray("$configsrv", \%customservice);
- foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
+ foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
print"$customservice{$key}[0]";
}
print< |
- | | $Lang::tr{'fwhost cust srvgrp'}: |
+ | | $Lang::tr{'fwhost cust srvgrp'} |
END
&General::readhasharray("$configsrvgrp", \%customservicegrp);
my $helper;
- foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
+ foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
if ($helper ne $customservicegrp{$key}[0]){
print" |
- | | $Lang::tr{'fwdfw man port'} |
+ | | $Lang::tr{'fwdfw man port'} |
END
foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
{
@@ -1422,12 +1652,12 @@ END
}
$fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
print< | |
+ | |
| | $Lang::tr{'fwhost icmptype'} |
END
&General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
print"All ICMP-Types";
- foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
+ foreach my $key (sort { ncmp($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
print"$icmptypes{$key}[0] ($icmptypes{$key}[1])";
}else{
@@ -1440,12 +1670,69 @@ END
END
&Header::closebox;
+ #---SNAT / DNAT ------------------------------------------------
+ &Header::openbox('100%', 'left', 'NAT');
+ print<
+ | $Lang::tr{'fwdfw use nat'} | |
+ | | $Lang::tr{'fwdfw dnat'} |
+END
+ print"Firewall: | ";
+ print "$Lang::tr{'all'}";
+ print "Default IP";
+ foreach my $alias (sort keys %aliases)
+ {
+ print "$alias";
+ }
+ print" | ";
+ $fwdfwsettings{'dnatport'}=~ tr/|/,/;
+ print" | Port: | | ";
+ print"
| ";
+ #SNAT
+ print" | | $Lang::tr{'fwdfw snat'} | ";
+ print"Firewall: | ";
+ foreach my $alias (sort keys %aliases)
+ {
+ print "$alias";
+ }
+ 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);
+ print "$network";
+ }
+ print" | | | | ";
+ print" ";
+ &Header::closebox();
#---Activate/logging/remark-------------------------------------
&Header::openbox('100%', 'left', $Lang::tr{'fwdfw additional'});
print<
- $Lang::tr{'remark'}: | |
+ $Lang::tr{'fwdfw rule action'} |
END
+ foreach ("ACCEPT","DROP","REJECT")
+ {
+ if($fwdfwsettings{'updatefwrule'} eq 'on'){
+ print"$Lang::tr{'fwdfw '.$_}";
+ }else{
+ if($fwdfwsettings{'POLICY'} eq 'MODE2'){
+ $fwdfwsettings{'RULE_ACTION'} = 'DROP';
+ }
+ if ($_ eq $fwdfwsettings{'RULE_ACTION'})
+ {
+ print"$Lang::tr{'fwdfw '.$_}";
+ }else{
+ print"$Lang::tr{'fwdfw '.$_}";
+ }
+ }
+ }
+ print" | ";
+ print"$Lang::tr{'remark'}: | | ";
if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
print "$Lang::tr{'fwdfw rulepos'}: | ";
for (my $count =1; $count <= $sum; $count++){
@@ -1469,8 +1756,8 @@ END
&Header::openbox('100%', 'left', $Lang::tr{'fwdfw timeframe'});
print<
- | $Lang::tr{'fwdfw timeframe'} |
-   |
+ | $Lang::tr{'fwdfw timeframe'} |
+ |
$Lang::tr{'time'}: |
$Lang::tr{'advproxy monday'} $Lang::tr{'advproxy tuesday'} $Lang::tr{'advproxy wednesday'} $Lang::tr{'advproxy thursday'} $Lang::tr{'advproxy friday'} $Lang::tr{'advproxy saturday'} $Lang::tr{'advproxy sunday'} |
@@ -1479,15 +1766,13 @@ END
|
-
-
-
-
-
-
-
-
- |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
END
for (my $i=0;$i<=23;$i++) {
@@ -1510,40 +1795,111 @@ END
print "\t\t\t\t\t$i:$j\n";
}
}
- print< |
-
-END
-
- #---ACTION------------------------------------------------------
- if($fwdfwsettings{'updatefwrule'} ne 'on'){
- print<
-
-
-
- |
-
-END
- }else{
- print<
-
-
-
-
-
-
-
-
-
-
-
- |
-
-END
- }
- &Header::closebox();
+ print<
+END
+ #---ACTION------------------------------------------------------
+ if($fwdfwsettings{'updatefwrule'} ne 'on'){
+ print<
+
+
+
+ |
+
+
+END
+ }else{
+ print<
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+END
+ }
+ &Header::closebox();
+}
+sub pos_up
+{
+ my %uphash=();
+ my %tmp=();
+ &General::readhasharray($fwdfwsettings{'config'}, \%uphash);
+ foreach my $key (sort keys %uphash){
+ if ($key eq $fwdfwsettings{'key'}) {
+ my $last = $key -1;
+ if (exists $uphash{$last}){
+ #save rule last
+ foreach my $y (0 .. $#{$uphash{$last}}) {
+ $tmp{0}[$y] = $uphash{$last}[$y];
+ }
+ #copy active rule to last
+ foreach my $i (0 .. $#{$uphash{$last}}) {
+ $uphash{$last}[$i] = $uphash{$key}[$i];
+ }
+ #copy saved rule to actual position
+ foreach my $x (0 .. $#{$tmp{0}}) {
+ $uphash{$key}[$x] = $tmp{0}[$x];
+ }
+ }
+ }
+ }
+ &General::writehasharray($fwdfwsettings{'config'}, \%uphash);
+ &rules;
+}
+sub pos_down
+{
+ my %downhash=();
+ my %tmp=();
+ &General::readhasharray($fwdfwsettings{'config'}, \%downhash);
+ foreach my $key (sort keys %downhash){
+ if ($key eq $fwdfwsettings{'key'}) {
+ my $next = $key + 1;
+ if (exists $downhash{$next}){
+ #save rule next
+ foreach my $y (0 .. $#{$downhash{$next}}) {
+ $tmp{0}[$y] = $downhash{$next}[$y];
+ }
+ #copy active rule to next
+ foreach my $i (0 .. $#{$downhash{$next}}) {
+ $downhash{$next}[$i] = $downhash{$key}[$i];
+ }
+ #copy saved rule to actual position
+ foreach my $x (0 .. $#{$tmp{0}}) {
+ $downhash{$key}[$x] = $tmp{0}[$x];
+ }
+ }
+ }
+ }
+ &General::writehasharray($fwdfwsettings{'config'}, \%downhash);
+ &rules;
+}
+sub rules
+{
+ if (!-f "${General::swroot}/forward/reread"){
+ system("touch ${General::swroot}/forward/reread");
+ system("touch ${General::swroot}/fwhosts/reread");
+ }
+}
+sub reread_rules
+{
+ system("/usr/local/bin/forwardfwctrl");
+ if ( -f "${General::swroot}/forward/reread"){
+ system("rm ${General::swroot}/forward/reread");
+ system("rm ${General::swroot}/fwhosts/reread");
+ }
}
sub saverule
{
@@ -1551,29 +1907,38 @@ sub saverule
my $config=shift;
&General::readhasharray("$config", $hash);
if (!$errormessage){
- #check if we change an forward rule to an external access
- if( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
- &changerule($configfwdfw);
- }
- #check if we change an forward rule to an outgoing
- if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'oldgrp1b'} ne 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
- &changerule($configfwdfw);
- }
- #check if we change an external access rule to a forward
- if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
+ ################################################################
+ #check if we change an INPUT rule to a OUTGOING
+ if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
&changerule($configinput);
+ #print"1";
}
- #check if we change an external access rule to a outgoing
- if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
+ #check if we change an INPUT rule to a FORWARD
+ elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
&changerule($configinput);
+ #print"2";
}
- #check if we change an outgoing rule to a forward
- if( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' &&$fwdfwsettings{'updatefwrule'} eq 'on'){
+ ################################################################
+ #check if we change an OUTGOING rule to an INPUT
+ elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
&changerule($configoutgoing);
+ #print"3";
}
- #check if we change an outgoing rule to a external access
- if( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
+ #check if we change an OUTGOING rule to a FORWARD
+ elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
&changerule($configoutgoing);
+ #print"4";
+ }
+ ################################################################
+ #check if we change a FORWARD rule to an INPUT
+ elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
+ &changerule($configfwdfw);
+ #print"5";
+ }
+ #check if we change a FORWARD rule to an OUTGOING
+ elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
+ &changerule($configfwdfw);
+ #print"6";
}
if ($fwdfwsettings{'updatefwrule'} ne 'on'){
my $key = &General::findhasharraykey ($hash);
@@ -1605,6 +1970,10 @@ sub saverule
$$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
$$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
$$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
+ $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
+ $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
+ $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
+ $$hash{$key}[31] = $fwdfwsettings{'nat'};
&General::writehasharray("$config", $hash);
}else{
foreach my $key (sort {$a <=> $b} keys %$hash){
@@ -1637,6 +2006,10 @@ sub saverule
$$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
$$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
$$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
+ $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
+ $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
+ $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
+ $$hash{$key}[31] = $fwdfwsettings{'nat'};
last;
}
}
@@ -1699,35 +2072,6 @@ sub saverule
}
}
}
-sub error
-{
- if ($errormessage) {
- &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
- print "$errormessage\n";
- print " \n";
- &Header::closebox();
- print" ";
- }
-}
-sub hint
-{
- if ($hint) {
- &Header::openbox('100%', 'left', $Lang::tr{'fwhost hint'});
- print "$hint\n";
- print " \n";
- &Header::closebox();
- print" ";
- }
-}
-sub get_name
-{
- my $val=shift;
- &General::setup_default_networks(\%defaultNetworks);
- foreach my $network (sort keys %defaultNetworks)
- {
- return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
- }
-}
sub validremark
{
# Checks a hostname against RFC1035
@@ -1748,80 +2092,11 @@ sub validremark
return 0;}
return 1;
}
-sub getsrcport
-{
- my %hash=%{(shift)};
- my $key=shift;
- if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
- $hash{$key}[10]=~ s/\|/,/g;
- print": $hash{$key}[10]";
- }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
- print": $hash{$key}[9] ";
- }
-}
-sub gettgtport
-{
- my %hash=%{(shift)};
- my $key=shift;
- my $service;
- my $prot;
- if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
- if($hash{$key}[14] eq 'cust_srv'){
- &General::readhasharray("$configsrv", \%customservice);
- foreach my $i (sort keys %customservice){
- if($customservice{$i}[0] eq $hash{$key}[15]){
- $service = $customservice{$i}[0];
- }
- }
- }elsif($hash{$key}[14] eq 'cust_srvgrp'){
- $service=$hash{$key}[15];
- }elsif($hash{$key}[14] eq 'TGT_PORT'){
- $hash{$key}[15]=~ s/\|/,/g;
- $service=$hash{$key}[15];
- }
- if($service){
- print": $service";
- }
- }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
- print": $hash{$key}[13]";
- }
-}
-sub get_serviceports
-{
- my $type=shift;
- my $name=shift;
- &General::readhasharray("$configsrv", \%customservice);
- &General::readhasharray("$configsrvgrp", \%customservicegrp);
- my $protocols;
- my $tcp;
- my $udp;
- 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];
- }
- }
- }elsif($type eq 'group'){
- foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
- 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($tcp && $udp){$protocols="TCP,UDP";
- }elsif($tcp){$protocols.="TCP";
- }elsif($udp){$protocols.="UDP";}
- return $protocols;
-}
sub viewtablerule
{
&General::readhash("/var/ipfire/ethernet/settings", \%netsettings);
- &viewtablenew(\%configfwdfw,$configfwdfw,$Lang::tr{'fwdfw rules'},"Forward" );
- &viewtablenew(\%configinputfw,$configinput,"",$Lang::tr{'external access'} );
+ &viewtablenew(\%configfwdfw,$configfwdfw,"","Forward" );
+ &viewtablenew(\%configinputfw,$configinput,"",$Lang::tr{'fwdfw xt access'} );
&viewtablenew(\%configoutgoingfw,$configoutgoing,"","Outgoing" );
}
sub viewtablenew
@@ -1832,7 +2107,10 @@ sub viewtablenew
my $title1=shift;
my $go='';
&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);
my $count=0;
@@ -1843,8 +2121,8 @@ sub viewtablenew
my @tmpsrc=();
my $coloryellow='';
print"$title1 ";
- print"";
- print"# | | $Lang::tr{'fwdfw source'} | Log | $Lang::tr{'fwdfw target'} | $Lang::tr{'protocol'} | $Lang::tr{'fwdfw time'} | $Lang::tr{'fwdfw action'} | ";
+ print"";
+ print"# | | | $Lang::tr{'fwdfw source'} | Log | $Lang::tr{'fwdfw target'} | $Lang::tr{'fwdfw action'} | ";
foreach my $key (sort {$a <=> $b} keys %$hash){
$tdcolor='';
@tmpsrc=();
@@ -1881,8 +2159,6 @@ sub viewtablenew
$$hash{$key}[2]='';
}
}
- #$$hash{$key}[3]='';
- #$$hash{$key}[5]='';
}
$$hash{'ACTIVE'}=$$hash{$key}[2];
$count++;
@@ -1898,9 +2174,11 @@ sub viewtablenew
}
}
print"";
+ #KEY
print<$key
+ $key |
END
+ #RULETYPE (A,R,D)
if ($$hash{$key}[0] eq 'ACCEPT'){
$ruletype='A';
$tooltip='ACCEPT';
@@ -1914,72 +2192,111 @@ END
$tooltip='REJECT';
$rulecolor=$color{'color16'};
}
- print"$ruletype | ";
- &getcolor($$hash{$key}[3],$$hash{$key}[4]);
+ print"$ruletype | ";
+ #Get Protocol
+ my $prot;
+ if ($$hash{$key}[8] && $$hash{$key}[7] eq 'ON'){#source prot if manual
+ push (@protocols,$$hash{$key}[8]);
+ }elsif ($$hash{$key}[12]){ #target prot if manual
+ push (@protocols,$$hash{$key}[12]);
+ }elsif($$hash{$key}[14] eq 'cust_srv'){
+ &get_serviceports("service",$$hash{$key}[15]);
+ }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
+ &get_serviceports("group",$$hash{$key}[15]);
+ }else{
+ push (@protocols,$Lang::tr{'all'});
+ }
+ my $protz=join(",",@protocols);
+ print"$protz | ";
+ @protocols=();
+ #SOURCE
+ my $ipfireiface;
+ &getcolor($$hash{$key}[3],$$hash{$key}[4],\%customhost);
print"";
+ if ($$hash{$key}[3] eq 'ipfire_src'){
+ $ipfireiface='Interface ';
+ }
if ($$hash{$key}[3] eq 'std_net_src'){
print &get_name($$hash{$key}[4]);
+ }elsif ($$hash{$key}[3] eq 'src_addr'){
+ my ($split1,$split2) = split("/",$$hash{$key}[4]);
+ if ($split2 eq '32'){
+ print $split1;
+ }else{
+ print $$hash{$key}[4];
+ }
+ }elsif ($$hash{$key}[4] eq 'RED1'){
+ print "$ipfireiface $Lang::tr{'fwdfw red'}";
}else{
- print $$hash{$key}[4];
+ print "$$hash{$key}[4]";
}
$tdcolor='';
+ #SOURCEPORT
&getsrcport(\%$hash,$key);
+ #Is this a SNAT rule?
+ if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
+ my $net=&get_name($$hash{$key}[29]);
+ if ( ! $net){ $net=$$hash{$key}[29];}
+ print" ->$net";
+ if ($$hash{$key}[30] ne ''){
+ print": $$hash{$key}[30]";
+ }
+ }
if ($$hash{$key}[17] eq 'ON'){
$log="/images/on.gif";
}else{
$log="/images/off.gif";
}
+ #LOGGING
print<
-
+ |
END
- &getcolor($$hash{$key}[5],$$hash{$key}[6]);
+ #TARGET
+ &getcolor($$hash{$key}[5],$$hash{$key}[6],\%customhost);
print<
END
- if ($$hash{$key}[5] eq 'std_net_tgt'){
- print &get_name($$hash{$key}[6]);
+ #Is this a DNAT rule?
+ if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
+ print "Firewall ($$hash{$key}[29])";
+ if($$hash{$key}[30] ne ''){
+ $$hash{$key}[30]=~ tr/|/,/;
+ print": $$hash{$key}[30]";
+ }
+ print" ->";
+ }
+ 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}[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 "$ipfireiface ".&get_name($$hash{$key}[6]);
+ }else{
+ print $$hash{$key}[6];
+ }
+ }elsif ($$hash{$key}[5] eq 'tgt_addr'){
+ my ($split1,$split2) = split("/",$$hash{$key}[6]);
+ if ($split2 eq '32'){
+ print $split1;
+ }else{
+ print $$hash{$key}[6];
+ }
}else{
- print $$hash{$key}[6];
+ print "$$hash{$key}[6]";
}
$tdcolor='';
+ #TARGETPORT
&gettgtport(\%$hash,$key);
print"";
- #Get Protocol
- my $prot;
- if ($$hash{$key}[12]){ #target prot if manual
- $prot=$$hash{$key}[12];
- }elsif($$hash{$key}[8]){ #source prot if manual
- $prot=$$hash{$key}[8];
- }elsif($$hash{$key}[14] eq 'cust_srv'){
- $prot=&get_serviceports("service",$$hash{$key}[15]);
- }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
- $prot=&get_serviceports("group",$$hash{$key}[15]);
- }else{
- $prot=$Lang::tr{'all'};
- }
- print"$prot | ";
- if ($$hash{$key}[18] eq 'ON'){
- my @days=();
- if($$hash{$key}[19] ne ''){push (@days,$Lang::tr{'fwdfw wd_mon'});}
- if($$hash{$key}[20] ne ''){push (@days,$Lang::tr{'fwdfw wd_tue'});}
- if($$hash{$key}[21] ne ''){push (@days,$Lang::tr{'fwdfw wd_wed'});}
- if($$hash{$key}[22] ne ''){push (@days,$Lang::tr{'fwdfw wd_thu'});}
- if($$hash{$key}[23] ne ''){push (@days,$Lang::tr{'fwdfw wd_fri'});}
- if($$hash{$key}[24] ne ''){push (@days,$Lang::tr{'fwdfw wd_sat'});}
- if($$hash{$key}[25] ne ''){push (@days,$Lang::tr{'fwdfw wd_sun'});}
- my $weekdays=join(",",@days);
- if (@days){
- print"$weekdays   $$hash{$key}[26] - $$hash{$key}[27] | ";
- }
- }else{
- print"24/7 | ";
- }
+ #RULE ACTIVE
if($$hash{$key}[2] eq 'ON'){
$gif="/images/on.gif"
@@ -1987,139 +2304,165 @@ END
$gif="/images/off.gif"
}
print<
-
+ | |
-
-
-
+ |
+
- |
-
-
+ |
+
- |
+
END
if (exists $$hash{$key-1}){
print<
-
+ |
- |
+
END
}else{
print" | ";
}
if (exists $$hash{$key+1}){
print<
-
+ |
- |
+
END
}else{
print" | ";
}
#REMARK
- print"";
- print"$Lang::tr{'remark'}: $$hash{$key}[16] | ";
- }
- print" ";
- &Header::closebox();
- print " ";
- }
-}
-sub getcolor
-{
- my $nettype=shift;
- my $val=shift;
- if($optionsfw{'SHOWCOLORS'} eq 'on'){
- if ($nettype eq 'ovpn_n2n_src' || $nettype eq 'ovpn_n2n_tgt' || $nettype eq 'ovpn_net_src' || $nettype eq 'ovpn_net_tgt'|| $nettype eq 'ovpn_host_src' || $nettype eq 'ovpn_host_tgt'){
- $tdcolor="style='border: 2px solid $Header::colourovpn;'";
- return;
- }
- if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
- $tdcolor="style='border: 2px solid $Header::colourvpn;'";
- return;
- }
- foreach my $alias (sort keys %aliases)
- {
- if ($val eq $alias){
- $tdcolor="style='border: 2px solid red;'";
- return;
+ if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
+ print"";
+ print" | | $$hash{$key}[16] | ";
}
- }
- if ($val eq 'GREEN'){
- $tdcolor="style='border: 2px solid $Header::colourgreen;'";
- }elsif ($val eq 'ORANGE'){
- $tdcolor="style='border: 2px solid $Header::colourorange;'";
- }elsif ($val eq 'BLUE'){
- $tdcolor="style='border: 2px solid $Header::colourblue;'";
- }elsif ($val eq 'RED'){
- $tdcolor="style='border: 2px solid $Header::colourred;'";
- }elsif ($val eq 'IPFire' ){
- $tdcolor="style='border: 2px solid $Header::colourred;'";
- }elsif($val =~ /^(.*?)\/(.*?)$/){
- my ($sip,$scidr) = split ("/",$val);
- if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
- $tdcolor="style='border: 2px solid $Header::colourorange;'";
+ if ($$hash{$key}[18] eq 'ON'){
+ #TIMEFRAME
+ if ($$hash{$key}[18] eq 'ON'){
+ my @days=();
+ if($$hash{$key}[19] ne ''){push (@days,$Lang::tr{'fwdfw wd_mon'});}
+ if($$hash{$key}[20] ne ''){push (@days,$Lang::tr{'fwdfw wd_tue'});}
+ if($$hash{$key}[21] ne ''){push (@days,$Lang::tr{'fwdfw wd_wed'});}
+ if($$hash{$key}[22] ne ''){push (@days,$Lang::tr{'fwdfw wd_thu'});}
+ if($$hash{$key}[23] ne ''){push (@days,$Lang::tr{'fwdfw wd_fri'});}
+ if($$hash{$key}[24] ne ''){push (@days,$Lang::tr{'fwdfw wd_sat'});}
+ if($$hash{$key}[25] ne ''){push (@days,$Lang::tr{'fwdfw wd_sun'});}
+ my $weekdays=join(",",@days);
+ if (@days){
+ print"";
+ print" | | $weekdays $$hash{$key}[26] - $$hash{$key}[27] | ";
+ }
+ }
}
- if ( &General::IpInSubnet($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
- $tdcolor="style='border: 2px solid $Header::colourgreen;'";
+ print" | ";
+ }
+ print" ";
+ #SHOW FINAL RULE
+ print "";
+ my $col;
+ if ($config eq '/var/ipfire/forward/config'){
+ my $pol='fwdfw '.$fwdfwsettings{'POLICY'};
+ if ($fwdfwsettings{'POLICY'} eq 'MODE1'){
+ $col="bgcolor='darkred'";
+ }else{
+ $col="bgcolor='green'";
}
- if ( &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
- $tdcolor="style='border: 2px solid $Header::colourblue;'";
+ &show_defaultrules($col,$pol);
+ }elsif ($config eq '/var/ipfire/forward/outgoing'){
+ if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){
+ $col="bgcolor='darkred'";
+ print"$Lang::tr{'fwdfw final_rule'} | $Lang::tr{'fwdfw pol block'} | ";
+ }else{
+ $col="bgcolor='green'";
+ print"$Lang::tr{'fwdfw final_rule'} | $Lang::tr{'fwdfw pol allow'} | ";
}
- }elsif ($val eq 'Default IP'){
- $tdcolor="style='border: 2px solid red;'";
}else{
- $tdcolor='';
+ print"$Lang::tr{'fwdfw final_rule'} | $Lang::tr{'fwdfw pol block'} | ";
}
- }
-}
-sub fillselect
-{
- my %hash=%{(shift)};
- my $val=shift;
- my $key;
- foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
- if($hash{$key}[0] eq $val){
- print"$hash{$key}[0]";
- }else{
- print"$hash{$key}[0]";
+ print" ";
+ print " ";
+ print "
";
+ &Header::closebox();
+ }else{
+ if ($optionsfw{'SHOWTABLES'} eq 'on'){
+ print "$title1 ";
+ print"$Lang::tr{'fwhost empty'} | ";
+ my $col;
+ if ($config eq '/var/ipfire/forward/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/forward/outgoing'){
+ print "";
+ my $pol='fwdfw '.$fwdfwsettings{'POLICY1'};
+ if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){
+ $col="bgcolor='darkred'";
+ print"$Lang::tr{'fwdfw final_rule'} | $Lang::tr{'fwdfw pol block'} | ";
+ }else{
+ $col="bgcolor='green'";
+ print"$Lang::tr{'fwdfw final_rule'} | $Lang::tr{'fwdfw pol allow'} | ";
+ }
+ }else{
+ print "";
+ print"$Lang::tr{'fwdfw final_rule'} | $Lang::tr{'fwdfw pol block'} | ";
+ }
+ print"
";
}
}
}
-sub rules
-{
- if (!-f "${General::swroot}/forward/reread"){
- system("touch ${General::swroot}/forward/reread");
- system("touch ${General::swroot}/fwhosts/reread");
- }
-}
-sub reread_rules
+&Header::closebigbox();
+&Header::closepage();
+
+sub show_defaultrules
{
- system("/usr/local/bin/forwardfwctrl");
- if ( -f "${General::swroot}/forward/reread"){
- system("rm ${General::swroot}/forward/reread");
- system("rm ${General::swroot}/fwhosts/reread");
+ my $col=shift;
+ my $pol=shift;
+ #STANDARD RULES (From WIKI)
+ print" ";
+ if ($col eq "bgcolor='green'"){
+ print "
";
+ my $blue = " $Lang::tr{'blue'} ($Lang::tr{'fwdfw pol block'})" if (&Header::blue_used());
+ my $orange = " $Lang::tr{'orange'} ($Lang::tr{'fwdfw pol block'})" if (&Header::orange_used());
+ my $blue1 = " $Lang::tr{'blue'} ($Lang::tr{'fwdfw pol allow'})" if (&Header::blue_used());
+ my $orange1 = " $Lang::tr{'orange'} ($Lang::tr{'fwdfw pol allow'})" if (&Header::orange_used());
+ print"$Lang::tr{'green'} | $Lang::tr{'red'} ($Lang::tr{'fwdfw pol allow'}) | ";
+ print"$orange1 | " if (&Header::orange_used());
+ print"$blue1 | " if (&Header::blue_used());
+ print" ";
+ if (&Header::orange_used()){
+ print"$Lang::tr{'orange'} | $Lang::tr{'red'} ($Lang::tr{'fwdfw pol allow'}) | $Lang::tr{'green'} ($Lang::tr{'fwdfw pol block'}) | ";
+ print"$blue | " if (&Header::blue_used());
+ print" ";
+ }
+ if (&Header::blue_used()){
+ print"$Lang::tr{'blue'} | $Lang::tr{'red'} ($Lang::tr{'fwdfw pol allow'}) | ";
+ print"$orange | " if (&Header::orange_used());
+ print" $Lang::tr{'green'} ($Lang::tr{'fwdfw pol block'}) | ";
+ print" ";
+ }
+ print"$Lang::tr{'fwdfw final_rule'} | $Lang::tr{'fwdfw pol allow'} | ";
+ }elsif($col eq "bgcolor='darkred'"){
+ print "";
+ print"$Lang::tr{'fwdfw final_rule'} | $Lang::tr{'fwdfw pol block'} | ";
}
}
-&Header::closebigbox();
-&Header::closepage();
| |