]>
git.ipfire.org Git - people/jschlag/ipfire-2.x.git/blob - html/cgi-bin/firewall.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
25 use feature
'unicode_strings';
27 no warnings
'uninitialized';
29 # enable only the following on debugging purpose
31 #use CGI::Carp 'fatalsToBrowser';
33 require '/var/ipfire/general-functions.pl';
34 require "${General::swroot}/lang.pl";
35 require "${General::swroot}/header.pl";
36 require "/usr/lib/firewall/firewall-lib.pl";
38 unless (-d
"${General::swroot}/firewall") { system("mkdir ${General::swroot}/firewall"); }
39 unless (-e
"${General::swroot}/firewall/settings") { system("touch ${General::swroot}/firewall/settings"); }
40 unless (-e
"${General::swroot}/firewall/config") { system("touch ${General::swroot}/firewall/config"); }
41 unless (-e
"${General::swroot}/firewall/input") { system("touch ${General::swroot}/firewall/input"); }
42 unless (-e
"${General::swroot}/firewall/outgoing") { system("touch ${General::swroot}/firewall/outgoing"); }
46 my %defaultNetworks=();
50 my %customnetworks=();
52 my %customservicegrp=();
58 my %configoutgoingfw=();
70 my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE","IPv6","IPIP");
73 my $confignet = "${General::swroot}/fwhosts/customnetworks";
74 my $confighost = "${General::swroot}/fwhosts/customhosts";
75 my $configgrp = "${General::swroot}/fwhosts/customgroups";
76 my $configsrv = "${General::swroot}/fwhosts/customservices";
77 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
78 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
79 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
80 my $configipsec = "${General::swroot}/vpn/config";
81 my $configipsecrw = "${General::swroot}/vpn/settings";
82 my $configfwdfw = "${General::swroot}/firewall/config";
83 my $configinput = "${General::swroot}/firewall/input";
84 my $configoutgoing = "${General::swroot}/firewall/outgoing";
85 my $configovpn = "${General::swroot}/ovpn/settings";
86 my $fwoptions = "${General::swroot}/optionsfw/settings";
87 my $ifacesettings = "${General::swroot}/ethernet/settings";
90 my $ipgrp="${General::swroot}/outgoing/groups";
94 &General
::readhash
("${General::swroot}/firewall/settings", \
%fwdfwsettings);
95 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
96 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
97 &General
::readhash
($fwoptions, \
%optionsfw);
98 &General
::readhash
($ifacesettings, \
%ifaces);
99 &General
::readhash
("$configovpn", \
%ovpnsettings);
100 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
101 &General
::readhasharray
("$configipsec", \
%ipsecconf);
102 &Header
::showhttpheaders
();
103 &Header
::getcgihash
(\
%fwdfwsettings);
104 &Header
::openpage
($Lang::tr
{'firewall rules'}, 1, '');
105 &Header
::openbigbox
('100%', 'center',$errormessage);
106 #### JAVA SCRIPT ####
109 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
111 var update_protocol = function() {
112 var protocol = \$("#protocol").val();
114 if (protocol === undefined)
117 // Check if a template is/should be used.
118 if (protocol === "template") {
119 \$("#PROTOCOL_TEMPLATE").show();
121 \$("#PROTOCOL_TEMPLATE").hide();
124 // Check if we are dealing with a protocol, that knows ports.
125 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
126 \$("#PROTOCOL_PORTS").show();
128 \$("#PROTOCOL_PORTS").hide();
132 if (protocol === "ICMP") {
133 \$("#PROTOCOL_ICMP_TYPES").show();
135 \$("#PROTOCOL_ICMP_TYPES").hide();
139 \$(document).ready(function() {
140 \$("#protocol").change(update_protocol);
143 // Show/Hide elements when NAT checkbox is checked.
144 if (\$("#USE_NAT").attr("checked")) {
145 \$("#actions").hide();
150 // Show NAT area when "use nat" checkbox is clicked
151 \$("#USE_NAT").change(function() {
153 \$("#actions").toggle();
157 if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) {
158 \$("#TIME_CONSTRAINTS").hide();
160 \$("#USE_TIME_CONSTRAINTS").change(function() {
161 \$("#TIME_CONSTRAINTS").toggle();
164 // Limit concurrent connections per ip
165 if(!\$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").attr("checked")) {
166 \$("#LIMIT_CON").hide();
168 \$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").change(function() {
169 \$("#LIMIT_CON").toggle();
172 // Rate-limit new connections
173 if(!\$("#USE_RATELIMIT").attr("checked")) {
174 \$("#RATELIMIT").hide();
176 \$("#USE_RATELIMIT").change(function() {
177 \$("#RATELIMIT").toggle();
180 // Automatically select radio buttons when corresponding
181 // dropdown menu changes.
182 \$("select").change(function() {
183 var id = \$(this).attr("name");
184 \$('#' + id).prop("checked", true);
192 if ($fwdfwsettings{'ACTION'} eq 'saverule')
194 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
195 &General
::readhasharray
("$configinput", \
%configinputfw);
196 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
197 #Set Variables according to the JQuery code in protocol section
198 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')
200 if ($fwdfwsettings{'SRC_PORT'} ne '')
202 $fwdfwsettings{'USE_SRC_PORT'} = 'ON';
204 if ($fwdfwsettings{'TGT_PORT'} ne '')
206 $fwdfwsettings{'USESRV'} = 'ON';
207 $fwdfwsettings{'grp3'} = 'TGT_PORT';
210 if ($fwdfwsettings{'PROT'} eq 'template')
212 $fwdfwsettings{'USESRV'} = 'ON';
214 $errormessage=&checksource
;
215 if(!$errormessage){&checktarget
;}
216 if(!$errormessage){&checkrule
;}
218 #check if manual ip (source) is orange network
219 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
220 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
221 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
226 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
227 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
229 #check if we try to break rules
230 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
231 $errormessage=$Lang::tr
{'fwdfw err same'};
234 if($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
235 $fwdfwsettings{'config'}=$configinput;
236 $fwdfwsettings{'chain'} = 'INPUTFW';
237 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
238 #check if we have an identical rule already
239 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
240 foreach my $key (sort keys %configinputfw){
241 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'},$fwdfwsettings{'RATE_LIMIT'},$fwdfwsettings{'ratecon'},$fwdfwsettings{'RATETIME'}"
242 eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27],$configinputfw{$key}[28],$configinputfw{$key}[29],$configinputfw{$key}[30],$configinputfw{$key}[31],$configinputfw{$key}[32],$configinputfw{$key}[33],$configinputfw{$key}[34],$configinputfw{$key}[35],$configinputfw{$key}[36]"){
243 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
244 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
245 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
247 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
250 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
251 $fwdfwsettings{'nosave'} = 'on';
256 #check Rulepos on new Rule
257 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
258 $fwdfwsettings{'oldrulenumber'}=$maxkey;
259 foreach my $key (sort keys %configinputfw){
260 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'},$fwdfwsettings{'RATE_LIMIT'},$fwdfwsettings{'ratecon'},$fwdfwsettings{'RATETIME'}"
261 eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27],$configinputfw{$key}[28],$configinputfw{$key}[29],$configinputfw{$key}[30],$configinputfw{$key}[31],$configinputfw{$key}[32],$configinputfw{$key}[33],$configinputfw{$key}[34],$configinputfw{$key}[35],$configinputfw{$key}[36]"){
262 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
266 #check if we just close a rule
267 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'} ) {
268 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
270 $fwdfwsettings{'nosave2'} = 'on';
274 if($fwdfwsettings{'nosave2'} ne 'on'){
275 &saverule
(\
%configinputfw,$configinput);
278 }elsif($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
280 $fwdfwsettings{'config'}=$configoutgoing;
281 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
282 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
283 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
284 foreach my $key (sort keys %configoutgoingfw){
285 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'},$fwdfwsettings{'RATE_LIMIT'},$fwdfwsettings{'ratecon'},$fwdfwsettings{'RATETIME'}"
286 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],$configoutgoingfw{$key}[32],$configoutgoingfw{$key}[33],$configoutgoingfw{$key}[34],$configoutgoingfw{$key}[35],$configoutgoingfw{$key}[36]"){
287 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
288 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
289 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
291 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
294 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
295 $fwdfwsettings{'nosave'} = 'on';
300 #check Rulepos on new Rule
301 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
302 $fwdfwsettings{'oldrulenumber'}=$maxkey;
303 foreach my $key (sort keys %configoutgoingfw){
304 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'},$fwdfwsettings{'RATE_LIMIT'},$fwdfwsettings{'ratecon'},$fwdfwsettings{'RATETIME'}"
305 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],$configoutgoingfw{$key}[32],$configoutgoingfw{$key}[33],$configoutgoingfw{$key}[34],$configoutgoingfw{$key}[35],$configoutgoingfw{$key}[36]"){
306 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
310 #check if we just close a rule
311 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'} ) {
312 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
313 $fwdfwsettings{'nosave2'} = 'on';
319 if ($fwdfwsettings{'nosave2'} ne 'on'){
320 &saverule
(\
%configoutgoingfw,$configoutgoing);
325 $fwdfwsettings{'config'}=$configfwdfw;
326 $fwdfwsettings{'chain'} = 'FORWARDFW';
327 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
328 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
329 #check if we have an identical rule already
330 foreach my $key (sort keys %configfwdfw){
331 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'},$fwdfwsettings{'RATE_LIMIT'},$fwdfwsettings{'ratecon'},$fwdfwsettings{'RATETIME'}"
332 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],$configfwdfw{$key}[32],$configfwdfw{$key}[33],$configfwdfw{$key}[34],$configfwdfw{$key}[35],$configfwdfw{$key}[36]"){
333 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
334 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
335 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
337 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
340 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
341 $fwdfwsettings{'nosave'} = 'on';
346 #check Rulepos on new Rule
347 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
348 $fwdfwsettings{'oldrulenumber'}=$maxkey;
349 foreach my $key (sort keys %configfwdfw){
350 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'},$fwdfwsettings{'RATE_LIMIT'},$fwdfwsettings{'ratecon'},$fwdfwsettings{'RATETIME'}"
351 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],$configfwdfw{$key}[32],$configfwdfw{$key}[33],$configfwdfw{$key}[34],$configfwdfw{$key}[35],$configfwdfw{$key}[36]"){
352 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
356 #check if we just close a rule
357 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'}){
358 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
359 $fwdfwsettings{'nosave2'} = 'on';
363 #check max concurrent connections per ip address
364 if ($fwdfwsettings{'LIMIT_CON_CON'} eq 'ON'){
365 if (!($fwdfwsettings{'concon'} =~ /^(\d+)$/)) {
366 $errormessage.=$Lang::tr
{'fwdfw err concon'};
369 $fwdfwsettings{'concon'}='';
371 #check ratelimit value
372 if ($fwdfwsettings{'RATE_LIMIT'} eq 'ON'){
373 if (!($fwdfwsettings{'ratecon'} =~ /^(\d+)$/)) {
374 $errormessage.=$Lang::tr
{'fwdfw err ratecon'};
377 $fwdfwsettings{'ratecon'}='';
381 if ($fwdfwsettings{'nosave2'} ne 'on'){
382 &saverule
(\
%configfwdfw,$configfwdfw);
389 if($fwdfwsettings{'nosave2'} ne 'on'){
390 &General
::firewall_config_changed
();
395 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
399 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
402 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
403 foreach my $key (sort keys %togglehash){
404 if ($key eq $fwdfwsettings{'key'}){
405 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
408 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
409 &General
::firewall_config_changed
();
412 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
415 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
416 foreach my $key (sort keys %togglehash){
417 if ($key eq $fwdfwsettings{'key'}){
418 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
421 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
422 &General
::firewall_config_changed
();
425 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
427 &General
::firewall_reload
();
430 if ($fwdfwsettings{'ACTION'} eq 'editrule')
432 $fwdfwsettings{'updatefwrule'}='on';
435 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
439 if ($fwdfwsettings{'ACTION'} eq 'moveup')
444 if ($fwdfwsettings{'ACTION'} eq 'movedown')
449 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
451 $fwdfwsettings{'copyfwrule'}='on';
454 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
463 &Header
::openbox
('100%', 'left', "");
465 <form method="POST" action="">
466 <table border='0' width="100%">
469 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'>
472 if (&General
::firewall_needs_reload
()) {
474 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'>
498 $fwdfwsettings{'updatefwrule'}='';
499 $fwdfwsettings{'config'}=$oldchain;
500 $fwdfwsettings{'nobase'}='on';
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 $fwdfwsettings{'grp1'}='std_net_src';
548 $fwdfwsettings{$fwdfwsettings{'grp1'}} = 'ALL';
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 if ($fwdfwsettings{'grp2'} ne 'ipfire'){
620 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
621 return $errormessage;
625 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
626 #check if ip with subnet
627 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
628 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
629 $subnet = &General
::iporsubtocidr
($subnet);
632 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
633 $ip=$fwdfwsettings{'tgt_addr'};
636 #check if ip is valid
637 if (! &General
::validip
($ip)){
638 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
639 return $errormessage;
641 #check and form valid IP
642 $ip=&General
::ip2dec
($ip);
643 $ip=&General
::dec2ip
($ip);
644 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
645 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
646 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
647 return $errormessage;
649 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
650 $fwdfwsettings{'grp2'}='std_net_tgt';
651 $fwdfwsettings{$fwdfwsettings{'grp2'}} = 'ALL';
653 #check for mac in targetgroup
654 if ($fwdfwsettings{'grp2'} eq 'cust_grp_tgt'){
655 &General
::readhasharray
("$configgrp", \
%customgrp);
656 &General
::readhasharray
("$confighost", \
%customhost);
657 foreach my $grpkey (sort keys %customgrp){
658 foreach my $hostkey (sort keys %customhost){
659 if ($customgrp{$grpkey}[2] eq $customhost{$hostkey}[0] && $customhost{$hostkey}[1] eq 'mac'){
660 $hint=$Lang::tr
{'fwdfw hint mac'};
667 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
669 if ($fwdfwsettings{'USESRV'} eq 'ON'){
670 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
671 $fwdfwsettings{'TGT_PROT'}='';
672 $fwdfwsettings{'ICMP_TGT'}='';
673 $fwdfwsettings{'TGT_PORT'}='';
675 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
676 $fwdfwsettings{'TGT_PROT'}='';
677 $fwdfwsettings{'ICMP_TGT'}='';
678 $fwdfwsettings{'TGT_PORT'}='';
679 #check target service
680 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
681 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
684 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
685 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
686 if ($fwdfwsettings{'TGT_PORT'} ne ''){
687 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
688 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
689 return $errormessage;
691 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
695 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
697 #change dashes with :
700 push(@values,"1:65535");
703 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
704 push(@values,"1:$2");
707 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
708 push(@values,"$1:65535");
711 $errormessage .= &General
::validportrange
($_, 'destination');
716 if (&General
::validport
($_)){
719 $errormessage=$Lang::tr
{'fwdfw err tgt_port'};
720 return $errormessage;
724 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
726 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
727 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
728 $fwdfwsettings{'TGT_PORT'} = '';
729 $fwdfwsettings{'ICMP_TGT'} = '';
730 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
731 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
732 $fwdfwsettings{'TGT_PORT'} = '';
733 $fwdfwsettings{'ICMP_TGT'}='';
734 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
735 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
736 $fwdfwsettings{'TGT_PORT'} = '';
737 $fwdfwsettings{'ICMP_TGT'}='';
738 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
739 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
740 $fwdfwsettings{'TGT_PORT'} = '';
745 if ($fwdfwsettings{'USESRV'} ne 'ON'){
746 $fwdfwsettings{'grp3'}='';
747 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
748 $fwdfwsettings{'ICMP_TGT'}='';
751 if($fwdfwsettings{'TIME'} eq 'ON'){
752 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 ''){
753 $errormessage=$Lang::tr
{'fwdfw err time'};
754 return $errormessage;
757 return $errormessage;
762 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
763 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
764 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
765 if ($fwdfwsettings{'dnatport'} eq "*") {
766 $fwdfwsettings{'dnatport'}="1:65535";
768 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
769 $fwdfwsettings{'dnatport'} = "1:$2";
771 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
772 $fwdfwsettings{'dnatport'} ="$1:65535";
777 if ($val =~ "," || $val>65536 || $val<0){
784 #check valid port for NAT
785 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
786 #RULE_ACTION must be ACCEPT if we use NAT
787 $fwdfwsettings{'RULE_ACTION'} = 'ACCEPT';
789 #if no dnat or snat selected errormessage
790 if ($fwdfwsettings{'nat'} eq ''){
791 $errormessage=$Lang::tr
{'fwdfw dnat nochoice'};
795 #if using snat, the external port has to be empty
796 if ($fwdfwsettings{'nat'} eq 'snat' && $fwdfwsettings{'dnatport'} ne ''){
797 $errormessage=$Lang::tr
{'fwdfw dnat extport'};
800 #if no dest port is given in nat area, take target host port
801 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
802 if($fwdfwsettings{'TGT_PORT'} eq '' && $fwdfwsettings{'dnatport'} ne '' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')){
803 $errormessage=$Lang::tr
{'fwdfw dnat porterr2'};
806 #check if port given in nat area is a single valid port or portrange
807 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
808 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
809 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
811 #get service Protocol and Port
812 foreach my $key (sort keys %customservice){
813 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
814 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
815 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
817 $custsrvport= $customservice{$key}[1];
820 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
822 #check if DNAT port is multiple
823 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
824 my @parts=split(",",$fwdfwsettings{'dnatport'});
828 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
830 #change dashes with :
833 push(@values,"1:65535");
836 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
837 push(@values,"1:$2");
840 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
841 push(@values,"$1:65535");
844 $errormessage .= &General
::validportrange
($_, 'destination');
849 if (&General
::validport
($_)){
856 $fwdfwsettings{'dnatport'}=join("|",@values);
858 #check if a rule with prot tcp or udp and ports is edited and now prot is "all", then delete all ports
859 if($fwdfwsettings{'PROT'} eq ''){
860 $fwdfwsettings{'dnatport'}='';
864 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
865 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
867 #check if source and target identical
868 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
869 $errormessage=$Lang::tr
{'fwdfw err same'};
870 return $errormessage;
872 #get source and targetip address if possible
873 my ($sip,$scidr,$tip,$tcidr);
874 ($sip,$scidr)=&get_ip
("src","grp1");
875 ($tip,$tcidr)=&get_ip
("tgt","grp2");
876 #check same iprange in source and target
877 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
878 my $networkip1=&General
::getnetworkip
($sip,$scidr);
879 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
880 if ($scidr gt $tcidr){
881 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
882 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
884 }elsif($scidr eq $tcidr && $scidr eq '32'){
885 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
886 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
887 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
888 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
889 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
892 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
893 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
897 #when icmp selected, no source and targetport allowed
898 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')){
899 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
902 #change protocol if prot not equal dest single service
903 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
904 foreach my $key (sort keys %customservice){
905 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
906 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
907 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
913 #check source and destination protocol if source manual and dest servicegroup
914 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
915 $fwdfwsettings{'PROT'} = '';
917 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
918 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
920 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
921 $fwdfwsettings{'USE_SRC_PORT'}='';
922 $fwdfwsettings{'SRC_PORT'}='';
923 #$fwdfwsettings{'USESRV'}='';
924 $fwdfwsettings{'TGT_PORT'}='';
925 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
926 foreach my $key (keys %icmptypes){
927 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
928 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
931 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
932 $fwdfwsettings{'USE_SRC_PORT'}='';
933 $fwdfwsettings{'SRC_PORT'}='';
934 $fwdfwsettings{'ICMP_TYPES'}='';
935 $fwdfwsettings{'USESRV'}='';
936 $fwdfwsettings{'TGT_PORT'}='';
937 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
938 $fwdfwsettings{'USE_SRC_PORT'}='';
939 $fwdfwsettings{'SRC_PORT'}='';
940 $fwdfwsettings{'ICMP_TYPES'}='';
941 $fwdfwsettings{'USESRV'}='';
942 $fwdfwsettings{'TGT_PORT'}='';
943 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
944 $fwdfwsettings{'USE_SRC_PORT'}='';
945 $fwdfwsettings{'SRC_PORT'}='';
946 $fwdfwsettings{'ICMP_TYPES'}='';
947 $fwdfwsettings{'USESRV'}='';
948 $fwdfwsettings{'TGT_PORT'}='';
949 }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){
950 $fwdfwsettings{'USE_SRC_PORT'}='';
951 $fwdfwsettings{'SRC_PORT'}='';
952 $fwdfwsettings{'ICMP_TYPES'}='';
953 $fwdfwsettings{'USESRV'}='';
954 $fwdfwsettings{'TGT_PORT'}='';
955 }elsif($fwdfwsettings{'PROT'} eq 'IPv6'){
956 $fwdfwsettings{'USE_SRC_PORT'}='';
957 $fwdfwsettings{'SRC_PORT'}='';
958 $fwdfwsettings{'ICMP_TYPES'}='';
959 $fwdfwsettings{'USESRV'}='';
960 $fwdfwsettings{'TGT_PORT'}='';
961 }elsif($fwdfwsettings{'PROT'} eq 'IPIP'){
962 $fwdfwsettings{'USE_SRC_PORT'}='';
963 $fwdfwsettings{'SRC_PORT'}='';
964 $fwdfwsettings{'ICMP_TYPES'}='';
965 $fwdfwsettings{'USESRV'}='';
966 $fwdfwsettings{'TGT_PORT'}='';
967 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP'){
968 $fwdfwsettings{'ICMP_TYPES'}='';
969 $fwdfwsettings{'SRC_PORT'}='';
970 $fwdfwsettings{'TGT_PORT'}='';
971 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
972 $fwdfwsettings{'ICMP_TYPES'}='';
978 #Test if manual IP is part of static OpenVPN networks
979 &General
::readhasharray
("$configccdnet", \
%ccdnet);
980 foreach my $key (sort keys %ccdnet){
981 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
982 my $sub=&General
::iporsubtodec
($vpnsubnet);
983 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
987 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
988 # because if one creates a custom host with the ip, we need to check the color there!
989 # It does not make sense to check this here
991 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
992 # Is also checked in getcolor
994 # Test if manual ip is part of an IPsec Network is also checked in getcolor
1004 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
1005 foreach my $key (sort {$a <=> $b} keys %delhash){
1006 if ($key >= $fwdfwsettings{'key'}) {
1007 my $next = $key + 1;
1008 if (exists $delhash{$next}) {
1009 foreach my $i (0 .. $#{$delhash{$next}}) {
1010 $delhash{$key}[$i] = $delhash{$next}[$i];
1015 # Remove the very last entry.
1016 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
1017 delete $delhash{$last_key};
1019 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
1020 &General
::firewall_config_changed
();
1022 if($fwdfwsettings{'nobase'} ne 'on'){
1035 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
1036 foreach my $key (sort keys %configfwdfw){
1037 if ($key eq $key1 ){
1038 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
1041 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
1042 &General
::firewall_config_changed
();
1046 if ($errormessage) {
1047 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1048 print "<class name='base'>$errormessage\n";
1049 print " </class>\n";
1050 &Header
::closebox
();
1055 my %hash=%{(shift)};
1058 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
1059 if($hash{$key}[0] eq $val){
1060 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1062 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1072 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1073 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1074 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1075 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1076 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1077 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1078 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1079 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1080 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1081 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1082 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1083 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1084 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1085 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1086 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1087 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1088 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1089 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1090 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1092 <table width='100%' border='0'>
1093 <tr><td width='50%' valign='top'>
1094 <table width='95%' border='0'>
1095 <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;'>
1097 foreach my $network (sort keys %defaultNetworks)
1099 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1100 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1101 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1102 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1103 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1104 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1105 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1106 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1107 if ($ifaces{$defnet}){
1108 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1110 print ">$network</option>";
1113 print"</select></td></tr>";
1115 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1116 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;'>";
1117 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1118 print"</select></td>";
1121 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1122 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;'>";
1123 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1124 print"</select></td>";
1127 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1128 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;'>";
1129 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1130 if($helper ne $customgrp{$key}[0] && $customgrp{$key}[2] ne 'none'){
1132 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1133 print ">$customgrp{$key}[0]</option>";
1135 $helper=$customgrp{$key}[0];
1137 print"</select></td>";
1139 #End left table. start right table (vpn)
1140 print"</tr></table></td><td valign='top'><table width='95%' border='0' align='right'><tr>";
1142 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1143 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;'>";
1144 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1145 print"</select></td></tr>";
1148 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1149 if ($ccdhost{$key}[33] ne '' ){
1150 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 '');
1152 print "<option value='$ccdhost{$key}[1]'";
1153 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1154 print ">$ccdhost{$key}[1]</option>";
1157 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1158 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>" ;
1160 if ($show eq '1'){$show='';print"</select></td></tr>";}
1162 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1163 if ($ccdhost{$key}[3] eq 'net'){
1164 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 '');
1166 print "<option value='$ccdhost{$key}[1]'";
1167 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1168 print ">$ccdhost{$key}[1]</option>";
1171 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1172 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>" ;
1174 if ($show eq '1'){$show='';print"</select></td></tr>";}
1176 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1177 if ($ipsecconf{$key}[3] eq 'net' || ($optionsfw{'SHOWDROPDOWN'} eq 'on' && $ipsecconf{$key}[3] ne 'host')){
1178 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 '');
1181 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1182 print ">$ipsecconf{$key}[1]</option>";
1185 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1186 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>";
1188 if ($show eq '1'){$show='';print"</select></td></tr>";}
1191 print"</td></tr></table><br>";
1199 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1200 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1201 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1202 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1203 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1204 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1205 $a=$netsettings{'GREEN_NETADDRESS'};
1206 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1207 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1208 $a=$netsettings{'ORANGE_NETADDRESS'};
1209 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1210 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1211 $a=$netsettings{'BLUE_NETADDRESS'};
1212 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1213 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1214 &General
::readhash
("$configovpn",\
%ovpnsettings);
1215 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1216 $b=&General
::iporsubtocidr
($b);
1218 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1219 &General
::readhasharray
("$confignet", \
%customnetwork);
1220 foreach my $key (keys %customnetwork){
1221 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1222 $a=$customnetwork{$key}[1];
1223 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1226 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1227 &General
::readhasharray
("$confighost", \
%customhost);
1228 foreach my $key (keys %customhost){
1229 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1230 if ($customhost{$key}[1] eq 'ip'){
1231 ($a,$b)=split (/\//,$customhost{$key}[2]);
1232 $b=&General
::iporsubtocidr
($b);
1234 if ($grp eq 'grp2'){
1235 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1247 &General
::setup_default_networks
(\
%defaultNetworks);
1248 foreach my $network (sort keys %defaultNetworks)
1250 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1255 my %hash=%{(shift)};
1257 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1258 $hash{$key}[10]=~ s/\|/,/g;
1259 print": $hash{$key}[10]";
1260 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1261 print": <br>$hash{$key}[9] ";
1266 my %hash=%{(shift)};
1270 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1271 if($hash{$key}[14] eq 'cust_srv'){
1272 &General
::readhasharray
("$configsrv", \
%customservice);
1273 foreach my $i (sort keys %customservice){
1274 if($customservice{$i}[0] eq $hash{$key}[15]){
1275 $service = $customservice{$i}[0];
1278 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1279 $service=$hash{$key}[15];
1280 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1281 $hash{$key}[15]=~ s/\|/,/g;
1282 $service=$hash{$key}[15];
1289 sub get_serviceports
1293 &General
::readhasharray
("$configsrv", \
%customservice);
1294 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1296 my @specprot=("IPIP","IPV6","IGMP","GRE","AH","ESP");
1297 if($type eq 'service'){
1298 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1299 if ($customservice{$key}[0] eq $name){
1300 push (@protocols,$customservice{$key}[2]);
1303 }elsif($type eq 'group'){
1304 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1305 if ($customservicegrp{$key}[0] eq $name){
1306 if ($customservicegrp{$key}[2] ~~ @specprot){
1307 push (@protocols," ".$customservicegrp{$key}[2]);
1309 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1310 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1311 if (!grep(/$customservice{$key1}[2]/, @protocols)){
1312 push (@protocols,$customservice{$key1}[2]);}
1320 # Sort protocols alphabetically.
1321 @protocols = sort(@protocols);
1330 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1331 # Don't colourise MAC addresses
1332 if (&General
::validmac
($val)) {
1338 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1339 foreach my $key (sort keys %$hash){
1340 if ($$hash{$key}[0] eq $val){
1341 $val=$$hash{$key}[2];
1346 if ($val eq 'GREEN'){
1347 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1349 }elsif ($val eq 'ORANGE'){
1350 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1352 }elsif ($val eq 'BLUE'){
1353 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1355 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1356 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1358 }elsif ($val eq 'IPFire' ){
1359 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1361 }elsif ($val eq 'OpenVPN-Dyn' ){
1362 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1364 }elsif ($val eq 'IPsec RW' ){
1365 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1367 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1368 my ($sip,$scidr) = split ("/",$val);
1369 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1370 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1373 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1374 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1377 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1378 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1381 }elsif ($val eq 'Default IP'){
1382 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1385 #Check if a manual IP or custom host is part of a VPN
1386 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1387 #Check if IP is part of OpenVPN dynamic subnet
1388 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1389 my ($c,$d) = split("/",$val);
1390 if (&General
::IpInSubnet
($c,$a,$b)){
1391 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1394 #Check if IP is part of OpenVPN static subnet
1395 foreach my $key (sort keys %ccdnet){
1396 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1397 $b =&General
::iporsubtodec
($b);
1398 if (&General
::IpInSubnet
($c,$a,$b)){
1399 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1403 #Check if IP is part of OpenVPN N2N subnet
1404 foreach my $key (sort keys %ccdhost){
1405 if ($ccdhost{$key}[3] eq 'net'){
1406 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1407 if (&General
::IpInSubnet
($c,$a,$b)){
1408 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1413 #Check if IP is part of IPsec RW network
1414 if ($ipsecsettings{'RW_NET'} ne ''){
1415 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1416 $b=&General
::iporsubtodec
($b);
1417 if (&General
::IpInSubnet
($c,$a,$b)){
1418 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1422 #Check if IP is part of a IPsec N2N network
1423 foreach my $key (sort keys %ipsecconf){
1424 if ($ipsecconf{$key}[11]){
1425 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1426 $b=&General
::iporsubtodec
($b);
1427 if (&General
::IpInSubnet
($c,$a,$b)){
1428 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1435 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'){
1436 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1439 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1440 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1444 foreach my $alias (sort keys %aliases)
1446 if ($val eq $alias){
1447 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1458 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1459 print "<class name='base'>$hint\n";
1460 print " </class>\n";
1461 &Header
::closebox
();
1467 &General
::setup_default_networks
(\
%defaultNetworks);
1468 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1469 #read all configfiles
1470 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1471 &General
::readhasharray
("$confignet", \
%customnetwork);
1472 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1473 &General
::readhasharray
("$confighost", \
%customhost);
1474 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1475 &General
::readhasharray
("$configgrp", \
%customgrp);
1476 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1477 &General
::get_aliases
(\
%aliases);
1481 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1482 my $config=$fwdfwsettings{'config'};
1485 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1486 my $redip = <CONN1
>;
1488 if (! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE2'){
1489 $fwdfwsettings{'RULE_ACTION'}='DROP';
1490 }elsif(! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE1'){
1491 $fwdfwsettings{'RULE_ACTION'}='ACCEPT';
1493 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1494 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1495 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1496 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1497 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1498 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1499 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1500 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1501 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1502 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1503 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1504 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1505 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1506 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1507 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1508 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1509 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1510 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1511 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1512 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1513 #check if update and get values
1514 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1515 &General
::readhasharray
("$config", \
%hash);
1516 foreach my $key (sort keys %hash){
1518 if ($key eq $fwdfwsettings{'key'}){
1519 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1520 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1521 $fwdfwsettings{'chain'} = $hash{$key}[1];
1522 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1523 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1524 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1525 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1526 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1527 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1528 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1529 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1530 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1531 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1532 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1533 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1534 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1535 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1536 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1537 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1538 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1539 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1540 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1541 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1542 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1543 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1544 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1545 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1546 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1547 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1548 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1549 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1550 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1551 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1552 $fwdfwsettings{'LIMIT_CON_CON'} = $hash{$key}[32];
1553 $fwdfwsettings{'concon'} = $hash{$key}[33];
1554 $fwdfwsettings{'RATE_LIMIT'} = $hash{$key}[34];
1555 $fwdfwsettings{'ratecon'} = $hash{$key}[35];
1556 $fwdfwsettings{'RATETIME'} = $hash{$key}[36];
1557 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1558 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1559 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1560 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1561 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1562 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1563 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1564 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1565 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1566 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1567 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1568 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1569 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1570 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1571 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1572 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1573 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1574 $checked{'LIMIT_CON_CON'}{$fwdfwsettings{'LIMIT_CON_CON'}} = 'CHECKED';
1575 $checked{'RATE_LIMIT'}{$fwdfwsettings{'RATE_LIMIT'}} = 'CHECKED';
1576 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1577 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1578 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1579 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1580 $selected{'dnat'}{$fwdfwsettings{'dnat'}} ='selected';
1581 $selected{'snat'}{$fwdfwsettings{'snat'}} ='selected';
1582 $selected{'RATETIME'}{$fwdfwsettings{'RATETIME'}} ='selected';
1585 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1586 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1587 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1588 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1589 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1590 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1591 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1592 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1593 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1594 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1595 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1596 $fwdfwsettings{'olduseratelimit'}=$fwdfwsettings{'RATE_LIMIT'};
1597 $fwdfwsettings{'olduseratelimitamount'}=$fwdfwsettings{'ratecon'};
1598 $fwdfwsettings{'oldratelimittime'}=$fwdfwsettings{'RATETIME'};
1600 #check if manual ip (source) is orange network
1601 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1602 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1603 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1604 $fwdfwsettings{'oldorange'} ='on';
1608 $fwdfwsettings{'ACTIVE'}='ON';
1609 $fwdfwsettings{'nat'} = 'dnat';
1610 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1611 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1612 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1613 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1614 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1615 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1616 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1617 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1618 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1619 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1620 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1621 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1622 #check if manual ip (source) is orange network
1623 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1624 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1625 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1626 $fwdfwsettings{'oldorange'} ='on';
1630 # Split manual source and target address and delete the subnet
1631 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1632 if ($scidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp1'}}=$sip;}
1633 my ($dip,$dcidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp2'}});
1634 if ($dcidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp2'}}=$dip;}
1635 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1636 #------SOURCE-------------------------------------------------------
1637 print "<form method='post'>";
1639 <table width='100%' border='0'>
1640 <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>
1642 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1643 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1644 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1645 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1646 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1647 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1648 if (! -z
"${General::swroot}/ethernet/aliases"){
1649 foreach my $alias (sort keys %aliases)
1651 print "<option value='$alias' $selected{'ipfire_src'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1656 <tr><td><br></td></tr>
1659 &gen_dd_block
('src','grp1');
1660 &Header
::closebox
();
1662 #---SNAT / DNAT ------------------------------------------------
1663 &Header
::openbox
('100%', 'left', 'NAT');
1666 <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}>
1667 $Lang::tr{'fwdfw use nat'}
1670 <table width='100%' border='0'>
1672 <td width='5%'></td>
1675 <input type='radio' name='nat' value='dnat' $checked{'nat'}{'dnat'}>
1676 $Lang::tr{'fwdfw dnat'}
1682 <td width='25%' align='right'>$Lang::tr{'dnat address'}:</td>
1684 <select name='dnat' style='width: 100%;'>
1685 <option value='AUTO' $selected{'dnat'}{'AUTO'}>- $Lang::tr{'automatic'} -</option>
1686 <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'red1'} ($redip)</option>
1689 foreach my $alias (sort keys %aliases) {
1690 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1694 foreach my $network (sort keys %defaultNetworks)
1696 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1697 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1698 print " selected='selected'" if ($fwdfwsettings{'dnat'} eq $defaultNetworks{$network}{'NAME'});
1699 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1708 <td width='5%'></td>
1711 <input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}>
1712 $Lang::tr{'fwdfw snat'}
1715 <td width='25%' align='right'>$Lang::tr{'snat new source ip address'}:</td>
1717 <select name='snat' style='width: 100%;'>
1720 foreach my $alias (sort keys %aliases) {
1721 print "<option value='$alias' $selected{'snat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1724 foreach my $network (sort keys %defaultNetworks) {
1725 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1726 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1727 print " selected='selected'" if ($fwdfwsettings{'snat'} eq $defaultNetworks{$network}{'NAME'});
1728 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1738 &Header
::closebox
();
1740 #---TARGET------------------------------------------------------
1741 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1743 <table width='100%' border='0'>
1744 <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>
1746 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1747 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1748 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1749 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1750 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1751 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1752 if (! -z
"${General::swroot}/ethernet/aliases"){
1753 foreach my $alias (sort keys %aliases)
1755 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1760 <tr><td><br></td></tr></table>
1762 &gen_dd_block
('tgt','grp2');
1764 #---PROTOCOL------------------------------------------------------
1765 $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
1766 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1767 $fwdfwsettings{'dnatport'} =~ tr/|/,/;
1769 # The dnatport may be empty, if it matches TGT_PORT
1770 if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
1771 $fwdfwsettings{'dnatport'} = "";
1774 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1775 #Fix Protocol for JQuery
1776 if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
1777 $fwdfwsettings{'PROT'} = 'template';
1780 <table width='100%' border='0'>
1783 <select name='PROT' id='protocol' style="width: 95px;">
1785 print "<option value=\"\"";
1786 if ($fwdfwsettings{'PROT'} eq '') {
1787 print " selected=\"selected\"";
1789 print ">$Lang::tr{'all'}</option>";
1791 print "<option value=\"template\"";
1792 print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp');
1793 print ">- $Lang::tr{'template'} -</option>";
1795 foreach (@PROTOCOLS) {
1796 print"<option value=\"$_\"";
1797 if ($_ eq $fwdfwsettings{'PROT'}) {
1798 print " selected=\"selected\"";
1801 print ">$Lang::tr{'fwdfw prot41'}</option>";
1803 print ">$_</option>";
1811 <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES">
1813 <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
1815 <select name='ICMP_TYPES' style='min-width:230px;'>
1817 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1818 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1819 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1820 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1821 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1823 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1833 <table width="100%" border="0" id="PROTOCOL_PORTS">
1835 <!-- #SOURCEPORT -->
1837 $Lang::tr{'fwdfw use srcport'}
1840 <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
1845 <!-- #TARGETPORT -->
1847 $Lang::tr{'fwdfw use srv'}
1851 <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
1855 <td colspan='3'></td>
1856 <td>$Lang::tr{'fwdfw external port nat'}:</td>
1858 <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
1863 <table width="100%" border="0" id="PROTOCOL_TEMPLATE">
1866 <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
1867 $Lang::tr{'fwhost cust service'}
1870 <select name='cust_srv' style='min-width: 230px;'>
1873 &General
::readhasharray
("$configsrv", \
%customservice);
1874 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1876 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1877 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1886 <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
1887 $Lang::tr{'fwhost cust srvgrp'}
1890 <select name='cust_srvgrp' style='min-width:230px;'>
1893 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1895 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1896 if ($helper ne $customservicegrp{$key}[0] && $customservicegrp{$key}[2] ne 'none'){
1898 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1899 print">$customservicegrp{$key}[0]</option>";
1901 $helper=$customservicegrp{$key}[0];
1915 $checked{"RULE_ACTION"}{$fwdfwsettings{'RULE_ACTION'}} = 'CHECKED';
1918 <table width="80%" class='tbl' id='actions'>
1920 <td width="33%" align="center" bgcolor="$color{'color17'}">
1923 <td width="33%" align="center" bgcolor="$color{'color25'}">
1926 <td width="33%" align="center" bgcolor="$color{'color16'}">
1931 <td width="33%" align="center">
1933 <input type="radio" name="RULE_ACTION" value="ACCEPT" $checked{"RULE_ACTION"}{"ACCEPT"}>
1934 <strong>$Lang::tr{'fwdfw ACCEPT'}</strong>
1937 <td width="33%" align="center">
1939 <input type="radio" name="RULE_ACTION" value="DROP" $checked{"RULE_ACTION"}{"DROP"}>
1940 <strong>$Lang::tr{'fwdfw DROP'}</strong>
1943 <td width="33%" align="center">
1945 <input type="radio" name="RULE_ACTION" value="REJECT" $checked{"RULE_ACTION"}{"REJECT"}>
1946 <strong>$Lang::tr{'fwdfw REJECT'}</strong>
1955 #---Activate/logging/remark-------------------------------------
1956 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1958 <table width='100%' border='0'>
1960 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>";
1961 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1962 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1963 for (my $count =1; $count <= $sum; $count++){
1964 print"<option value='$count' ";
1965 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1966 print">$count</option>";
1968 print"</select></td></tr>";
1970 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1975 <table width='100%'>
1979 if ($fwdfwsettings{'updatefwrule'} eq 'on') {
1982 <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}>
1984 <td>$Lang::tr{'fwdfw rule activate'}</td>
1989 <input type="hidden" name="ACTIVE" value="ON">
1998 <input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'}>
2000 <td>$Lang::tr{'fwdfw log rule'}</td>
2004 <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}>
2006 <td>$Lang::tr{'fwdfw timeframe'}</td>
2008 <tr id="TIME_CONSTRAINTS">
2010 <table width="66%" border="0">
2012 <td width="8em"> </td>
2013 <td align="center">$Lang::tr{'advproxy monday'}</td>
2014 <td align="center">$Lang::tr{'advproxy tuesday'}</td>
2015 <td align="center">$Lang::tr{'advproxy wednesday'}</td>
2016 <td align="center">$Lang::tr{'advproxy thursday'}</td>
2017 <td align="center">$Lang::tr{'advproxy friday'}</td>
2018 <td align="center">$Lang::tr{'advproxy saturday'}</td>
2019 <td align="center">$Lang::tr{'advproxy sunday'}</td>
2023 <td width="8em"> </td>
2024 <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
2025 <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
2026 <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
2027 <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
2028 <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
2029 <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
2030 <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
2032 <select name='TIME_FROM'>
2034 for (my $i=0;$i<=23;$i++) {
2035 $i = sprintf("%02s",$i);
2036 for (my $j=0;$j<=45;$j+=15) {
2037 $j = sprintf("%02s",$j);
2038 my $time = $i.":".$j;
2039 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
2044 <select name='TIME_TO'>
2046 for (my $i=0;$i<=23;$i++) {
2047 $i = sprintf("%02s",$i);
2048 for (my $j=0;$j<=45;$j+=15) {
2049 $j = sprintf("%02s",$j);
2050 my $time = $i.":".$j;
2051 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
2063 <input type='checkbox' name='LIMIT_CON_CON' id="USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP" value='ON' $checked{'LIMIT_CON_CON'}{'ON'}>
2065 <td>$Lang::tr{'fwdfw limitconcon'}</td>
2069 <table width='66%' border='0'>
2071 <td width="20em"> </td>
2072 <td>$Lang::tr{'fwdfw maxconcon'}: <input type='text' name='concon' size='2' value="$fwdfwsettings{'concon'}"></td>
2079 <input type='checkbox' name='RATE_LIMIT' id="USE_RATELIMIT" value='ON' $checked{'RATE_LIMIT'}{'ON'}>
2081 <td>$Lang::tr{'fwdfw ratelimit'}</td>
2085 <table width='66%' border='0'>
2087 <td width="20em"> </td>
2088 <td>$Lang::tr{'fwdfw numcon'}: <input type='text' name='ratecon' size='2' value="$fwdfwsettings{'ratecon'}"> /
2089 <select name='RATETIME' style='width:100px;'>
2090 <option value='second' $selected{'RATETIME'}{'second'}>$Lang::tr{'age second'}</option>
2091 <option value='minute' $selected{'RATETIME'}{'minute'}>$Lang::tr{'minute'}</option>
2092 <option value='hour' $selected{'RATETIME'}{'hour'}>$Lang::tr{'hour'}</option>
2103 #---ACTION------------------------------------------------------
2104 if($fwdfwsettings{'updatefwrule'} ne 'on'){
2106 <table border='0' width='100%'>
2107 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
2108 <input type='hidden' name='config' value='$config' >
2109 <input type='hidden' name='ACTION' value='saverule' ></form>
2110 <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>
2116 <table border='0' width='100%'>
2117 <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'}'>
2118 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
2119 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
2120 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
2121 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
2122 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
2123 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
2124 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
2125 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
2126 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
2127 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
2128 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
2129 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
2130 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
2131 <input type='hidden' name='oldconcon' value='$fwdfwsettings{'oldconcon'}' />
2132 <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>
2136 &Header
::closebox
();
2142 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
2143 foreach my $key (sort keys %uphash){
2144 if ($key eq $fwdfwsettings{'key'}) {
2146 if (exists $uphash{$last}){
2148 foreach my $y (0 .. $#{$uphash{$last}}) {
2149 $tmp{0}[$y] = $uphash{$last}[$y];
2151 #copy active rule to last
2152 foreach my $i (0 .. $#{$uphash{$last}}) {
2153 $uphash{$last}[$i] = $uphash{$key}[$i];
2155 #copy saved rule to actual position
2156 foreach my $x (0 .. $#{$tmp{0}}) {
2157 $uphash{$key}[$x] = $tmp{0}[$x];
2162 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
2163 &General
::firewall_config_changed
();
2169 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
2170 foreach my $key (sort keys %downhash){
2171 if ($key eq $fwdfwsettings{'key'}) {
2172 my $next = $key + 1;
2173 if (exists $downhash{$next}){
2175 foreach my $y (0 .. $#{$downhash{$next}}) {
2176 $tmp{0}[$y] = $downhash{$next}[$y];
2178 #copy active rule to next
2179 foreach my $i (0 .. $#{$downhash{$next}}) {
2180 $downhash{$next}[$i] = $downhash{$key}[$i];
2182 #copy saved rule to actual position
2183 foreach my $x (0 .. $#{$tmp{0}}) {
2184 $downhash{$key}[$x] = $tmp{0}[$x];
2189 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
2190 &General
::firewall_config_changed
();
2196 &General
::readhasharray
("$config", $hash);
2197 if (!$errormessage){
2198 ################################################################
2199 #check if we change an INPUT rule to a OUTGOING
2200 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2201 &changerule
($configinput);
2204 #check if we change an INPUT rule to a FORWARD
2205 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2206 &changerule
($configinput);
2209 ################################################################
2210 #check if we change an OUTGOING rule to an INPUT
2211 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2212 &changerule
($configoutgoing);
2215 #check if we change an OUTGOING rule to a FORWARD
2216 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2217 &changerule
($configoutgoing);
2220 ################################################################
2221 #check if we change a FORWARD rule to an INPUT
2222 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2223 &changerule
($configfwdfw);
2226 #check if we change a FORWARD rule to an OUTGOING
2227 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2228 &changerule
($configfwdfw);
2231 $fwdfwsettings{'ruleremark'}=~ s/,/;/g;
2232 utf8
::decode
($fwdfwsettings{'ruleremark'});
2233 $fwdfwsettings{'ruleremark'}=&Header
::escape
($fwdfwsettings{'ruleremark'});
2234 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2235 my $key = &General
::findhasharraykey
($hash);
2236 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2237 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2238 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2239 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2240 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2241 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2242 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2243 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2244 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2245 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2246 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2247 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2248 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2249 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2250 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2251 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2252 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2253 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2254 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2255 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2256 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2257 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2258 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2259 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2260 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2261 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2262 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2263 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2264 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2265 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2266 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2267 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2268 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2269 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2270 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2271 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2272 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2273 &General
::writehasharray
("$config", $hash);
2275 foreach my $key (sort {$a <=> $b} keys %$hash){
2276 if($key eq $fwdfwsettings{'key'}){
2277 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2278 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2279 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2280 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2281 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2282 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2283 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2284 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2285 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2286 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2287 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2288 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2289 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2290 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2291 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2292 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2293 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2294 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2295 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2296 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2297 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2298 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2299 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2300 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2301 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2302 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2303 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2304 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2305 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2306 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2307 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2308 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2309 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2310 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2311 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2312 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2313 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2318 &General
::writehasharray
("$config", $hash);
2319 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2321 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2322 for (my $z=0;$z<$val;$z++){
2323 foreach my $key (sort {$a <=> $b} keys %$hash){
2324 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2326 if (exists $$hash{$last}){
2328 foreach my $y (0 .. $#{$$hash{$last}}) {
2329 $tmp{0}[$y] = $$hash{$last}[$y];
2331 #copy active rule to last
2332 foreach my $i (0 .. $#{$$hash{$last}}) {
2333 $$hash{$last}[$i] = $$hash{$key}[$i];
2335 #copy saved rule to actual position
2336 foreach my $x (0 .. $#{$tmp{0}}) {
2337 $$hash{$key}[$x] = $tmp{0}[$x];
2342 $fwdfwsettings{'oldrulenumber'}--;
2344 &General
::writehasharray
("$config", $hash);
2345 &General
::firewall_config_changed
();
2346 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2348 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2349 for (my $z=0;$z<$val;$z++){
2350 foreach my $key (sort {$a <=> $b} keys %$hash){
2351 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2352 my $next = $key + 1;
2353 if (exists $$hash{$next}){
2355 foreach my $y (0 .. $#{$$hash{$next}}) {
2356 $tmp{0}[$y] = $$hash{$next}[$y];
2358 #copy active rule to next
2359 foreach my $i (0 .. $#{$$hash{$next}}) {
2360 $$hash{$next}[$i] = $$hash{$key}[$i];
2362 #copy saved rule to actual position
2363 foreach my $x (0 .. $#{$tmp{0}}) {
2364 $$hash{$key}[$x] = $tmp{0}[$x];
2369 $fwdfwsettings{'oldrulenumber'}++;
2371 &General
::writehasharray
("$config", $hash);
2372 &General
::firewall_config_changed
();
2378 # Checks a hostname against RFC1035
2381 # Try to decode $remark into UTF-8. If this doesn't work,
2382 # we assume that the string it not sane.
2383 if (!utf8
::decode
($remark)) {
2387 # Check if the string only contains of printable characters.
2388 if ($remark =~ /^[[:print:]]*$/) {
2395 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2397 &viewtablenew
(\
%configfwdfw, $configfwdfw, $Lang::tr
{'firewall rules'});
2398 &viewtablenew
(\
%configinputfw, $configinput, $Lang::tr
{'incoming firewall access'});
2399 &viewtablenew
(\
%configoutgoingfw, $configoutgoing, $Lang::tr
{'outgoing firewall access'});
2408 my $show_box = (! -z
$config) || ($optionsfw{'SHOWTABLES'} eq 'on');
2409 return if (!$show_box);
2411 &General
::get_aliases
(\
%aliases);
2412 &General
::readhasharray
("$confighost", \
%customhost);
2413 &General
::readhasharray
("$config", $hash);
2414 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2415 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2416 &General
::readhasharray
("$configgrp", \
%customgrp);
2417 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2419 &Header
::openbox
('100%', 'left', $title);
2420 print "<table width='100%' cellspacing='0' class='tbl'>";
2434 <th align='right' width='3%'>
2437 <th width='2%'></th>
2439 <b>$Lang::tr{'protocol'}</b>
2441 <th align='center' width='30%'>
2442 <b>$Lang::tr{'fwdfw source'}</b>
2445 <b>$Lang::tr{'fwdfw log'}</b>
2447 <th align='center' width='30%'>
2448 <b>$Lang::tr{'fwdfw target'}</b>
2450 <th align='center' colspan='6' width='18%'>
2451 <b>$Lang::tr{'fwdfw action'}</b>
2456 foreach my $key (sort {$a <=> $b} keys %$hash){
2460 #check if vpn hosts/nets have been deleted
2461 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2462 push (@tmpsrc,$$hash{$key}[4]);
2464 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2465 push (@tmptgt,$$hash{$key}[6]);
2467 foreach my $host (@tmpsrc){
2468 if($$hash{$key}[3] eq 'ipsec_net_src'){
2469 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2472 }elsif($$hash{$key}[3] eq 'ovpn_net_src'){
2473 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2476 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src'){
2477 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2480 }elsif($$hash{$key}[3] eq 'ovpn_host_src'){
2481 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2486 foreach my $host (@tmptgt){
2487 if($$hash{$key}[5] eq 'ipsec_net_tgt'){
2488 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2491 }elsif($$hash{$key}[5] eq 'ovpn_net_tgt'){
2492 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2495 }elsif($$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2496 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2499 }elsif($$hash{$key}[5] eq 'ovpn_host_tgt'){
2500 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2505 #check if networkgroups or servicegroups are empty
2506 foreach my $netgroup (sort keys %customgrp){
2507 if(($$hash{$key}[4] eq $customgrp{$netgroup}[0] || $$hash{$key}[6] eq $customgrp{$netgroup}[0]) && $customgrp{$netgroup}[2] eq 'none'){
2511 foreach my $srvgroup (sort keys %customservicegrp){
2512 if($$hash{$key}[15] eq $customservicegrp{$srvgroup}[0] && $customservicegrp{$srvgroup}[2] eq 'none'){
2516 $$hash{'ACTIVE'}=$$hash{$key}[2];
2518 if($coloryellow eq 'on'){
2519 $color="$color{'color14'}";
2521 }elsif($coloryellow eq ''){
2523 $color="$color{'color22'}";
2526 $color="$color{'color20'}";
2530 <tr bgcolor='$color'>
2531 <td align='right' width='3%'>
2537 if ($$hash{$key}[0] eq 'ACCEPT'){
2540 $rulecolor=$color{'color17'};
2541 }elsif($$hash{$key}[0] eq 'DROP'){
2544 $rulecolor=$color{'color25'};
2545 }elsif($$hash{$key}[0] eq 'REJECT'){
2548 $rulecolor=$color{'color16'};
2552 <td bgcolor='$rulecolor' align='center' width='2%'>
2553 <span title='$tooltip'> </span>
2559 if ($$hash{$key}[8]){
2560 if ($$hash{$key}[8] eq "IPv6"){
2561 push (@protocols,$Lang::tr
{'fwdfw prot41 short'})
2563 push (@protocols,$$hash{$key}[8]);
2565 }elsif($$hash{$key}[14] eq 'cust_srv'){
2566 &get_serviceports
("service",$$hash{$key}[15]);
2567 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2568 &get_serviceports
("group",$$hash{$key}[15]);
2570 push (@protocols,$Lang::tr
{'all'});
2573 my $protz=join(", ",@protocols);
2574 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2575 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2576 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2577 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2578 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2582 }elsif($#protocols gt '3'){
2583 print"<td align='center'><span title='$protz'>$Lang::tr{'fwdfw many'}</span></td>";
2585 print"<td align='center'>$protz</td>";
2590 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2591 print"<td align='center' width='30%' $tdcolor>";
2592 if ($$hash{$key}[3] eq 'ipfire_src'){
2593 $ipfireiface=$Lang::tr
{'fwdfw iface'};
2595 if ($$hash{$key}[3] eq 'std_net_src'){
2596 print &get_name
($$hash{$key}[4]);
2597 }elsif ($$hash{$key}[3] eq 'src_addr'){
2598 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2599 if ($split2 eq '32'){
2602 print $$hash{$key}[4];
2604 }elsif ($$hash{$key}[4] eq 'RED1'){
2605 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2606 }elsif ($$hash{$key}[4] eq 'ALL'){
2607 print "$ipfireiface $Lang::tr{'all'}";
2609 if ($$hash{$key}[4] eq 'GREEN' || $$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE' || $$hash{$key}[4] eq 'RED'){
2610 print "$ipfireiface $Lang::tr{lc($$hash{$key}[4])}";
2612 print "$ipfireiface $$hash{$key}[4]";
2617 &getsrcport
(\
%$hash,$key);
2618 #Is this a SNAT rule?
2619 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2620 my $net=&get_name
($$hash{$key}[29]);
2621 if ( ! $net){ $net=$$hash{$key}[29];}
2623 if ($$hash{$key}[30] ne ''){
2624 print": $$hash{$key}[30]";
2627 if ($$hash{$key}[17] eq 'ON'){
2628 $log="/images/on.gif";
2630 $log="/images/off.gif";
2636 <form method='POST' action=''>
2637 <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 ;'/>
2638 <input type='hidden' name='key' value='$key' />
2639 <input type='hidden' name='config' value='$config' />
2640 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2645 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2647 <td align='center' $tdcolor>
2649 #Is this a DNAT rule?
2651 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2652 if ($$hash{$key}[29] eq 'Default IP'){$$hash{$key}[29]=$Lang::tr
{'red1'};}
2653 if ($$hash{$key}[29] eq 'AUTO'){
2654 my @src_addresses=&fwlib
::get_addresses
(\
%$hash,$key,'src');
2656 foreach my $val (@src_addresses){
2657 push (@nat_ifaces,&fwlib
::get_nat_address
($$hash{$key}[29],$val));
2659 @nat_ifaces=&del_double
(@nat_ifaces);
2662 $natstring = "($$hash{$key}[29])";
2664 print "$Lang::tr{'firewall'} $natstring";
2665 if($$hash{$key}[30] ne ''){
2666 $$hash{$key}[30]=~ tr/|/,/;
2667 print": $$hash{$key}[30]";
2671 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire'){
2672 if ($$hash{$key}[6] eq 'RED1'){
2673 print "$Lang::tr{'red1'}";
2674 }elsif ($$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE'|| $$hash{$key}[6] eq 'ALL' || $$hash{$key}[6] eq 'RED')
2676 print &get_name
($$hash{$key}[6]);
2678 print $$hash{$key}[6];
2680 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2681 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2682 if ($split2 eq '32'){
2685 print $$hash{$key}[6];
2688 print "$$hash{$key}[6]";
2692 &gettgtport
(\
%$hash,$key);
2695 if($$hash{$key}[2] eq 'ON'){
2696 $gif="/images/on.gif"
2699 $gif="/images/off.gif"
2702 <td width='3%' align='center'>
2703 <form method='POST' action=''>
2704 <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;' />
2705 <input type='hidden' name='key' value='$key' />
2706 <input type='hidden' name='config' value='$config' />
2707 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2710 <td width='3%' align='center'>
2711 <form method='POST' action=''>
2712 <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;' />
2713 <input type='hidden' name='key' value='$key' />
2714 <input type='hidden' name='config' value='$config' />
2715 <input type='hidden' name='ACTION' value='editrule' />
2718 <td width='3%' align='center'>
2719 <form method='POST' action=''>
2720 <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;' />
2721 <input type='hidden' name='key' value='$key' />
2722 <input type='hidden' name='config' value='$config' />
2723 <input type='hidden' name='ACTION' value='copyrule' />
2726 <td width='3%' align='center'>
2727 <form method='POST' action=''>
2728 <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;' />
2729 <input type='hidden' name='key' value='$key' />
2730 <input type='hidden' name='config' value='$config' />
2731 <input type='hidden' name='ACTION' value='deleterule' />
2735 if (exists $$hash{$key-1}){
2737 <td width='3%' align='center'>
2738 <form method='POST' action=''>
2739 <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;' />
2740 <input type='hidden' name='key' value='$key' />
2741 <input type='hidden' name='config' value='$config' />
2742 <input type='hidden' name='ACTION' value='moveup' />
2747 print"<td width='3%'></td>";
2750 if (exists $$hash{$key+1}){
2752 <td width='3%' align='center'>
2753 <form method='POST' action=''>
2754 <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;' />
2755 <input type='hidden' name='key' value='$key' />
2756 <input type='hidden' name='config' value='$config' />
2757 <input type='hidden' name='ACTION' value='movedown' />
2763 print"<td width='3%'></td></tr>";
2766 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2768 <tr bgcolor='$color'>
2770 <td bgcolor='$rulecolor'></td>
2772 <em>$$hash{$key}[16]</em>
2778 if ($$hash{$key}[18] eq 'ON'){
2780 if ($$hash{$key}[18] eq 'ON'){
2782 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2783 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2784 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2785 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2786 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2787 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2788 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2789 my $weekdays=join(",",@days);
2791 print"<tr bgcolor='$color'>";
2792 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27]</td></tr>";
2796 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2798 } elsif ($optionsfw{'SHOWTABLES'} eq 'on') {
2801 <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td>
2807 my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'};
2808 my $colour = "bgcolor='green'";
2809 if ($fwdfwsettings{'POLICY'} eq 'MODE1') {
2810 $colour = "bgcolor='darkred'";
2814 if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) {
2817 <td colspan='13'> </td>
2820 <td colspan='13' style="padding-left:0px;padding-right:0px">
2821 <table width="100%" border='1' rules="cols" cellspacing='0'>
2828 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2831 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2832 ($Lang::tr{'fwdfw pol allow'})
2836 if (&Header
::orange_used
()) {
2839 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2840 ($Lang::tr{'fwdfw pol allow'})
2845 if (&Header
::blue_used
()) {
2848 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2849 ($Lang::tr{'fwdfw pol allow'})
2857 if (&Header
::orange_used
()) {
2860 <td align='center' width='20%'>
2861 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2864 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2865 ($Lang::tr{'fwdfw pol allow'})
2868 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2869 ($Lang::tr{'fwdfw pol block'})
2873 if (&Header
::blue_used
()) {
2876 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2877 ($Lang::tr{'fwdfw pol block'})
2885 if (&Header
::blue_used
()) {
2889 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2892 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2893 ($Lang::tr{'fwdfw pol allow'})
2897 if (&Header
::orange_used
()) {
2900 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2901 ($Lang::tr{'fwdfw pol block'})
2908 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2909 ($Lang::tr{'fwdfw pol block'})
2921 $message = $Lang::tr
{'fwdfw pol allow'};
2923 } elsif ($config eq '/var/ipfire/firewall/outgoing' && ($fwdfwsettings{'POLICY1'} ne 'MODE1')) {
2924 $message = $Lang::tr
{'fwdfw pol allow'};
2925 $colour = "bgcolor='green'";
2927 $message = $Lang::tr
{'fwdfw pol block'};
2928 $colour = "bgcolor='darkred'";
2934 <td $colour align='center' colspan='13'>
2935 <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font>
2944 &Header
::closebox
();
2947 &Header
::closebigbox
();
2948 &Header
::closepage
();