X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fforwardfw.cgi;h=e3bbe5900156c7a45a77eaf8949d9c960b9c5656;hp=737ffcbf67478c1634789282136a79994635e022;hb=35f95ba741115576b9d5d695183d24f8b9523327;hpb=f8bf364f0d758902de954f8e43bf372d3259929e diff --git a/html/cgi-bin/forwardfw.cgi b/html/cgi-bin/forwardfw.cgi index 737ffcbf6..e3bbe5900 100755 --- a/html/cgi-bin/forwardfw.cgi +++ b/html/cgi-bin/forwardfw.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2012 # +# Copyright (C) 2013 Alexander Marx # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -19,7 +19,6 @@ # # ############################################################################### - use strict; use Sort::Naturally; no warnings 'uninitialized'; @@ -64,7 +63,6 @@ my %aliases=(); my %optionsfw=(); my %ifaces=(); -my $VERSION='0.9.9.10'; my $color; my $confignet = "${General::swroot}/fwhosts/customnetworks"; my $confighost = "${General::swroot}/fwhosts/customhosts"; @@ -99,6 +97,27 @@ my @protocols; &Header::getcgihash(\%fwdfwsettings); &Header::openpage($Lang::tr{'fwdfw menu'}, 1, ''); &Header::openbigbox('100%', 'center',$errormessage); +#### JAVA SCRIPT #### +print< + \$(document).ready(function() { + // Automatically select radio buttons when corresponding + // dropdown menu changes. + \$("select").change(function() { + var id = \$(this).attr("name"); + //When using SNAT or DNAT, check "USE NAT" Checkbox + if ( id === 'snat' || id === 'dnat') { + \$('#USE_NAT').prop('checked', true); + } + \$('#' + id).prop("checked", true); + }); + }); +function checkradio(a){ + \$(a).attr('checked', true); +} + +END + #### ACTION ##### if ($fwdfwsettings{'ACTION'} eq 'saverule') @@ -357,7 +376,7 @@ if ($fwdfwsettings{'ACTION'} eq 'copyrule') $fwdfwsettings{'copyfwrule'}='on'; &newrule; } -if ($fwdfwsettings{'ACTION'} eq '') +if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset') { &base; } @@ -366,7 +385,7 @@ sub addrule { &error; if (-f "${General::swroot}/forward/reread"){ - print "
    $Lang::tr{'fwhost reread'}

"; + print "
    $Lang::tr{'fwhost reread'}

"; } &Header::openbox('100%', 'left', $Lang::tr{'fwdfw menu'}); print "
"; @@ -380,8 +399,6 @@ sub base { &hint; &addrule; - print "

"; - print "

