]>
git.ipfire.org Git - people/mfischer/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 "${General::swroot}/geoip-functions.pl";
37 require "/usr/lib/firewall/firewall-lib.pl";
39 unless (-d
"${General::swroot}/firewall") { system("mkdir ${General::swroot}/firewall"); }
40 unless (-e
"${General::swroot}/firewall/settings") { system("touch ${General::swroot}/firewall/settings"); }
41 unless (-e
"${General::swroot}/firewall/config") { system("touch ${General::swroot}/firewall/config"); }
42 unless (-e
"${General::swroot}/firewall/input") { system("touch ${General::swroot}/firewall/input"); }
43 unless (-e
"${General::swroot}/firewall/outgoing") { system("touch ${General::swroot}/firewall/outgoing"); }
47 my %defaultNetworks=();
51 my %customgeoipgrp=();
52 my %customnetworks=();
54 my %customservicegrp=();
60 my %configoutgoingfw=();
72 my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE","IPv6","IPIP");
75 my $confignet = "${General::swroot}/fwhosts/customnetworks";
76 my $confighost = "${General::swroot}/fwhosts/customhosts";
77 my $configgrp = "${General::swroot}/fwhosts/customgroups";
78 my $configgeoipgrp = "${General::swroot}/fwhosts/customgeoipgrp";
79 my $configsrv = "${General::swroot}/fwhosts/customservices";
80 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
81 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
82 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
83 my $configipsec = "${General::swroot}/vpn/config";
84 my $configipsecrw = "${General::swroot}/vpn/settings";
85 my $configfwdfw = "${General::swroot}/firewall/config";
86 my $configinput = "${General::swroot}/firewall/input";
87 my $configoutgoing = "${General::swroot}/firewall/outgoing";
88 my $configovpn = "${General::swroot}/ovpn/settings";
89 my $fwoptions = "${General::swroot}/optionsfw/settings";
90 my $ifacesettings = "${General::swroot}/ethernet/settings";
93 my $ipgrp="${General::swroot}/outgoing/groups";
97 &General
::readhash
("${General::swroot}/firewall/settings", \
%fwdfwsettings);
98 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
99 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
100 &General
::readhash
($fwoptions, \
%optionsfw);
101 &General
::readhash
($ifacesettings, \
%ifaces);
102 &General
::readhash
("$configovpn", \
%ovpnsettings);
103 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
104 &General
::readhasharray
("$configipsec", \
%ipsecconf);
105 &Header
::showhttpheaders
();
106 &Header
::getcgihash
(\
%fwdfwsettings);
107 &Header
::openpage
($Lang::tr
{'firewall rules'}, 1, '');
108 &Header
::openbigbox
('100%', 'center',$errormessage);
109 #### JAVA SCRIPT ####
112 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
114 var update_protocol = function() {
115 var protocol = \$("#protocol").val();
117 if (protocol === undefined)
120 // Check if a template is/should be used.
121 if (protocol === "template") {
122 \$("#PROTOCOL_TEMPLATE").show();
124 \$("#PROTOCOL_TEMPLATE").hide();
127 // Check if we are dealing with a protocol, that knows ports.
128 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
129 \$("#PROTOCOL_PORTS").show();
131 \$("#PROTOCOL_PORTS").hide();
135 if (protocol === "ICMP") {
136 \$("#PROTOCOL_ICMP_TYPES").show();
138 \$("#PROTOCOL_ICMP_TYPES").hide();
142 \$(document).ready(function() {
143 \$("#protocol").change(update_protocol);
146 // Show/Hide elements when NAT checkbox is checked.
147 if (\$("#USE_NAT").attr("checked")) {
148 \$("#actions").hide();
153 // Show NAT area when "use nat" checkbox is clicked
154 \$("#USE_NAT").change(function() {
156 \$("#actions").toggle();
160 if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) {
161 \$("#TIME_CONSTRAINTS").hide();
163 \$("#USE_TIME_CONSTRAINTS").change(function() {
164 \$("#TIME_CONSTRAINTS").toggle();
167 // Limit concurrent connections per ip
168 if(!\$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").attr("checked")) {
169 \$("#LIMIT_CON").hide();
171 \$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").change(function() {
172 \$("#LIMIT_CON").toggle();
175 // Rate-limit new connections
176 if(!\$("#USE_RATELIMIT").attr("checked")) {
177 \$("#RATELIMIT").hide();
179 \$("#USE_RATELIMIT").change(function() {
180 \$("#RATELIMIT").toggle();
183 // Automatically select radio buttons when corresponding
184 // dropdown menu changes.
185 \$("select").change(function() {
186 var id = \$(this).attr("name");
187 \$('#' + id).prop("checked", true);
195 if ($fwdfwsettings{'ACTION'} eq 'saverule')
197 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
198 &General
::readhasharray
("$configinput", \
%configinputfw);
199 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
200 #Set Variables according to the JQuery code in protocol section
201 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')
203 if ($fwdfwsettings{'SRC_PORT'} ne '')
205 $fwdfwsettings{'USE_SRC_PORT'} = 'ON';
207 if ($fwdfwsettings{'TGT_PORT'} ne '')
209 $fwdfwsettings{'USESRV'} = 'ON';
210 $fwdfwsettings{'grp3'} = 'TGT_PORT';
213 if ($fwdfwsettings{'PROT'} eq 'template')
215 $fwdfwsettings{'USESRV'} = 'ON';
217 $errormessage=&checksource
;
218 if(!$errormessage){&checktarget
;}
219 if(!$errormessage){&checkrule
;}
221 #check if manual ip (source) is orange network
222 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
223 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
224 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
229 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
230 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
232 #check if we try to break rules
233 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
234 $errormessage=$Lang::tr
{'fwdfw err same'};
237 if($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
238 $fwdfwsettings{'config'}=$configinput;
239 $fwdfwsettings{'chain'} = 'INPUTFW';
240 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
241 #check if we have an identical rule already
242 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
243 foreach my $key (sort keys %configinputfw){
244 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'}"
245 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]"){
246 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
247 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
248 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
250 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
253 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
254 $fwdfwsettings{'nosave'} = 'on';
259 #check Rulepos on new Rule
260 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
261 $fwdfwsettings{'oldrulenumber'}=$maxkey;
262 foreach my $key (sort keys %configinputfw){
263 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'}"
264 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]"){
265 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
269 #check if we just close a rule
270 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'} ) {
271 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
273 $fwdfwsettings{'nosave2'} = 'on';
277 if($fwdfwsettings{'nosave2'} ne 'on'){
278 &saverule
(\
%configinputfw,$configinput);
281 }elsif($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
283 $fwdfwsettings{'config'}=$configoutgoing;
284 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
285 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
286 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
287 foreach my $key (sort keys %configoutgoingfw){
288 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'}"
289 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]"){
290 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
291 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
292 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
294 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
297 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
298 $fwdfwsettings{'nosave'} = 'on';
303 #check Rulepos on new Rule
304 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
305 $fwdfwsettings{'oldrulenumber'}=$maxkey;
306 foreach my $key (sort keys %configoutgoingfw){
307 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'}"
308 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]"){
309 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
313 #check if we just close a rule
314 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'} ) {
315 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
316 $fwdfwsettings{'nosave2'} = 'on';
322 if ($fwdfwsettings{'nosave2'} ne 'on'){
323 &saverule
(\
%configoutgoingfw,$configoutgoing);
328 $fwdfwsettings{'config'}=$configfwdfw;
329 $fwdfwsettings{'chain'} = 'FORWARDFW';
330 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
331 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
332 #check if we have an identical rule already
333 foreach my $key (sort keys %configfwdfw){
334 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'},$fwdfwsettings{'LIMIT_CON_CON'},$fwdfwsettings{'concon'},$fwdfwsettings{'RATE_LIMIT'},$fwdfwsettings{'ratecon'},$fwdfwsettings{'RATETIME'}"
335 eq "$configfwdfw{$key}[0],$configfwdfw{$key}[2],$configfwdfw{$key}[3],$configfwdfw{$key}[4],$configfwdfw{$key}[5],$configfwdfw{$key}[6],$configfwdfw{$key}[7],$configfwdfw{$key}[8],$configfwdfw{$key}[9],$configfwdfw{$key}[10],$configfwdfw{$key}[11],$configfwdfw{$key}[12],$configfwdfw{$key}[13],$configfwdfw{$key}[14],$configfwdfw{$key}[15],$configfwdfw{$key}[18],$configfwdfw{$key}[19],$configfwdfw{$key}[20],$configfwdfw{$key}[21],$configfwdfw{$key}[22],$configfwdfw{$key}[23],$configfwdfw{$key}[24],$configfwdfw{$key}[25],$configfwdfw{$key}[26],$configfwdfw{$key}[27],$configfwdfw{$key}[28],$configfwdfw{$key}[29],$configfwdfw{$key}[30],$configfwdfw{$key}[31],$configfwdfw{$key}[32],$configfwdfw{$key}[33],$configfwdfw{$key}[34],$configfwdfw{$key}[35],$configfwdfw{$key}[36]"){
336 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
337 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
338 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
340 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
343 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
344 $fwdfwsettings{'nosave'} = 'on';
349 #check Rulepos on new Rule
350 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
351 $fwdfwsettings{'oldrulenumber'}=$maxkey;
352 foreach my $key (sort keys %configfwdfw){
353 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'}"
354 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]"){
355 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
359 #check if we just close a rule
360 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'}){
361 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
362 $fwdfwsettings{'nosave2'} = 'on';
366 #check max concurrent connections per ip address
367 if ($fwdfwsettings{'LIMIT_CON_CON'} eq 'ON'){
368 if (!($fwdfwsettings{'concon'} =~ /^(\d+)$/)) {
369 $errormessage.=$Lang::tr
{'fwdfw err concon'};
372 $fwdfwsettings{'concon'}='';
374 #check ratelimit value
375 if ($fwdfwsettings{'RATE_LIMIT'} eq 'ON'){
376 if (!($fwdfwsettings{'ratecon'} =~ /^(\d+)$/)) {
377 $errormessage.=$Lang::tr
{'fwdfw err ratecon'};
380 $fwdfwsettings{'ratecon'}='';
384 if ($fwdfwsettings{'nosave2'} ne 'on'){
385 &saverule
(\
%configfwdfw,$configfwdfw);
392 if($fwdfwsettings{'nosave2'} ne 'on'){
393 &General
::firewall_config_changed
();
398 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
402 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
405 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
406 foreach my $key (sort keys %togglehash){
407 if ($key eq $fwdfwsettings{'key'}){
408 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
411 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
412 &General
::firewall_config_changed
();
415 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
418 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
419 foreach my $key (sort keys %togglehash){
420 if ($key eq $fwdfwsettings{'key'}){
421 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
424 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
425 &General
::firewall_config_changed
();
428 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
430 &General
::firewall_reload
();
433 if ($fwdfwsettings{'ACTION'} eq 'editrule')
435 $fwdfwsettings{'updatefwrule'}='on';
438 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
442 if ($fwdfwsettings{'ACTION'} eq 'moveup')
447 if ($fwdfwsettings{'ACTION'} eq 'movedown')
452 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
454 $fwdfwsettings{'copyfwrule'}='on';
457 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
466 &Header
::openbox
('100%', 'left', "");
468 <form method="POST" action="">
469 <table border='0' width="100%">
472 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'>
475 if (&General
::firewall_needs_reload
()) {
477 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'>
501 $fwdfwsettings{'updatefwrule'}='';
502 $fwdfwsettings{'config'}=$oldchain;
503 $fwdfwsettings{'nobase'}='on';
509 #check ip-address if manual
510 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
511 #check if ip with subnet
512 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
513 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
514 $subnet = &General
::iporsubtocidr
($subnet);
515 $fwdfwsettings{'isip'}='on';
518 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
519 $ip=$fwdfwsettings{'src_addr'};
521 $fwdfwsettings{'isip'}='on';
524 if ($fwdfwsettings{'isip'} ne 'on'){
525 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
526 $fwdfwsettings{'ismac'}='on';
529 if ($fwdfwsettings{'isip'} eq 'on'){
530 ##check if ip is valid
531 if (! &General
::validip
($ip)){
532 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
533 return $errormessage;
535 #check and form valid IP
536 $ip=&General
::ip2dec
($ip);
537 $ip=&General
::dec2ip
($ip);
538 #check if net or broadcast
539 $fwdfwsettings{'src_addr'}="$ip/$subnet";
540 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
541 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
542 return $errormessage;
545 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
546 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
547 return $errormessage;
549 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
550 $fwdfwsettings{'grp1'}='std_net_src';
551 $fwdfwsettings{$fwdfwsettings{'grp1'}} = 'ALL';
555 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
556 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
557 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
561 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
563 #change dashes with :
566 push(@values,"1:65535");
569 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
570 push(@values,"1:$2");
573 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
574 push(@values,"$1:65535");
577 $errormessage .= &General
::validportrange
($_, 'destination');
582 if (&General
::validport
($_)){
589 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
591 return $errormessage;
596 &General
::readhasharray
("$configsrv", \
%customservice);
597 #check DNAT settings (has to be single Host and single Port or portrange)
598 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
599 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
600 #check if manual ip is a single Host (if set)
601 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
602 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
603 my @tmp1= split ("/",$tmp[3]);
604 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
606 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
607 return $errormessage;
610 #check if Port is a single Port or portrange
611 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
612 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
613 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
614 return $errormessage;
616 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
617 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
618 return $errormessage;
622 if ($fwdfwsettings{'grp2'} ne 'ipfire'){
623 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
624 return $errormessage;
628 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
629 #check if ip with subnet
630 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
631 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
632 $subnet = &General
::iporsubtocidr
($subnet);
635 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
636 $ip=$fwdfwsettings{'tgt_addr'};
639 #check if ip is valid
640 if (! &General
::validip
($ip)){
641 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
642 return $errormessage;
644 #check and form valid IP
645 $ip=&General
::ip2dec
($ip);
646 $ip=&General
::dec2ip
($ip);
647 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
648 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
649 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
650 return $errormessage;
652 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
653 $fwdfwsettings{'grp2'}='std_net_tgt';
654 $fwdfwsettings{$fwdfwsettings{'grp2'}} = 'ALL';
656 #check for mac in targetgroup
657 if ($fwdfwsettings{'grp2'} eq 'cust_grp_tgt'){
658 &General
::readhasharray
("$configgrp", \
%customgrp);
659 &General
::readhasharray
("$confighost", \
%customhost);
660 foreach my $grpkey (sort keys %customgrp){
661 foreach my $hostkey (sort keys %customhost){
662 if ($customgrp{$grpkey}[2] eq $customhost{$hostkey}[0] && $customhost{$hostkey}[1] eq 'mac'){
663 $hint=$Lang::tr
{'fwdfw hint mac'};
670 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
672 if ($fwdfwsettings{'USESRV'} eq 'ON'){
673 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
674 $fwdfwsettings{'TGT_PROT'}='';
675 $fwdfwsettings{'ICMP_TGT'}='';
676 $fwdfwsettings{'TGT_PORT'}='';
678 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
679 $fwdfwsettings{'TGT_PROT'}='';
680 $fwdfwsettings{'ICMP_TGT'}='';
681 $fwdfwsettings{'TGT_PORT'}='';
682 #check target service
683 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
684 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
687 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
688 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
689 if ($fwdfwsettings{'TGT_PORT'} ne ''){
690 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
691 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
692 return $errormessage;
694 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
698 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
700 #change dashes with :
703 push(@values,"1:65535");
706 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
707 push(@values,"1:$2");
710 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
711 push(@values,"$1:65535");
714 $errormessage .= &General
::validportrange
($_, 'destination');
719 if (&General
::validport
($_)){
722 $errormessage=$Lang::tr
{'fwdfw err tgt_port'};
723 return $errormessage;
727 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
729 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
730 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
731 $fwdfwsettings{'TGT_PORT'} = '';
732 $fwdfwsettings{'ICMP_TGT'} = '';
733 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
734 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
735 $fwdfwsettings{'TGT_PORT'} = '';
736 $fwdfwsettings{'ICMP_TGT'}='';
737 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
738 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
739 $fwdfwsettings{'TGT_PORT'} = '';
740 $fwdfwsettings{'ICMP_TGT'}='';
741 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
742 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
743 $fwdfwsettings{'TGT_PORT'} = '';
748 if ($fwdfwsettings{'USESRV'} ne 'ON'){
749 $fwdfwsettings{'grp3'}='';
750 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
751 $fwdfwsettings{'ICMP_TGT'}='';
754 if($fwdfwsettings{'TIME'} eq 'ON'){
755 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 ''){
756 $errormessage=$Lang::tr
{'fwdfw err time'};
757 return $errormessage;
760 return $errormessage;
765 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
766 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
767 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
768 if ($fwdfwsettings{'dnatport'} eq "*") {
769 $fwdfwsettings{'dnatport'}="1:65535";
771 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
772 $fwdfwsettings{'dnatport'} = "1:$2";
774 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
775 $fwdfwsettings{'dnatport'} ="$1:65535";
780 if ($val =~ "," || $val>65536 || $val<0){
787 #check valid port for NAT
788 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
789 #RULE_ACTION must be ACCEPT if we use NAT
790 $fwdfwsettings{'RULE_ACTION'} = 'ACCEPT';
792 #if no dnat or snat selected errormessage
793 if ($fwdfwsettings{'nat'} eq ''){
794 $errormessage=$Lang::tr
{'fwdfw dnat nochoice'};
798 #if using snat, the external port has to be empty
799 if ($fwdfwsettings{'nat'} eq 'snat' && $fwdfwsettings{'dnatport'} ne ''){
800 $errormessage=$Lang::tr
{'fwdfw dnat extport'};
803 #if no dest port is given in nat area, take target host port
804 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
805 if($fwdfwsettings{'TGT_PORT'} eq '' && $fwdfwsettings{'dnatport'} ne '' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')){
806 $errormessage=$Lang::tr
{'fwdfw dnat porterr2'};
809 #check if port given in nat area is a single valid port or portrange
810 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
811 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
812 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
814 #get service Protocol and Port
815 foreach my $key (sort keys %customservice){
816 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
817 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
818 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
820 $custsrvport= $customservice{$key}[1];
823 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
825 #check if DNAT port is multiple
826 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
827 my @parts=split(",",$fwdfwsettings{'dnatport'});
831 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
833 #change dashes with :
836 push(@values,"1:65535");
839 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
840 push(@values,"1:$2");
843 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
844 push(@values,"$1:65535");
847 $errormessage .= &General
::validportrange
($_, 'destination');
852 if (&General
::validport
($_)){
859 $fwdfwsettings{'dnatport'}=join("|",@values);
861 #check if a rule with prot tcp or udp and ports is edited and now prot is "all", then delete all ports
862 if($fwdfwsettings{'PROT'} eq ''){
863 $fwdfwsettings{'dnatport'}='';
867 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
868 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
870 #check if source and target identical
871 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
872 $errormessage=$Lang::tr
{'fwdfw err same'};
873 return $errormessage;
875 #get source and targetip address if possible
876 my ($sip,$scidr,$tip,$tcidr);
877 ($sip,$scidr)=&get_ip
("src","grp1");
878 ($tip,$tcidr)=&get_ip
("tgt","grp2");
879 #check same iprange in source and target
880 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
881 my $networkip1=&General
::getnetworkip
($sip,$scidr);
882 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
883 if ($scidr gt $tcidr){
884 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
885 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
887 }elsif($scidr eq $tcidr && $scidr eq '32'){
888 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
889 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
890 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
891 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
892 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
895 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
896 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
900 #when icmp selected, no source and targetport allowed
901 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')){
902 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
905 #change protocol if prot not equal dest single service
906 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
907 foreach my $key (sort keys %customservice){
908 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
909 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
910 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
916 #check source and destination protocol if source manual and dest servicegroup
917 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
918 $fwdfwsettings{'PROT'} = '';
920 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
921 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
923 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
924 $fwdfwsettings{'USE_SRC_PORT'}='';
925 $fwdfwsettings{'SRC_PORT'}='';
926 #$fwdfwsettings{'USESRV'}='';
927 $fwdfwsettings{'TGT_PORT'}='';
928 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
929 foreach my $key (keys %icmptypes){
930 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
931 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
934 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
935 $fwdfwsettings{'USE_SRC_PORT'}='';
936 $fwdfwsettings{'SRC_PORT'}='';
937 $fwdfwsettings{'ICMP_TYPES'}='';
938 $fwdfwsettings{'USESRV'}='';
939 $fwdfwsettings{'TGT_PORT'}='';
940 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
941 $fwdfwsettings{'USE_SRC_PORT'}='';
942 $fwdfwsettings{'SRC_PORT'}='';
943 $fwdfwsettings{'ICMP_TYPES'}='';
944 $fwdfwsettings{'USESRV'}='';
945 $fwdfwsettings{'TGT_PORT'}='';
946 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
947 $fwdfwsettings{'USE_SRC_PORT'}='';
948 $fwdfwsettings{'SRC_PORT'}='';
949 $fwdfwsettings{'ICMP_TYPES'}='';
950 $fwdfwsettings{'USESRV'}='';
951 $fwdfwsettings{'TGT_PORT'}='';
952 }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){
953 $fwdfwsettings{'USE_SRC_PORT'}='';
954 $fwdfwsettings{'SRC_PORT'}='';
955 $fwdfwsettings{'ICMP_TYPES'}='';
956 $fwdfwsettings{'USESRV'}='';
957 $fwdfwsettings{'TGT_PORT'}='';
958 }elsif($fwdfwsettings{'PROT'} eq 'IPv6'){
959 $fwdfwsettings{'USE_SRC_PORT'}='';
960 $fwdfwsettings{'SRC_PORT'}='';
961 $fwdfwsettings{'ICMP_TYPES'}='';
962 $fwdfwsettings{'USESRV'}='';
963 $fwdfwsettings{'TGT_PORT'}='';
964 }elsif($fwdfwsettings{'PROT'} eq 'IPIP'){
965 $fwdfwsettings{'USE_SRC_PORT'}='';
966 $fwdfwsettings{'SRC_PORT'}='';
967 $fwdfwsettings{'ICMP_TYPES'}='';
968 $fwdfwsettings{'USESRV'}='';
969 $fwdfwsettings{'TGT_PORT'}='';
970 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP'){
971 $fwdfwsettings{'ICMP_TYPES'}='';
972 $fwdfwsettings{'SRC_PORT'}='';
973 $fwdfwsettings{'TGT_PORT'}='';
974 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
975 $fwdfwsettings{'ICMP_TYPES'}='';
981 #Test if manual IP is part of static OpenVPN networks
982 &General
::readhasharray
("$configccdnet", \
%ccdnet);
983 foreach my $key (sort keys %ccdnet){
984 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
985 my $sub=&General
::iporsubtodec
($vpnsubnet);
986 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
990 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
991 # because if one creates a custom host with the ip, we need to check the color there!
992 # It does not make sense to check this here
994 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
995 # Is also checked in getcolor
997 # Test if manual ip is part of an IPsec Network is also checked in getcolor
1007 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
1008 foreach my $key (sort {$a <=> $b} keys %delhash){
1009 if ($key >= $fwdfwsettings{'key'}) {
1010 my $next = $key + 1;
1011 if (exists $delhash{$next}) {
1012 foreach my $i (0 .. $#{$delhash{$next}}) {
1013 $delhash{$key}[$i] = $delhash{$next}[$i];
1018 # Remove the very last entry.
1019 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
1020 delete $delhash{$last_key};
1022 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
1023 &General
::firewall_config_changed
();
1025 if($fwdfwsettings{'nobase'} ne 'on'){
1038 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
1039 foreach my $key (sort keys %configfwdfw){
1040 if ($key eq $key1 ){
1041 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
1044 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
1045 &General
::firewall_config_changed
();
1049 if ($errormessage) {
1050 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1051 print "<class name='base'>$errormessage\n";
1052 print " </class>\n";
1053 &Header
::closebox
();
1058 my %hash=%{(shift)};
1061 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
1062 if($hash{$key}[0] eq $val){
1063 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1065 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1075 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1076 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1077 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1078 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1079 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1080 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1081 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1082 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1083 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1084 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1085 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1086 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1087 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1088 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1089 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1090 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1091 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1092 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1093 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1095 <table width='100%' border='0'>
1096 <tr><td width='50%' valign='top'>
1097 <table width='95%' border='0'>
1098 <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;'>
1100 foreach my $network (sort keys %defaultNetworks)
1102 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1103 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1104 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1105 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1106 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1107 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1108 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1109 if ($ifaces{$defnet}){
1110 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1112 print ">$network</option>";
1115 print"</select></td></tr>";
1117 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1118 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;'>";
1119 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1120 print"</select></td>";
1123 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1124 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;'>";
1125 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1126 print"</select></td>";
1129 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1130 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;'>";
1131 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1132 if($helper ne $customgrp{$key}[0] && $customgrp{$key}[2] ne 'none'){
1134 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1135 print ">$customgrp{$key}[0]</option>";
1137 $helper=$customgrp{$key}[0];
1139 print"</select></td>";
1141 # geoip locations / groups.
1142 my @geoip_locations = &fwlib
::get_geoip_locations
();
1145 print "<td valign='top'><input type='radio' name='$grp' id='cust_geoip_$srctgt' value='cust_geoip_$srctgt' $checked{$grp}{'cust_geoip_'.$srctgt}></td>\n";
1146 print "<td>$Lang::tr{'geoip'}</td>\n";
1147 print "<td align='right'><select name='cust_geoip_$srctgt' style='width:200px;'>\n";
1149 # Add GeoIP groups to dropdown.
1150 if (!-z
$configgeoipgrp) {
1151 print "<optgroup label='$Lang::tr{'fwhost cust geoipgroup'}'>\n";
1152 foreach my $key (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) } keys %customgeoipgrp) {
1155 # Generate stored value for select detection.
1156 my $stored = join(':', "group",$customgeoipgrp{$key}[0]);
1158 # Only show a group once and group with elements.
1159 if($helper ne $customgeoipgrp{$key}[0] && $customgeoipgrp{$key}[2] ne 'none') {
1160 # Mark current entry as selected.
1161 if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $stored) {
1162 $selected = "selected='selected'";
1164 print"<option $selected value='group:$customgeoipgrp{$key}[0]'>$customgeoipgrp{$key}[0]</option>\n";
1166 $helper=$customgeoipgrp{$key}[0];
1168 print "</optgroup>\n";
1172 print "<optgroup label='$Lang::tr{'fwhost cust geoiplocation'}'>\n";
1173 foreach my $location (@geoip_locations) {
1175 my $country_name = &GeoIP
::get_full_country_name
($location);
1177 # Mark current entry as selected.
1179 if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $location) {
1180 $selected = "selected='selected'";
1182 print "<option $selected value='$location'>$location - $country_name</option>\n";
1184 print "</optgroup>\n";
1186 # Close GeoIP dropdown.
1187 print "</select></td>\n";
1189 #End left table. start right table (vpn)
1190 print"</tr></table></td><td valign='top'><table width='95%' border='0' align='right'><tr>";
1192 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1193 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;'>";
1194 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1195 print"</select></td></tr>";
1198 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1199 if ($ccdhost{$key}[33] ne '' ){
1200 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 '');
1202 print "<option value='$ccdhost{$key}[1]'";
1203 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1204 print ">$ccdhost{$key}[1]</option>";
1207 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1208 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>" ;
1210 if ($show eq '1'){$show='';print"</select></td></tr>";}
1212 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1213 if ($ccdhost{$key}[3] eq 'net'){
1214 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 '');
1216 print "<option value='$ccdhost{$key}[1]'";
1217 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1218 print ">$ccdhost{$key}[1]</option>";
1221 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1222 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>" ;
1224 if ($show eq '1'){$show='';print"</select></td></tr>";}
1226 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1227 if ($ipsecconf{$key}[3] eq 'net' || ($optionsfw{'SHOWDROPDOWN'} eq 'on' && $ipsecconf{$key}[3] ne 'host')){
1228 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 '');
1231 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1232 print ">$ipsecconf{$key}[1]</option>";
1235 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1236 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>";
1238 if ($show eq '1'){$show='';print"</select></td></tr>";}
1241 print"</td></tr></table><br>";
1249 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1250 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1251 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1252 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1253 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1254 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1255 $a=$netsettings{'GREEN_NETADDRESS'};
1256 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1257 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1258 $a=$netsettings{'ORANGE_NETADDRESS'};
1259 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1260 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1261 $a=$netsettings{'BLUE_NETADDRESS'};
1262 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1263 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1264 &General
::readhash
("$configovpn",\
%ovpnsettings);
1265 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1266 $b=&General
::iporsubtocidr
($b);
1268 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1269 &General
::readhasharray
("$confignet", \
%customnetwork);
1270 foreach my $key (keys %customnetwork){
1271 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1272 $a=$customnetwork{$key}[1];
1273 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1276 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1277 &General
::readhasharray
("$confighost", \
%customhost);
1278 foreach my $key (keys %customhost){
1279 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1280 if ($customhost{$key}[1] eq 'ip'){
1281 ($a,$b)=split (/\//,$customhost{$key}[2]);
1282 $b=&General
::iporsubtocidr
($b);
1284 if ($grp eq 'grp2'){
1285 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1297 &General
::setup_default_networks
(\
%defaultNetworks);
1298 foreach my $network (sort keys %defaultNetworks)
1300 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1305 my %hash=%{(shift)};
1307 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1308 $hash{$key}[10]=~ s/\|/,/g;
1309 print": $hash{$key}[10]";
1310 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1311 print": <br>$hash{$key}[9] ";
1316 my %hash=%{(shift)};
1320 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1321 if($hash{$key}[14] eq 'cust_srv'){
1322 &General
::readhasharray
("$configsrv", \
%customservice);
1323 foreach my $i (sort keys %customservice){
1324 if($customservice{$i}[0] eq $hash{$key}[15]){
1325 $service = $customservice{$i}[0];
1328 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1329 $service=$hash{$key}[15];
1330 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1331 $hash{$key}[15]=~ s/\|/,/g;
1332 $service=$hash{$key}[15];
1339 sub get_serviceports
1343 &General
::readhasharray
("$configsrv", \
%customservice);
1344 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1346 my @specprot=("IPIP","IPV6","IGMP","GRE","AH","ESP");
1347 if($type eq 'service'){
1348 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1349 if ($customservice{$key}[0] eq $name){
1350 push (@protocols,$customservice{$key}[2]);
1353 }elsif($type eq 'group'){
1354 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1355 if ($customservicegrp{$key}[0] eq $name){
1356 if ($customservicegrp{$key}[2] ~~ @specprot){
1357 push (@protocols," ".$customservicegrp{$key}[2]);
1359 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1360 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1361 if (!grep(/$customservice{$key1}[2]/, @protocols)){
1362 push (@protocols,$customservice{$key1}[2]);}
1370 # Sort protocols alphabetically.
1371 @protocols = sort(@protocols);
1380 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1381 # Don't colourise MAC addresses
1382 if (&General
::validmac
($val)) {
1388 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1389 foreach my $key (sort keys %$hash){
1390 if ($$hash{$key}[0] eq $val){
1391 $val=$$hash{$key}[2];
1396 if ($val eq 'GREEN'){
1397 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1399 }elsif ($val eq 'ORANGE'){
1400 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1402 }elsif ($val eq 'BLUE'){
1403 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1405 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1406 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1408 }elsif ($val eq 'IPFire' ){
1409 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1411 }elsif ($val eq 'OpenVPN-Dyn' ){
1412 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1414 }elsif ($val eq 'IPsec RW' ){
1415 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1417 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1418 my ($sip,$scidr) = split ("/",$val);
1419 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1420 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1423 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1424 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1427 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1428 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1431 }elsif ($val eq 'Default IP'){
1432 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1435 #Check if a manual IP or custom host is part of a VPN
1436 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1437 #Check if IP is part of OpenVPN dynamic subnet
1438 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1439 my ($c,$d) = split("/",$val);
1440 if (&General
::IpInSubnet
($c,$a,$b)){
1441 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1444 #Check if IP is part of OpenVPN static subnet
1445 foreach my $key (sort keys %ccdnet){
1446 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1447 $b =&General
::iporsubtodec
($b);
1448 if (&General
::IpInSubnet
($c,$a,$b)){
1449 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1453 #Check if IP is part of OpenVPN N2N subnet
1454 foreach my $key (sort keys %ccdhost){
1455 if ($ccdhost{$key}[3] eq 'net'){
1456 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1457 if (&General
::IpInSubnet
($c,$a,$b)){
1458 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1463 #Check if IP is part of IPsec RW network
1464 if ($ipsecsettings{'RW_NET'} ne ''){
1465 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1466 $b=&General
::iporsubtodec
($b);
1467 if (&General
::IpInSubnet
($c,$a,$b)){
1468 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1472 #Check if IP is part of a IPsec N2N network
1473 foreach my $key (sort keys %ipsecconf){
1474 if ($ipsecconf{$key}[11]){
1475 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1476 $b=&General
::iporsubtodec
($b);
1477 if (&General
::IpInSubnet
($c,$a,$b)){
1478 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1485 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'){
1486 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1489 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1490 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1494 foreach my $alias (sort keys %aliases)
1496 if ($val eq $alias){
1497 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1508 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1509 print "<class name='base'>$hint\n";
1510 print " </class>\n";
1511 &Header
::closebox
();
1517 &General
::setup_default_networks
(\
%defaultNetworks);
1518 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1519 #read all configfiles
1520 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1521 &General
::readhasharray
("$confignet", \
%customnetwork);
1522 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1523 &General
::readhasharray
("$confighost", \
%customhost);
1524 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1525 &General
::readhasharray
("$configgrp", \
%customgrp);
1526 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
1527 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1528 &General
::get_aliases
(\
%aliases);
1532 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1533 my $config=$fwdfwsettings{'config'};
1536 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1537 my $redip = <CONN1
>;
1539 if (! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE2'){
1540 $fwdfwsettings{'RULE_ACTION'}='DROP';
1541 }elsif(! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE1'){
1542 $fwdfwsettings{'RULE_ACTION'}='ACCEPT';
1544 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1545 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1546 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1547 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1548 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1549 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1550 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1551 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1552 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1553 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1554 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1555 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1556 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1557 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1558 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1559 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1560 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1561 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1562 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1563 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1564 #check if update and get values
1565 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1566 &General
::readhasharray
("$config", \
%hash);
1567 foreach my $key (sort keys %hash){
1569 if ($key eq $fwdfwsettings{'key'}){
1570 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1571 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1572 $fwdfwsettings{'chain'} = $hash{$key}[1];
1573 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1574 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1575 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1576 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1577 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1578 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1579 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1580 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1581 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1582 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1583 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1584 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1585 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1586 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1587 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1588 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1589 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1590 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1591 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1592 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1593 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1594 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1595 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1596 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1597 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1598 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1599 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1600 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1601 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1602 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1603 $fwdfwsettings{'LIMIT_CON_CON'} = $hash{$key}[32];
1604 $fwdfwsettings{'concon'} = $hash{$key}[33];
1605 $fwdfwsettings{'RATE_LIMIT'} = $hash{$key}[34];
1606 $fwdfwsettings{'ratecon'} = $hash{$key}[35];
1607 $fwdfwsettings{'RATETIME'} = $hash{$key}[36];
1608 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1609 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1610 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1611 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1612 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1613 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1614 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1615 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1616 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1617 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1618 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1619 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1620 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1621 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1622 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1623 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1624 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1625 $checked{'LIMIT_CON_CON'}{$fwdfwsettings{'LIMIT_CON_CON'}} = 'CHECKED';
1626 $checked{'RATE_LIMIT'}{$fwdfwsettings{'RATE_LIMIT'}} = 'CHECKED';
1627 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1628 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1629 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1630 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1631 $selected{'dnat'}{$fwdfwsettings{'dnat'}} ='selected';
1632 $selected{'snat'}{$fwdfwsettings{'snat'}} ='selected';
1633 $selected{'RATETIME'}{$fwdfwsettings{'RATETIME'}} ='selected';
1636 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1637 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1638 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1639 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1640 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1641 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1642 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1643 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1644 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1645 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1646 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1647 $fwdfwsettings{'olduseratelimit'}=$fwdfwsettings{'RATE_LIMIT'};
1648 $fwdfwsettings{'olduseratelimitamount'}=$fwdfwsettings{'ratecon'};
1649 $fwdfwsettings{'oldratelimittime'}=$fwdfwsettings{'RATETIME'};
1651 #check if manual ip (source) is orange network
1652 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1653 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1654 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1655 $fwdfwsettings{'oldorange'} ='on';
1659 $fwdfwsettings{'ACTIVE'}='ON';
1660 $fwdfwsettings{'nat'} = 'dnat';
1661 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1662 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1663 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1664 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1665 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1666 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1667 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1668 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1669 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1670 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1671 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1672 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1673 #check if manual ip (source) is orange network
1674 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1675 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1676 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1677 $fwdfwsettings{'oldorange'} ='on';
1681 # Split manual source and target address and delete the subnet
1682 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1683 if ($scidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp1'}}=$sip;}
1684 my ($dip,$dcidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp2'}});
1685 if ($dcidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp2'}}=$dip;}
1686 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1687 #------SOURCE-------------------------------------------------------
1688 print "<form method='post'>";
1690 <table width='100%' border='0'>
1691 <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>
1693 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1694 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1695 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1696 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1697 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1698 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1699 if (! -z
"${General::swroot}/ethernet/aliases"){
1700 foreach my $alias (sort keys %aliases)
1702 print "<option value='$alias' $selected{'ipfire_src'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1707 <tr><td><br></td></tr>
1710 &gen_dd_block
('src','grp1');
1711 &Header
::closebox
();
1713 #---SNAT / DNAT ------------------------------------------------
1714 &Header
::openbox
('100%', 'left', 'NAT');
1717 <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}>
1718 $Lang::tr{'fwdfw use nat'}
1721 <table width='100%' border='0'>
1723 <td width='5%'></td>
1726 <input type='radio' name='nat' value='dnat' $checked{'nat'}{'dnat'}>
1727 $Lang::tr{'fwdfw dnat'}
1733 <td width='25%' align='right'>$Lang::tr{'dnat address'}:</td>
1735 <select name='dnat' style='width: 100%;'>
1736 <option value='AUTO' $selected{'dnat'}{'AUTO'}>- $Lang::tr{'automatic'} -</option>
1737 <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'red1'} ($redip)</option>
1740 foreach my $alias (sort keys %aliases) {
1741 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1745 foreach my $network (sort keys %defaultNetworks)
1747 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1748 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1749 print " selected='selected'" if ($fwdfwsettings{'dnat'} eq $defaultNetworks{$network}{'NAME'});
1750 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1759 <td width='5%'></td>
1762 <input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}>
1763 $Lang::tr{'fwdfw snat'}
1766 <td width='25%' align='right'>$Lang::tr{'snat new source ip address'}:</td>
1768 <select name='snat' style='width: 100%;'>
1771 foreach my $alias (sort keys %aliases) {
1772 print "<option value='$alias' $selected{'snat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1775 foreach my $network (sort keys %defaultNetworks) {
1776 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1777 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1778 print " selected='selected'" if ($fwdfwsettings{'snat'} eq $defaultNetworks{$network}{'NAME'});
1779 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1789 &Header
::closebox
();
1791 #---TARGET------------------------------------------------------
1792 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1794 <table width='100%' border='0'>
1795 <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>
1797 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1798 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1799 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1800 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1801 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1802 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1803 if (! -z
"${General::swroot}/ethernet/aliases"){
1804 foreach my $alias (sort keys %aliases)
1806 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1811 <tr><td><br></td></tr></table>
1813 &gen_dd_block
('tgt','grp2');
1815 #---PROTOCOL------------------------------------------------------
1816 $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
1817 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1818 $fwdfwsettings{'dnatport'} =~ tr/|/,/;
1820 # The dnatport may be empty, if it matches TGT_PORT
1821 if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
1822 $fwdfwsettings{'dnatport'} = "";
1825 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1826 #Fix Protocol for JQuery
1827 if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
1828 $fwdfwsettings{'PROT'} = 'template';
1831 <table width='100%' border='0'>
1834 <select name='PROT' id='protocol' style="width: 95px;">
1836 print "<option value=\"\"";
1837 if ($fwdfwsettings{'PROT'} eq '') {
1838 print " selected=\"selected\"";
1840 print ">$Lang::tr{'all'}</option>";
1842 print "<option value=\"template\"";
1843 print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp');
1844 print ">- $Lang::tr{'template'} -</option>";
1846 foreach (@PROTOCOLS) {
1847 print"<option value=\"$_\"";
1848 if ($_ eq $fwdfwsettings{'PROT'}) {
1849 print " selected=\"selected\"";
1852 print ">$Lang::tr{'fwdfw prot41'}</option>";
1854 print ">$_</option>";
1862 <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES">
1864 <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
1866 <select name='ICMP_TYPES' style='min-width:230px;'>
1868 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1869 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1870 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1871 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1872 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1874 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1884 <table width="100%" border="0" id="PROTOCOL_PORTS">
1886 <!-- #SOURCEPORT -->
1888 $Lang::tr{'fwdfw use srcport'}
1891 <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
1896 <!-- #TARGETPORT -->
1898 $Lang::tr{'fwdfw use srv'}
1902 <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
1906 <td colspan='3'></td>
1907 <td>$Lang::tr{'fwdfw external port nat'}:</td>
1909 <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
1914 <table width="100%" border="0" id="PROTOCOL_TEMPLATE">
1917 <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
1918 $Lang::tr{'fwhost cust service'}
1921 <select name='cust_srv' style='min-width: 230px;'>
1924 &General
::readhasharray
("$configsrv", \
%customservice);
1925 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1927 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1928 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1937 <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
1938 $Lang::tr{'fwhost cust srvgrp'}
1941 <select name='cust_srvgrp' style='min-width:230px;'>
1944 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1946 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1947 if ($helper ne $customservicegrp{$key}[0] && $customservicegrp{$key}[2] ne 'none'){
1949 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1950 print">$customservicegrp{$key}[0]</option>";
1952 $helper=$customservicegrp{$key}[0];
1966 $checked{"RULE_ACTION"}{$fwdfwsettings{'RULE_ACTION'}} = 'CHECKED';
1969 <table width="80%" class='tbl' id='actions'>
1971 <td width="33%" align="center" bgcolor="$color{'color17'}">
1974 <td width="33%" align="center" bgcolor="$color{'color25'}">
1977 <td width="33%" align="center" bgcolor="$color{'color16'}">
1982 <td width="33%" align="center">
1984 <input type="radio" name="RULE_ACTION" value="ACCEPT" $checked{"RULE_ACTION"}{"ACCEPT"}>
1985 <strong>$Lang::tr{'fwdfw ACCEPT'}</strong>
1988 <td width="33%" align="center">
1990 <input type="radio" name="RULE_ACTION" value="DROP" $checked{"RULE_ACTION"}{"DROP"}>
1991 <strong>$Lang::tr{'fwdfw DROP'}</strong>
1994 <td width="33%" align="center">
1996 <input type="radio" name="RULE_ACTION" value="REJECT" $checked{"RULE_ACTION"}{"REJECT"}>
1997 <strong>$Lang::tr{'fwdfw REJECT'}</strong>
2006 #---Activate/logging/remark-------------------------------------
2007 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
2009 <table width='100%' border='0'>
2011 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>";
2012 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
2013 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
2014 for (my $count =1; $count <= $sum; $count++){
2015 print"<option value='$count' ";
2016 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
2017 print">$count</option>";
2019 print"</select></td></tr>";
2021 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
2026 <table width='100%'>
2030 if ($fwdfwsettings{'updatefwrule'} eq 'on') {
2033 <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}>
2035 <td>$Lang::tr{'fwdfw rule activate'}</td>
2040 <input type="hidden" name="ACTIVE" value="ON">
2049 <input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'}>
2051 <td>$Lang::tr{'fwdfw log rule'}</td>
2055 <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}>
2057 <td>$Lang::tr{'fwdfw timeframe'}</td>
2059 <tr id="TIME_CONSTRAINTS">
2061 <table width="66%" border="0">
2063 <td width="8em"> </td>
2064 <td align="center">$Lang::tr{'advproxy monday'}</td>
2065 <td align="center">$Lang::tr{'advproxy tuesday'}</td>
2066 <td align="center">$Lang::tr{'advproxy wednesday'}</td>
2067 <td align="center">$Lang::tr{'advproxy thursday'}</td>
2068 <td align="center">$Lang::tr{'advproxy friday'}</td>
2069 <td align="center">$Lang::tr{'advproxy saturday'}</td>
2070 <td align="center">$Lang::tr{'advproxy sunday'}</td>
2074 <td width="8em"> </td>
2075 <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
2076 <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
2077 <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
2078 <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
2079 <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
2080 <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
2081 <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
2083 <select name='TIME_FROM'>
2085 for (my $i=0;$i<=23;$i++) {
2086 $i = sprintf("%02s",$i);
2087 for (my $j=0;$j<=45;$j+=15) {
2088 $j = sprintf("%02s",$j);
2089 my $time = $i.":".$j;
2090 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
2095 <select name='TIME_TO'>
2097 for (my $i=0;$i<=23;$i++) {
2098 $i = sprintf("%02s",$i);
2099 for (my $j=0;$j<=45;$j+=15) {
2100 $j = sprintf("%02s",$j);
2101 my $time = $i.":".$j;
2102 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
2114 <input type='checkbox' name='LIMIT_CON_CON' id="USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP" value='ON' $checked{'LIMIT_CON_CON'}{'ON'}>
2116 <td>$Lang::tr{'fwdfw limitconcon'}</td>
2120 <table width='66%' border='0'>
2122 <td width="20em"> </td>
2123 <td>$Lang::tr{'fwdfw maxconcon'}: <input type='text' name='concon' size='2' value="$fwdfwsettings{'concon'}"></td>
2130 <input type='checkbox' name='RATE_LIMIT' id="USE_RATELIMIT" value='ON' $checked{'RATE_LIMIT'}{'ON'}>
2132 <td>$Lang::tr{'fwdfw ratelimit'}</td>
2136 <table width='66%' border='0'>
2138 <td width="20em"> </td>
2139 <td>$Lang::tr{'fwdfw numcon'}: <input type='text' name='ratecon' size='2' value="$fwdfwsettings{'ratecon'}"> /
2140 <select name='RATETIME' style='width:100px;'>
2141 <option value='second' $selected{'RATETIME'}{'second'}>$Lang::tr{'age second'}</option>
2142 <option value='minute' $selected{'RATETIME'}{'minute'}>$Lang::tr{'minute'}</option>
2143 <option value='hour' $selected{'RATETIME'}{'hour'}>$Lang::tr{'hour'}</option>
2154 #---ACTION------------------------------------------------------
2155 if($fwdfwsettings{'updatefwrule'} ne 'on'){
2157 <table border='0' width='100%'>
2158 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
2159 <input type='hidden' name='config' value='$config' >
2160 <input type='hidden' name='ACTION' value='saverule' ></form>
2161 <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>
2167 <table border='0' width='100%'>
2168 <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'}'>
2169 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
2170 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
2171 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
2172 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
2173 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
2174 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
2175 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
2176 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
2177 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
2178 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
2179 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
2180 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
2181 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
2182 <input type='hidden' name='oldconcon' value='$fwdfwsettings{'oldconcon'}' />
2183 <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>
2187 &Header
::closebox
();
2193 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
2194 foreach my $key (sort keys %uphash){
2195 if ($key eq $fwdfwsettings{'key'}) {
2197 if (exists $uphash{$last}){
2199 foreach my $y (0 .. $#{$uphash{$last}}) {
2200 $tmp{0}[$y] = $uphash{$last}[$y];
2202 #copy active rule to last
2203 foreach my $i (0 .. $#{$uphash{$last}}) {
2204 $uphash{$last}[$i] = $uphash{$key}[$i];
2206 #copy saved rule to actual position
2207 foreach my $x (0 .. $#{$tmp{0}}) {
2208 $uphash{$key}[$x] = $tmp{0}[$x];
2213 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
2214 &General
::firewall_config_changed
();
2220 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
2221 foreach my $key (sort keys %downhash){
2222 if ($key eq $fwdfwsettings{'key'}) {
2223 my $next = $key + 1;
2224 if (exists $downhash{$next}){
2226 foreach my $y (0 .. $#{$downhash{$next}}) {
2227 $tmp{0}[$y] = $downhash{$next}[$y];
2229 #copy active rule to next
2230 foreach my $i (0 .. $#{$downhash{$next}}) {
2231 $downhash{$next}[$i] = $downhash{$key}[$i];
2233 #copy saved rule to actual position
2234 foreach my $x (0 .. $#{$tmp{0}}) {
2235 $downhash{$key}[$x] = $tmp{0}[$x];
2240 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
2241 &General
::firewall_config_changed
();
2247 &General
::readhasharray
("$config", $hash);
2248 if (!$errormessage){
2249 ################################################################
2250 #check if we change an INPUT rule to a OUTGOING
2251 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2252 &changerule
($configinput);
2255 #check if we change an INPUT rule to a FORWARD
2256 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2257 &changerule
($configinput);
2260 ################################################################
2261 #check if we change an OUTGOING rule to an INPUT
2262 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2263 &changerule
($configoutgoing);
2266 #check if we change an OUTGOING rule to a FORWARD
2267 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2268 &changerule
($configoutgoing);
2271 ################################################################
2272 #check if we change a FORWARD rule to an INPUT
2273 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2274 &changerule
($configfwdfw);
2277 #check if we change a FORWARD rule to an OUTGOING
2278 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2279 &changerule
($configfwdfw);
2282 $fwdfwsettings{'ruleremark'}=~ s/,/;/g;
2283 utf8
::decode
($fwdfwsettings{'ruleremark'});
2284 $fwdfwsettings{'ruleremark'}=&Header
::escape
($fwdfwsettings{'ruleremark'});
2285 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2286 my $key = &General
::findhasharraykey
($hash);
2287 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2288 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2289 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2290 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2291 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2292 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2293 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2294 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2295 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2296 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2297 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2298 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2299 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2300 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2301 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2302 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2303 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2304 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2305 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2306 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2307 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2308 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2309 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2310 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2311 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2312 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2313 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2314 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2315 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2316 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2317 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2318 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2319 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2320 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2321 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2322 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2323 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2324 &General
::writehasharray
("$config", $hash);
2326 foreach my $key (sort {$a <=> $b} keys %$hash){
2327 if($key eq $fwdfwsettings{'key'}){
2328 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2329 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2330 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2331 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2332 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2333 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2334 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2335 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2336 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2337 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2338 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2339 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2340 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2341 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2342 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2343 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2344 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2345 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2346 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2347 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2348 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2349 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2350 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2351 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2352 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2353 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2354 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2355 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2356 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2357 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2358 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2359 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2360 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2361 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2362 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2363 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2364 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2369 &General
::writehasharray
("$config", $hash);
2370 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2372 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2373 for (my $z=0;$z<$val;$z++){
2374 foreach my $key (sort {$a <=> $b} keys %$hash){
2375 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2377 if (exists $$hash{$last}){
2379 foreach my $y (0 .. $#{$$hash{$last}}) {
2380 $tmp{0}[$y] = $$hash{$last}[$y];
2382 #copy active rule to last
2383 foreach my $i (0 .. $#{$$hash{$last}}) {
2384 $$hash{$last}[$i] = $$hash{$key}[$i];
2386 #copy saved rule to actual position
2387 foreach my $x (0 .. $#{$tmp{0}}) {
2388 $$hash{$key}[$x] = $tmp{0}[$x];
2393 $fwdfwsettings{'oldrulenumber'}--;
2395 &General
::writehasharray
("$config", $hash);
2396 &General
::firewall_config_changed
();
2397 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2399 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2400 for (my $z=0;$z<$val;$z++){
2401 foreach my $key (sort {$a <=> $b} keys %$hash){
2402 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2403 my $next = $key + 1;
2404 if (exists $$hash{$next}){
2406 foreach my $y (0 .. $#{$$hash{$next}}) {
2407 $tmp{0}[$y] = $$hash{$next}[$y];
2409 #copy active rule to next
2410 foreach my $i (0 .. $#{$$hash{$next}}) {
2411 $$hash{$next}[$i] = $$hash{$key}[$i];
2413 #copy saved rule to actual position
2414 foreach my $x (0 .. $#{$tmp{0}}) {
2415 $$hash{$key}[$x] = $tmp{0}[$x];
2420 $fwdfwsettings{'oldrulenumber'}++;
2422 &General
::writehasharray
("$config", $hash);
2423 &General
::firewall_config_changed
();
2429 # Checks a hostname against RFC1035
2432 # Try to decode $remark into UTF-8. If this doesn't work,
2433 # we assume that the string it not sane.
2434 if (!utf8
::decode
($remark)) {
2438 # Check if the string only contains of printable characters.
2439 if ($remark =~ /^[[:print:]]*$/) {
2446 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2448 &viewtablenew
(\
%configfwdfw, $configfwdfw, $Lang::tr
{'firewall rules'});
2449 &viewtablenew
(\
%configinputfw, $configinput, $Lang::tr
{'incoming firewall access'});
2450 &viewtablenew
(\
%configoutgoingfw, $configoutgoing, $Lang::tr
{'outgoing firewall access'});
2459 my $show_box = (! -z
$config) || ($optionsfw{'SHOWTABLES'} eq 'on');
2460 return if (!$show_box);
2462 &General
::get_aliases
(\
%aliases);
2463 &General
::readhasharray
("$confighost", \
%customhost);
2464 &General
::readhasharray
("$config", $hash);
2465 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2466 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2467 &General
::readhasharray
("$configgrp", \
%customgrp);
2468 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2470 &Header
::openbox
('100%', 'left', $title);
2471 print "<table width='100%' cellspacing='0' class='tbl'>";
2485 <th align='right' width='3%'>
2488 <th width='2%'></th>
2490 <b>$Lang::tr{'protocol'}</b>
2492 <th align='center' width='30%'>
2493 <b>$Lang::tr{'fwdfw source'}</b>
2496 <b>$Lang::tr{'fwdfw log'}</b>
2498 <th align='center' width='30%'>
2499 <b>$Lang::tr{'fwdfw target'}</b>
2501 <th align='center' colspan='6' width='18%'>
2502 <b>$Lang::tr{'fwdfw action'}</b>
2507 foreach my $key (sort {$a <=> $b} keys %$hash){
2511 #check if vpn hosts/nets have been deleted
2512 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2513 push (@tmpsrc,$$hash{$key}[4]);
2515 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2516 push (@tmptgt,$$hash{$key}[6]);
2518 foreach my $host (@tmpsrc){
2519 if($$hash{$key}[3] eq 'ipsec_net_src'){
2520 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2523 }elsif($$hash{$key}[3] eq 'ovpn_net_src'){
2524 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2527 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src'){
2528 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2531 }elsif($$hash{$key}[3] eq 'ovpn_host_src'){
2532 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2537 foreach my $host (@tmptgt){
2538 if($$hash{$key}[5] eq 'ipsec_net_tgt'){
2539 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2542 }elsif($$hash{$key}[5] eq 'ovpn_net_tgt'){
2543 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2546 }elsif($$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2547 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2550 }elsif($$hash{$key}[5] eq 'ovpn_host_tgt'){
2551 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2556 #check if networkgroups or servicegroups are empty
2557 foreach my $netgroup (sort keys %customgrp){
2558 if(($$hash{$key}[4] eq $customgrp{$netgroup}[0] || $$hash{$key}[6] eq $customgrp{$netgroup}[0]) && $customgrp{$netgroup}[2] eq 'none'){
2562 foreach my $srvgroup (sort keys %customservicegrp){
2563 if($$hash{$key}[15] eq $customservicegrp{$srvgroup}[0] && $customservicegrp{$srvgroup}[2] eq 'none'){
2567 $$hash{'ACTIVE'}=$$hash{$key}[2];
2569 if($coloryellow eq 'on'){
2570 $color="$color{'color14'}";
2572 }elsif($coloryellow eq ''){
2574 $color="$color{'color22'}";
2577 $color="$color{'color20'}";
2581 <tr bgcolor='$color'>
2582 <td align='right' width='3%'>
2588 if ($$hash{$key}[0] eq 'ACCEPT'){
2591 $rulecolor=$color{'color17'};
2592 }elsif($$hash{$key}[0] eq 'DROP'){
2595 $rulecolor=$color{'color25'};
2596 }elsif($$hash{$key}[0] eq 'REJECT'){
2599 $rulecolor=$color{'color16'};
2603 <td bgcolor='$rulecolor' align='center' width='2%'>
2604 <span title='$tooltip'> </span>
2610 if ($$hash{$key}[8]){
2611 if ($$hash{$key}[8] eq "IPv6"){
2612 push (@protocols,$Lang::tr
{'fwdfw prot41 short'})
2614 push (@protocols,$$hash{$key}[8]);
2616 }elsif($$hash{$key}[14] eq 'cust_srv'){
2617 &get_serviceports
("service",$$hash{$key}[15]);
2618 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2619 &get_serviceports
("group",$$hash{$key}[15]);
2621 push (@protocols,$Lang::tr
{'all'});
2624 my $protz=join(", ",@protocols);
2625 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2626 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2627 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2628 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2629 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2633 }elsif($#protocols gt '3'){
2634 print"<td align='center'><span title='$protz'>$Lang::tr{'fwdfw many'}</span></td>";
2636 print"<td align='center'>$protz</td>";
2641 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2642 print"<td align='center' width='30%' $tdcolor>";
2643 if ($$hash{$key}[3] eq 'ipfire_src'){
2644 $ipfireiface=$Lang::tr
{'fwdfw iface'};
2646 if ($$hash{$key}[3] eq 'std_net_src'){
2647 print &get_name
($$hash{$key}[4]);
2648 }elsif ($$hash{$key}[3] eq 'src_addr'){
2649 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2650 if ($split2 eq '32'){
2653 print $$hash{$key}[4];
2655 }elsif ($$hash{$key}[3] eq 'cust_geoip_src') {
2656 my ($split1,$split2) = split(":", $$hash{$key}[4]);
2660 print "$Lang::tr{'geoip'}: $$hash{$key}[4]\n";
2662 }elsif ($$hash{$key}[4] eq 'RED1'){
2663 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2664 }elsif ($$hash{$key}[4] eq 'ALL'){
2665 print "$ipfireiface $Lang::tr{'all'}";
2667 if ($$hash{$key}[4] eq 'GREEN' || $$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE' || $$hash{$key}[4] eq 'RED'){
2668 print "$ipfireiface $Lang::tr{lc($$hash{$key}[4])}";
2670 print "$ipfireiface $$hash{$key}[4]";
2675 &getsrcport
(\
%$hash,$key);
2676 #Is this a SNAT rule?
2677 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2678 my $net=&get_name
($$hash{$key}[29]);
2679 if ( ! $net){ $net=$$hash{$key}[29];}
2681 if ($$hash{$key}[30] ne ''){
2682 print": $$hash{$key}[30]";
2685 if ($$hash{$key}[17] eq 'ON'){
2686 $log="/images/on.gif";
2688 $log="/images/off.gif";
2694 <form method='POST' action=''>
2695 <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 ;'/>
2696 <input type='hidden' name='key' value='$key' />
2697 <input type='hidden' name='config' value='$config' />
2698 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2703 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2705 <td align='center' $tdcolor>
2707 #Is this a DNAT rule?
2709 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2710 if ($$hash{$key}[29] eq 'Default IP'){$$hash{$key}[29]=$Lang::tr
{'red1'};}
2711 if ($$hash{$key}[29] eq 'AUTO'){
2712 my @src_addresses=&fwlib
::get_addresses
(\
%$hash,$key,'src');
2714 foreach my $val (@src_addresses){
2715 push (@nat_ifaces,&fwlib
::get_nat_address
($$hash{$key}[29],$val));
2717 @nat_ifaces=&del_double
(@nat_ifaces);
2720 $natstring = "($$hash{$key}[29])";
2722 print "$Lang::tr{'firewall'} $natstring";
2723 if($$hash{$key}[30] ne ''){
2724 $$hash{$key}[30]=~ tr/|/,/;
2725 print": $$hash{$key}[30]";
2729 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire'){
2730 if ($$hash{$key}[6] eq 'RED1'){
2731 print "$Lang::tr{'red1'}";
2732 }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')
2734 print &get_name
($$hash{$key}[6]);
2736 print $$hash{$key}[6];
2738 }elsif ($$hash{$key}[5] eq 'cust_geoip_tgt') {
2739 my ($split1,$split2) = split(":", $$hash{$key}[6]);
2743 print "$Lang::tr{'geoip'}: $$hash{$key}[6]\n";
2745 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2746 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2747 if ($split2 eq '32'){
2750 print $$hash{$key}[6];
2753 print "$$hash{$key}[6]";
2757 &gettgtport
(\
%$hash,$key);
2760 if($$hash{$key}[2] eq 'ON'){
2761 $gif="/images/on.gif"
2763 $gif="/images/off.gif"
2766 <td width='3%' align='center'>
2767 <form method='POST' action=''>
2768 <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;' />
2769 <input type='hidden' name='key' value='$key' />
2770 <input type='hidden' name='config' value='$config' />
2771 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2774 <td width='3%' align='center'>
2775 <form method='POST' action=''>
2776 <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;' />
2777 <input type='hidden' name='key' value='$key' />
2778 <input type='hidden' name='config' value='$config' />
2779 <input type='hidden' name='ACTION' value='editrule' />
2782 <td width='3%' align='center'>
2783 <form method='POST' action=''>
2784 <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;' />
2785 <input type='hidden' name='key' value='$key' />
2786 <input type='hidden' name='config' value='$config' />
2787 <input type='hidden' name='ACTION' value='copyrule' />
2790 <td width='3%' align='center'>
2791 <form method='POST' action=''>
2792 <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;' />
2793 <input type='hidden' name='key' value='$key' />
2794 <input type='hidden' name='config' value='$config' />
2795 <input type='hidden' name='ACTION' value='deleterule' />
2799 if (exists $$hash{$key-1}){
2801 <td width='3%' align='center'>
2802 <form method='POST' action=''>
2803 <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;' />
2804 <input type='hidden' name='key' value='$key' />
2805 <input type='hidden' name='config' value='$config' />
2806 <input type='hidden' name='ACTION' value='moveup' />
2811 print"<td width='3%'></td>";
2814 if (exists $$hash{$key+1}){
2816 <td width='3%' align='center'>
2817 <form method='POST' action=''>
2818 <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;' />
2819 <input type='hidden' name='key' value='$key' />
2820 <input type='hidden' name='config' value='$config' />
2821 <input type='hidden' name='ACTION' value='movedown' />
2827 print"<td width='3%'></td></tr>";
2830 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2832 <tr bgcolor='$color'>
2834 <td bgcolor='$rulecolor'></td>
2836 <em>$$hash{$key}[16]</em>
2842 if ($$hash{$key}[18] eq 'ON'){
2844 if ($$hash{$key}[18] eq 'ON'){
2846 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2847 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2848 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2849 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2850 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2851 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2852 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2853 my $weekdays=join(",",@days);
2855 print"<tr bgcolor='$color'>";
2856 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27]</td></tr>";
2860 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2862 } elsif ($optionsfw{'SHOWTABLES'} eq 'on') {
2865 <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td>
2871 my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'};
2872 my $colour = "bgcolor='green'";
2873 if ($fwdfwsettings{'POLICY'} eq 'MODE1') {
2874 $colour = "bgcolor='darkred'";
2878 if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) {
2881 <td colspan='13'> </td>
2884 <td colspan='13' style="padding-left:0px;padding-right:0px">
2885 <table width="100%" border='1' rules="cols" cellspacing='0'>
2892 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2895 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2896 ($Lang::tr{'fwdfw pol allow'})
2900 if (&Header
::orange_used
()) {
2903 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2904 ($Lang::tr{'fwdfw pol allow'})
2909 if (&Header
::blue_used
()) {
2912 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2913 ($Lang::tr{'fwdfw pol allow'})
2921 if (&Header
::orange_used
()) {
2924 <td align='center' width='20%'>
2925 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2928 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2929 ($Lang::tr{'fwdfw pol allow'})
2932 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2933 ($Lang::tr{'fwdfw pol block'})
2937 if (&Header
::blue_used
()) {
2940 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2941 ($Lang::tr{'fwdfw pol block'})
2949 if (&Header
::blue_used
()) {
2953 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2956 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2957 ($Lang::tr{'fwdfw pol allow'})
2961 if (&Header
::orange_used
()) {
2964 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2965 ($Lang::tr{'fwdfw pol block'})
2972 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2973 ($Lang::tr{'fwdfw pol block'})
2985 $message = $Lang::tr
{'fwdfw pol allow'};
2987 } elsif ($config eq '/var/ipfire/firewall/outgoing' && ($fwdfwsettings{'POLICY1'} ne 'MODE1')) {
2988 $message = $Lang::tr
{'fwdfw pol allow'};
2989 $colour = "bgcolor='green'";
2991 $message = $Lang::tr
{'fwdfw pol block'};
2992 $colour = "bgcolor='darkred'";
2998 <td $colour align='center' colspan='13'>
2999 <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font>
3008 &Header
::closebox
();
3011 &Header
::closebigbox
();
3012 &Header
::closepage
();