]>
git.ipfire.org Git - people/stevee/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 ###############################################################################
24 no warnings
'uninitialized';
25 # enable only the following on debugging purpose
27 #use CGI::Carp 'fatalsToBrowser';
29 require '/var/ipfire/general-functions.pl';
30 require "${General::swroot}/lang.pl";
31 require "${General::swroot}/header.pl";
32 require "${General::swroot}/firewall/bin/firewall-lib.pl";
34 unless (-d
"${General::swroot}/firewall") { system("mkdir ${General::swroot}/firewall"); }
35 unless (-e
"${General::swroot}/firewall/settings") { system("touch ${General::swroot}/firewall/settings"); }
36 unless (-e
"${General::swroot}/firewall/config") { system("touch ${General::swroot}/firewall/config"); }
37 unless (-e
"${General::swroot}/firewall/input") { system("touch ${General::swroot}/firewall/input"); }
38 unless (-e
"${General::swroot}/firewall/outgoing") { system("touch ${General::swroot}/firewall/outgoing"); }
42 my %defaultNetworks=();
46 my %customnetworks=();
48 my %customservicegrp=();
54 my %configoutgoingfw=();
66 my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE","IPv6","IPIP");
69 my $confignet = "${General::swroot}/fwhosts/customnetworks";
70 my $confighost = "${General::swroot}/fwhosts/customhosts";
71 my $configgrp = "${General::swroot}/fwhosts/customgroups";
72 my $configsrv = "${General::swroot}/fwhosts/customservices";
73 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
74 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
75 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
76 my $configipsec = "${General::swroot}/vpn/config";
77 my $configipsecrw = "${General::swroot}/vpn/settings";
78 my $configfwdfw = "${General::swroot}/firewall/config";
79 my $configinput = "${General::swroot}/firewall/input";
80 my $configoutgoing = "${General::swroot}/firewall/outgoing";
81 my $configovpn = "${General::swroot}/ovpn/settings";
82 my $fwoptions = "${General::swroot}/optionsfw/settings";
83 my $ifacesettings = "${General::swroot}/ethernet/settings";
86 my $ipgrp="${General::swroot}/outgoing/groups";
90 &General
::readhash
("${General::swroot}/firewall/settings", \
%fwdfwsettings);
91 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
92 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
93 &General
::readhash
($fwoptions, \
%optionsfw);
94 &General
::readhash
($ifacesettings, \
%ifaces);
95 &General
::readhash
("$configovpn", \
%ovpnsettings);
96 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
97 &General
::readhasharray
("$configipsec", \
%ipsecconf);
98 &Header
::showhttpheaders
();
99 &Header
::getcgihash
(\
%fwdfwsettings);
100 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
101 &Header
::openbigbox
('100%', 'center',$errormessage);
102 #### JAVA SCRIPT ####
105 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
107 var update_protocol = function() {
108 var protocol = \$("#protocol").val();
110 if (protocol === undefined)
113 // Check if a template is/should be used.
114 if (protocol === "template") {
115 \$("#PROTOCOL_TEMPLATE").show();
117 \$("#PROTOCOL_TEMPLATE").hide();
120 // Check if we are dealing with a protocol, that knows ports.
121 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
122 \$("#PROTOCOL_PORTS").show();
124 \$("#PROTOCOL_PORTS").hide();
128 if (protocol === "ICMP") {
129 \$("#PROTOCOL_ICMP_TYPES").show();
131 \$("#PROTOCOL_ICMP_TYPES").hide();
135 \$(document).ready(function() {
136 \$("#protocol").change(update_protocol);
139 // When nat not used, hide it
140 if (! \$("#USE_NAT").attr("checked")) {
144 // Show NAT area when "use nat" checkbox is clicked
145 \$("#USE_NAT").change(function() {
150 if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) {
151 \$("#TIME_CONSTRAINTS").hide();
153 \$("#USE_TIME_CONSTRAINTS").change(function() {
154 \$("#TIME_CONSTRAINTS").toggle();
157 // Automatically select radio buttons when corresponding
158 // dropdown menu changes.
159 \$("select").change(function() {
160 var id = \$(this).attr("name");
162 // When using SNAT or DNAT, check "USE NAT" Checkbox
163 if (id === 'snat' || id === 'dnat') {
164 \$('#USE_NAT').prop('checked', true);
166 \$('#' + id).prop("checked", true);
174 if ($fwdfwsettings{'ACTION'} eq 'saverule')
176 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
177 &General
::readhasharray
("$configinput", \
%configinputfw);
178 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
179 #Set Variables according to the JQuery code in protocol section
180 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')
182 if ($fwdfwsettings{'SRC_PORT'} ne '')
184 $fwdfwsettings{'USE_SRC_PORT'} = 'ON';
186 if ($fwdfwsettings{'TGT_PORT'} ne '')
188 $fwdfwsettings{'USESRV'} = 'ON';
189 $fwdfwsettings{'grp3'} = 'TGT_PORT';
192 if ($fwdfwsettings{'PROT'} eq 'template')
194 $fwdfwsettings{'USESRV'} = 'ON';
196 $errormessage=&checksource
;
197 if(!$errormessage){&checktarget
;}
198 if(!$errormessage){&checkrule
;}
199 #check if manual ip (source) is orange network
200 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
201 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
202 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
207 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
208 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
210 #check if we try to break rules
211 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
212 $errormessage=$Lang::tr
{'fwdfw err same'};
215 if($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
216 $fwdfwsettings{'config'}=$configinput;
217 $fwdfwsettings{'chain'} = 'INPUTFW';
218 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
219 #check if we have an identical rule already
220 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
221 foreach my $key (sort keys %configinputfw){
222 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'}"
223 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]"){
224 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
225 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
227 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
228 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
230 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
231 $fwdfwsettings{'nosave'} = 'on';
236 #check Rulepos on new Rule
237 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
238 $fwdfwsettings{'oldrulenumber'}=$maxkey;
239 foreach my $key (sort keys %configinputfw){
240 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'}"
241 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]"){
242 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
246 #check if we just close a rule
247 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'}) {
248 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
250 $fwdfwsettings{'nosave2'} = 'on';
254 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
255 if ($fwdfwsettings{'nobase'} ne 'on'){
256 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
258 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
259 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
260 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
261 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
262 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
263 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
265 if($fwdfwsettings{'nosave2'} ne 'on'){
266 &saverule
(\
%configinputfw,$configinput);
269 }elsif($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
271 $fwdfwsettings{'config'}=$configoutgoing;
272 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
273 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
274 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
275 foreach my $key (sort keys %configoutgoingfw){
276 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'}"
277 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]"){
278 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
279 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
281 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
282 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
284 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
285 $fwdfwsettings{'nosave'} = 'on';
290 #check Rulepos on new Rule
291 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
292 print"CHECK OUTGOING DOPPELTE REGEL<br>";
293 $fwdfwsettings{'oldrulenumber'}=$maxkey;
294 foreach my $key (sort keys %configoutgoingfw){
295 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'}"
296 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]"){
297 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
301 #check if we just close a rule
302 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'}) {
303 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
304 $fwdfwsettings{'nosave2'} = 'on';
310 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
311 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
312 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
313 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
314 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
315 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
316 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
317 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
319 if ($fwdfwsettings{'nobase'} eq 'on'){
320 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
322 if ($fwdfwsettings{'nosave2'} ne 'on'){
323 &saverule
(\
%configoutgoingfw,$configoutgoing);
328 $fwdfwsettings{'config'}=$configfwdfw;
329 $fwdfwsettings{'chain'} = 'FORWARDFW';
330 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
331 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
332 #check if we have an identical rule already
333 foreach my $key (sort keys %configfwdfw){
334 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'}"
335 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]"){
336 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
337 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
339 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
340 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
342 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
343 $fwdfwsettings{'nosave'} = 'on';
348 #check Rulepos on new Rule
349 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
350 $fwdfwsettings{'oldrulenumber'}=$maxkey;
351 foreach my $key (sort keys %configfwdfw){
352 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'}"
353 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]"){
354 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
358 #check if we just close a rule
359 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'}) {
360 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
361 $fwdfwsettings{'nosave2'} = 'on';
367 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
368 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
369 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
370 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
371 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
372 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
373 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
374 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
376 if ($fwdfwsettings{'nobase'} eq 'on'){
377 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
379 if ($fwdfwsettings{'nosave2'} ne 'on'){
380 &saverule
(\
%configfwdfw,$configfwdfw);
387 if($fwdfwsettings{'nosave2'} ne 'on'){
388 &General
::firewall_config_changed
();
393 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
397 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
400 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
401 foreach my $key (sort keys %togglehash){
402 if ($key eq $fwdfwsettings{'key'}){
403 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
406 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
407 &General
::firewall_config_changed
();
410 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
413 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
414 foreach my $key (sort keys %togglehash){
415 if ($key eq $fwdfwsettings{'key'}){
416 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
419 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
420 &General
::firewall_config_changed
();
423 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
425 &General
::firewall_reload
();
428 if ($fwdfwsettings{'ACTION'} eq 'editrule')
430 $fwdfwsettings{'updatefwrule'}='on';
433 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
437 if ($fwdfwsettings{'ACTION'} eq 'moveup')
442 if ($fwdfwsettings{'ACTION'} eq 'movedown')
447 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
449 $fwdfwsettings{'copyfwrule'}='on';
452 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
461 &Header
::openbox
('100%', 'left', "");
463 <form method="POST" action="">
464 <table border='0' width="100%">
467 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'>
470 if (&General
::firewall_needs_reload
()) {
472 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'>
496 $fwdfwsettings{'updatefwrule'}='';
497 $fwdfwsettings{'config'}=$oldchain;
498 $fwdfwsettings{'nobase'}='on';
500 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
501 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
506 #check ip-address if manual
507 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
508 #check if ip with subnet
509 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
510 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
511 $subnet = &General
::iporsubtocidr
($subnet);
512 $fwdfwsettings{'isip'}='on';
515 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
516 $ip=$fwdfwsettings{'src_addr'};
518 $fwdfwsettings{'isip'}='on';
521 if ($fwdfwsettings{'isip'} ne 'on'){
522 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
523 $fwdfwsettings{'ismac'}='on';
526 if ($fwdfwsettings{'isip'} eq 'on'){
527 ##check if ip is valid
528 if (! &General
::validip
($ip)){
529 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
530 return $errormessage;
532 #check and form valid IP
533 $ip=&General
::ip2dec
($ip);
534 $ip=&General
::dec2ip
($ip);
535 #check if net or broadcast
536 $fwdfwsettings{'src_addr'}="$ip/$subnet";
537 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
538 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
539 return $errormessage;
542 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
543 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
544 return $errormessage;
546 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
547 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
548 return $errormessage;
552 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
553 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
554 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
558 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
560 #change dashes with :
563 push(@values,"1:65535");
566 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
567 push(@values,"1:$2");
570 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
571 push(@values,"$1:65535");
574 $errormessage .= &General
::validportrange
($_, 'destination');
579 if (&General
::validport
($_)){
586 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
588 return $errormessage;
593 &General
::readhasharray
("$configsrv", \
%customservice);
594 #check DNAT settings (has to be single Host and single Port or portrange)
595 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
596 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
597 #check if manual ip is a single Host (if set)
598 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
599 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
600 my @tmp1= split ("/",$tmp[3]);
601 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
603 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
604 return $errormessage;
607 #check if Port is a single Port or portrange
608 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
609 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
610 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
611 return $errormessage;
613 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
614 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
615 return $errormessage;
619 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
620 return $errormessage;
623 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
624 #check if ip with subnet
625 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
626 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
627 $subnet = &General
::iporsubtocidr
($subnet);
630 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
631 $ip=$fwdfwsettings{'tgt_addr'};
634 #check if ip is valid
635 if (! &General
::validip
($ip)){
636 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
637 return $errormessage;
639 #check and form valid IP
640 $ip=&General
::ip2dec
($ip);
641 $ip=&General
::dec2ip
($ip);
642 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
643 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
644 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
645 return $errormessage;
647 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
648 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
649 return $errormessage;
652 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
654 if ($fwdfwsettings{'USESRV'} eq 'ON'){
655 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
656 $fwdfwsettings{'TGT_PROT'}='';
657 $fwdfwsettings{'ICMP_TGT'}='';
658 $fwdfwsettings{'TGT_PORT'}='';
660 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
661 $fwdfwsettings{'TGT_PROT'}='';
662 $fwdfwsettings{'ICMP_TGT'}='';
663 $fwdfwsettings{'TGT_PORT'}='';
664 #check target service
665 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
666 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
669 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
670 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
671 if ($fwdfwsettings{'TGT_PORT'} ne ''){
672 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
673 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
674 return $errormessage;
676 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
680 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
682 #change dashes with :
685 push(@values,"1:65535");
688 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
689 push(@values,"1:$2");
692 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
693 push(@values,"$1:65535");
696 $errormessage .= &General
::validportrange
($_, 'destination');
701 if (&General
::validport
($_)){
707 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
709 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
710 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
711 $fwdfwsettings{'TGT_PORT'} = '';
712 $fwdfwsettings{'ICMP_TGT'} = '';
713 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
714 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
715 $fwdfwsettings{'TGT_PORT'} = '';
716 $fwdfwsettings{'ICMP_TGT'}='';
717 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
718 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
719 $fwdfwsettings{'TGT_PORT'} = '';
720 $fwdfwsettings{'ICMP_TGT'}='';
721 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
722 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
723 $fwdfwsettings{'TGT_PORT'} = '';
728 if ($fwdfwsettings{'USESRV'} ne 'ON'){
729 $fwdfwsettings{'grp3'}='';
730 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
731 $fwdfwsettings{'ICMP_TGT'}='';
734 if($fwdfwsettings{'TIME'} eq 'ON'){
735 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 ''){
736 $errormessage=$Lang::tr
{'fwdfw err time'};
737 return $errormessage;
740 return $errormessage;
745 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
746 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
747 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
748 if ($fwdfwsettings{'dnatport'} eq "*") {
749 $fwdfwsettings{'dnatport'}="1:65535";
751 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
752 $fwdfwsettings{'dnatport'} = "1:$2";
754 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
755 $fwdfwsettings{'dnatport'} ="$1:65535";
760 if ($val =~ "," || $val>65536 || $val<0){
767 #check valid port for NAT
768 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
769 #if no port is given in nat area, take target host port
770 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
771 #check if port given in nat area is a single valid port or portrange
772 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
773 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
774 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
776 #get servcie Protocol and Port
777 foreach my $key (sort keys %customservice){
778 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
779 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
780 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
782 $custsrvport= $customservice{$key}[1];
785 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
787 #check if DNAT port is multiple
788 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
789 my @parts=split(",",$fwdfwsettings{'dnatport'});
793 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
795 #change dashes with :
798 push(@values,"1:65535");
801 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
802 push(@values,"1:$2");
805 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
806 push(@values,"$1:65535");
809 $errormessage .= &General
::validportrange
($_, 'destination');
814 if (&General
::validport
($_)){
821 $fwdfwsettings{'dnatport'}=join("|",@values);
825 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
826 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
828 #check if source and target identical
829 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
830 $errormessage=$Lang::tr
{'fwdfw err same'};
831 return $errormessage;
833 #get source and targetip address if possible
834 my ($sip,$scidr,$tip,$tcidr);
835 ($sip,$scidr)=&get_ip
("src","grp1");
836 ($tip,$tcidr)=&get_ip
("tgt","grp2");
837 #check same iprange in source and target
838 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
839 my $networkip1=&General
::getnetworkip
($sip,$scidr);
840 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
841 if ($scidr gt $tcidr){
842 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
843 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
845 }elsif($scidr eq $tcidr && $scidr eq '32'){
846 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
847 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
848 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
849 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
850 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
853 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
854 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
858 #When using source- or targetport, the protocol has to be TCP or UDP
859 if (($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON') && ($fwdfwsettings{'SRC_PORT'} ne '' || $fwdfwsettings{'TGT_PORT'} ne '') && ($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP')){
860 $errormessage.=$Lang::tr
{'fwdfw err prot_port1'};
863 #when icmp selected, no targetport allowed
864 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')){
865 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
868 #change protocol if prot not equal dest single service
869 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
870 foreach my $key (sort keys %customservice){
871 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
872 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
873 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
879 #check source and destination protocol if source manual and dest servicegroup
880 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
881 $fwdfwsettings{'PROT'} = '';
883 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
884 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
886 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
887 $fwdfwsettings{'USE_SRC_PORT'}='';
888 $fwdfwsettings{'SRC_PORT'}='';
889 #$fwdfwsettings{'USESRV'}='';
890 $fwdfwsettings{'TGT_PORT'}='';
891 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
892 foreach my $key (keys %icmptypes){
893 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
894 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
897 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
898 $fwdfwsettings{'USE_SRC_PORT'}='';
899 $fwdfwsettings{'SRC_PORT'}='';
900 $fwdfwsettings{'ICMP_TYPES'}='';
901 $fwdfwsettings{'USESRV'}='';
902 $fwdfwsettings{'TGT_PORT'}='';
903 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
904 $fwdfwsettings{'USE_SRC_PORT'}='';
905 $fwdfwsettings{'SRC_PORT'}='';
906 $fwdfwsettings{'ICMP_TYPES'}='';
907 $fwdfwsettings{'USESRV'}='';
908 $fwdfwsettings{'TGT_PORT'}='';
909 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
910 $fwdfwsettings{'USE_SRC_PORT'}='';
911 $fwdfwsettings{'SRC_PORT'}='';
912 $fwdfwsettings{'ICMP_TYPES'}='';
913 $fwdfwsettings{'USESRV'}='';
914 $fwdfwsettings{'TGT_PORT'}='';
915 }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){
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 'IPv6'){
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 'IPIP'){
928 $fwdfwsettings{'USE_SRC_PORT'}='';
929 $fwdfwsettings{'SRC_PORT'}='';
930 $fwdfwsettings{'ICMP_TYPES'}='';
931 $fwdfwsettings{'USESRV'}='';
932 $fwdfwsettings{'TGT_PORT'}='';
933 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP' && $fwdfwsettings{'PROT'} ne 'ICMP'){
934 $fwdfwsettings{'ICMP_TYPES'}='';
935 $fwdfwsettings{'PROT'} = '';
936 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
937 $fwdfwsettings{'ICMP_TYPES'}='';
942 my ($base1,$val1,$base2,$val2) = @_;
944 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
945 &dec_counter
($confignet,\
%customnetwork,$val1);
946 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
947 &dec_counter
($confighost,\
%customhost,$val1);
948 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
949 &dec_counter
($configgrp,\
%customgrp,$val1);
950 }elsif($base1 eq 'cust_srv'){
951 &dec_counter
($configsrv,\
%customservice,$val1);
952 }elsif($base1 eq 'cust_srvgrp'){
953 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
956 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
957 &inc_counter
($confignet,\
%customnetwork,$val2);
958 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
959 &inc_counter
($confighost,\
%customhost,$val2);
960 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
961 &inc_counter
($configgrp,\
%customgrp,$val2);
962 }elsif($base2 eq 'cust_srv'){
963 &inc_counter
($configsrv,\
%customservice,$val2);
964 }elsif($base2 eq 'cust_srvgrp'){
965 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
971 #Test if manual IP is part of static OpenVPN networks
972 &General
::readhasharray
("$configccdnet", \
%ccdnet);
973 foreach my $key (sort keys %ccdnet){
974 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
975 my $sub=&General
::iporsubtodec
($vpnsubnet);
976 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
980 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
981 # because if one creates a custom host with the ip, we need to check the color there!
982 # It does not make sense to check this here
984 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
985 # Is also checked in getcolor
987 # Test if manual ip is part of an IPsec Network is also checked in getcolor
997 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
998 foreach my $key (sort {$a <=> $b} keys %delhash){
999 if ($key == $fwdfwsettings{'key'}){
1000 #check hosts/net and groups
1001 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
1002 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
1003 #check services and groups
1004 if ($delhash{$key}[11] eq 'ON'){
1005 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
1008 if ($key >= $fwdfwsettings{'key'}) {
1009 my $next = $key + 1;
1010 if (exists $delhash{$next}) {
1011 foreach my $i (0 .. $#{$delhash{$next}}) {
1012 $delhash{$key}[$i] = $delhash{$next}[$i];
1017 # Remove the very last entry.
1018 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
1019 delete $delhash{$last_key};
1021 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
1022 &General
::firewall_config_changed
();
1024 if($fwdfwsettings{'nobase'} ne 'on'){
1031 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
1032 foreach my $key (sort keys %configfwdfw){
1033 if ($key eq $key1 ){
1034 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
1037 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
1038 &General
::firewall_config_changed
();
1043 my %hash=%{(shift)};
1046 &General
::readhasharray
($config, \
%hash);
1047 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1048 if($hash{$key}[0] eq $val){
1049 $pos=$#{$hash{$key}};
1050 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
1053 &General
::writehasharray
($config, \
%hash);
1057 if ($errormessage) {
1058 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1059 print "<class name='base'>$errormessage\n";
1060 print " </class>\n";
1061 &Header
::closebox
();
1067 my %hash=%{(shift)};
1070 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
1071 if($hash{$key}[0] eq $val){
1072 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1074 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1084 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1085 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1086 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1087 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1088 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1089 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1090 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1091 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1092 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1093 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1094 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1095 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1096 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1097 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1098 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1099 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1100 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1101 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1102 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1104 <table width='100%' border='0'>
1105 <tr><td width='50%' valign='top'>
1106 <table width='100%' border='0'>
1107 <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;'>
1109 foreach my $network (sort keys %defaultNetworks)
1111 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1112 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1113 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1114 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1115 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1116 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1117 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1118 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1119 if ($ifaces{$defnet}){
1120 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1122 print ">$network</option>";
1125 print"</select></td></tr>";
1127 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1128 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;'>";
1129 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1130 print"</select></td>";
1133 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1134 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;'>";
1135 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1136 print"</select></td>";
1139 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1140 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;'>";
1141 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1142 if($helper ne $customgrp{$key}[0]){
1144 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1145 print ">$customgrp{$key}[0]</option>";
1147 $helper=$customgrp{$key}[0];
1149 print"</select></td>";
1151 #End left table. start right table (vpn)
1152 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1154 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1155 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;'>";
1156 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1157 print"</select></td></tr>";
1160 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1161 if ($ccdhost{$key}[33] ne '' ){
1162 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 '');
1164 print "<option value='$ccdhost{$key}[1]'";
1165 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1166 print ">$ccdhost{$key}[1]</option>";
1169 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1170 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>" ;
1172 if ($show eq '1'){$show='';print"</select></td></tr>";}
1174 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1175 if ($ccdhost{$key}[3] eq 'net'){
1176 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 '');
1178 print "<option value='$ccdhost{$key}[1]'";
1179 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1180 print ">$ccdhost{$key}[1]</option>";
1183 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1184 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>" ;
1186 if ($show eq '1'){$show='';print"</select></td></tr>";}
1188 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1189 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1190 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 '');
1193 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1194 print ">$ipsecconf{$key}[1]</option>";
1197 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1198 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>";
1200 if ($show eq '1'){$show='';print"</select></td></tr>";}
1203 print"</td></tr></table><br>";
1211 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1212 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1213 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1214 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1215 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1216 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1217 $a=$netsettings{'GREEN_NETADDRESS'};
1218 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1219 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1220 $a=$netsettings{'ORANGE_NETADDRESS'};
1221 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1222 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1223 $a=$netsettings{'BLUE_NETADDRESS'};
1224 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1225 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1226 &General
::readhash
("$configovpn",\
%ovpnsettings);
1227 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1228 $b=&General
::iporsubtocidr
($b);
1230 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1231 &General
::readhasharray
("$confignet", \
%customnetwork);
1232 foreach my $key (keys %customnetwork){
1233 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1234 $a=$customnetwork{$key}[1];
1235 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1238 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1239 &General
::readhasharray
("$confighost", \
%customhost);
1240 foreach my $key (keys %customhost){
1241 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1242 if ($customhost{$key}[1] eq 'ip'){
1243 ($a,$b)=split (/\//,$customhost{$key}[2]);
1244 $b=&General
::iporsubtocidr
($b);
1246 if ($grp eq 'grp2'){
1247 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1259 &General
::setup_default_networks
(\
%defaultNetworks);
1260 foreach my $network (sort keys %defaultNetworks)
1262 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1267 my %hash=%{(shift)};
1269 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1270 $hash{$key}[10]=~ s/\|/,/g;
1271 print": $hash{$key}[10]";
1272 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1273 print": <br>$hash{$key}[9] ";
1278 my %hash=%{(shift)};
1282 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1283 if($hash{$key}[14] eq 'cust_srv'){
1284 &General
::readhasharray
("$configsrv", \
%customservice);
1285 foreach my $i (sort keys %customservice){
1286 if($customservice{$i}[0] eq $hash{$key}[15]){
1287 $service = $customservice{$i}[0];
1290 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1291 $service=$hash{$key}[15];
1292 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1293 $hash{$key}[15]=~ s/\|/,/g;
1294 $service=$hash{$key}[15];
1301 sub get_serviceports
1305 &General
::readhasharray
("$configsrv", \
%customservice);
1306 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1311 if($type eq 'service'){
1312 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1313 if ($customservice{$key}[0] eq $name){
1314 push (@protocols,$customservice{$key}[2]);
1317 }elsif($type eq 'group'){
1318 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1319 if ($customservicegrp{$key}[0] eq $name){
1320 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1321 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1322 if($customservice{$key1}[2] eq 'TCP'){
1324 }elsif($customservice{$key1}[2] eq 'ICMP'){
1326 }elsif($customservice{$key1}[2] eq 'UDP'){
1334 if($tcp && $udp && $icmp){
1335 push (@protocols,"TCP,UDP, <br>ICMP");
1339 push (@protocols,"TCP");
1342 push (@protocols,"UDP");
1345 push (@protocols,"ICMP");
1354 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1356 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1357 foreach my $key (sort keys %$hash){
1358 if ($$hash{$key}[0] eq $val){
1359 $val=$$hash{$key}[2];
1364 if ($val eq 'GREEN'){
1365 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1367 }elsif ($val eq 'ORANGE'){
1368 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1370 }elsif ($val eq 'BLUE'){
1371 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1373 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1374 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1376 }elsif ($val eq 'IPFire' ){
1377 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1379 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1380 my ($sip,$scidr) = split ("/",$val);
1381 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1382 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1385 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1386 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1389 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1390 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1393 }elsif ($val eq 'Default IP'){
1394 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1397 #Check if a manual IP or custom host is part of a VPN
1398 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1399 #Check if IP is part of OpenVPN dynamic subnet
1400 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1401 my ($c,$d) = split("/",$val);
1402 if (&General
::IpInSubnet
($c,$a,$b)){
1403 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1406 #Check if IP is part of OpenVPN static subnet
1407 foreach my $key (sort keys %ccdnet){
1408 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1409 $b =&General
::iporsubtodec
($b);
1410 if (&General
::IpInSubnet
($c,$a,$b)){
1411 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1415 #Check if IP is part of OpenVPN N2N subnet
1416 foreach my $key (sort keys %ccdhost){
1417 if ($ccdhost{$key}[3] eq 'net'){
1418 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1419 if (&General
::IpInSubnet
($c,$a,$b)){
1420 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1425 #Check if IP is part of IPsec RW network
1426 if ($ipsecsettings{'RW_NET'} ne ''){
1427 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1428 $b=&General
::iporsubtodec
($b);
1429 if (&General
::IpInSubnet
($c,$a,$b)){
1430 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1434 #Check if IP is part of a IPsec N2N network
1435 foreach my $key (sort keys %ipsecconf){
1436 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1437 if (&General
::IpInSubnet
($c,$a,$b)){
1438 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1444 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'){
1445 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1448 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1449 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1453 foreach my $alias (sort keys %aliases)
1455 if ($val eq $alias){
1456 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1467 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1468 print "<class name='base'>$hint\n";
1469 print " </class>\n";
1470 &Header
::closebox
();
1477 my %hash=%{(shift)};
1481 &General
::readhasharray
($config, \
%hash);
1482 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1483 if($hash{$key}[0] eq $val){
1484 $pos=$#{$hash{$key}};
1485 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1488 &General
::writehasharray
($config, \
%hash);
1493 &General
::setup_default_networks
(\
%defaultNetworks);
1494 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1495 #read all configfiles
1496 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1497 &General
::readhasharray
("$confignet", \
%customnetwork);
1498 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1499 &General
::readhasharray
("$confighost", \
%customhost);
1500 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1501 &General
::readhasharray
("$configgrp", \
%customgrp);
1502 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1503 &General
::get_aliases
(\
%aliases);
1507 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1508 my $config=$fwdfwsettings{'config'};
1511 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1512 my $redip = <CONN1
>;
1514 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1515 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1516 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1517 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1518 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1519 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1520 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1521 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1522 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1523 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1524 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1525 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1526 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1527 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1528 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1529 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1530 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1531 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1532 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1533 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1534 #check if update and get values
1535 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1536 &General
::readhasharray
("$config", \
%hash);
1537 foreach my $key (sort keys %hash){
1539 if ($key eq $fwdfwsettings{'key'}){
1540 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1541 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1542 $fwdfwsettings{'chain'} = $hash{$key}[1];
1543 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1544 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1545 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1546 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1547 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1548 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1549 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1550 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1551 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1552 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1553 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1554 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1555 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1556 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1557 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1558 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1559 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1560 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1561 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1562 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1563 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1564 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1565 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1566 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1567 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1568 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1569 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1570 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1571 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1572 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1573 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1574 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1575 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1576 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1577 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1578 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1579 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1580 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1581 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1582 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1583 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1584 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1585 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1586 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1587 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1588 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1589 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1590 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1591 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1592 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1593 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1594 $selected{'dnat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1595 $selected{'snat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1598 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1599 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1600 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1601 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1602 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1603 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1604 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1605 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1606 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1607 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1608 #check if manual ip (source) is orange network
1609 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1610 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1611 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1612 $fwdfwsettings{'oldorange'} ='on';
1616 $fwdfwsettings{'ACTIVE'}='ON';
1617 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1618 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1619 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1620 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1621 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1622 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1623 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1624 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1625 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1626 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1627 #check if manual ip (source) is orange network
1628 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1629 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1630 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1631 $fwdfwsettings{'oldorange'} ='on';
1635 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1636 &Header
::closebox
();
1637 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1638 #------SOURCE-------------------------------------------------------
1639 print "<form method='post'>";
1641 <table width='100%' border='0'>
1642 <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>
1644 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1645 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1646 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1647 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1648 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1649 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1650 if (! -z
"${General::swroot}/ethernet/aliases"){
1651 foreach my $alias (sort keys %aliases)
1653 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1658 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1660 &gen_dd_block
('src','grp1');
1662 &Header
::closebox
();
1664 #---SNAT / DNAT ------------------------------------------------
1665 &Header
::openbox
('100%', 'left', 'NAT');
1668 <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}>
1669 $Lang::tr{'fwdfw use nat'}
1672 <table width='100%' border='0'>
1674 <td width='5%'></td>
1677 <input type='radio' name='nat' id='dnat' value='dnat' checked>
1678 $Lang::tr{'fwdfw dnat'}
1685 <td width='25%' align='right'>$Lang::tr{'dnat address'}:</td>
1687 <select name='dnat' style='width: 100%;'>
1688 <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'default ip'}</option>
1690 foreach my $alias (sort keys %aliases) {
1691 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
1697 <td colspan="2" width='55%'>
1698 <input type='hidden' name='dnat' value='Default IP'>
1707 <td width='5%'></td>
1710 <input type='radio' name='nat' id='snat' value='snat' $checked{'nat'}{'snat'}>
1711 $Lang::tr{'fwdfw snat'}
1714 <td width='25%' align='right'>$Lang::tr{'snat new source ip address'}:</td>
1716 <select name='snat' style='width: 100%;'>
1719 foreach my $alias (sort keys %aliases) {
1720 print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
1723 # XXX this is composed in a very ugly fashion
1724 foreach my $network (sort keys %defaultNetworks) {
1725 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1726 next if($defaultNetworks{$network}{'NAME'} eq "ALL");
1727 next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
1729 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1730 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
1731 print ">$network</option>";
1741 &Header
::closebox
();
1743 #---TARGET------------------------------------------------------
1744 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1746 <table width='100%' border='0'>
1747 <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>
1749 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1750 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1751 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1752 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1753 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1754 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1755 if (! -z
"${General::swroot}/ethernet/aliases"){
1756 foreach my $alias (sort keys %aliases)
1758 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1763 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1765 &gen_dd_block
('tgt','grp2');
1768 #---PROTOCOL------------------------------------------------------
1769 $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
1770 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1771 $fwdfwsettings{'dnatport'} =~ tr/|/,/;
1773 # The dnatport may be empty, if it matches TGT_PORT
1774 if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
1775 $fwdfwsettings{'dnatport'} = "";
1778 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1779 #Fix Protocol for JQuery
1780 if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
1781 $fwdfwsettings{'PROT'} = 'template';
1784 <table width='100%' border='0'>
1787 <select name='PROT' id='protocol' style="width: 95px;">
1789 print "<option value=\"\"";
1790 if ($fwdfwsettings{'PROT'} eq '') {
1791 print " selected=\"selected\"";
1793 print ">$Lang::tr{'all'}</option>";
1795 print "<option value=\"template\"";
1796 print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp');
1797 print ">- $Lang::tr{'template'} -</option>";
1799 foreach (@PROTOCOLS) {
1800 print"<option value=\"$_\"";
1801 if ($_ eq $fwdfwsettings{'PROT'}) {
1802 print " selected=\"selected\"";
1805 print ">$Lang::tr{'fwdfw prot41'}</option>";
1807 print ">$_</option>";
1815 <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES">
1817 <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
1819 <select name='ICMP_TYPES' style='min-width:230px;'>
1821 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1822 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1823 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1824 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1825 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1827 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1837 <table width="100%" border="0" id="PROTOCOL_PORTS">
1839 <!-- #SOURCEPORT -->
1841 $Lang::tr{'fwdfw use srcport'}
1844 <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
1849 <!-- #TARGETPORT -->
1851 $Lang::tr{'fwdfw use srv'}
1855 <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
1859 <td colspan='3'></td>
1860 <td>$Lang::tr{'fwdfw external port nat'}:</td>
1862 <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
1867 <table width="100%" border="0" id="PROTOCOL_TEMPLATE">
1870 <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
1871 $Lang::tr{'fwhost cust service'}
1874 <select name='cust_srv' style='min-width: 230px;'>
1877 &General
::readhasharray
("$configsrv", \
%customservice);
1878 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1880 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1881 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1890 <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
1891 $Lang::tr{'fwhost cust srvgrp'}
1894 <select name='cust_srvgrp' style='min-width:230px;'>
1897 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1899 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1900 if ($helper ne $customservicegrp{$key}[0]){
1902 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1903 print">$customservicegrp{$key}[0]</option>";
1905 $helper=$customservicegrp{$key}[0];
1920 $checked{"RULE_ACTION"} = ();
1921 foreach ("ACCEPT", "DROP", "REJECT") {
1922 $checked{"RULE_ACTION"}{$_} = "";
1925 if($fwdfwsettings{'updatefwrule'} eq 'on') {
1926 $checked{"RULE_ACTION"}{$fwdfwsettings{'RULE_ACTION'}} = "checked";
1927 } elsif ($fwdfwsettings{'POLICY'} eq 'MODE1') {
1928 $checked{"RULE_ACTION"}{"ACCEPT"} = "checked";
1929 } elsif ($fwdfwsettings{'POLICY'} eq 'MODE2') {
1930 $checked{"RULE_ACTION"}{"DROP"} = "checked";
1937 <table width="80%" border="0">
1939 <td width="33%" align="center" bgcolor="$color{'color17'}">
1942 <td width="33%" align="center" bgcolor="$color{'color25'}">
1945 <td width="33%" align="center" bgcolor="$color{'color16'}">
1950 <td width="33%" align="center">
1952 <input type="radio" name="RULE_ACTION" value="ACCEPT" $checked{"RULE_ACTION"}{"ACCEPT"}>
1953 <strong>$Lang::tr{'fwdfw ACCEPT'}</strong>
1956 <td width="33%" align="center">
1958 <input type="radio" name="RULE_ACTION" value="DROP" $checked{"RULE_ACTION"}{"DROP"}>
1959 <strong>$Lang::tr{'fwdfw DROP'}</strong>
1962 <td width="33%" align="center">
1964 <input type="radio" name="RULE_ACTION" value="REJECT" $checked{"RULE_ACTION"}{"REJECT"}>
1965 <strong>$Lang::tr{'fwdfw REJECT'}</strong>
1975 #---Activate/logging/remark-------------------------------------
1976 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1978 <table width='100%' border='0'>
1980 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>";
1981 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1982 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1983 for (my $count =1; $count <= $sum; $count++){
1984 print"<option value='$count' ";
1985 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1986 print">$count</option>";
1988 print"</select></td></tr>";
1990 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1995 <table width='100%'>
1999 if ($fwdfwsettings{'updatefwrule'} eq 'on') {
2002 <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}>
2004 <td>$Lang::tr{'fwdfw rule activate'}</td>
2009 <input type="hidden" name="ACTIVE" value="ON">
2018 <input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'}>
2020 <td>$Lang::tr{'fwdfw log rule'}</td>
2024 <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}>
2026 <td>$Lang::tr{'fwdfw timeframe'}</td>
2028 <tr id="TIME_CONSTRAINTS">
2030 <table width="66%" border="0">
2032 <td width="8em"> </td>
2033 <td align="center">$Lang::tr{'advproxy monday'}</td>
2034 <td align="center">$Lang::tr{'advproxy tuesday'}</td>
2035 <td align="center">$Lang::tr{'advproxy wednesday'}</td>
2036 <td align="center">$Lang::tr{'advproxy thursday'}</td>
2037 <td align="center">$Lang::tr{'advproxy friday'}</td>
2038 <td align="center">$Lang::tr{'advproxy saturday'}</td>
2039 <td align="center">$Lang::tr{'advproxy sunday'}</td>
2043 <td width="8em"> </td>
2044 <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
2045 <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
2046 <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
2047 <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
2048 <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
2049 <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
2050 <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
2052 <select name='TIME_FROM'>
2054 for (my $i=0;$i<=23;$i++) {
2055 $i = sprintf("%02s",$i);
2056 for (my $j=0;$j<=45;$j+=15) {
2057 $j = sprintf("%02s",$j);
2058 my $time = $i.":".$j;
2059 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
2064 <select name='TIME_TO'>
2066 for (my $i=0;$i<=23;$i++) {
2067 $i = sprintf("%02s",$i);
2068 for (my $j=0;$j<=45;$j+=15) {
2069 $j = sprintf("%02s",$j);
2070 my $time = $i.":".$j;
2071 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
2085 #---ACTION------------------------------------------------------
2086 if($fwdfwsettings{'updatefwrule'} ne 'on'){
2088 <table border='0' width='100%'>
2089 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
2090 <input type='hidden' name='config' value='$config' >
2091 <input type='hidden' name='ACTION' value='saverule' ></form>
2092 <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>
2098 <table border='0' width='100%'>
2099 <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'}'>
2100 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
2101 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
2102 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
2103 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
2104 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
2105 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
2106 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
2107 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
2108 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
2109 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
2110 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
2111 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
2112 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
2113 <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>
2117 &Header
::closebox
();
2123 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
2124 foreach my $key (sort keys %uphash){
2125 if ($key eq $fwdfwsettings{'key'}) {
2127 if (exists $uphash{$last}){
2129 foreach my $y (0 .. $#{$uphash{$last}}) {
2130 $tmp{0}[$y] = $uphash{$last}[$y];
2132 #copy active rule to last
2133 foreach my $i (0 .. $#{$uphash{$last}}) {
2134 $uphash{$last}[$i] = $uphash{$key}[$i];
2136 #copy saved rule to actual position
2137 foreach my $x (0 .. $#{$tmp{0}}) {
2138 $uphash{$key}[$x] = $tmp{0}[$x];
2143 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
2144 &General
::firewall_config_changed
();
2150 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
2151 foreach my $key (sort keys %downhash){
2152 if ($key eq $fwdfwsettings{'key'}) {
2153 my $next = $key + 1;
2154 if (exists $downhash{$next}){
2156 foreach my $y (0 .. $#{$downhash{$next}}) {
2157 $tmp{0}[$y] = $downhash{$next}[$y];
2159 #copy active rule to next
2160 foreach my $i (0 .. $#{$downhash{$next}}) {
2161 $downhash{$next}[$i] = $downhash{$key}[$i];
2163 #copy saved rule to actual position
2164 foreach my $x (0 .. $#{$tmp{0}}) {
2165 $downhash{$key}[$x] = $tmp{0}[$x];
2170 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
2171 &General
::firewall_config_changed
();
2177 &General
::readhasharray
("$config", $hash);
2178 if (!$errormessage){
2179 ################################################################
2180 #check if we change an INPUT rule to a OUTGOING
2181 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2182 &changerule
($configinput);
2185 #check if we change an INPUT rule to a FORWARD
2186 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2187 &changerule
($configinput);
2190 ################################################################
2191 #check if we change an OUTGOING rule to an INPUT
2192 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2193 &changerule
($configoutgoing);
2196 #check if we change an OUTGOING rule to a FORWARD
2197 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2198 &changerule
($configoutgoing);
2201 ################################################################
2202 #check if we change a FORWARD rule to an INPUT
2203 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2204 &changerule
($configfwdfw);
2207 #check if we change a FORWARD rule to an OUTGOING
2208 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2209 &changerule
($configfwdfw);
2212 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2213 my $key = &General
::findhasharraykey
($hash);
2214 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2215 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2216 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2217 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2218 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2219 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2220 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2221 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2222 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2223 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2224 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2225 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2226 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2227 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2228 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2229 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2230 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2231 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2232 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2233 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2234 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2235 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2236 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2237 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2238 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2239 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2240 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2241 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2242 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2243 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2244 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2245 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2246 &General
::writehasharray
("$config", $hash);
2248 foreach my $key (sort {$a <=> $b} keys %$hash){
2249 if($key eq $fwdfwsettings{'key'}){
2250 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2251 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2252 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2253 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2254 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2255 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2256 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2257 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2258 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2259 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2260 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2261 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2262 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2263 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2264 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2265 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2266 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2267 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2268 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2269 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2270 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2271 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2272 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2273 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2274 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2275 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2276 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2277 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2278 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2279 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2280 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2281 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2286 &General
::writehasharray
("$config", $hash);
2287 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2289 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2290 for (my $z=0;$z<$val;$z++){
2291 foreach my $key (sort {$a <=> $b} keys %$hash){
2292 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2294 if (exists $$hash{$last}){
2296 foreach my $y (0 .. $#{$$hash{$last}}) {
2297 $tmp{0}[$y] = $$hash{$last}[$y];
2299 #copy active rule to last
2300 foreach my $i (0 .. $#{$$hash{$last}}) {
2301 $$hash{$last}[$i] = $$hash{$key}[$i];
2303 #copy saved rule to actual position
2304 foreach my $x (0 .. $#{$tmp{0}}) {
2305 $$hash{$key}[$x] = $tmp{0}[$x];
2310 $fwdfwsettings{'oldrulenumber'}--;
2312 &General
::writehasharray
("$config", $hash);
2313 &General
::firewall_config_changed
();
2314 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2316 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2317 for (my $z=0;$z<$val;$z++){
2318 foreach my $key (sort {$a <=> $b} keys %$hash){
2319 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2320 my $next = $key + 1;
2321 if (exists $$hash{$next}){
2323 foreach my $y (0 .. $#{$$hash{$next}}) {
2324 $tmp{0}[$y] = $$hash{$next}[$y];
2326 #copy active rule to next
2327 foreach my $i (0 .. $#{$$hash{$next}}) {
2328 $$hash{$next}[$i] = $$hash{$key}[$i];
2330 #copy saved rule to actual position
2331 foreach my $x (0 .. $#{$tmp{0}}) {
2332 $$hash{$key}[$x] = $tmp{0}[$x];
2337 $fwdfwsettings{'oldrulenumber'}++;
2339 &General
::writehasharray
("$config", $hash);
2340 &General
::firewall_config_changed
();
2346 # Checks a hostname against RFC1035
2349 # Each part should be at least two characters in length
2350 # but no more than 63 characters
2351 if (length ($remark) < 1 || length ($remark) > 255) {
2353 # Only valid characters are a-z, A-Z, 0-9 and -
2354 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2356 # First character can only be a letter or a digit
2357 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2359 # Last character can only be a letter or a digit
2360 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2366 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2368 &viewtablenew
(\
%configfwdfw, $configfwdfw, $Lang::tr
{'firewall rules'});
2369 &viewtablenew
(\
%configinputfw, $configinput, $Lang::tr
{'external access'});
2370 &viewtablenew
(\
%configoutgoingfw, $configoutgoing, $Lang::tr
{'outgoing firewall'});
2380 my $show_box = (! -z
$config) || ($optionsfw{'SHOWTABLES'} eq 'on');
2381 return if (!$show_box);
2383 &General
::get_aliases
(\
%aliases);
2384 &General
::readhasharray
("$confighost", \
%customhost);
2385 &General
::readhasharray
("$config", $hash);
2386 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2387 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2389 &Header
::openbox
('100%', 'left', $title);
2390 print "<table width='100%' cellspacing='0' border='0'>";
2403 <th align='right' width='3%'>
2406 <th width='2%'></th>
2408 <b>$Lang::tr{'protocol'}</b>
2410 <th align='center' width='30%'>
2411 <b>$Lang::tr{'fwdfw source'}</b>
2414 <b>$Lang::tr{'fwdfw log'}</b>
2416 <th align='center' width='30%'>
2417 <b>$Lang::tr{'fwdfw target'}</b>
2419 <th align='center' colspan='6' width='18%'>
2420 <b>$Lang::tr{'fwdfw action'}</b>
2425 foreach my $key (sort {$a <=> $b} keys %$hash){
2428 #check if vpn hosts/nets have been deleted
2429 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2430 push (@tmpsrc,$$hash{$key}[4]);
2432 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2433 push (@tmpsrc,$$hash{$key}[6]);
2435 foreach my $host (@tmpsrc){
2436 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2437 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2439 &disable_rule
($key);
2442 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2443 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2445 &disable_rule
($key);
2448 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2449 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2451 &disable_rule
($key);
2454 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2455 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2457 &disable_rule
($key);
2462 $$hash{'ACTIVE'}=$$hash{$key}[2];
2464 if($coloryellow eq 'on'){
2465 print"<tr bgcolor='$color{'color14'}' >";
2467 }elsif($coloryellow eq ''){
2469 $color="$color{'color22'}";
2472 $color="$color{'color20'}";
2476 <tr bgcolor='$color'>
2477 <td align='right' width='3%'>
2483 if ($$hash{$key}[0] eq 'ACCEPT'){
2486 $rulecolor=$color{'color17'};
2487 }elsif($$hash{$key}[0] eq 'DROP'){
2490 $rulecolor=$color{'color25'};
2491 }elsif($$hash{$key}[0] eq 'REJECT'){
2494 $rulecolor=$color{'color16'};
2498 <td bgcolor='$rulecolor' align='center' width='2%'>
2499 <span title='$tooltip'> </span>
2505 if ($$hash{$key}[8]){
2506 if ($$hash{$key}[8] eq "IPv6"){
2507 push (@protocols,$Lang::tr
{'fwdfw prot41 short'})
2509 push (@protocols,$$hash{$key}[8]);
2511 }elsif($$hash{$key}[14] eq 'cust_srv'){
2512 &get_serviceports
("service",$$hash{$key}[15]);
2513 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2514 &get_serviceports
("group",$$hash{$key}[15]);
2516 push (@protocols,$Lang::tr
{'all'});
2519 my $protz=join(",",@protocols);
2520 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2521 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2522 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2523 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2524 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2529 print"<td align='center'>$protz</td>";
2534 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2535 print"<td align='center' width='30%' $tdcolor>";
2536 if ($$hash{$key}[3] eq 'ipfire_src'){
2537 $ipfireiface=$Lang::tr
{'fwdfw iface'};
2539 if ($$hash{$key}[3] eq 'std_net_src'){
2540 print &get_name
($$hash{$key}[4]);
2541 }elsif ($$hash{$key}[3] eq 'src_addr'){
2542 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2543 if ($split2 eq '32'){
2546 print $$hash{$key}[4];
2548 }elsif ($$hash{$key}[4] eq 'RED1'){
2549 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2551 print "$$hash{$key}[4]";
2555 &getsrcport
(\
%$hash,$key);
2556 #Is this a SNAT rule?
2557 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2558 my $net=&get_name
($$hash{$key}[29]);
2559 if ( ! $net){ $net=$$hash{$key}[29];}
2561 if ($$hash{$key}[30] ne ''){
2562 print": $$hash{$key}[30]";
2565 if ($$hash{$key}[17] eq 'ON'){
2566 $log="/images/on.gif";
2568 $log="/images/off.gif";
2574 <form method='POST' action=''>
2575 <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 ;'/>
2576 <input type='hidden' name='key' value='$key' />
2577 <input type='hidden' name='config' value='$config' />
2578 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2583 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2585 <td align='center' $tdcolor>
2587 #Is this a DNAT rule?
2588 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2589 print "Firewall ($$hash{$key}[29])";
2590 if($$hash{$key}[30] ne ''){
2591 $$hash{$key}[30]=~ tr/|/,/;
2592 print": $$hash{$key}[30]";
2596 if ($$hash{$key}[5] eq 'ipfire'){
2597 $ipfireiface='Interface';
2599 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire' || $$hash{$key}[6] eq 'RED1' || $$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE' ){
2600 if ($$hash{$key}[6] eq 'RED1'){
2601 print "$ipfireiface $Lang::tr{'red1'}";
2602 }elsif ($$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE'|| $$hash{$key}[6] eq 'ALL')
2604 print "$ipfireiface ".&get_name
($$hash{$key}[6]);
2606 print $$hash{$key}[6];
2608 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2609 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2610 if ($split2 eq '32'){
2613 print $$hash{$key}[6];
2616 print "$$hash{$key}[6]";
2620 &gettgtport
(\
%$hash,$key);
2623 if($$hash{$key}[2] eq 'ON'){
2624 $gif="/images/on.gif"
2627 $gif="/images/off.gif"
2630 <td width='3%' align='center'>
2631 <form method='POST' action=''>
2632 <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;' />
2633 <input type='hidden' name='key' value='$key' />
2634 <input type='hidden' name='config' value='$config' />
2635 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2638 <td width='3%' align='center'>
2639 <form method='POST' action=''>
2640 <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;' />
2641 <input type='hidden' name='key' value='$key' />
2642 <input type='hidden' name='config' value='$config' />
2643 <input type='hidden' name='ACTION' value='editrule' />
2646 <td width='3%' align='center'>
2647 <form method='POST' action=''>
2648 <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;' />
2649 <input type='hidden' name='key' value='$key' />
2650 <input type='hidden' name='config' value='$config' />
2651 <input type='hidden' name='ACTION' value='copyrule' />
2654 <td width='3%' align='center'>
2655 <form method='POST' action=''>
2656 <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;' />
2657 <input type='hidden' name='key' value='$key' />
2658 <input type='hidden' name='config' value='$config' />
2659 <input type='hidden' name='ACTION' value='deleterule' />
2663 if (exists $$hash{$key-1}){
2665 <td width='3%' align='center'>
2666 <form method='POST' action=''>
2667 <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;' />
2668 <input type='hidden' name='key' value='$key' />
2669 <input type='hidden' name='config' value='$config' />
2670 <input type='hidden' name='ACTION' value='moveup' />
2675 print"<td width='3%'></td>";
2678 if (exists $$hash{$key+1}){
2680 <td width='3%' align='center'>
2681 <form method='POST' action=''>
2682 <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;' />
2683 <input type='hidden' name='key' value='$key' />
2684 <input type='hidden' name='config' value='$config' />
2685 <input type='hidden' name='ACTION' value='movedown' />
2691 print"<td width='3%'></td></tr>";
2694 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2696 <tr bgcolor='$color'>
2698 <td bgcolor='$rulecolor'></td>
2700 <em>$$hash{$key}[16]</em>
2706 if ($$hash{$key}[18] eq 'ON'){
2708 if ($$hash{$key}[18] eq 'ON'){
2710 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2711 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2712 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2713 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2714 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2715 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2716 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2717 my $weekdays=join(",",@days);
2719 print"<tr bgcolor='$color'>";
2720 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27]</td></tr>";
2724 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2726 } elsif ($optionsfw{'SHOWTABLES'} eq 'on') {
2729 <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td>
2735 my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'};
2736 my $colour = "bgcolor='green'";
2737 if ($fwdfwsettings{'POLICY'} eq 'MODE1') {
2738 $colour = "bgcolor='darkred'";
2742 if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) {
2745 <td colspan='13'> </td>
2749 <table width="100%" border='1' rules="cols" cellspacing='0'>
2756 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2759 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2760 ($Lang::tr{'fwdfw pol allow'})
2764 if (&Header
::orange_used
()) {
2767 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2768 ($Lang::tr{'fwdfw pol allow'})
2773 if (&Header
::blue_used
()) {
2776 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2777 ($Lang::tr{'fwdfw pol allow'})
2785 if (&Header
::orange_used
()) {
2788 <td align='center' width='20%'>
2789 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2792 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2793 ($Lang::tr{'fwdfw pol allow'})
2796 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2797 ($Lang::tr{'fwdfw pol block'})
2801 if (&Header
::blue_used
()) {
2804 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2805 ($Lang::tr{'fwdfw pol block'})
2813 if (&Header
::blue_used
()) {
2817 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2820 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2821 ($Lang::tr{'fwdfw pol allow'})
2825 if (&Header
::orange_used
()) {
2828 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2829 ($Lang::tr{'fwdfw pol block'})
2832 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2833 ($Lang::tr{'fwdfw pol block'})
2847 $message = $Lang::tr
{'fwdfw pol allow'};
2849 } elsif ($config eq '/var/ipfire/firewall/outgoing') {
2850 $message = $Lang::tr
{'fwdfw pol allow'};
2853 $message = $Lang::tr
{'fwdfw pol block'};
2854 $colour = "bgcolor='darkred'";
2860 <td $colour align='center' colspan='13'>
2861 <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font>
2870 &Header
::closebox
();
2873 &Header
::closebigbox
();
2874 &Header
::closepage
();