Version: $VERSION
"; } sub changerule { @@ -412,7 +429,9 @@ sub checksource } if ($fwdfwsettings{'isip'} ne 'on'){ - if (&General::validmac($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';} + if (&General::validmac($fwdfwsettings{'src_addr'})){ + $fwdfwsettings{'ismac'}='on'; + } } if ($fwdfwsettings{'isip'} eq 'on'){ ##check if ip is valid @@ -424,12 +443,6 @@ sub checksource $ip=&General::ip2dec($ip); $ip=&General::dec2ip($ip); #check if net or broadcast - my @tmp= split (/\./,$ip); - if (($tmp[3] eq "0") || ($tmp[3] eq "255")) - { - $errormessage=$Lang::tr{'fwhost err hostip'}."
"; - return $errormessage; - } $fwdfwsettings{'src_addr'}="$ip/$subnet"; if(!&General::validipandmask($fwdfwsettings{'src_addr'})){ $errormessage.=$Lang::tr{'fwdfw err src_addr'}."
"; @@ -977,7 +990,7 @@ print< - "; #custom networks if (! -z $confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ - print""; } #custom hosts if (! -z $confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ - print""; } #custom groups if (! -z $configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ - print"
$Lang::tr{'fwhost stdnet'}
$Lang::tr{'fwhost stdnet'}
$Lang::tr{'fwhost cust net'}
$Lang::tr{'fwhost cust net'}
$Lang::tr{'fwhost cust addr'}
$Lang::tr{'fwhost cust addr'}
$Lang::tr{'fwhost cust grp'}
$Lang::tr{'fwhost cust grp'}
"; # CCD networks if( ! -z $configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ - print""; } #OVPN CCD Hosts foreach my $key (sort { ncmp($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){ if ($ccdhost{$key}[33] ne '' ){ - print"" ; + print"" ; } if ($show eq '1'){$show='';print"";} #OVPN N2N foreach my $key (sort { ncmp($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){ if ($ccdhost{$key}[3] eq 'net'){ - print"" ; + print"" ; } if ($show eq '1'){$show='';print"";} #IPsec netze @@ -1068,11 +1081,11 @@ END } } if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){ - print""; + print""; } if ($show eq '1'){$show='';print"";} - print"
$Lang::tr{'fwhost ccdnet'}$Lang::tr{'fwhost ccdnet'}
$Lang::tr{'fwhost ccdhost'}
$Lang::tr{'fwhost ccdhost'}$Lang::tr{'fwhost ccdhost'}
$Lang::tr{'fwhost ccdhost'}
$Lang::tr{'fwhost ovpn_n2n'}:
$Lang::tr{'fwhost ovpn_n2n'}:$Lang::tr{'fwhost ovpn_n2n'}
$Lang::tr{'fwhost ovpn_n2n'}
$Lang::tr{'fwhost ipsec net'}
$Lang::tr{'fwhost ipsec net'}
"; + print""; print"
"; } sub get_ip @@ -1227,47 +1240,55 @@ sub getcolor my $val=shift; my $hash=shift; if($optionsfw{'SHOWCOLORS'} eq 'on'){ + #custom Hosts + if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){ + foreach my $key (sort keys %$hash){ + if ($$hash{$key}[0] eq $val){ + $val=$$hash{$key}[2]; + } + } + } #standard networks if ($val eq 'GREEN'){ - $tdcolor="style='border: 1px solid $Header::colourgreen;'"; + $tdcolor="style='background-color: $Header::colourgreen;color:white;'"; return; }elsif ($val eq 'ORANGE'){ - $tdcolor="style='border: 1px solid $Header::colourorange;'"; + $tdcolor="style='background-color: $Header::colourorange;color:white;'"; return; }elsif ($val eq 'BLUE'){ - $tdcolor="style='border: 1px solid $Header::colourblue;'"; + $tdcolor="style='background-color: $Header::colourblue;color:white;'"; return; }elsif ($val eq 'RED' ||$val eq 'RED1' ){ - $tdcolor="style='border: 1px solid $Header::colourred;'"; + $tdcolor="style='background-color: $Header::colourred;color:white;'"; return; }elsif ($val eq 'IPFire' ){ - $tdcolor="style='border: 1px solid $Header::colourred;'"; + $tdcolor="style='background-color: $Header::colourred;color:white;'"; return; }elsif($val =~ /^(.*?)\/(.*?)$/){ my ($sip,$scidr) = split ("/",$val); if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){ - $tdcolor="style='border: 1px solid $Header::colourorange;'"; + $tdcolor="style='background-color: $Header::colourorange;color:white;'"; return; } if ( &General::IpInSubnet($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){ - $tdcolor="style='border: 1px solid $Header::colourgreen;'"; + $tdcolor="style='background-color: $Header::colourgreen;color:white;'"; return; } if ( &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){ - $tdcolor="style='border: 1px solid $Header::colourblue;'"; + $tdcolor="style='background-color: $Header::colourblue;color:white;'"; return; } }elsif ($val eq 'Default IP'){ - $tdcolor="style='border: 1px solid $Header::colourred;'"; + $tdcolor="style='background-color: $Header::colourred;color:white;'"; return; } - #Check if a manual IP is part of a VPN - if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr'){ + #Check if a manual IP or custom host is part of a VPN + if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){ #Check if IP is part of OpenVPN dynamic subnet my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'}); my ($c,$d) = split("/",$val); if (&General::IpInSubnet($c,$a,$b)){ - $tdcolor="style='border: 1px solid $Header::colourovpn;'"; + $tdcolor="style='background-color: $Header::colourovpn;color:white;'"; return; } #Check if IP is part of OpenVPN static subnet @@ -1275,7 +1296,7 @@ sub getcolor my ($a,$b) = split("/",$ccdnet{$key}[1]); $b =&General::iporsubtodec($b); if (&General::IpInSubnet($c,$a,$b)){ - $tdcolor="style='border: 1px solid $Header::colourovpn;'"; + $tdcolor="style='background-color: $Header::colourovpn;color:white;'"; return; } } @@ -1284,7 +1305,7 @@ sub getcolor if ($ccdhost{$key}[3] eq 'net'){ my ($a,$b) = split("/",$ccdhost{$key}[11]); if (&General::IpInSubnet($c,$a,$b)){ - $tdcolor="style='border: 1px solid $Header::colourovpn;'"; + $tdcolor="style='background-color: $Header::colourovpn;color:white;'"; return; } } @@ -1294,7 +1315,7 @@ sub getcolor my ($a,$b) = split("/",$ipsecsettings{'RW_NET'}); $b=&General::iporsubtodec($b); if (&General::IpInSubnet($c,$a,$b)){ - $tdcolor="style='border: 1px solid $Header::colourvpn;'"; + $tdcolor="style='background-color: $Header::colourvpn;color:white;'"; return; } } @@ -1302,33 +1323,25 @@ sub getcolor foreach my $key (sort keys %ipsecconf){ my ($a,$b) = split("/",$ipsecconf{$key}[11]); if (&General::IpInSubnet($c,$a,$b)){ - $tdcolor="style='border: 1px solid $Header::colourvpn;'"; + $tdcolor="style='background-color: $Header::colourvpn;color:white;'"; return; } } } #VPN networks 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: 1px solid $Header::colourovpn;'"; + $tdcolor="style='background-color: $Header::colourovpn;color:white;'"; return; } if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){ - $tdcolor="style='border: 1px solid $Header::colourvpn;'"; + $tdcolor="style='background-color: $Header::colourvpn;color:white;'"; return; } - #custom Hosts - if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){ - foreach my $key (sort keys %$hash){ - if ($$hash{$key}[0] eq $val){ - $val=$$hash{$key}[2]; - } - } - } #ALIASE foreach my $alias (sort keys %aliases) { if ($val eq $alias){ - $tdcolor="style='border: 1px solid $Header::colourred;'"; + $tdcolor="style='background-color:$Header::colourred;color:white;'"; return; } } @@ -1514,13 +1527,13 @@ sub newrule #------SOURCE------------------------------------------------------- print< - $Lang::tr{'fwdfw sourceip'}Firewall + $Lang::tr{'fwdfw sourceip'}Firewall END print"
END &gen_dd_block('src','grp1'); print<
+

