]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/firewall.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
25 use feature
'unicode_strings';
27 no warnings
'uninitialized';
29 # enable only the following on debugging purpose
31 #use CGI::Carp 'fatalsToBrowser';
33 require '/var/ipfire/general-functions.pl';
34 require "${General::swroot}/lang.pl";
35 require "${General::swroot}/header.pl";
36 require "/usr/lib/firewall/firewall-lib.pl";
38 unless (-d
"${General::swroot}/firewall") { system("mkdir ${General::swroot}/firewall"); }
39 unless (-e
"${General::swroot}/firewall/settings") { system("touch ${General::swroot}/firewall/settings"); }
40 unless (-e
"${General::swroot}/firewall/config") { system("touch ${General::swroot}/firewall/config"); }
41 unless (-e
"${General::swroot}/firewall/input") { system("touch ${General::swroot}/firewall/input"); }
42 unless (-e
"${General::swroot}/firewall/outgoing") { system("touch ${General::swroot}/firewall/outgoing"); }
46 my %defaultNetworks=();
50 my %customnetworks=();
52 my %customservicegrp=();
58 my %configoutgoingfw=();
70 my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE","IPv6","IPIP");
73 my $confignet = "${General::swroot}/fwhosts/customnetworks";
74 my $confighost = "${General::swroot}/fwhosts/customhosts";
75 my $configgrp = "${General::swroot}/fwhosts/customgroups";
76 my $configsrv = "${General::swroot}/fwhosts/customservices";
77 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
78 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
79 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
80 my $configipsec = "${General::swroot}/vpn/config";
81 my $configipsecrw = "${General::swroot}/vpn/settings";
82 my $configfwdfw = "${General::swroot}/firewall/config";
83 my $configinput = "${General::swroot}/firewall/input";
84 my $configoutgoing = "${General::swroot}/firewall/outgoing";
85 my $configovpn = "${General::swroot}/ovpn/settings";
86 my $fwoptions = "${General::swroot}/optionsfw/settings";
87 my $ifacesettings = "${General::swroot}/ethernet/settings";
90 my $ipgrp="${General::swroot}/outgoing/groups";
94 &General
::readhash
("${General::swroot}/firewall/settings", \
%fwdfwsettings);
95 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
96 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
97 &General
::readhash
($fwoptions, \
%optionsfw);
98 &General
::readhash
($ifacesettings, \
%ifaces);
99 &General
::readhash
("$configovpn", \
%ovpnsettings);
100 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
101 &General
::readhasharray
("$configipsec", \
%ipsecconf);
102 &Header
::showhttpheaders
();
103 &Header
::getcgihash
(\
%fwdfwsettings);
104 &Header
::openpage
($Lang::tr
{'firewall rules'}, 1, '');
105 &Header
::openbigbox
('100%', 'center',$errormessage);
106 #### JAVA SCRIPT ####
109 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
111 var update_protocol = function() {
112 var protocol = \$("#protocol").val();
114 if (protocol === undefined)
117 // Check if a template is/should be used.
118 if (protocol === "template") {
119 \$("#PROTOCOL_TEMPLATE").show();
121 \$("#PROTOCOL_TEMPLATE").hide();
124 // Check if we are dealing with a protocol, that knows ports.
125 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
126 \$("#PROTOCOL_PORTS").show();
128 \$("#PROTOCOL_PORTS").hide();
132 if (protocol === "ICMP") {
133 \$("#PROTOCOL_ICMP_TYPES").show();
135 \$("#PROTOCOL_ICMP_TYPES").hide();
139 \$(document).ready(function() {
140 \$("#protocol").change(update_protocol);
143 // Show/Hide elements when NAT checkbox is checked.
144 if (\$("#USE_NAT").attr("checked")) {
145 \$("#actions").hide();
150 // Show NAT area when "use nat" checkbox is clicked
151 \$("#USE_NAT").change(function() {
153 \$("#actions").toggle();
157 if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) {
158 \$("#TIME_CONSTRAINTS").hide();
160 \$("#USE_TIME_CONSTRAINTS").change(function() {
161 \$("#TIME_CONSTRAINTS").toggle();
164 // Limit concurrent connections per ip
165 if(!\$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").attr("checked")) {
166 \$("#LIMIT_CON").hide();
168 \$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").change(function() {
169 \$("#LIMIT_CON").toggle();
172 // Automatically select radio buttons when corresponding
173 // dropdown menu changes.
174 \$("select").change(function() {
175 var id = \$(this).attr("name");
176 \$('#' + id).prop("checked", true);
184 if ($fwdfwsettings{'ACTION'} eq 'saverule')
186 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
187 &General
::readhasharray
("$configinput", \
%configinputfw);
188 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
189 #Set Variables according to the JQuery code in protocol section
190 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')
192 if ($fwdfwsettings{'SRC_PORT'} ne '')
194 $fwdfwsettings{'USE_SRC_PORT'} = 'ON';
196 if ($fwdfwsettings{'TGT_PORT'} ne '')
198 $fwdfwsettings{'USESRV'} = 'ON';
199 $fwdfwsettings{'grp3'} = 'TGT_PORT';
202 if ($fwdfwsettings{'PROT'} eq 'template')
204 $fwdfwsettings{'USESRV'} = 'ON';
206 $errormessage=&checksource
;
207 if(!$errormessage){&checktarget
;}
208 if(!$errormessage){&checkrule
;}
210 #check if manual ip (source) is orange network
211 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
212 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
213 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
218 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
219 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
221 #check if we try to break rules
222 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
223 $errormessage=$Lang::tr
{'fwdfw err same'};
226 if($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
227 $fwdfwsettings{'config'}=$configinput;
228 $fwdfwsettings{'chain'} = 'INPUTFW';
229 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
230 #check if we have an identical rule already
231 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
232 foreach my $key (sort keys %configinputfw){
233 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'}"
234 eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27],$configinputfw{$key}[28],$configinputfw{$key}[29],$configinputfw{$key}[30],$configinputfw{$key}[31],$configinputfw{$key}[32],$configinputfw{$key}[33]"){
235 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
236 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
237 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
239 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
242 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
243 $fwdfwsettings{'nosave'} = 'on';
248 #check Rulepos on new Rule
249 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
250 $fwdfwsettings{'oldrulenumber'}=$maxkey;
251 foreach my $key (sort keys %configinputfw){
252 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'}"
253 eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27],$configinputfw{$key}[28],$configinputfw{$key}[29],$configinputfw{$key}[30],$configinputfw{$key}[31],$configinputfw{$key}[32],$configinputfw{$key}[33]"){
254 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
258 #check if we just close a rule
259 if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'} && $fwdfwsettings{'oldconcon'} eq $fwdfwsettings{'LIMIT_CON_CON'}) {
260 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
262 $fwdfwsettings{'nosave2'} = 'on';
266 if($fwdfwsettings{'nosave2'} ne 'on'){
267 &saverule
(\
%configinputfw,$configinput);
270 }elsif($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
272 $fwdfwsettings{'config'}=$configoutgoing;
273 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
274 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
275 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
276 foreach my $key (sort keys %configoutgoingfw){
277 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'}"
278 eq "$configoutgoingfw{$key}[0],$configoutgoingfw{$key}[2],$configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],$configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],$configoutgoingfw{$key}[7],$configoutgoingfw{$key}[8],$configoutgoingfw{$key}[9],$configoutgoingfw{$key}[10],$configoutgoingfw{$key}[11],$configoutgoingfw{$key}[12],$configoutgoingfw{$key}[13],$configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],$configoutgoingfw{$key}[17],$configoutgoingfw{$key}[18],$configoutgoingfw{$key}[19],$configoutgoingfw{$key}[20],$configoutgoingfw{$key}[21],$configoutgoingfw{$key}[22],$configoutgoingfw{$key}[23],$configoutgoingfw{$key}[24],$configoutgoingfw{$key}[25],$configoutgoingfw{$key}[26],$configoutgoingfw{$key}[27],$configoutgoingfw{$key}[28],$configoutgoingfw{$key}[29],$configoutgoingfw{$key}[30],$configoutgoingfw{$key}[31],$configinputfw{$key}[32],$configinputfw{$key}[33]"){
279 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
280 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
281 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
283 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
286 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
287 $fwdfwsettings{'nosave'} = 'on';
292 #check Rulepos on new Rule
293 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
294 $fwdfwsettings{'oldrulenumber'}=$maxkey;
295 foreach my $key (sort keys %configoutgoingfw){
296 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'}"
297 eq "$configoutgoingfw{$key}[0],$configoutgoingfw{$key}[2],$configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],$configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],$configoutgoingfw{$key}[7],$configoutgoingfw{$key}[8],$configoutgoingfw{$key}[9],$configoutgoingfw{$key}[10],$configoutgoingfw{$key}[11],$configoutgoingfw{$key}[12],$configoutgoingfw{$key}[13],$configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],$configoutgoingfw{$key}[17],$configoutgoingfw{$key}[18],$configoutgoingfw{$key}[19],$configoutgoingfw{$key}[20],$configoutgoingfw{$key}[21],$configoutgoingfw{$key}[22],$configoutgoingfw{$key}[23],$configoutgoingfw{$key}[24],$configoutgoingfw{$key}[25],$configoutgoingfw{$key}[26],$configoutgoingfw{$key}[27],$configoutgoingfw{$key}[28],$configoutgoingfw{$key}[29],$configoutgoingfw{$key}[30],$configoutgoingfw{$key}[31],$configinputfw{$key}[32],$configinputfw{$key}[33]"){
298 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
302 #check if we just close a rule
303 if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'}) {
304 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
305 $fwdfwsettings{'nosave2'} = 'on';
311 if ($fwdfwsettings{'nosave2'} ne 'on'){
312 &saverule
(\
%configoutgoingfw,$configoutgoing);
317 $fwdfwsettings{'config'}=$configfwdfw;
318 $fwdfwsettings{'chain'} = 'FORWARDFW';
319 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
320 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
321 #check if we have an identical rule already
322 foreach my $key (sort keys %configfwdfw){
323 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'}"
324 eq "$configfwdfw{$key}[0],$configfwdfw{$key}[2],$configfwdfw{$key}[3],$configfwdfw{$key}[4],$configfwdfw{$key}[5],$configfwdfw{$key}[6],$configfwdfw{$key}[7],$configfwdfw{$key}[8],$configfwdfw{$key}[9],$configfwdfw{$key}[10],$configfwdfw{$key}[11],$configfwdfw{$key}[12],$configfwdfw{$key}[13],$configfwdfw{$key}[14],$configfwdfw{$key}[15],$configfwdfw{$key}[18],$configfwdfw{$key}[19],$configfwdfw{$key}[20],$configfwdfw{$key}[21],$configfwdfw{$key}[22],$configfwdfw{$key}[23],$configfwdfw{$key}[24],$configfwdfw{$key}[25],$configfwdfw{$key}[26],$configfwdfw{$key}[27],$configfwdfw{$key}[28],$configfwdfw{$key}[29],$configfwdfw{$key}[30],$configfwdfw{$key}[31],$configinputfw{$key}[32],$configinputfw{$key}[33]"){
325 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
326 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
327 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
329 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
332 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
333 $fwdfwsettings{'nosave'} = 'on';
338 #check Rulepos on new Rule
339 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
340 $fwdfwsettings{'oldrulenumber'}=$maxkey;
341 foreach my $key (sort keys %configfwdfw){
342 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'}"
343 eq "$configfwdfw{$key}[0],$configfwdfw{$key}[2],$configfwdfw{$key}[3],$configfwdfw{$key}[4],$configfwdfw{$key}[5],$configfwdfw{$key}[6],$configfwdfw{$key}[7],$configfwdfw{$key}[8],$configfwdfw{$key}[9],$configfwdfw{$key}[10],$configfwdfw{$key}[11],$configfwdfw{$key}[12],$configfwdfw{$key}[13],$configfwdfw{$key}[14],$configfwdfw{$key}[15],$configfwdfw{$key}[18],$configfwdfw{$key}[19],$configfwdfw{$key}[20],$configfwdfw{$key}[21],$configfwdfw{$key}[22],$configfwdfw{$key}[23],$configfwdfw{$key}[24],$configfwdfw{$key}[25],$configfwdfw{$key}[26],$configfwdfw{$key}[27],$configfwdfw{$key}[28],$configfwdfw{$key}[29],$configfwdfw{$key}[30],$configfwdfw{$key}[31],$configinputfw{$key}[32],$configinputfw{$key}[33]"){
344 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
348 #check if we just close a rule
349 if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'} && $fwdfwsettings{'oldconcon'} eq $fwdfwsettings{'LIMIT_CON_CON'}) {
350 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
351 $fwdfwsettings{'nosave2'} = 'on';
355 #check max concurrent connections per ip address
356 if ($fwdfwsettings{'LIMIT_CON_CON'} eq 'ON'){
357 if (!($fwdfwsettings{'concon'} =~ /^(\d+)$/)) {
358 $errormessage.=$Lang::tr
{'fwdfw err concon'};
361 $fwdfwsettings{'concon'}='';
365 if ($fwdfwsettings{'nosave2'} ne 'on'){
366 &saverule
(\
%configfwdfw,$configfwdfw);
373 if($fwdfwsettings{'nosave2'} ne 'on'){
374 &General
::firewall_config_changed
();
379 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
383 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
386 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
387 foreach my $key (sort keys %togglehash){
388 if ($key eq $fwdfwsettings{'key'}){
389 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
392 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
393 &General
::firewall_config_changed
();
396 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
399 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
400 foreach my $key (sort keys %togglehash){
401 if ($key eq $fwdfwsettings{'key'}){
402 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
405 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
406 &General
::firewall_config_changed
();
409 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
411 &General
::firewall_reload
();
414 if ($fwdfwsettings{'ACTION'} eq 'editrule')
416 $fwdfwsettings{'updatefwrule'}='on';
419 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
423 if ($fwdfwsettings{'ACTION'} eq 'moveup')
428 if ($fwdfwsettings{'ACTION'} eq 'movedown')
433 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
435 $fwdfwsettings{'copyfwrule'}='on';
438 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
447 &Header
::openbox
('100%', 'left', "");
449 <form method="POST" action="">
450 <table border='0' width="100%">
453 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'>
456 if (&General
::firewall_needs_reload
()) {
458 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'>
482 $fwdfwsettings{'updatefwrule'}='';
483 $fwdfwsettings{'config'}=$oldchain;
484 $fwdfwsettings{'nobase'}='on';
490 #check ip-address if manual
491 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
492 #check if ip with subnet
493 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
494 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
495 $subnet = &General
::iporsubtocidr
($subnet);
496 $fwdfwsettings{'isip'}='on';
499 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
500 $ip=$fwdfwsettings{'src_addr'};
502 $fwdfwsettings{'isip'}='on';
505 if ($fwdfwsettings{'isip'} ne 'on'){
506 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
507 $fwdfwsettings{'ismac'}='on';
510 if ($fwdfwsettings{'isip'} eq 'on'){
511 ##check if ip is valid
512 if (! &General
::validip
($ip)){
513 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
514 return $errormessage;
516 #check and form valid IP
517 $ip=&General
::ip2dec
($ip);
518 $ip=&General
::dec2ip
($ip);
519 #check if net or broadcast
520 $fwdfwsettings{'src_addr'}="$ip/$subnet";
521 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
522 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
523 return $errormessage;
526 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
527 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
528 return $errormessage;
530 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
531 $fwdfwsettings{'grp1'}='std_net_src';
532 $fwdfwsettings{$fwdfwsettings{'grp1'}} = 'ALL';
536 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
537 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
538 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
542 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
544 #change dashes with :
547 push(@values,"1:65535");
550 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
551 push(@values,"1:$2");
554 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
555 push(@values,"$1:65535");
558 $errormessage .= &General
::validportrange
($_, 'destination');
563 if (&General
::validport
($_)){
570 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
572 return $errormessage;
577 &General
::readhasharray
("$configsrv", \
%customservice);
578 #check DNAT settings (has to be single Host and single Port or portrange)
579 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
580 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
581 #check if manual ip is a single Host (if set)
582 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
583 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
584 my @tmp1= split ("/",$tmp[3]);
585 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
587 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
588 return $errormessage;
591 #check if Port is a single Port or portrange
592 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
593 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
594 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
595 return $errormessage;
597 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
598 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
599 return $errormessage;
603 if ($fwdfwsettings{'grp2'} ne 'ipfire'){
604 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
605 return $errormessage;
609 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
610 #check if ip with subnet
611 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
612 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
613 $subnet = &General
::iporsubtocidr
($subnet);
616 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
617 $ip=$fwdfwsettings{'tgt_addr'};
620 #check if ip is valid
621 if (! &General
::validip
($ip)){
622 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
623 return $errormessage;
625 #check and form valid IP
626 $ip=&General
::ip2dec
($ip);
627 $ip=&General
::dec2ip
($ip);
628 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
629 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
630 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
631 return $errormessage;
633 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
634 $fwdfwsettings{'grp2'}='std_net_tgt';
635 $fwdfwsettings{$fwdfwsettings{'grp2'}} = 'ALL';
637 #check for mac in targetgroup
638 if ($fwdfwsettings{'grp2'} eq 'cust_grp_tgt'){
639 &General
::readhasharray
("$configgrp", \
%customgrp);
640 &General
::readhasharray
("$confighost", \
%customhost);
641 foreach my $grpkey (sort keys %customgrp){
642 foreach my $hostkey (sort keys %customhost){
643 if ($customgrp{$grpkey}[2] eq $customhost{$hostkey}[0] && $customhost{$hostkey}[1] eq 'mac'){
644 $hint=$Lang::tr
{'fwdfw hint mac'};
651 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
653 if ($fwdfwsettings{'USESRV'} eq 'ON'){
654 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
655 $fwdfwsettings{'TGT_PROT'}='';
656 $fwdfwsettings{'ICMP_TGT'}='';
657 $fwdfwsettings{'TGT_PORT'}='';
659 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
660 $fwdfwsettings{'TGT_PROT'}='';
661 $fwdfwsettings{'ICMP_TGT'}='';
662 $fwdfwsettings{'TGT_PORT'}='';
663 #check target service
664 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
665 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
668 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
669 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
670 if ($fwdfwsettings{'TGT_PORT'} ne ''){
671 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
672 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
673 return $errormessage;
675 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
679 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
681 #change dashes with :
684 push(@values,"1:65535");
687 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
688 push(@values,"1:$2");
691 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
692 push(@values,"$1:65535");
695 $errormessage .= &General
::validportrange
($_, 'destination');
700 if (&General
::validport
($_)){
703 $errormessage=$Lang::tr
{'fwdfw err tgt_port'};
704 return $errormessage;
708 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
710 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
711 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
712 $fwdfwsettings{'TGT_PORT'} = '';
713 $fwdfwsettings{'ICMP_TGT'} = '';
714 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
715 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
716 $fwdfwsettings{'TGT_PORT'} = '';
717 $fwdfwsettings{'ICMP_TGT'}='';
718 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
719 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
720 $fwdfwsettings{'TGT_PORT'} = '';
721 $fwdfwsettings{'ICMP_TGT'}='';
722 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
723 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
724 $fwdfwsettings{'TGT_PORT'} = '';
729 if ($fwdfwsettings{'USESRV'} ne 'ON'){
730 $fwdfwsettings{'grp3'}='';
731 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
732 $fwdfwsettings{'ICMP_TGT'}='';
735 if($fwdfwsettings{'TIME'} eq 'ON'){
736 if($fwdfwsettings{'TIME_MON'} eq '' && $fwdfwsettings{'TIME_TUE'} eq '' && $fwdfwsettings{'TIME_WED'} eq '' && $fwdfwsettings{'TIME_THU'} eq '' && $fwdfwsettings{'TIME_FRI'} eq '' && $fwdfwsettings{'TIME_SAT'} eq '' && $fwdfwsettings{'TIME_SUN'} eq ''){
737 $errormessage=$Lang::tr
{'fwdfw err time'};
738 return $errormessage;
741 return $errormessage;
746 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
747 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
748 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
749 if ($fwdfwsettings{'dnatport'} eq "*") {
750 $fwdfwsettings{'dnatport'}="1:65535";
752 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
753 $fwdfwsettings{'dnatport'} = "1:$2";
755 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
756 $fwdfwsettings{'dnatport'} ="$1:65535";
761 if ($val =~ "," || $val>65536 || $val<0){
768 #check valid port for NAT
769 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
770 #RULE_ACTION must be ACCEPT if we use NAT
771 $fwdfwsettings{'RULE_ACTION'} = 'ACCEPT';
773 #if no dnat or snat selected errormessage
774 if ($fwdfwsettings{'nat'} eq ''){
775 $errormessage=$Lang::tr
{'fwdfw dnat nochoice'};
779 #if using snat, the external port has to be empty
780 if ($fwdfwsettings{'nat'} eq 'snat' && $fwdfwsettings{'dnatport'} ne ''){
781 $errormessage=$Lang::tr
{'fwdfw dnat extport'};
784 #if no dest port is given in nat area, take target host port
785 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
786 if($fwdfwsettings{'TGT_PORT'} eq '' && $fwdfwsettings{'dnatport'} ne '' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')){
787 $errormessage=$Lang::tr
{'fwdfw dnat porterr2'};
790 #check if port given in nat area is a single valid port or portrange
791 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
792 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
793 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
795 #get service Protocol and Port
796 foreach my $key (sort keys %customservice){
797 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
798 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
799 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
801 $custsrvport= $customservice{$key}[1];
804 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
806 #check if DNAT port is multiple
807 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
808 my @parts=split(",",$fwdfwsettings{'dnatport'});
812 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
814 #change dashes with :
817 push(@values,"1:65535");
820 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
821 push(@values,"1:$2");
824 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
825 push(@values,"$1:65535");
828 $errormessage .= &General
::validportrange
($_, 'destination');
833 if (&General
::validport
($_)){
840 $fwdfwsettings{'dnatport'}=join("|",@values);
842 #check if a rule with prot tcp or udp and ports is edited and now prot is "all", then delete all ports
843 if($fwdfwsettings{'PROT'} eq ''){
844 $fwdfwsettings{'dnatport'}='';
848 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
849 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
851 #check if source and target identical
852 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
853 $errormessage=$Lang::tr
{'fwdfw err same'};
854 return $errormessage;
856 #get source and targetip address if possible
857 my ($sip,$scidr,$tip,$tcidr);
858 ($sip,$scidr)=&get_ip
("src","grp1");
859 ($tip,$tcidr)=&get_ip
("tgt","grp2");
860 #check same iprange in source and target
861 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
862 my $networkip1=&General
::getnetworkip
($sip,$scidr);
863 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
864 if ($scidr gt $tcidr){
865 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
866 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
868 }elsif($scidr eq $tcidr && $scidr eq '32'){
869 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
870 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
871 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
872 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
873 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
876 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
877 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
881 #when icmp selected, no source and targetport allowed
882 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')){
883 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
886 #change protocol if prot not equal dest single service
887 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
888 foreach my $key (sort keys %customservice){
889 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
890 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
891 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
897 #check source and destination protocol if source manual and dest servicegroup
898 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
899 $fwdfwsettings{'PROT'} = '';
901 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
902 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
904 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
905 $fwdfwsettings{'USE_SRC_PORT'}='';
906 $fwdfwsettings{'SRC_PORT'}='';
907 #$fwdfwsettings{'USESRV'}='';
908 $fwdfwsettings{'TGT_PORT'}='';
909 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
910 foreach my $key (keys %icmptypes){
911 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
912 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
915 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
916 $fwdfwsettings{'USE_SRC_PORT'}='';
917 $fwdfwsettings{'SRC_PORT'}='';
918 $fwdfwsettings{'ICMP_TYPES'}='';
919 $fwdfwsettings{'USESRV'}='';
920 $fwdfwsettings{'TGT_PORT'}='';
921 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
922 $fwdfwsettings{'USE_SRC_PORT'}='';
923 $fwdfwsettings{'SRC_PORT'}='';
924 $fwdfwsettings{'ICMP_TYPES'}='';
925 $fwdfwsettings{'USESRV'}='';
926 $fwdfwsettings{'TGT_PORT'}='';
927 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
928 $fwdfwsettings{'USE_SRC_PORT'}='';
929 $fwdfwsettings{'SRC_PORT'}='';
930 $fwdfwsettings{'ICMP_TYPES'}='';
931 $fwdfwsettings{'USESRV'}='';
932 $fwdfwsettings{'TGT_PORT'}='';
933 }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){
934 $fwdfwsettings{'USE_SRC_PORT'}='';
935 $fwdfwsettings{'SRC_PORT'}='';
936 $fwdfwsettings{'ICMP_TYPES'}='';
937 $fwdfwsettings{'USESRV'}='';
938 $fwdfwsettings{'TGT_PORT'}='';
939 }elsif($fwdfwsettings{'PROT'} eq 'IPv6'){
940 $fwdfwsettings{'USE_SRC_PORT'}='';
941 $fwdfwsettings{'SRC_PORT'}='';
942 $fwdfwsettings{'ICMP_TYPES'}='';
943 $fwdfwsettings{'USESRV'}='';
944 $fwdfwsettings{'TGT_PORT'}='';
945 }elsif($fwdfwsettings{'PROT'} eq 'IPIP'){
946 $fwdfwsettings{'USE_SRC_PORT'}='';
947 $fwdfwsettings{'SRC_PORT'}='';
948 $fwdfwsettings{'ICMP_TYPES'}='';
949 $fwdfwsettings{'USESRV'}='';
950 $fwdfwsettings{'TGT_PORT'}='';
951 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP'){
952 $fwdfwsettings{'ICMP_TYPES'}='';
953 $fwdfwsettings{'SRC_PORT'}='';
954 $fwdfwsettings{'TGT_PORT'}='';
955 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
956 $fwdfwsettings{'ICMP_TYPES'}='';
962 #Test if manual IP is part of static OpenVPN networks
963 &General
::readhasharray
("$configccdnet", \
%ccdnet);
964 foreach my $key (sort keys %ccdnet){
965 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
966 my $sub=&General
::iporsubtodec
($vpnsubnet);
967 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
971 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
972 # because if one creates a custom host with the ip, we need to check the color there!
973 # It does not make sense to check this here
975 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
976 # Is also checked in getcolor
978 # Test if manual ip is part of an IPsec Network is also checked in getcolor
988 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
989 foreach my $key (sort {$a <=> $b} keys %delhash){
990 if ($key >= $fwdfwsettings{'key'}) {
992 if (exists $delhash{$next}) {
993 foreach my $i (0 .. $#{$delhash{$next}}) {
994 $delhash{$key}[$i] = $delhash{$next}[$i];
999 # Remove the very last entry.
1000 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
1001 delete $delhash{$last_key};
1003 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
1004 &General
::firewall_config_changed
();
1006 if($fwdfwsettings{'nobase'} ne 'on'){
1019 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
1020 foreach my $key (sort keys %configfwdfw){
1021 if ($key eq $key1 ){
1022 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
1025 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
1026 &General
::firewall_config_changed
();
1030 if ($errormessage) {
1031 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1032 print "<class name='base'>$errormessage\n";
1033 print " </class>\n";
1034 &Header
::closebox
();
1039 my %hash=%{(shift)};
1042 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
1043 if($hash{$key}[0] eq $val){
1044 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1046 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1056 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1057 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1058 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1059 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1060 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1061 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1062 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1063 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1064 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1065 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1066 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1067 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1068 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1069 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1070 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1071 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1072 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1073 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1074 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1076 <table width='100%' border='0'>
1077 <tr><td width='50%' valign='top'>
1078 <table width='95%' border='0'>
1079 <tr><td width='1%'><input type='radio' name='$grp' id='std_net_$srctgt' 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;'>
1081 foreach my $network (sort keys %defaultNetworks)
1083 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1084 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1085 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1086 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1087 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1088 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1089 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1090 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1091 if ($ifaces{$defnet}){
1092 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1094 print ">$network</option>";
1097 print"</select></td></tr>";
1099 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1100 print"<tr><td><input type='radio' name='$grp' id='cust_net_$srctgt' 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;'>";
1101 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1102 print"</select></td>";
1105 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1106 print"<tr><td><input type='radio' name='$grp' id='cust_host_$srctgt' 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;'>";
1107 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1108 print"</select></td>";
1111 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1112 print"<tr><td valign='top'><input type='radio' name='$grp' id='cust_grp_$srctgt' 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;'>";
1113 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1114 if($helper ne $customgrp{$key}[0] && $customgrp{$key}[2] ne 'none'){
1116 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1117 print ">$customgrp{$key}[0]</option>";
1119 $helper=$customgrp{$key}[0];
1121 print"</select></td>";
1123 #End left table. start right table (vpn)
1124 print"</tr></table></td><td valign='top'><table width='95%' border='0' align='right'><tr>";
1126 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1127 print"<td width='1%'><input type='radio' name='$grp' id='ovpn_net_$srctgt' 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;'>";
1128 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1129 print"</select></td></tr>";
1132 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1133 if ($ccdhost{$key}[33] ne '' ){
1134 print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_host_$srctgt' 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 '');
1136 print "<option value='$ccdhost{$key}[1]'";
1137 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1138 print ">$ccdhost{$key}[1]</option>";
1141 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1142 print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_host_$srctgt' 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>" ;
1144 if ($show eq '1'){$show='';print"</select></td></tr>";}
1146 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1147 if ($ccdhost{$key}[3] eq 'net'){
1148 print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_n2n_$srctgt' 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 '');
1150 print "<option value='$ccdhost{$key}[1]'";
1151 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1152 print ">$ccdhost{$key}[1]</option>";
1155 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1156 print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_n2n_$srctgt' 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>" ;
1158 if ($show eq '1'){$show='';print"</select></td></tr>";}
1160 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1161 if ($ipsecconf{$key}[3] eq 'net' || ($optionsfw{'SHOWDROPDOWN'} eq 'on' && $ipsecconf{$key}[3] ne 'host')){
1162 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 '');
1165 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1166 print ">$ipsecconf{$key}[1]</option>";
1169 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1170 print"<tr><td valign='top'><input type='radio' name='$grp' id='ipsec_net_$srctgt' 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>";
1172 if ($show eq '1'){$show='';print"</select></td></tr>";}
1175 print"</td></tr></table><br>";
1183 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1184 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1185 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1186 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1187 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1188 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1189 $a=$netsettings{'GREEN_NETADDRESS'};
1190 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1191 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1192 $a=$netsettings{'ORANGE_NETADDRESS'};
1193 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1194 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1195 $a=$netsettings{'BLUE_NETADDRESS'};
1196 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1197 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1198 &General
::readhash
("$configovpn",\
%ovpnsettings);
1199 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1200 $b=&General
::iporsubtocidr
($b);
1202 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1203 &General
::readhasharray
("$confignet", \
%customnetwork);
1204 foreach my $key (keys %customnetwork){
1205 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1206 $a=$customnetwork{$key}[1];
1207 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1210 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1211 &General
::readhasharray
("$confighost", \
%customhost);
1212 foreach my $key (keys %customhost){
1213 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1214 if ($customhost{$key}[1] eq 'ip'){
1215 ($a,$b)=split (/\//,$customhost{$key}[2]);
1216 $b=&General
::iporsubtocidr
($b);
1218 if ($grp eq 'grp2'){
1219 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1231 &General
::setup_default_networks
(\
%defaultNetworks);
1232 foreach my $network (sort keys %defaultNetworks)
1234 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1239 my %hash=%{(shift)};
1241 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1242 $hash{$key}[10]=~ s/\|/,/g;
1243 print": $hash{$key}[10]";
1244 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1245 print": <br>$hash{$key}[9] ";
1250 my %hash=%{(shift)};
1254 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1255 if($hash{$key}[14] eq 'cust_srv'){
1256 &General
::readhasharray
("$configsrv", \
%customservice);
1257 foreach my $i (sort keys %customservice){
1258 if($customservice{$i}[0] eq $hash{$key}[15]){
1259 $service = $customservice{$i}[0];
1262 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1263 $service=$hash{$key}[15];
1264 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1265 $hash{$key}[15]=~ s/\|/,/g;
1266 $service=$hash{$key}[15];
1273 sub get_serviceports
1277 &General
::readhasharray
("$configsrv", \
%customservice);
1278 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1280 my @specprot=("IPIP","IPV6","IGMP","GRE","AH","ESP");
1281 if($type eq 'service'){
1282 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1283 if ($customservice{$key}[0] eq $name){
1284 push (@protocols,$customservice{$key}[2]);
1287 }elsif($type eq 'group'){
1288 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1289 if ($customservicegrp{$key}[0] eq $name){
1290 if ($customservicegrp{$key}[2] ~~ @specprot){
1291 push (@protocols," ".$customservicegrp{$key}[2]);
1293 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1294 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1295 if (!grep(/$customservice{$key1}[2]/, @protocols)){
1296 push (@protocols,$customservice{$key1}[2]);}
1304 # Sort protocols alphabetically.
1305 @protocols = sort(@protocols);
1314 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1315 # Don't colourise MAC addresses
1316 if (&General
::validmac
($val)) {
1322 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1323 foreach my $key (sort keys %$hash){
1324 if ($$hash{$key}[0] eq $val){
1325 $val=$$hash{$key}[2];
1330 if ($val eq 'GREEN'){
1331 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1333 }elsif ($val eq 'ORANGE'){
1334 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1336 }elsif ($val eq 'BLUE'){
1337 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1339 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1340 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1342 }elsif ($val eq 'IPFire' ){
1343 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1345 }elsif ($val eq 'OpenVPN-Dyn' ){
1346 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1348 }elsif ($val eq 'IPsec RW' ){
1349 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1351 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1352 my ($sip,$scidr) = split ("/",$val);
1353 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1354 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1357 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1358 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1361 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1362 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1365 }elsif ($val eq 'Default IP'){
1366 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1369 #Check if a manual IP or custom host is part of a VPN
1370 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1371 #Check if IP is part of OpenVPN dynamic subnet
1372 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1373 my ($c,$d) = split("/",$val);
1374 if (&General
::IpInSubnet
($c,$a,$b)){
1375 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1378 #Check if IP is part of OpenVPN static subnet
1379 foreach my $key (sort keys %ccdnet){
1380 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1381 $b =&General
::iporsubtodec
($b);
1382 if (&General
::IpInSubnet
($c,$a,$b)){
1383 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1387 #Check if IP is part of OpenVPN N2N subnet
1388 foreach my $key (sort keys %ccdhost){
1389 if ($ccdhost{$key}[3] eq 'net'){
1390 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1391 if (&General
::IpInSubnet
($c,$a,$b)){
1392 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1397 #Check if IP is part of IPsec RW network
1398 if ($ipsecsettings{'RW_NET'} ne ''){
1399 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1400 $b=&General
::iporsubtodec
($b);
1401 if (&General
::IpInSubnet
($c,$a,$b)){
1402 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1406 #Check if IP is part of a IPsec N2N network
1407 foreach my $key (sort keys %ipsecconf){
1408 if ($ipsecconf{$key}[11]){
1409 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1410 $b=&General
::iporsubtodec
($b);
1411 if (&General
::IpInSubnet
($c,$a,$b)){
1412 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1419 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'){
1420 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1423 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1424 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1428 foreach my $alias (sort keys %aliases)
1430 if ($val eq $alias){
1431 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1442 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1443 print "<class name='base'>$hint\n";
1444 print " </class>\n";
1445 &Header
::closebox
();
1451 &General
::setup_default_networks
(\
%defaultNetworks);
1452 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1453 #read all configfiles
1454 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1455 &General
::readhasharray
("$confignet", \
%customnetwork);
1456 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1457 &General
::readhasharray
("$confighost", \
%customhost);
1458 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1459 &General
::readhasharray
("$configgrp", \
%customgrp);
1460 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1461 &General
::get_aliases
(\
%aliases);
1465 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1466 my $config=$fwdfwsettings{'config'};
1469 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1470 my $redip = <CONN1
>;
1472 if (! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE2'){
1473 $fwdfwsettings{'RULE_ACTION'}='DROP';
1474 }elsif(! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE1'){
1475 $fwdfwsettings{'RULE_ACTION'}='ACCEPT';
1477 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1478 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1479 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1480 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1481 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1482 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1483 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1484 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1485 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1486 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1487 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1488 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1489 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1490 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1491 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1492 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1493 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1494 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1495 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1496 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1497 #check if update and get values
1498 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1499 &General
::readhasharray
("$config", \
%hash);
1500 foreach my $key (sort keys %hash){
1502 if ($key eq $fwdfwsettings{'key'}){
1503 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1504 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1505 $fwdfwsettings{'chain'} = $hash{$key}[1];
1506 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1507 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1508 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1509 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1510 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1511 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1512 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1513 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1514 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1515 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1516 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1517 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1518 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1519 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1520 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1521 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1522 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1523 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1524 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1525 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1526 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1527 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1528 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1529 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1530 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1531 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1532 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1533 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1534 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1535 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1536 $fwdfwsettings{'LIMIT_CON_CON'} = $hash{$key}[32];
1537 $fwdfwsettings{'concon'} = $hash{$key}[33];
1538 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1539 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1540 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1541 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1542 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1543 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1544 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1545 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1546 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1547 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1548 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1549 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1550 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1551 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1552 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1553 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1554 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1555 $checked{'LIMIT_CON_CON'}{$fwdfwsettings{'LIMIT_CON_CON'}} = 'CHECKED';
1556 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1557 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1558 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1559 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1560 $selected{'dnat'}{$fwdfwsettings{'dnat'}} ='selected';
1561 $selected{'snat'}{$fwdfwsettings{'snat'}} ='selected';
1564 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1565 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1566 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1567 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1568 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1569 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1570 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1571 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1572 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1573 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1574 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1575 #check if manual ip (source) is orange network
1576 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1577 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1578 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1579 $fwdfwsettings{'oldorange'} ='on';
1583 $fwdfwsettings{'ACTIVE'}='ON';
1584 $fwdfwsettings{'nat'} = 'dnat';
1585 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1586 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1587 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1588 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1589 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1590 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1591 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1592 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1593 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1594 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1595 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1596 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1597 #check if manual ip (source) is orange network
1598 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1599 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1600 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1601 $fwdfwsettings{'oldorange'} ='on';
1605 # Split manual source and target address and delete the subnet
1606 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1607 if ($scidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp1'}}=$sip;}
1608 my ($dip,$dcidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp2'}});
1609 if ($dcidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp2'}}=$dip;}
1610 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1611 #------SOURCE-------------------------------------------------------
1612 print "<form method='post'>";
1614 <table width='100%' border='0'>
1615 <tr><td width='1%'><input type='radio' name='grp1' value='src_addr' checked></td><td width='60%'>$Lang::tr{'fwdfw sourceip'}<input type='TEXT' name='src_addr' value='$fwdfwsettings{'src_addr'}' size='16' maxlength='18' ></td><td width='1%'><input type='radio' name='grp1' id='ipfire_src' value='ipfire_src' $checked{'grp1'}{'ipfire_src'}></td><td><b>Firewall</b></td>
1617 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1618 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1619 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1620 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1621 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1622 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1623 if (! -z
"${General::swroot}/ethernet/aliases"){
1624 foreach my $alias (sort keys %aliases)
1626 print "<option value='$alias' $selected{'ipfire_src'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1631 <tr><td><br></td></tr>
1634 &gen_dd_block
('src','grp1');
1635 &Header
::closebox
();
1637 #---SNAT / DNAT ------------------------------------------------
1638 &Header
::openbox
('100%', 'left', 'NAT');
1641 <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}>
1642 $Lang::tr{'fwdfw use nat'}
1645 <table width='100%' border='0'>
1647 <td width='5%'></td>
1650 <input type='radio' name='nat' value='dnat' $checked{'nat'}{'dnat'}>
1651 $Lang::tr{'fwdfw dnat'}
1657 <td width='25%' align='right'>$Lang::tr{'dnat address'}:</td>
1659 <select name='dnat' style='width: 100%;'>
1660 <option value='AUTO' $selected{'dnat'}{'AUTO'}>- $Lang::tr{'automatic'} -</option>
1661 <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'red1'} ($redip)</option>
1664 foreach my $alias (sort keys %aliases) {
1665 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1669 foreach my $network (sort keys %defaultNetworks)
1671 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1672 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1673 print " selected='selected'" if ($fwdfwsettings{'dnat'} eq $defaultNetworks{$network}{'NAME'});
1674 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1683 <td width='5%'></td>
1686 <input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}>
1687 $Lang::tr{'fwdfw snat'}
1690 <td width='25%' align='right'>$Lang::tr{'snat new source ip address'}:</td>
1692 <select name='snat' style='width: 100%;'>
1695 foreach my $alias (sort keys %aliases) {
1696 print "<option value='$alias' $selected{'snat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1699 foreach my $network (sort keys %defaultNetworks) {
1700 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1701 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1702 print " selected='selected'" if ($fwdfwsettings{'snat'} eq $defaultNetworks{$network}{'NAME'});
1703 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1713 &Header
::closebox
();
1715 #---TARGET------------------------------------------------------
1716 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1718 <table width='100%' border='0'>
1719 <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td width='60%' nowrap='nowrap'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16' maxlength='18'><td width='1%'><input type='radio' name='grp2' id='ipfire' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>Firewall</b></td>
1721 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1722 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1723 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1724 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1725 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1726 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1727 if (! -z
"${General::swroot}/ethernet/aliases"){
1728 foreach my $alias (sort keys %aliases)
1730 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1735 <tr><td><br></td></tr></table>
1737 &gen_dd_block
('tgt','grp2');
1739 #---PROTOCOL------------------------------------------------------
1740 $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
1741 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1742 $fwdfwsettings{'dnatport'} =~ tr/|/,/;
1744 # The dnatport may be empty, if it matches TGT_PORT
1745 if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
1746 $fwdfwsettings{'dnatport'} = "";
1749 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1750 #Fix Protocol for JQuery
1751 if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
1752 $fwdfwsettings{'PROT'} = 'template';
1755 <table width='100%' border='0'>
1758 <select name='PROT' id='protocol' style="width: 95px;">
1760 print "<option value=\"\"";
1761 if ($fwdfwsettings{'PROT'} eq '') {
1762 print " selected=\"selected\"";
1764 print ">$Lang::tr{'all'}</option>";
1766 print "<option value=\"template\"";
1767 print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp');
1768 print ">- $Lang::tr{'template'} -</option>";
1770 foreach (@PROTOCOLS) {
1771 print"<option value=\"$_\"";
1772 if ($_ eq $fwdfwsettings{'PROT'}) {
1773 print " selected=\"selected\"";
1776 print ">$Lang::tr{'fwdfw prot41'}</option>";
1778 print ">$_</option>";
1786 <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES">
1788 <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
1790 <select name='ICMP_TYPES' style='min-width:230px;'>
1792 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1793 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1794 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1795 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1796 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1798 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1808 <table width="100%" border="0" id="PROTOCOL_PORTS">
1810 <!-- #SOURCEPORT -->
1812 $Lang::tr{'fwdfw use srcport'}
1815 <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
1820 <!-- #TARGETPORT -->
1822 $Lang::tr{'fwdfw use srv'}
1826 <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
1830 <td colspan='3'></td>
1831 <td>$Lang::tr{'fwdfw external port nat'}:</td>
1833 <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
1838 <table width="100%" border="0" id="PROTOCOL_TEMPLATE">
1841 <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
1842 $Lang::tr{'fwhost cust service'}
1845 <select name='cust_srv' style='min-width: 230px;'>
1848 &General
::readhasharray
("$configsrv", \
%customservice);
1849 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1851 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1852 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1861 <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
1862 $Lang::tr{'fwhost cust srvgrp'}
1865 <select name='cust_srvgrp' style='min-width:230px;'>
1868 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1870 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1871 if ($helper ne $customservicegrp{$key}[0] && $customservicegrp{$key}[2] ne 'none'){
1873 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1874 print">$customservicegrp{$key}[0]</option>";
1876 $helper=$customservicegrp{$key}[0];
1890 $checked{"RULE_ACTION"}{$fwdfwsettings{'RULE_ACTION'}} = 'CHECKED';
1893 <table width="80%" class='tbl' id='actions'>
1895 <td width="33%" align="center" bgcolor="$color{'color17'}">
1898 <td width="33%" align="center" bgcolor="$color{'color25'}">
1901 <td width="33%" align="center" bgcolor="$color{'color16'}">
1906 <td width="33%" align="center">
1908 <input type="radio" name="RULE_ACTION" value="ACCEPT" $checked{"RULE_ACTION"}{"ACCEPT"}>
1909 <strong>$Lang::tr{'fwdfw ACCEPT'}</strong>
1912 <td width="33%" align="center">
1914 <input type="radio" name="RULE_ACTION" value="DROP" $checked{"RULE_ACTION"}{"DROP"}>
1915 <strong>$Lang::tr{'fwdfw DROP'}</strong>
1918 <td width="33%" align="center">
1920 <input type="radio" name="RULE_ACTION" value="REJECT" $checked{"RULE_ACTION"}{"REJECT"}>
1921 <strong>$Lang::tr{'fwdfw REJECT'}</strong>
1930 #---Activate/logging/remark-------------------------------------
1931 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1933 <table width='100%' border='0'>
1935 print"<tr><td width='12%'>$Lang::tr{'remark'}:</td><td width='88%' align='left'><input type='text' name='ruleremark' maxlength='255' value='$fwdfwsettings{'ruleremark'}' style='width:99%;'></td></tr>";
1936 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1937 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1938 for (my $count =1; $count <= $sum; $count++){
1939 print"<option value='$count' ";
1940 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1941 print">$count</option>";
1943 print"</select></td></tr>";
1945 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1950 <table width='100%'>
1954 if ($fwdfwsettings{'updatefwrule'} eq 'on') {
1957 <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}>
1959 <td>$Lang::tr{'fwdfw rule activate'}</td>
1964 <input type="hidden" name="ACTIVE" value="ON">
1973 <input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'}>
1975 <td>$Lang::tr{'fwdfw log rule'}</td>
1979 <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}>
1981 <td>$Lang::tr{'fwdfw timeframe'}</td>
1983 <tr id="TIME_CONSTRAINTS">
1985 <table width="66%" border="0">
1987 <td width="8em"> </td>
1988 <td align="center">$Lang::tr{'advproxy monday'}</td>
1989 <td align="center">$Lang::tr{'advproxy tuesday'}</td>
1990 <td align="center">$Lang::tr{'advproxy wednesday'}</td>
1991 <td align="center">$Lang::tr{'advproxy thursday'}</td>
1992 <td align="center">$Lang::tr{'advproxy friday'}</td>
1993 <td align="center">$Lang::tr{'advproxy saturday'}</td>
1994 <td align="center">$Lang::tr{'advproxy sunday'}</td>
1998 <td width="8em"> </td>
1999 <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
2000 <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
2001 <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
2002 <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
2003 <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
2004 <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
2005 <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
2007 <select name='TIME_FROM'>
2009 for (my $i=0;$i<=23;$i++) {
2010 $i = sprintf("%02s",$i);
2011 for (my $j=0;$j<=45;$j+=15) {
2012 $j = sprintf("%02s",$j);
2013 my $time = $i.":".$j;
2014 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
2019 <select name='TIME_TO'>
2021 for (my $i=0;$i<=23;$i++) {
2022 $i = sprintf("%02s",$i);
2023 for (my $j=0;$j<=45;$j+=15) {
2024 $j = sprintf("%02s",$j);
2025 my $time = $i.":".$j;
2026 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
2038 <input type='checkbox' name='LIMIT_CON_CON' id="USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP" value='ON' $checked{'LIMIT_CON_CON'}{'ON'}>
2040 <td>$Lang::tr{'fwdfw limitconcon'}</td>
2044 <table width='66%' border='0'>
2046 <td width="20em"> </td>
2047 <td>$Lang::tr{'fwdfw maxconcon'}: <input type='text' name='concon' size='2' value="$fwdfwsettings{'concon'}"></td>
2056 #---ACTION------------------------------------------------------
2057 if($fwdfwsettings{'updatefwrule'} ne 'on'){
2059 <table border='0' width='100%'>
2060 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
2061 <input type='hidden' name='config' value='$config' >
2062 <input type='hidden' name='ACTION' value='saverule' ></form>
2063 <form method='post' style='display:inline;'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='reset'></form></td></tr>
2069 <table border='0' width='100%'>
2070 <tr><td align='right'><input type='submit' value='$Lang::tr{'fwdfw change'}' style='min-width:100px;' /><input type='hidden' name='updatefwrule' value='$fwdfwsettings{'updatefwrule'}'><input type='hidden' name='key' value='$fwdfwsettings{'key'}'>
2071 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
2072 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
2073 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
2074 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
2075 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
2076 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
2077 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
2078 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
2079 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
2080 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
2081 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
2082 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
2083 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
2084 <input type='hidden' name='oldconcon' value='$fwdfwsettings{'oldconcon'}' />
2085 <input type='hidden' name='ACTION' value='saverule' ></form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value'reset'></td></td>
2089 &Header
::closebox
();
2095 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
2096 foreach my $key (sort keys %uphash){
2097 if ($key eq $fwdfwsettings{'key'}) {
2099 if (exists $uphash{$last}){
2101 foreach my $y (0 .. $#{$uphash{$last}}) {
2102 $tmp{0}[$y] = $uphash{$last}[$y];
2104 #copy active rule to last
2105 foreach my $i (0 .. $#{$uphash{$last}}) {
2106 $uphash{$last}[$i] = $uphash{$key}[$i];
2108 #copy saved rule to actual position
2109 foreach my $x (0 .. $#{$tmp{0}}) {
2110 $uphash{$key}[$x] = $tmp{0}[$x];
2115 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
2116 &General
::firewall_config_changed
();
2122 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
2123 foreach my $key (sort keys %downhash){
2124 if ($key eq $fwdfwsettings{'key'}) {
2125 my $next = $key + 1;
2126 if (exists $downhash{$next}){
2128 foreach my $y (0 .. $#{$downhash{$next}}) {
2129 $tmp{0}[$y] = $downhash{$next}[$y];
2131 #copy active rule to next
2132 foreach my $i (0 .. $#{$downhash{$next}}) {
2133 $downhash{$next}[$i] = $downhash{$key}[$i];
2135 #copy saved rule to actual position
2136 foreach my $x (0 .. $#{$tmp{0}}) {
2137 $downhash{$key}[$x] = $tmp{0}[$x];
2142 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
2143 &General
::firewall_config_changed
();
2149 &General
::readhasharray
("$config", $hash);
2150 if (!$errormessage){
2151 ################################################################
2152 #check if we change an INPUT rule to a OUTGOING
2153 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2154 &changerule
($configinput);
2157 #check if we change an INPUT rule to a FORWARD
2158 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2159 &changerule
($configinput);
2162 ################################################################
2163 #check if we change an OUTGOING rule to an INPUT
2164 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2165 &changerule
($configoutgoing);
2168 #check if we change an OUTGOING rule to a FORWARD
2169 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2170 &changerule
($configoutgoing);
2173 ################################################################
2174 #check if we change a FORWARD rule to an INPUT
2175 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2176 &changerule
($configfwdfw);
2179 #check if we change a FORWARD rule to an OUTGOING
2180 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2181 &changerule
($configfwdfw);
2184 $fwdfwsettings{'ruleremark'}=~ s/,/;/g;
2185 utf8
::decode
($fwdfwsettings{'ruleremark'});
2186 $fwdfwsettings{'ruleremark'}=&Header
::escape
($fwdfwsettings{'ruleremark'});
2187 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2188 my $key = &General
::findhasharraykey
($hash);
2189 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2190 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2191 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2192 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2193 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2194 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2195 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2196 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2197 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2198 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2199 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2200 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2201 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2202 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2203 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2204 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2205 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2206 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2207 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2208 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2209 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2210 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2211 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2212 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2213 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2214 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2215 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2216 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2217 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2218 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2219 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2220 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2221 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2222 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2223 &General
::writehasharray
("$config", $hash);
2225 foreach my $key (sort {$a <=> $b} keys %$hash){
2226 if($key eq $fwdfwsettings{'key'}){
2227 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2228 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2229 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2230 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2231 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2232 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2233 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2234 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2235 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2236 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2237 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2238 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2239 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2240 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2241 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2242 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2243 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2244 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2245 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2246 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2247 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2248 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2249 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2250 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2251 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2252 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2253 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2254 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2255 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2256 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2257 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2258 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2259 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2260 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2265 &General
::writehasharray
("$config", $hash);
2266 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2268 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2269 for (my $z=0;$z<$val;$z++){
2270 foreach my $key (sort {$a <=> $b} keys %$hash){
2271 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2273 if (exists $$hash{$last}){
2275 foreach my $y (0 .. $#{$$hash{$last}}) {
2276 $tmp{0}[$y] = $$hash{$last}[$y];
2278 #copy active rule to last
2279 foreach my $i (0 .. $#{$$hash{$last}}) {
2280 $$hash{$last}[$i] = $$hash{$key}[$i];
2282 #copy saved rule to actual position
2283 foreach my $x (0 .. $#{$tmp{0}}) {
2284 $$hash{$key}[$x] = $tmp{0}[$x];
2289 $fwdfwsettings{'oldrulenumber'}--;
2291 &General
::writehasharray
("$config", $hash);
2292 &General
::firewall_config_changed
();
2293 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2295 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2296 for (my $z=0;$z<$val;$z++){
2297 foreach my $key (sort {$a <=> $b} keys %$hash){
2298 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2299 my $next = $key + 1;
2300 if (exists $$hash{$next}){
2302 foreach my $y (0 .. $#{$$hash{$next}}) {
2303 $tmp{0}[$y] = $$hash{$next}[$y];
2305 #copy active rule to next
2306 foreach my $i (0 .. $#{$$hash{$next}}) {
2307 $$hash{$next}[$i] = $$hash{$key}[$i];
2309 #copy saved rule to actual position
2310 foreach my $x (0 .. $#{$tmp{0}}) {
2311 $$hash{$key}[$x] = $tmp{0}[$x];
2316 $fwdfwsettings{'oldrulenumber'}++;
2318 &General
::writehasharray
("$config", $hash);
2319 &General
::firewall_config_changed
();
2325 # Checks a hostname against RFC1035
2328 # Try to decode $remark into UTF-8. If this doesn't work,
2329 # we assume that the string it not sane.
2330 if (!utf8
::decode
($remark)) {
2334 # Check if the string only contains of printable characters.
2335 if ($remark =~ /^[[:print:]]*$/) {
2342 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2344 &viewtablenew
(\
%configfwdfw, $configfwdfw, $Lang::tr
{'firewall rules'});
2345 &viewtablenew
(\
%configinputfw, $configinput, $Lang::tr
{'incoming firewall access'});
2346 &viewtablenew
(\
%configoutgoingfw, $configoutgoing, $Lang::tr
{'outgoing firewall access'});
2355 my $show_box = (! -z
$config) || ($optionsfw{'SHOWTABLES'} eq 'on');
2356 return if (!$show_box);
2358 &General
::get_aliases
(\
%aliases);
2359 &General
::readhasharray
("$confighost", \
%customhost);
2360 &General
::readhasharray
("$config", $hash);
2361 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2362 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2363 &General
::readhasharray
("$configgrp", \
%customgrp);
2364 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2366 &Header
::openbox
('100%', 'left', $title);
2367 print "<table width='100%' cellspacing='0' class='tbl'>";
2381 <th align='right' width='3%'>
2384 <th width='2%'></th>
2386 <b>$Lang::tr{'protocol'}</b>
2388 <th align='center' width='30%'>
2389 <b>$Lang::tr{'fwdfw source'}</b>
2392 <b>$Lang::tr{'fwdfw log'}</b>
2394 <th align='center' width='30%'>
2395 <b>$Lang::tr{'fwdfw target'}</b>
2397 <th align='center' colspan='6' width='18%'>
2398 <b>$Lang::tr{'fwdfw action'}</b>
2403 foreach my $key (sort {$a <=> $b} keys %$hash){
2407 #check if vpn hosts/nets have been deleted
2408 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2409 push (@tmpsrc,$$hash{$key}[4]);
2411 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2412 push (@tmptgt,$$hash{$key}[6]);
2414 foreach my $host (@tmpsrc){
2415 if($$hash{$key}[3] eq 'ipsec_net_src'){
2416 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2419 }elsif($$hash{$key}[3] eq 'ovpn_net_src'){
2420 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2423 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src'){
2424 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2427 }elsif($$hash{$key}[3] eq 'ovpn_host_src'){
2428 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2433 foreach my $host (@tmptgt){
2434 if($$hash{$key}[5] eq 'ipsec_net_tgt'){
2435 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2438 }elsif($$hash{$key}[5] eq 'ovpn_net_tgt'){
2439 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2442 }elsif($$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2443 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2446 }elsif($$hash{$key}[5] eq 'ovpn_host_tgt'){
2447 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2452 #check if networkgroups or servicegroups are empty
2453 foreach my $netgroup (sort keys %customgrp){
2454 if(($$hash{$key}[4] eq $customgrp{$netgroup}[0] || $$hash{$key}[6] eq $customgrp{$netgroup}[0]) && $customgrp{$netgroup}[2] eq 'none'){
2458 foreach my $srvgroup (sort keys %customservicegrp){
2459 if($$hash{$key}[15] eq $customservicegrp{$srvgroup}[0] && $customservicegrp{$srvgroup}[2] eq 'none'){
2463 $$hash{'ACTIVE'}=$$hash{$key}[2];
2465 if($coloryellow eq 'on'){
2466 $color="$color{'color14'}";
2468 }elsif($coloryellow eq ''){
2470 $color="$color{'color22'}";
2473 $color="$color{'color20'}";
2477 <tr bgcolor='$color'>
2478 <td align='right' width='3%'>
2484 if ($$hash{$key}[0] eq 'ACCEPT'){
2487 $rulecolor=$color{'color17'};
2488 }elsif($$hash{$key}[0] eq 'DROP'){
2491 $rulecolor=$color{'color25'};
2492 }elsif($$hash{$key}[0] eq 'REJECT'){
2495 $rulecolor=$color{'color16'};
2499 <td bgcolor='$rulecolor' align='center' width='2%'>
2500 <span title='$tooltip'> </span>
2506 if ($$hash{$key}[8]){
2507 if ($$hash{$key}[8] eq "IPv6"){
2508 push (@protocols,$Lang::tr
{'fwdfw prot41 short'})
2510 push (@protocols,$$hash{$key}[8]);
2512 }elsif($$hash{$key}[14] eq 'cust_srv'){
2513 &get_serviceports
("service",$$hash{$key}[15]);
2514 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2515 &get_serviceports
("group",$$hash{$key}[15]);
2517 push (@protocols,$Lang::tr
{'all'});
2520 my $protz=join(", ",@protocols);
2521 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2522 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2523 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2524 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2525 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2529 }elsif($#protocols gt '3'){
2530 print"<td align='center'><span title='$protz'>$Lang::tr{'fwdfw many'}</span></td>";
2532 print"<td align='center'>$protz</td>";
2537 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2538 print"<td align='center' width='30%' $tdcolor>";
2539 if ($$hash{$key}[3] eq 'ipfire_src'){
2540 $ipfireiface=$Lang::tr
{'fwdfw iface'};
2542 if ($$hash{$key}[3] eq 'std_net_src'){
2543 print &get_name
($$hash{$key}[4]);
2544 }elsif ($$hash{$key}[3] eq 'src_addr'){
2545 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2546 if ($split2 eq '32'){
2549 print $$hash{$key}[4];
2551 }elsif ($$hash{$key}[4] eq 'RED1'){
2552 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2553 }elsif ($$hash{$key}[4] eq 'ALL'){
2554 print "$ipfireiface $Lang::tr{'all'}";
2556 if ($$hash{$key}[4] eq 'GREEN' || $$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE' || $$hash{$key}[4] eq 'RED'){
2557 print "$ipfireiface $Lang::tr{lc($$hash{$key}[4])}";
2559 print "$ipfireiface $$hash{$key}[4]";
2564 &getsrcport
(\
%$hash,$key);
2565 #Is this a SNAT rule?
2566 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2567 my $net=&get_name
($$hash{$key}[29]);
2568 if ( ! $net){ $net=$$hash{$key}[29];}
2570 if ($$hash{$key}[30] ne ''){
2571 print": $$hash{$key}[30]";
2574 if ($$hash{$key}[17] eq 'ON'){
2575 $log="/images/on.gif";
2577 $log="/images/off.gif";
2583 <form method='POST' action=''>
2584 <input type='image' img src='$log' alt='$Lang::tr{'click to disable'}' title='$Lang::tr{'fwdfw togglelog'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'/>
2585 <input type='hidden' name='key' value='$key' />
2586 <input type='hidden' name='config' value='$config' />
2587 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2592 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2594 <td align='center' $tdcolor>
2596 #Is this a DNAT rule?
2598 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2599 if ($$hash{$key}[29] eq 'Default IP'){$$hash{$key}[29]=$Lang::tr
{'red1'};}
2600 if ($$hash{$key}[29] eq 'AUTO'){
2601 my @src_addresses=&fwlib
::get_addresses
(\
%$hash,$key,'src');
2603 foreach my $val (@src_addresses){
2604 push (@nat_ifaces,&fwlib
::get_nat_address
($$hash{$key}[29],$val));
2606 @nat_ifaces=&del_double
(@nat_ifaces);
2609 $natstring = "($$hash{$key}[29])";
2611 print "$Lang::tr{'firewall'} $natstring";
2612 if($$hash{$key}[30] ne ''){
2613 $$hash{$key}[30]=~ tr/|/,/;
2614 print": $$hash{$key}[30]";
2618 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire'){
2619 if ($$hash{$key}[6] eq 'RED1'){
2620 print "$Lang::tr{'red1'}";
2621 }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')
2623 print &get_name
($$hash{$key}[6]);
2625 print $$hash{$key}[6];
2627 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2628 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2629 if ($split2 eq '32'){
2632 print $$hash{$key}[6];
2635 print "$$hash{$key}[6]";
2639 &gettgtport
(\
%$hash,$key);
2642 if($$hash{$key}[2] eq 'ON'){
2643 $gif="/images/on.gif"
2646 $gif="/images/off.gif"
2649 <td width='3%' align='center'>
2650 <form method='POST' action=''>
2651 <input type='image' img src='$gif' alt='$Lang::tr{'click to disable'}' title='$Lang::tr{'fwdfw toggle'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2652 <input type='hidden' name='key' value='$key' />
2653 <input type='hidden' name='config' value='$config' />
2654 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2657 <td width='3%' align='center'>
2658 <form method='POST' action=''>
2659 <input type='image' img src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'fwdfw edit'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2660 <input type='hidden' name='key' value='$key' />
2661 <input type='hidden' name='config' value='$config' />
2662 <input type='hidden' name='ACTION' value='editrule' />
2665 <td width='3%' align='center'>
2666 <form method='POST' action=''>
2667 <input type='image' img src='/images/addblue.gif' alt='$Lang::tr{'fwdfw copy'}' title='$Lang::tr{'fwdfw copy'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2668 <input type='hidden' name='key' value='$key' />
2669 <input type='hidden' name='config' value='$config' />
2670 <input type='hidden' name='ACTION' value='copyrule' />
2673 <td width='3%' align='center'>
2674 <form method='POST' action=''>
2675 <input type='image' img src='/images/delete.gif' alt='$Lang::tr{'delete'}' title='$Lang::tr{'fwdfw delete'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2676 <input type='hidden' name='key' value='$key' />
2677 <input type='hidden' name='config' value='$config' />
2678 <input type='hidden' name='ACTION' value='deleterule' />
2682 if (exists $$hash{$key-1}){
2684 <td width='3%' align='center'>
2685 <form method='POST' action=''>
2686 <input type='image' img src='/images/up.gif' alt='$Lang::tr{'fwdfw moveup'}' title='$Lang::tr{'fwdfw moveup'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2687 <input type='hidden' name='key' value='$key' />
2688 <input type='hidden' name='config' value='$config' />
2689 <input type='hidden' name='ACTION' value='moveup' />
2694 print"<td width='3%'></td>";
2697 if (exists $$hash{$key+1}){
2699 <td width='3%' align='center'>
2700 <form method='POST' action=''>
2701 <input type='image' img src='/images/down.gif' alt='$Lang::tr{'fwdfw movedown'}' title='$Lang::tr{'fwdfw movedown'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2702 <input type='hidden' name='key' value='$key' />
2703 <input type='hidden' name='config' value='$config' />
2704 <input type='hidden' name='ACTION' value='movedown' />
2710 print"<td width='3%'></td></tr>";
2713 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2715 <tr bgcolor='$color'>
2717 <td bgcolor='$rulecolor'></td>
2719 <em>$$hash{$key}[16]</em>
2725 if ($$hash{$key}[18] eq 'ON'){
2727 if ($$hash{$key}[18] eq 'ON'){
2729 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2730 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2731 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2732 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2733 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2734 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2735 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2736 my $weekdays=join(",",@days);
2738 print"<tr bgcolor='$color'>";
2739 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27]</td></tr>";
2743 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2745 } elsif ($optionsfw{'SHOWTABLES'} eq 'on') {
2748 <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td>
2754 my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'};
2755 my $colour = "bgcolor='green'";
2756 if ($fwdfwsettings{'POLICY'} eq 'MODE1') {
2757 $colour = "bgcolor='darkred'";
2761 if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) {
2764 <td colspan='13'> </td>
2767 <td colspan='13' style="padding-left:0px;padding-right:0px">
2768 <table width="100%" border='1' rules="cols" cellspacing='0'>
2775 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2778 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2779 ($Lang::tr{'fwdfw pol allow'})
2783 if (&Header
::orange_used
()) {
2786 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2787 ($Lang::tr{'fwdfw pol allow'})
2792 if (&Header
::blue_used
()) {
2795 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2796 ($Lang::tr{'fwdfw pol allow'})
2804 if (&Header
::orange_used
()) {
2807 <td align='center' width='20%'>
2808 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2811 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2812 ($Lang::tr{'fwdfw pol allow'})
2815 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2816 ($Lang::tr{'fwdfw pol block'})
2820 if (&Header
::blue_used
()) {
2823 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2824 ($Lang::tr{'fwdfw pol block'})
2832 if (&Header
::blue_used
()) {
2836 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2839 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2840 ($Lang::tr{'fwdfw pol allow'})
2844 if (&Header
::orange_used
()) {
2847 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2848 ($Lang::tr{'fwdfw pol block'})
2855 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2856 ($Lang::tr{'fwdfw pol block'})
2868 $message = $Lang::tr
{'fwdfw pol allow'};
2870 } elsif ($config eq '/var/ipfire/firewall/outgoing' && ($fwdfwsettings{'POLICY1'} ne 'MODE1')) {
2871 $message = $Lang::tr
{'fwdfw pol allow'};
2872 $colour = "bgcolor='green'";
2874 $message = $Lang::tr
{'fwdfw pol block'};
2875 $colour = "bgcolor='darkred'";
2881 <td $colour align='center' colspan='13'>
2882 <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font>
2891 &Header
::closebox
();
2894 &Header
::closebigbox
();
2895 &Header
::closepage
();