+ END print" +
$Lang::tr{'fwdfw use srcport'} $Lang::tr{'fwdfw man port'}
$Lang::tr{'fwdfw targetip'}Firewall
$Lang::tr{'fwdfw targetip'}Firewall

END &gen_dd_block('tgt','grp2'); print<
+

- - - + - + + END - print""; + print""; $fwdfwsettings{'dnatport'}=~ tr/|/,/; - print""; + print""; print""; #SNAT - print""; - print""; + print"
$Lang::tr{'fwdfw use srv'}$Lang::tr{'fwhost cust service'}
$Lang::tr{'fwdfw use srv'}$Lang::tr{'fwhost cust service'}
$Lang::tr{'fwhost cust srvgrp'}
$Lang::tr{'fwhost cust srvgrp'}
$Lang::tr{'fwdfw man port'}
$Lang::tr{'fwdfw man port'}
$Lang::tr{'fwhost icmptype'}
$Lang::tr{'fwdfw use nat'}
$Lang::tr{'fwdfw dnat'}
$Lang::tr{'fwdfw use nat'}
$Lang::tr{'fwdfw dnat'}IPFire: Firewall:
Port:
Port:

$Lang::tr{'fwdfw snat'}IPFire:
$Lang::tr{'fwdfw snat'}Firewall:
"; + print""; print"
"; &Header::closebox(); #---Activate/logging/remark------------------------------------- @@ -1711,8 +1724,7 @@ END } } print""; - print"$Lang::tr{'remark'}:"; - #print"$Lang::tr{'remark'}:"; + print"$Lang::tr{'remark'}:"; if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){ print "$Lang::tr{'fwdfw rulepos'}:$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'} @@ -1746,15 +1758,13 @@ END - - - - - - - - - + + + + + + +

END #---ACTION------------------------------------------------------ if($fwdfwsettings{'updatefwrule'} ne 'on'){ @@ -1787,9 +1796,10 @@ END -
- -
+ +
+ +
END }else{ print<$title1
"; print""; - print""; + print""; foreach my $key (sort {$a <=> $b} keys %$hash){ $tdcolor=''; @tmpsrc=(); @@ -2158,7 +2168,7 @@ sub viewtablenew print""; #KEY print<$key   + END #RULETYPE (A,R,D) if ($$hash{$key}[0] eq 'ACCEPT'){ @@ -2232,12 +2242,11 @@ END #LOGGING print< -
-
+ END #TARGET &getcolor($$hash{$key}[5],$$hash{$key}[6],\%customhost); @@ -2287,51 +2296,45 @@ 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""; @@ -2339,7 +2342,7 @@ END #REMARK if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){ print""; - print""; + print""; } if ($$hash{$key}[18] eq 'ON'){ #TIMEFRAME @@ -2355,13 +2358,14 @@ END my $weekdays=join(",",@days); if (@days){ print""; - print""; + print""; } } } print""; } print"
#$Lang::tr{'fwdfw source'}Log$Lang::tr{'fwdfw target'}$Lang::tr{'fwdfw action'}
#$Lang::tr{'fwdfw source'}Log$Lang::tr{'fwdfw target'}$Lang::tr{'fwdfw action'}
$key   + - +
-
+
-
+
-
+
-
+
-
+
-
   $$hash{$key}[16]
   $$hash{$key}[16]
   $weekdays   $$hash{$key}[26] - $$hash{$key}[27]
   $weekdays   $$hash{$key}[26] - $$hash{$key}[27]
"; + #SHOW FINAL RULE print ""; my $col; if ($config eq '/var/ipfire/forward/config'){ @@ -2373,15 +2377,15 @@ END } &show_defaultrules($col,$pol); }elsif ($config eq '/var/ipfire/forward/outgoing'){ - my $pol='fwdfw '.$fwdfwsettings{'POLICY1'}; if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){ $col="bgcolor='darkred'"; + print""; }else{ $col="bgcolor='green'"; + print""; } - print""; }else{ - print""; + print""; } print"
$Lang::tr{'fwdfw final_rule'}$Lang::tr{'fwdfw pol block'}
$Lang::tr{'fwdfw final_rule'}$Lang::tr{'fwdfw pol allow'}
$Lang::tr{'fwdfw final_rule'}$Lang::tr{$pol}
$Lang::tr{'fwdfw final_rule'}$Lang::tr{'fwdfw MODE1'}
$Lang::tr{'fwdfw final_rule'}$Lang::tr{'fwdfw pol block'}
"; print "
"; @@ -2405,12 +2409,14 @@ END 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'}"; } - print"$Lang::tr{'fwdfw final_rule'}$Lang::tr{$pol}"; }else{ - print"$Lang::tr{'fwdfw final_rule'}$Lang::tr{'fwdfw MODE1'}"; + print ""; + print""; } print"
$Lang::tr{'fwdfw final_rule'}$Lang::tr{'fwdfw pol block'}


"; } @@ -2424,18 +2430,31 @@ sub show_defaultrules my $col=shift; my $pol=shift; #STANDARD RULES (From WIKI) - print"
"; - print ""; - if ($col eq "bgcolor='green'"){ - my $blue = " $Lang::tr{'blue'} ($Lang::tr{'fwdfw pol block'})" if $ifaces{'BLUE_DEV'}; - my $orange = " $Lang::tr{'orange'} ($Lang::tr{'fwdfw pol block'})" if $ifaces{'ORANGE_DEV'}; - my $blue1 = " $Lang::tr{'blue'} ($Lang::tr{'fwdfw pol allow'})" if $ifaces{'BLUE_DEV'}; - my $orange1 = " $Lang::tr{'orange'} ($Lang::tr{'fwdfw pol allow'})" if $ifaces{'ORANGE_DEV'}; - print""; - print""; - print"" if $ifaces{'BLUE_DEV'}; - print""; - }elsif($col eq "bgcolor='darkred'"){ - print""; - } + print"
$Lang::tr{'green'} $Lang::tr{'red'} ($Lang::tr{'fwdfw pol allow'})$orange1$blue1
$Lang::tr{'orange'} $Lang::tr{'red'} ($Lang::tr{'fwdfw pol allow'}) $Lang::tr{'green'} ($Lang::tr{'fwdfw pol block'})$blue
$Lang::tr{'blue'} $Lang::tr{'red'} ($Lang::tr{'fwdfw pol allow'})$orange $Lang::tr{'green'} ($Lang::tr{'fwdfw pol block'})
$Lang::tr{'fwdfw final_rule'} $Lang::tr{'fwdfw pol allow'}
$Lang::tr{'fwdfw final_rule'}$Lang::tr{$pol}
"; + 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""; + print"" if (&Header::orange_used()); + print"" if (&Header::blue_used()); + print""; + if (&Header::orange_used()){ + print""; + print"" if (&Header::blue_used()); + print""; + } + if (&Header::blue_used()){ + print""; + print"" if (&Header::orange_used()); + print""; + print""; + } + print""; + }elsif($col eq "bgcolor='darkred'"){ + print "
$Lang::tr{'green'} $Lang::tr{'red'} ($Lang::tr{'fwdfw pol allow'})$orange1$blue1
$Lang::tr{'orange'} $Lang::tr{'red'} ($Lang::tr{'fwdfw pol allow'}) $Lang::tr{'green'} ($Lang::tr{'fwdfw pol block'})$blue
$Lang::tr{'blue'} $Lang::tr{'red'} ($Lang::tr{'fwdfw pol allow'})$orange $Lang::tr{'green'} ($Lang::tr{'fwdfw pol block'})
$Lang::tr{'fwdfw final_rule'} $Lang::tr{'fwdfw pol allow'}
"; + print""; + } }
$Lang::tr{'fwdfw final_rule'}$Lang::tr{'fwdfw pol block'}