]>
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=();
73 my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE","IPv6","IPIP");
76 my $confignet = "${General::swroot}/fwhosts/customnetworks";
77 my $confighost = "${General::swroot}/fwhosts/customhosts";
78 my $configgrp = "${General::swroot}/fwhosts/customgroups";
79 my $configgeoipgrp = "${General::swroot}/fwhosts/customgeoipgrp";
80 my $configsrv = "${General::swroot}/fwhosts/customservices";
81 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
82 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
83 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
84 my $configipsec = "${General::swroot}/vpn/config";
85 my $configipsecrw = "${General::swroot}/vpn/settings";
86 my $configfwdfw = "${General::swroot}/firewall/config";
87 my $configinput = "${General::swroot}/firewall/input";
88 my $configoutgoing = "${General::swroot}/firewall/outgoing";
89 my $configovpn = "${General::swroot}/ovpn/settings";
90 my $fwoptions = "${General::swroot}/optionsfw/settings";
91 my $ifacesettings = "${General::swroot}/ethernet/settings";
94 my $ipgrp="${General::swroot}/outgoing/groups";
98 &General
::readhash
("${General::swroot}/firewall/settings", \
%fwdfwsettings);
99 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
100 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
101 &General
::readhash
($fwoptions, \
%optionsfw);
102 &General
::readhash
($ifacesettings, \
%ifaces);
103 &General
::readhash
("$configovpn", \
%ovpnsettings);
104 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
105 &General
::readhasharray
("$configipsec", \
%ipsecconf);
106 &Header
::showhttpheaders
();
107 &Header
::getcgihash
(\
%fwdfwsettings);
108 &Header
::openpage
($Lang::tr
{'firewall rules'}, 1, '');
109 &Header
::openbigbox
('100%', 'center',$errormessage);
110 #### JAVA SCRIPT ####
113 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
115 var update_protocol = function() {
116 var protocol = \$("#protocol").val();
118 if (protocol === undefined)
121 // Check if a template is/should be used.
122 if (protocol === "template") {
123 \$("#PROTOCOL_TEMPLATE").show();
125 \$("#PROTOCOL_TEMPLATE").hide();
128 // Check if we are dealing with a protocol, that knows ports.
129 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
130 \$("#PROTOCOL_PORTS").show();
132 \$("#PROTOCOL_PORTS").hide();
136 if (protocol === "ICMP") {
137 \$("#PROTOCOL_ICMP_TYPES").show();
139 \$("#PROTOCOL_ICMP_TYPES").hide();
143 \$(document).ready(function() {
144 \$("#protocol").change(update_protocol);
147 // Show/Hide elements when NAT checkbox is checked.
148 if (\$("#USE_NAT").attr("checked")) {
149 \$("#actions").hide();
154 // Show NAT area when "use nat" checkbox is clicked
155 \$("#USE_NAT").change(function() {
157 \$("#actions").toggle();
160 // Hide SNAT items when DNAT is selected and vice versa.
161 if (\$('input[name=nat]:checked').val() == 'dnat') {
167 // Show/Hide elements when SNAT/DNAT get changed.
168 \$('input[name=nat]').change(function() {
169 \$('.snat').toggle();
170 \$('.dnat').toggle();
174 if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) {
175 \$("#TIME_CONSTRAINTS").hide();
177 \$("#USE_TIME_CONSTRAINTS").change(function() {
178 \$("#TIME_CONSTRAINTS").toggle();
181 // Limit concurrent connections per ip
182 if(!\$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").attr("checked")) {
183 \$("#LIMIT_CON").hide();
185 \$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").change(function() {
186 \$("#LIMIT_CON").toggle();
189 // Rate-limit new connections
190 if(!\$("#USE_RATELIMIT").attr("checked")) {
191 \$("#RATELIMIT").hide();
193 \$("#USE_RATELIMIT").change(function() {
194 \$("#RATELIMIT").toggle();
197 // Automatically select radio buttons when corresponding
198 // dropdown menu changes.
199 \$("select").change(function() {
200 var id = \$(this).attr("name");
201 \$('#' + id).prop("checked", true);
209 if ($fwdfwsettings{'ACTION'} eq 'saverule')
211 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
212 &General
::readhasharray
("$configinput", \
%configinputfw);
213 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
215 #Set Variables according to the JQuery code in protocol section
216 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')
218 if ($fwdfwsettings{'SRC_PORT'} ne '')
220 $fwdfwsettings{'USE_SRC_PORT'} = 'ON';
222 if ($fwdfwsettings{'TGT_PORT'} ne '')
224 $fwdfwsettings{'USESRV'} = 'ON';
225 $fwdfwsettings{'grp3'} = 'TGT_PORT';
228 if ($fwdfwsettings{'PROT'} eq 'template')
230 $fwdfwsettings{'USESRV'} = 'ON';
232 $errormessage=&checksource
;
233 if(!$errormessage){&checktarget
;}
234 if(!$errormessage){&checkrule
;}
236 #check if manual ip (source) is orange network
237 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
238 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
239 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
244 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
245 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
247 #check if we try to break rules
248 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
249 $errormessage=$Lang::tr
{'fwdfw err same'};
252 if ($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
253 $fwdfwsettings{'config'}=$configinput;
254 $fwdfwsettings{'chain'} = 'INPUTFW';
255 $maxkey=&General
::findhasharraykey
(\
%configinputfw);
256 %rulehash=%configinputfw;
257 }elsif ($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
259 $fwdfwsettings{'config'}=$configoutgoing;
260 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
261 $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
262 %rulehash=%configoutgoingfw;
265 $fwdfwsettings{'config'}=$configfwdfw;
266 $fwdfwsettings{'chain'} = 'FORWARDFW';
267 $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
268 %rulehash=%configfwdfw;
270 #check if we have an identical rule already
271 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
272 foreach my $key (sort keys %rulehash){
273 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{'ruleremark'},$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'}"
274 eq "$rulehash{$key}[0],$rulehash{$key}[2],$rulehash{$key}[3],$rulehash{$key}[4],$rulehash{$key}[5],$rulehash{$key}[6],$rulehash{$key}[7],$rulehash{$key}[8],$rulehash{$key}[9],$rulehash{$key}[10],$rulehash{$key}[11],$rulehash{$key}[12],$rulehash{$key}[13],$rulehash{$key}[14],$rulehash{$key}[15],$rulehash{$key}[16],$rulehash{$key}[17],$rulehash{$key}[18],$rulehash{$key}[19],$rulehash{$key}[20],$rulehash{$key}[21],$rulehash{$key}[22],$rulehash{$key}[23],$rulehash{$key}[24],$rulehash{$key}[25],$rulehash{$key}[26],$rulehash{$key}[27],$rulehash{$key}[28],$rulehash{$key}[29],$rulehash{$key}[30],$rulehash{$key}[31],$rulehash{$key}[32],$rulehash{$key}[33],$rulehash{$key}[34],$rulehash{$key}[35],$rulehash{$key}[36]"){
275 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
276 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
277 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
279 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
282 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
283 $fwdfwsettings{'nosave'} = 'on';
288 #check Rulepos on new Rule
289 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
290 $fwdfwsettings{'oldrulenumber'}=$maxkey;
291 foreach my $key (sort keys %rulehash){
292 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'}"
293 eq "$rulehash{$key}[0],$rulehash{$key}[2],$rulehash{$key}[3],$rulehash{$key}[4],$rulehash{$key}[5],$rulehash{$key}[6],$rulehash{$key}[7],$rulehash{$key}[8],$rulehash{$key}[9],$rulehash{$key}[10],$rulehash{$key}[11],$rulehash{$key}[12],$rulehash{$key}[13],$rulehash{$key}[14],$rulehash{$key}[15],$rulehash{$key}[18],$rulehash{$key}[19],$rulehash{$key}[20],$rulehash{$key}[21],$rulehash{$key}[22],$rulehash{$key}[23],$rulehash{$key}[24],$rulehash{$key}[25],$rulehash{$key}[26],$rulehash{$key}[27],$rulehash{$key}[28],$rulehash{$key}[29],$rulehash{$key}[30],$rulehash{$key}[31],$rulehash{$key}[32],$rulehash{$key}[33],$rulehash{$key}[34],$rulehash{$key}[35],$rulehash{$key}[36]"){
294 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
298 #check if we just close a rule
299 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'}){
300 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
301 $fwdfwsettings{'nosave2'} = 'on';
305 #check max concurrent connections per ip address
306 if ($fwdfwsettings{'LIMIT_CON_CON'} eq 'ON'){
307 if (!($fwdfwsettings{'concon'} =~ /^(\d+)$/)) {
308 $errormessage.=$Lang::tr
{'fwdfw err concon'};
311 $fwdfwsettings{'concon'}='';
313 #check ratelimit value
314 if ($fwdfwsettings{'RATE_LIMIT'} eq 'ON'){
315 if (!($fwdfwsettings{'ratecon'} =~ /^(\d+)$/)) {
316 $errormessage.=$Lang::tr
{'fwdfw err ratecon'};
319 $fwdfwsettings{'ratecon'}='';
323 if ($fwdfwsettings{'nosave2'} ne 'on'){
324 &saverule
(\
%rulehash,$fwdfwsettings{'config'});
330 if($fwdfwsettings{'nosave2'} ne 'on'){
331 &General
::firewall_config_changed
();
336 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
340 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
343 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
344 foreach my $key (sort keys %togglehash){
345 if ($key eq $fwdfwsettings{'key'}){
346 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
349 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
350 &General
::firewall_config_changed
();
353 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
356 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
357 foreach my $key (sort keys %togglehash){
358 if ($key eq $fwdfwsettings{'key'}){
359 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
362 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
363 &General
::firewall_config_changed
();
366 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
368 &General
::firewall_reload
();
371 if ($fwdfwsettings{'ACTION'} eq 'editrule')
373 $fwdfwsettings{'updatefwrule'}='on';
376 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
380 if ($fwdfwsettings{'ACTION'} eq 'moveup')
385 if ($fwdfwsettings{'ACTION'} eq 'movedown')
390 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
392 $fwdfwsettings{'copyfwrule'}='on';
395 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
404 &Header
::openbox
('100%', 'left', "");
406 <form method="POST" action="">
407 <table border='0' width="100%">
410 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'>
413 if (&General
::firewall_needs_reload
()) {
415 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'>
439 $fwdfwsettings{'updatefwrule'}='';
440 $fwdfwsettings{'config'}=$oldchain;
441 $fwdfwsettings{'nobase'}='on';
447 #check ip-address if manual
448 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
449 #check if ip with subnet
450 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
451 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
452 $subnet = &General
::iporsubtocidr
($subnet);
453 $fwdfwsettings{'isip'}='on';
456 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
457 $ip=$fwdfwsettings{'src_addr'};
459 $fwdfwsettings{'isip'}='on';
462 if ($fwdfwsettings{'isip'} ne 'on'){
463 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
464 $fwdfwsettings{'ismac'}='on';
467 if ($fwdfwsettings{'isip'} eq 'on'){
468 ##check if ip is valid
469 if (! &General
::validip
($ip)){
470 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
471 return $errormessage;
473 #check and form valid IP
474 $ip=&General
::ip2dec
($ip);
475 $ip=&General
::dec2ip
($ip);
476 #check if net or broadcast
477 $fwdfwsettings{'src_addr'}="$ip/$subnet";
478 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
479 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
480 return $errormessage;
483 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
484 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
485 return $errormessage;
487 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
488 $fwdfwsettings{'grp1'}='std_net_src';
489 $fwdfwsettings{$fwdfwsettings{'grp1'}} = 'ALL';
493 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
494 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
495 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
499 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
501 #change dashes with :
504 push(@values,"1:65535");
507 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
508 push(@values,"1:$2");
511 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
512 push(@values,"$1:65535");
515 $errormessage .= &General
::validportrange
($_, 'destination');
520 if (&General
::validport
($_)){
527 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
529 return $errormessage;
534 &General
::readhasharray
("$configsrv", \
%customservice);
535 #check DNAT settings (has to be single Host and single Port or portrange)
536 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
537 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
538 #check if manual ip is a single Host (if set)
539 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
540 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
541 my @tmp1= split ("/",$tmp[3]);
542 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
544 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
545 return $errormessage;
548 #check if Port is a single Port or portrange
549 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
550 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
551 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
552 return $errormessage;
554 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
555 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
556 return $errormessage;
560 if ($fwdfwsettings{'grp2'} ne 'ipfire'){
561 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
562 return $errormessage;
566 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
567 #check if ip with subnet
568 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
569 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
570 $subnet = &General
::iporsubtocidr
($subnet);
573 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
574 $ip=$fwdfwsettings{'tgt_addr'};
577 #check if ip is valid
578 if (! &General
::validip
($ip)){
579 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
580 return $errormessage;
582 #check and form valid IP
583 $ip=&General
::ip2dec
($ip);
584 $ip=&General
::dec2ip
($ip);
585 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
586 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
587 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
588 return $errormessage;
590 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
591 $fwdfwsettings{'grp2'}='std_net_tgt';
592 $fwdfwsettings{$fwdfwsettings{'grp2'}} = 'ALL';
594 #check for mac in targetgroup
595 if ($fwdfwsettings{'grp2'} eq 'cust_grp_tgt'){
596 &General
::readhasharray
("$configgrp", \
%customgrp);
597 &General
::readhasharray
("$confighost", \
%customhost);
598 foreach my $grpkey (sort keys %customgrp){
599 foreach my $hostkey (sort keys %customhost){
600 if ($customgrp{$grpkey}[2] eq $customhost{$hostkey}[0] && $customgrp{$grpkey}[2] eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $customhost{$hostkey}[1] eq 'mac'){
601 $hint=$Lang::tr
{'fwdfw hint mac'};
608 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
610 if ($fwdfwsettings{'USESRV'} eq 'ON'){
611 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
612 $fwdfwsettings{'TGT_PROT'}='';
613 $fwdfwsettings{'ICMP_TGT'}='';
614 $fwdfwsettings{'TGT_PORT'}='';
616 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
617 $fwdfwsettings{'TGT_PROT'}='';
618 $fwdfwsettings{'ICMP_TGT'}='';
619 $fwdfwsettings{'TGT_PORT'}='';
620 #check target service
621 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
622 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
625 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
626 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
627 if ($fwdfwsettings{'TGT_PORT'} ne ''){
628 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
629 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
630 return $errormessage;
632 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
636 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
638 #change dashes with :
641 push(@values,"1:65535");
644 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
645 push(@values,"1:$2");
648 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
649 push(@values,"$1:65535");
652 $errormessage .= &General
::validportrange
($_, 'destination');
657 if (&General
::validport
($_)){
660 $errormessage=$Lang::tr
{'fwdfw err tgt_port'};
661 return $errormessage;
665 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
667 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
668 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
669 $fwdfwsettings{'TGT_PORT'} = '';
670 $fwdfwsettings{'ICMP_TGT'} = '';
671 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
672 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
673 $fwdfwsettings{'TGT_PORT'} = '';
674 $fwdfwsettings{'ICMP_TGT'}='';
675 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
676 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
677 $fwdfwsettings{'TGT_PORT'} = '';
678 $fwdfwsettings{'ICMP_TGT'}='';
679 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
680 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
681 $fwdfwsettings{'TGT_PORT'} = '';
686 if ($fwdfwsettings{'USESRV'} ne 'ON'){
687 $fwdfwsettings{'grp3'}='';
688 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
689 $fwdfwsettings{'ICMP_TGT'}='';
692 if($fwdfwsettings{'TIME'} eq 'ON'){
693 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 ''){
694 $errormessage=$Lang::tr
{'fwdfw err time'};
695 return $errormessage;
698 return $errormessage;
703 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
704 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
705 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
706 if ($fwdfwsettings{'dnatport'} eq "*") {
707 $fwdfwsettings{'dnatport'}="1:65535";
709 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
710 $fwdfwsettings{'dnatport'} = "1:$2";
712 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
713 $fwdfwsettings{'dnatport'} ="$1:65535";
718 if ($val =~ "," || $val>65536 || $val<0){
725 #check valid port for NAT
726 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
727 #RULE_ACTION must be ACCEPT if we use NAT
728 $fwdfwsettings{'RULE_ACTION'} = 'ACCEPT';
730 #if no dnat or snat selected errormessage
731 if ($fwdfwsettings{'nat'} eq ''){
732 $errormessage=$Lang::tr
{'fwdfw dnat nochoice'};
736 #if using snat, the external port has to be empty
737 if ($fwdfwsettings{'nat'} eq 'snat' && $fwdfwsettings{'dnatport'} ne ''){
738 $errormessage=$Lang::tr
{'fwdfw dnat extport'};
741 #if no dest port is given in nat area, take target host port
742 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
743 if($fwdfwsettings{'TGT_PORT'} eq '' && $fwdfwsettings{'dnatport'} ne '' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')){
744 $errormessage=$Lang::tr
{'fwdfw dnat porterr2'};
747 #check if port given in nat area is a single valid port or portrange
748 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
749 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
750 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
752 #get service Protocol and Port
753 foreach my $key (sort keys %customservice){
754 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
755 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
756 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
758 $custsrvport= $customservice{$key}[1];
761 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
763 #check if DNAT port is multiple
764 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
765 my @parts=split(",",$fwdfwsettings{'dnatport'});
769 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
771 #change dashes with :
774 push(@values,"1:65535");
777 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
778 push(@values,"1:$2");
781 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
782 push(@values,"$1:65535");
785 $errormessage .= &General
::validportrange
($_, 'destination');
790 if (&General
::validport
($_)){
797 $fwdfwsettings{'dnatport'}=join("|",@values);
799 #check if a rule with prot tcp or udp and ports is edited and now prot is "all", then delete all ports
800 if($fwdfwsettings{'PROT'} eq ''){
801 $fwdfwsettings{'dnatport'}='';
805 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
806 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
808 #check if source and target identical
809 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL' && $fwdfwsettings{'grp2'} ne 'ipfire'){
810 $errormessage=$Lang::tr
{'fwdfw err same'};
811 return $errormessage;
813 #get source and targetip address if possible
814 my ($sip,$scidr,$tip,$tcidr);
815 ($sip,$scidr)=&get_ip
("src","grp1");
816 ($tip,$tcidr)=&get_ip
("tgt","grp2");
817 #check same iprange in source and target
818 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
819 my $networkip1=&General
::getnetworkip
($sip,$scidr);
820 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
821 if ($scidr gt $tcidr){
822 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
823 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
825 }elsif($scidr eq $tcidr && $scidr eq '32'){
826 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
827 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
828 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
829 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
830 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
833 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
834 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
838 #when icmp selected, no source and targetport allowed
839 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')){
840 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
843 #change protocol if prot not equal dest single service
844 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
845 foreach my $key (sort keys %customservice){
846 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
847 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
848 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
854 #check source and destination protocol if source manual and dest servicegroup
855 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
856 $fwdfwsettings{'PROT'} = '';
858 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
859 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
861 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
862 $fwdfwsettings{'USE_SRC_PORT'}='';
863 $fwdfwsettings{'SRC_PORT'}='';
864 #$fwdfwsettings{'USESRV'}='';
865 $fwdfwsettings{'TGT_PORT'}='';
866 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
867 foreach my $key (keys %icmptypes){
868 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
869 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
872 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
873 $fwdfwsettings{'USE_SRC_PORT'}='';
874 $fwdfwsettings{'SRC_PORT'}='';
875 $fwdfwsettings{'ICMP_TYPES'}='';
876 $fwdfwsettings{'USESRV'}='';
877 $fwdfwsettings{'TGT_PORT'}='';
878 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
879 $fwdfwsettings{'USE_SRC_PORT'}='';
880 $fwdfwsettings{'SRC_PORT'}='';
881 $fwdfwsettings{'ICMP_TYPES'}='';
882 $fwdfwsettings{'USESRV'}='';
883 $fwdfwsettings{'TGT_PORT'}='';
884 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
885 $fwdfwsettings{'USE_SRC_PORT'}='';
886 $fwdfwsettings{'SRC_PORT'}='';
887 $fwdfwsettings{'ICMP_TYPES'}='';
888 $fwdfwsettings{'USESRV'}='';
889 $fwdfwsettings{'TGT_PORT'}='';
890 }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){
891 $fwdfwsettings{'USE_SRC_PORT'}='';
892 $fwdfwsettings{'SRC_PORT'}='';
893 $fwdfwsettings{'ICMP_TYPES'}='';
894 $fwdfwsettings{'USESRV'}='';
895 $fwdfwsettings{'TGT_PORT'}='';
896 }elsif($fwdfwsettings{'PROT'} eq 'IPv6'){
897 $fwdfwsettings{'USE_SRC_PORT'}='';
898 $fwdfwsettings{'SRC_PORT'}='';
899 $fwdfwsettings{'ICMP_TYPES'}='';
900 $fwdfwsettings{'USESRV'}='';
901 $fwdfwsettings{'TGT_PORT'}='';
902 }elsif($fwdfwsettings{'PROT'} eq 'IPIP'){
903 $fwdfwsettings{'USE_SRC_PORT'}='';
904 $fwdfwsettings{'SRC_PORT'}='';
905 $fwdfwsettings{'ICMP_TYPES'}='';
906 $fwdfwsettings{'USESRV'}='';
907 $fwdfwsettings{'TGT_PORT'}='';
908 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP'){
909 $fwdfwsettings{'ICMP_TYPES'}='';
910 $fwdfwsettings{'SRC_PORT'}='';
911 $fwdfwsettings{'TGT_PORT'}='';
912 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
913 $fwdfwsettings{'ICMP_TYPES'}='';
919 #Test if manual IP is part of static OpenVPN networks
920 &General
::readhasharray
("$configccdnet", \
%ccdnet);
921 foreach my $key (sort keys %ccdnet){
922 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
923 my $sub=&General
::iporsubtodec
($vpnsubnet);
924 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
928 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
929 # because if one creates a custom host with the ip, we need to check the color there!
930 # It does not make sense to check this here
932 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
933 # Is also checked in getcolor
935 # Test if manual ip is part of an IPsec Network is also checked in getcolor
945 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
946 foreach my $key (sort {$a <=> $b} keys %delhash){
947 if ($key >= $fwdfwsettings{'key'}) {
949 if (exists $delhash{$next}) {
950 foreach my $i (0 .. $#{$delhash{$next}}) {
951 $delhash{$key}[$i] = $delhash{$next}[$i];
956 # Remove the very last entry.
957 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
958 delete $delhash{$last_key};
960 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
961 &General
::firewall_config_changed
();
963 if($fwdfwsettings{'nobase'} ne 'on'){
976 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
977 foreach my $key (sort keys %configfwdfw){
979 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
982 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
983 &General
::firewall_config_changed
();
988 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
989 print "<class name='base'>$errormessage\n";
990 print " </class>\n";
999 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
1000 if($hash{$key}[0] eq $val){
1001 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1003 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1013 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1014 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1015 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1016 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1017 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1018 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1019 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1020 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1021 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1022 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1023 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1024 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1025 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1026 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1027 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1028 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1029 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1030 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1031 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1033 <table width='100%' border='0'>
1034 <tr><td width='50%' valign='top'>
1035 <table width='95%' border='0'>
1036 <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;'>
1038 foreach my $network (sort keys %defaultNetworks)
1040 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1041 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1042 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1043 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1044 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1045 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1046 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1047 if ($ifaces{$defnet}){
1048 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1050 print ">$network</option>";
1053 print"</select></td></tr>";
1055 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1056 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;'>";
1057 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1058 print"</select></td>";
1061 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1062 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;'>";
1063 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1064 print"</select></td>";
1067 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1068 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;'>";
1069 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1070 if($helper ne $customgrp{$key}[0] && $customgrp{$key}[2] ne 'none'){
1072 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1073 print ">$customgrp{$key}[0]</option>";
1075 $helper=$customgrp{$key}[0];
1077 print"</select></td>";
1079 # geoip locations / groups.
1080 my @geoip_locations = &fwlib
::get_geoip_locations
();
1083 print "<td valign='top'><input type='radio' name='$grp' id='cust_geoip_$srctgt' value='cust_geoip_$srctgt' $checked{$grp}{'cust_geoip_'.$srctgt}></td>\n";
1084 print "<td>$Lang::tr{'geoip'}</td>\n";
1085 print "<td align='right'><select name='cust_geoip_$srctgt' style='width:200px;'>\n";
1087 # Add GeoIP groups to dropdown.
1088 if (!-z
$configgeoipgrp) {
1089 print "<optgroup label='$Lang::tr{'fwhost cust geoipgroup'}'>\n";
1090 foreach my $key (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) } keys %customgeoipgrp) {
1093 # Generate stored value for select detection.
1094 my $stored = join(':', "group",$customgeoipgrp{$key}[0]);
1096 # Only show a group once and group with elements.
1097 if($helper ne $customgeoipgrp{$key}[0] && $customgeoipgrp{$key}[2] ne 'none') {
1098 # Mark current entry as selected.
1099 if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $stored) {
1100 $selected = "selected='selected'";
1102 print"<option $selected value='group:$customgeoipgrp{$key}[0]'>$customgeoipgrp{$key}[0]</option>\n";
1104 $helper=$customgeoipgrp{$key}[0];
1106 print "</optgroup>\n";
1110 print "<optgroup label='$Lang::tr{'fwhost cust geoiplocation'}'>\n";
1111 foreach my $location (@geoip_locations) {
1113 my $country_name = &GeoIP
::get_full_country_name
($location);
1115 # Mark current entry as selected.
1117 if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $location) {
1118 $selected = "selected='selected'";
1120 print "<option $selected value='$location'>$location - $country_name</option>\n";
1122 print "</optgroup>\n";
1124 # Close GeoIP dropdown.
1125 print "</select></td>\n";
1127 #End left table. start right table (vpn)
1128 print"</tr></table></td><td valign='top'><table width='95%' border='0' align='right'><tr>";
1130 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1131 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;'>";
1132 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1133 print"</select></td></tr>";
1136 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1137 if ($ccdhost{$key}[33] ne '' ){
1138 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 '');
1140 print "<option value='$ccdhost{$key}[1]'";
1141 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1142 print ">$ccdhost{$key}[1]</option>";
1145 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1146 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>" ;
1148 if ($show eq '1'){$show='';print"</select></td></tr>";}
1150 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1151 if ($ccdhost{$key}[3] eq 'net'){
1152 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 '');
1154 print "<option value='$ccdhost{$key}[1]'";
1155 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1156 print ">$ccdhost{$key}[1]</option>";
1159 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1160 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>" ;
1162 if ($show eq '1'){$show='';print"</select></td></tr>";}
1164 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1165 if ($ipsecconf{$key}[3] eq 'net' || ($optionsfw{'SHOWDROPDOWN'} eq 'on' && $ipsecconf{$key}[3] ne 'host')){
1166 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 '');
1169 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1170 print ">$ipsecconf{$key}[1]</option>";
1173 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1174 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>";
1176 if ($show eq '1'){$show='';print"</select></td></tr>";}
1179 print"</td></tr></table><br>";
1187 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1188 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1189 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1190 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1191 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1192 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1193 $a=$netsettings{'GREEN_NETADDRESS'};
1194 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1195 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1196 $a=$netsettings{'ORANGE_NETADDRESS'};
1197 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1198 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1199 $a=$netsettings{'BLUE_NETADDRESS'};
1200 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1201 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1202 &General
::readhash
("$configovpn",\
%ovpnsettings);
1203 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1204 $b=&General
::iporsubtocidr
($b);
1206 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1207 &General
::readhasharray
("$confignet", \
%customnetwork);
1208 foreach my $key (keys %customnetwork){
1209 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1210 $a=$customnetwork{$key}[1];
1211 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1214 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1215 &General
::readhasharray
("$confighost", \
%customhost);
1216 foreach my $key (keys %customhost){
1217 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1218 if ($customhost{$key}[1] eq 'ip'){
1219 ($a,$b)=split (/\//,$customhost{$key}[2]);
1220 $b=&General
::iporsubtocidr
($b);
1222 if ($grp eq 'grp2'){
1223 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1235 &General
::setup_default_networks
(\
%defaultNetworks);
1236 foreach my $network (sort keys %defaultNetworks)
1238 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1243 my %hash=%{(shift)};
1245 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1246 $hash{$key}[10]=~ s/\|/,/g;
1247 print": $hash{$key}[10]";
1248 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1249 print": <br>$hash{$key}[9] ";
1254 my %hash=%{(shift)};
1258 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1259 if($hash{$key}[14] eq 'cust_srv'){
1260 &General
::readhasharray
("$configsrv", \
%customservice);
1261 foreach my $i (sort keys %customservice){
1262 if($customservice{$i}[0] eq $hash{$key}[15]){
1263 $service = $customservice{$i}[0];
1266 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1267 $service=$hash{$key}[15];
1268 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1269 $hash{$key}[15]=~ s/\|/,/g;
1270 $service=$hash{$key}[15];
1277 sub get_serviceports
1281 &General
::readhasharray
("$configsrv", \
%customservice);
1282 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1284 my @specprot=("IPIP","IPV6","IGMP","GRE","AH","ESP");
1285 if($type eq 'service'){
1286 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1287 if ($customservice{$key}[0] eq $name){
1288 push (@protocols,$customservice{$key}[2]);
1291 }elsif($type eq 'group'){
1292 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1293 if ($customservicegrp{$key}[0] eq $name){
1294 if ($customservicegrp{$key}[2] ~~ @specprot){
1295 push (@protocols," ".$customservicegrp{$key}[2]);
1297 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1298 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1299 if (!grep(/$customservice{$key1}[2]/, @protocols)){
1300 push (@protocols,$customservice{$key1}[2]);}
1308 # Sort protocols alphabetically.
1309 @protocols = sort(@protocols);
1318 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1319 # Don't colourise MAC addresses
1320 if (&General
::validmac
($val)) {
1326 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1327 foreach my $key (sort keys %$hash){
1328 if ($$hash{$key}[0] eq $val){
1329 $val=$$hash{$key}[2];
1334 if ($val eq 'GREEN'){
1335 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1337 }elsif ($val eq 'ORANGE'){
1338 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1340 }elsif ($val eq 'BLUE'){
1341 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1343 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1344 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1346 }elsif ($val eq 'IPFire' ){
1347 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1349 }elsif ($val eq 'OpenVPN-Dyn' ){
1350 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1352 }elsif ($val eq 'IPsec RW' ){
1353 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1355 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1356 my ($sip,$scidr) = split ("/",$val);
1357 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1358 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1361 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1362 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1365 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1366 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1369 }elsif ($val eq 'Default IP'){
1370 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1373 #Check if a manual IP or custom host is part of a VPN
1374 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1375 #Check if IP is part of OpenVPN dynamic subnet
1376 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1377 my ($c,$d) = split("/",$val);
1378 if (&General
::IpInSubnet
($c,$a,$b)){
1379 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1382 #Check if IP is part of OpenVPN static subnet
1383 foreach my $key (sort keys %ccdnet){
1384 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1385 $b =&General
::iporsubtodec
($b);
1386 if (&General
::IpInSubnet
($c,$a,$b)){
1387 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1391 #Check if IP is part of OpenVPN N2N subnet
1392 foreach my $key (sort keys %ccdhost){
1393 if ($ccdhost{$key}[3] eq 'net'){
1394 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1395 if (&General
::IpInSubnet
($c,$a,$b)){
1396 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1401 #Check if IP is part of IPsec RW network
1402 if ($ipsecsettings{'RW_NET'} ne ''){
1403 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1404 $b=&General
::iporsubtodec
($b);
1405 if (&General
::IpInSubnet
($c,$a,$b)){
1406 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1410 #Check if IP is part of a IPsec N2N network
1411 foreach my $key (sort keys %ipsecconf){
1412 if ($ipsecconf{$key}[11]){
1413 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1414 $b=&General
::iporsubtodec
($b);
1415 if (&General
::IpInSubnet
($c,$a,$b)){
1416 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1423 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'){
1424 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1427 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1428 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1432 foreach my $alias (sort keys %aliases)
1434 if ($val eq $alias){
1435 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1446 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1447 print "<class name='base'>$hint\n";
1448 print " </class>\n";
1449 &Header
::closebox
();
1455 &General
::setup_default_networks
(\
%defaultNetworks);
1456 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1457 #read all configfiles
1458 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1459 &General
::readhasharray
("$confignet", \
%customnetwork);
1460 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1461 &General
::readhasharray
("$confighost", \
%customhost);
1462 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1463 &General
::readhasharray
("$configgrp", \
%customgrp);
1464 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
1465 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1466 &General
::get_aliases
(\
%aliases);
1470 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1471 my $config=$fwdfwsettings{'config'};
1474 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1475 my $redip = <CONN1
>;
1477 if (! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE2'){
1478 $fwdfwsettings{'RULE_ACTION'}='DROP';
1479 }elsif(! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE1'){
1480 $fwdfwsettings{'RULE_ACTION'}='ACCEPT';
1482 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1483 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1484 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1485 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1486 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1487 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1488 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1489 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1490 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1491 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1492 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1493 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1494 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1495 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1496 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1497 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1498 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1499 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1500 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1501 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1502 #check if update and get values
1503 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1504 &General
::readhasharray
("$config", \
%hash);
1505 foreach my $key (sort keys %hash){
1507 if ($key eq $fwdfwsettings{'key'}){
1508 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1509 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1510 $fwdfwsettings{'chain'} = $hash{$key}[1];
1511 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1512 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1513 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1514 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1515 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1516 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1517 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1518 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1519 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1520 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1521 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1522 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1523 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1524 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1525 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1526 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1527 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1528 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1529 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1530 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1531 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1532 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1533 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1534 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1535 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1536 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1537 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1538 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1539 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1540 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1541 $fwdfwsettings{'LIMIT_CON_CON'} = $hash{$key}[32];
1542 $fwdfwsettings{'concon'} = $hash{$key}[33];
1543 $fwdfwsettings{'RATE_LIMIT'} = $hash{$key}[34];
1544 $fwdfwsettings{'ratecon'} = $hash{$key}[35];
1545 $fwdfwsettings{'RATETIME'} = $hash{$key}[36];
1546 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1547 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1548 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1549 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1550 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1551 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1552 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1553 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1554 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1555 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1556 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1557 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1558 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1559 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1560 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1561 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1562 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1563 $checked{'LIMIT_CON_CON'}{$fwdfwsettings{'LIMIT_CON_CON'}} = 'CHECKED';
1564 $checked{'RATE_LIMIT'}{$fwdfwsettings{'RATE_LIMIT'}} = 'CHECKED';
1565 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1566 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1567 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1568 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1569 $selected{'dnat'}{$fwdfwsettings{'dnat'}} ='selected';
1570 $selected{'snat'}{$fwdfwsettings{'snat'}} ='selected';
1571 $selected{'RATETIME'}{$fwdfwsettings{'RATETIME'}} ='selected';
1574 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1575 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1576 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1577 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1578 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1579 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1580 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1581 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1582 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1583 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1584 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1585 $fwdfwsettings{'olduseratelimit'}=$fwdfwsettings{'RATE_LIMIT'};
1586 $fwdfwsettings{'olduseratelimitamount'}=$fwdfwsettings{'ratecon'};
1587 $fwdfwsettings{'oldratelimittime'}=$fwdfwsettings{'RATETIME'};
1589 #check if manual ip (source) is orange network
1590 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1591 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1592 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1593 $fwdfwsettings{'oldorange'} ='on';
1597 $fwdfwsettings{'ACTIVE'}='ON';
1598 $fwdfwsettings{'nat'} = 'dnat';
1599 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1600 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1601 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1602 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1603 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1604 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1605 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1606 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1607 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1608 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1609 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1610 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1611 #check if manual ip (source) is orange network
1612 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1613 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1614 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1615 $fwdfwsettings{'oldorange'} ='on';
1619 # Split manual source and target address and delete the subnet
1620 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1621 if ($scidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp1'}}=$sip;}
1622 my ($dip,$dcidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp2'}});
1623 if ($dcidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp2'}}=$dip;}
1624 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1625 #------SOURCE-------------------------------------------------------
1626 print "<form method='post'>";
1628 <table width='100%' border='0'>
1629 <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>
1631 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1632 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1633 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1634 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1635 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1636 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1637 if (! -z
"${General::swroot}/ethernet/aliases"){
1638 foreach my $alias (sort keys %aliases)
1640 print "<option value='$alias' $selected{'ipfire_src'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1645 <tr><td><br></td></tr>
1648 &gen_dd_block
('src','grp1');
1649 &Header
::closebox
();
1651 #---SNAT / DNAT ------------------------------------------------
1652 &Header
::openbox
('100%', 'left', 'NAT');
1655 <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}>
1656 $Lang::tr{'fwdfw use nat'}
1659 <table class='fw-nat' width='100%' border='0'>
1661 <td width='5%'></td>
1664 <input type='radio' name='nat' value='dnat' $checked{'nat'}{'dnat'}>
1665 $Lang::tr{'fwdfw dnat'}
1671 <td width='25%' align='right'><span class='dnat'>$Lang::tr{'dnat address'}:</span></td>
1673 <select name='dnat' class='dnat' style='width: 100%;'>
1674 <option value='AUTO' $selected{'dnat'}{'AUTO'}>- $Lang::tr{'automatic'} -</option>
1675 <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'red1'} ($redip)</option>
1678 foreach my $alias (sort keys %aliases) {
1679 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1683 foreach my $network (sort keys %defaultNetworks)
1685 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1686 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1687 print " selected='selected'" if ($fwdfwsettings{'dnat'} eq $defaultNetworks{$network}{'NAME'});
1688 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1697 <td width='5%'></td>
1700 <input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}>
1701 $Lang::tr{'fwdfw snat'}
1704 <td width='25%' align='right'><span class='snat'>$Lang::tr{'snat new source ip address'}:</span></td>
1706 <select name='snat' class='snat' style='width: 100%;'>
1709 foreach my $alias (sort keys %aliases) {
1710 print "<option value='$alias' $selected{'snat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1713 foreach my $network (sort keys %defaultNetworks) {
1714 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1715 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1716 print " selected='selected'" if ($fwdfwsettings{'snat'} eq $defaultNetworks{$network}{'NAME'});
1717 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1727 &Header
::closebox
();
1729 #---TARGET------------------------------------------------------
1730 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1732 <table width='100%' border='0'>
1733 <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>
1735 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1736 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1737 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1738 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1739 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1740 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1741 if (! -z
"${General::swroot}/ethernet/aliases"){
1742 foreach my $alias (sort keys %aliases)
1744 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1749 <tr><td><br></td></tr></table>
1751 &gen_dd_block
('tgt','grp2');
1753 #---PROTOCOL------------------------------------------------------
1754 $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
1755 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1756 $fwdfwsettings{'dnatport'} =~ tr/|/,/;
1758 # The dnatport may be empty, if it matches TGT_PORT
1759 if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
1760 $fwdfwsettings{'dnatport'} = "";
1763 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1764 #Fix Protocol for JQuery
1765 if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
1766 $fwdfwsettings{'PROT'} = 'template';
1769 <table width='100%' border='0'>
1772 <select name='PROT' id='protocol' style="width: 95px;">
1774 print "<option value=\"\"";
1775 if ($fwdfwsettings{'PROT'} eq '') {
1776 print " selected=\"selected\"";
1778 print ">$Lang::tr{'all'}</option>";
1780 print "<option value=\"template\"";
1781 print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp');
1782 print ">- $Lang::tr{'template'} -</option>";
1784 foreach (@PROTOCOLS) {
1785 print"<option value=\"$_\"";
1786 if ($_ eq $fwdfwsettings{'PROT'}) {
1787 print " selected=\"selected\"";
1790 print ">$Lang::tr{'fwdfw prot41'}</option>";
1792 print ">$_</option>";
1800 <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES">
1802 <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
1804 <select name='ICMP_TYPES' style='min-width:230px;'>
1806 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1807 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1808 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1809 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1810 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1812 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1822 <table width="100%" border="0" id="PROTOCOL_PORTS">
1824 <!-- #SOURCEPORT -->
1826 $Lang::tr{'fwdfw use srcport'}
1829 <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
1834 <!-- #TARGETPORT -->
1836 $Lang::tr{'fwdfw use srv'}
1840 <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
1844 <td colspan='3'></td>
1845 <td>$Lang::tr{'fwdfw external port nat'}:</td>
1847 <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
1852 <table width="100%" border="0" id="PROTOCOL_TEMPLATE">
1855 <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
1856 $Lang::tr{'fwhost cust service'}
1859 <select name='cust_srv' style='min-width: 230px;'>
1862 &General
::readhasharray
("$configsrv", \
%customservice);
1863 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1865 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1866 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1875 <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
1876 $Lang::tr{'fwhost cust srvgrp'}
1879 <select name='cust_srvgrp' style='min-width:230px;'>
1882 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1884 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1885 if ($helper ne $customservicegrp{$key}[0] && $customservicegrp{$key}[2] ne 'none'){
1887 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1888 print">$customservicegrp{$key}[0]</option>";
1890 $helper=$customservicegrp{$key}[0];
1904 $checked{"RULE_ACTION"}{$fwdfwsettings{'RULE_ACTION'}} = 'CHECKED';
1907 <table width="80%" class='tbl' id='actions'>
1909 <td width="33%" align="center" bgcolor="$color{'color17'}">
1912 <td width="33%" align="center" bgcolor="$color{'color25'}">
1915 <td width="33%" align="center" bgcolor="$color{'color16'}">
1920 <td width="33%" align="center">
1922 <input type="radio" name="RULE_ACTION" value="ACCEPT" $checked{"RULE_ACTION"}{"ACCEPT"}>
1923 <strong>$Lang::tr{'fwdfw ACCEPT'}</strong>
1926 <td width="33%" align="center">
1928 <input type="radio" name="RULE_ACTION" value="DROP" $checked{"RULE_ACTION"}{"DROP"}>
1929 <strong>$Lang::tr{'fwdfw DROP'}</strong>
1932 <td width="33%" align="center">
1934 <input type="radio" name="RULE_ACTION" value="REJECT" $checked{"RULE_ACTION"}{"REJECT"}>
1935 <strong>$Lang::tr{'fwdfw REJECT'}</strong>
1944 #---Activate/logging/remark-------------------------------------
1945 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1947 <table width='100%' border='0'>
1949 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>";
1950 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1951 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1952 for (my $count =1; $count <= $sum; $count++){
1953 print"<option value='$count' ";
1954 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1955 print">$count</option>";
1957 print"</select></td></tr>";
1959 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1964 <table width='100%'>
1968 if ($fwdfwsettings{'updatefwrule'} eq 'on') {
1971 <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}>
1973 <td>$Lang::tr{'fwdfw rule activate'}</td>
1978 <input type="hidden" name="ACTIVE" value="ON">
1987 <input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'}>
1989 <td>$Lang::tr{'fwdfw log rule'}</td>
1993 <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}>
1995 <td>$Lang::tr{'fwdfw timeframe'}</td>
1997 <tr id="TIME_CONSTRAINTS">
1999 <table width="66%" border="0">
2001 <td width="8em"> </td>
2002 <td align="center">$Lang::tr{'advproxy monday'}</td>
2003 <td align="center">$Lang::tr{'advproxy tuesday'}</td>
2004 <td align="center">$Lang::tr{'advproxy wednesday'}</td>
2005 <td align="center">$Lang::tr{'advproxy thursday'}</td>
2006 <td align="center">$Lang::tr{'advproxy friday'}</td>
2007 <td align="center">$Lang::tr{'advproxy saturday'}</td>
2008 <td align="center">$Lang::tr{'advproxy sunday'}</td>
2012 <td width="8em"> </td>
2013 <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
2014 <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
2015 <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
2016 <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
2017 <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
2018 <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
2019 <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
2021 <select name='TIME_FROM'>
2023 for (my $i=0;$i<=23;$i++) {
2024 $i = sprintf("%02s",$i);
2025 for (my $j=0;$j<=45;$j+=15) {
2026 $j = sprintf("%02s",$j);
2027 my $time = $i.":".$j;
2028 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
2033 <select name='TIME_TO'>
2035 for (my $i=0;$i<=23;$i++) {
2036 $i = sprintf("%02s",$i);
2037 for (my $j=0;$j<=45;$j+=15) {
2038 $j = sprintf("%02s",$j);
2039 my $time = $i.":".$j;
2040 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
2052 <input type='checkbox' name='LIMIT_CON_CON' id="USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP" value='ON' $checked{'LIMIT_CON_CON'}{'ON'}>
2054 <td>$Lang::tr{'fwdfw limitconcon'}</td>
2058 <table width='66%' border='0'>
2060 <td width="20em"> </td>
2061 <td>$Lang::tr{'fwdfw maxconcon'}: <input type='text' name='concon' size='2' value="$fwdfwsettings{'concon'}"></td>
2068 <input type='checkbox' name='RATE_LIMIT' id="USE_RATELIMIT" value='ON' $checked{'RATE_LIMIT'}{'ON'}>
2070 <td>$Lang::tr{'fwdfw ratelimit'}</td>
2074 <table width='66%' border='0'>
2076 <td width="20em"> </td>
2077 <td>$Lang::tr{'fwdfw numcon'}: <input type='text' name='ratecon' size='2' value="$fwdfwsettings{'ratecon'}"> /
2078 <select name='RATETIME' style='width:100px;'>
2079 <option value='second' $selected{'RATETIME'}{'second'}>$Lang::tr{'age second'}</option>
2080 <option value='minute' $selected{'RATETIME'}{'minute'}>$Lang::tr{'minute'}</option>
2081 <option value='hour' $selected{'RATETIME'}{'hour'}>$Lang::tr{'hour'}</option>
2092 #---ACTION------------------------------------------------------
2093 if($fwdfwsettings{'updatefwrule'} ne 'on'){
2095 <table border='0' width='100%'>
2096 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
2097 <input type='hidden' name='config' value='$config' >
2098 <input type='hidden' name='ACTION' value='saverule' ></form>
2099 <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>
2105 <table border='0' width='100%'>
2106 <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'}'>
2107 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
2108 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
2109 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
2110 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
2111 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
2112 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
2113 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
2114 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
2115 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
2116 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
2117 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
2118 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
2119 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
2120 <input type='hidden' name='oldconcon' value='$fwdfwsettings{'oldconcon'}' />
2121 <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>
2125 &Header
::closebox
();
2131 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
2132 foreach my $key (sort keys %uphash){
2133 if ($key eq $fwdfwsettings{'key'}) {
2135 if (exists $uphash{$last}){
2137 foreach my $y (0 .. $#{$uphash{$last}}) {
2138 $tmp{0}[$y] = $uphash{$last}[$y];
2140 #copy active rule to last
2141 foreach my $i (0 .. $#{$uphash{$last}}) {
2142 $uphash{$last}[$i] = $uphash{$key}[$i];
2144 #copy saved rule to actual position
2145 foreach my $x (0 .. $#{$tmp{0}}) {
2146 $uphash{$key}[$x] = $tmp{0}[$x];
2151 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
2152 &General
::firewall_config_changed
();
2158 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
2159 foreach my $key (sort keys %downhash){
2160 if ($key eq $fwdfwsettings{'key'}) {
2161 my $next = $key + 1;
2162 if (exists $downhash{$next}){
2164 foreach my $y (0 .. $#{$downhash{$next}}) {
2165 $tmp{0}[$y] = $downhash{$next}[$y];
2167 #copy active rule to next
2168 foreach my $i (0 .. $#{$downhash{$next}}) {
2169 $downhash{$next}[$i] = $downhash{$key}[$i];
2171 #copy saved rule to actual position
2172 foreach my $x (0 .. $#{$tmp{0}}) {
2173 $downhash{$key}[$x] = $tmp{0}[$x];
2178 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
2179 &General
::firewall_config_changed
();
2185 &General
::readhasharray
("$config", $hash);
2186 if (!$errormessage){
2187 ################################################################
2188 #check if we change an INPUT rule to a OUTGOING
2189 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2190 &changerule
($configinput);
2193 #check if we change an INPUT rule to a FORWARD
2194 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2195 &changerule
($configinput);
2198 ################################################################
2199 #check if we change an OUTGOING rule to an INPUT
2200 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2201 &changerule
($configoutgoing);
2204 #check if we change an OUTGOING rule to a FORWARD
2205 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2206 &changerule
($configoutgoing);
2209 ################################################################
2210 #check if we change a FORWARD rule to an INPUT
2211 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2212 &changerule
($configfwdfw);
2215 #check if we change a FORWARD rule to an OUTGOING
2216 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2217 &changerule
($configfwdfw);
2220 $fwdfwsettings{'ruleremark'}=~ s/,/;/g;
2221 utf8
::decode
($fwdfwsettings{'ruleremark'});
2222 $fwdfwsettings{'ruleremark'}=&Header
::escape
($fwdfwsettings{'ruleremark'});
2223 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2224 my $key = &General
::findhasharraykey
($hash);
2225 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2226 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2227 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2228 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2229 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2230 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2231 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2232 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2233 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2234 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2235 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2236 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2237 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2238 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2239 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2240 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2241 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2242 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2243 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2244 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2245 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2246 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2247 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2248 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2249 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2250 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2251 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2252 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2253 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2254 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2255 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2256 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2257 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2258 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2259 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2260 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2261 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2262 &General
::writehasharray
("$config", $hash);
2264 foreach my $key (sort {$a <=> $b} keys %$hash){
2265 if($key eq $fwdfwsettings{'key'}){
2266 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2267 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2268 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2269 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2270 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2271 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2272 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2273 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2274 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2275 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2276 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2277 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2278 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2279 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2280 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2281 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2282 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2283 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2284 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2285 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2286 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2287 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2288 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2289 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2290 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2291 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2292 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2293 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2294 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2295 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2296 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2297 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2298 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2299 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2300 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2301 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2302 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2307 &General
::writehasharray
("$config", $hash);
2308 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2310 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2311 for (my $z=0;$z<$val;$z++){
2312 foreach my $key (sort {$a <=> $b} keys %$hash){
2313 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2315 if (exists $$hash{$last}){
2317 foreach my $y (0 .. $#{$$hash{$last}}) {
2318 $tmp{0}[$y] = $$hash{$last}[$y];
2320 #copy active rule to last
2321 foreach my $i (0 .. $#{$$hash{$last}}) {
2322 $$hash{$last}[$i] = $$hash{$key}[$i];
2324 #copy saved rule to actual position
2325 foreach my $x (0 .. $#{$tmp{0}}) {
2326 $$hash{$key}[$x] = $tmp{0}[$x];
2331 $fwdfwsettings{'oldrulenumber'}--;
2333 &General
::writehasharray
("$config", $hash);
2334 &General
::firewall_config_changed
();
2335 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2337 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2338 for (my $z=0;$z<$val;$z++){
2339 foreach my $key (sort {$a <=> $b} keys %$hash){
2340 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2341 my $next = $key + 1;
2342 if (exists $$hash{$next}){
2344 foreach my $y (0 .. $#{$$hash{$next}}) {
2345 $tmp{0}[$y] = $$hash{$next}[$y];
2347 #copy active rule to next
2348 foreach my $i (0 .. $#{$$hash{$next}}) {
2349 $$hash{$next}[$i] = $$hash{$key}[$i];
2351 #copy saved rule to actual position
2352 foreach my $x (0 .. $#{$tmp{0}}) {
2353 $$hash{$key}[$x] = $tmp{0}[$x];
2358 $fwdfwsettings{'oldrulenumber'}++;
2360 &General
::writehasharray
("$config", $hash);
2361 &General
::firewall_config_changed
();
2367 # Checks a hostname against RFC1035
2370 # Try to decode $remark into UTF-8. If this doesn't work,
2371 # we assume that the string it not sane.
2372 if (!utf8
::decode
($remark)) {
2376 # Check if the string only contains of printable characters.
2377 if ($remark =~ /^[[:print:]]*$/) {
2384 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2386 &viewtablenew
(\
%configfwdfw, $configfwdfw, $Lang::tr
{'firewall rules'});
2387 &viewtablenew
(\
%configinputfw, $configinput, $Lang::tr
{'incoming firewall access'});
2388 &viewtablenew
(\
%configoutgoingfw, $configoutgoing, $Lang::tr
{'outgoing firewall access'});
2397 my $show_box = (! -z
$config) || ($optionsfw{'SHOWTABLES'} eq 'on');
2398 return if (!$show_box);
2400 &General
::get_aliases
(\
%aliases);
2401 &General
::readhasharray
("$confighost", \
%customhost);
2402 &General
::readhasharray
("$config", $hash);
2403 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2404 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2405 &General
::readhasharray
("$configgrp", \
%customgrp);
2406 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2408 &Header
::openbox
('100%', 'left', $title);
2409 print "<table width='100%' cellspacing='0' class='tbl'>";
2423 <th align='right' width='3%'>
2426 <th width='2%'></th>
2428 <b>$Lang::tr{'protocol'}</b>
2430 <th align='center' width='30%'>
2431 <b>$Lang::tr{'fwdfw source'}</b>
2434 <b>$Lang::tr{'fwdfw log'}</b>
2436 <th align='center' width='30%'>
2437 <b>$Lang::tr{'fwdfw target'}</b>
2439 <th align='center' colspan='6' width='18%'>
2440 <b>$Lang::tr{'fwdfw action'}</b>
2445 foreach my $key (sort {$a <=> $b} keys %$hash){
2449 #check if vpn hosts/nets have been deleted
2450 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2451 push (@tmpsrc,$$hash{$key}[4]);
2453 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2454 push (@tmptgt,$$hash{$key}[6]);
2456 foreach my $host (@tmpsrc){
2457 if($$hash{$key}[3] eq 'ipsec_net_src'){
2458 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2461 }elsif($$hash{$key}[3] eq 'ovpn_net_src'){
2462 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2465 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src'){
2466 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2469 }elsif($$hash{$key}[3] eq 'ovpn_host_src'){
2470 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2475 foreach my $host (@tmptgt){
2476 if($$hash{$key}[5] eq 'ipsec_net_tgt'){
2477 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2480 }elsif($$hash{$key}[5] eq 'ovpn_net_tgt'){
2481 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2484 }elsif($$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2485 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2488 }elsif($$hash{$key}[5] eq 'ovpn_host_tgt'){
2489 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2494 #check if networkgroups or servicegroups are empty
2495 foreach my $netgroup (sort keys %customgrp){
2496 if(($$hash{$key}[4] eq $customgrp{$netgroup}[0] || $$hash{$key}[6] eq $customgrp{$netgroup}[0]) && $customgrp{$netgroup}[2] eq 'none'){
2500 foreach my $srvgroup (sort keys %customservicegrp){
2501 if($$hash{$key}[15] eq $customservicegrp{$srvgroup}[0] && $customservicegrp{$srvgroup}[2] eq 'none'){
2505 $$hash{'ACTIVE'}=$$hash{$key}[2];
2507 if($coloryellow eq 'on'){
2508 $color="$color{'color14'}";
2510 }elsif($coloryellow eq ''){
2512 $color="$color{'color22'}";
2515 $color="$color{'color20'}";
2519 <tr bgcolor='$color'>
2520 <td align='right' width='3%'>
2526 if ($$hash{$key}[0] eq 'ACCEPT'){
2529 $rulecolor=$color{'color17'};
2530 }elsif($$hash{$key}[0] eq 'DROP'){
2533 $rulecolor=$color{'color25'};
2534 }elsif($$hash{$key}[0] eq 'REJECT'){
2537 $rulecolor=$color{'color16'};
2541 <td bgcolor='$rulecolor' align='center' width='2%'>
2542 <span title='$tooltip'> </span>
2548 if ($$hash{$key}[8]){
2549 if ($$hash{$key}[8] eq "IPv6"){
2550 push (@protocols,$Lang::tr
{'fwdfw prot41 short'})
2552 push (@protocols,$$hash{$key}[8]);
2554 }elsif($$hash{$key}[14] eq 'cust_srv'){
2555 &get_serviceports
("service",$$hash{$key}[15]);
2556 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2557 &get_serviceports
("group",$$hash{$key}[15]);
2559 push (@protocols,$Lang::tr
{'all'});
2562 my $protz=join(", ",@protocols);
2563 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2564 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2565 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2566 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2567 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2571 }elsif($#protocols gt '3'){
2572 print"<td align='center'><span title='$protz'>$Lang::tr{'fwdfw many'}</span></td>";
2574 print"<td align='center'>$protz</td>";
2579 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2580 print"<td align='center' width='30%' $tdcolor>";
2581 if ($$hash{$key}[3] eq 'ipfire_src'){
2582 $ipfireiface=$Lang::tr
{'fwdfw iface'};
2584 if ($$hash{$key}[3] eq 'std_net_src'){
2585 print &get_name
($$hash{$key}[4]);
2586 }elsif ($$hash{$key}[3] eq 'src_addr'){
2587 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2588 if ($split2 eq '32'){
2591 print $$hash{$key}[4];
2593 }elsif ($$hash{$key}[3] eq 'cust_geoip_src') {
2594 my ($split1,$split2) = split(":", $$hash{$key}[4]);
2598 print "$Lang::tr{'geoip'}: $$hash{$key}[4]\n";
2600 }elsif ($$hash{$key}[4] eq 'RED1'){
2601 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2602 }elsif ($$hash{$key}[4] eq 'ALL'){
2603 print "$ipfireiface $Lang::tr{'all'}";
2605 if ($$hash{$key}[4] eq 'GREEN' || $$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE' || $$hash{$key}[4] eq 'RED'){
2606 print "$ipfireiface $Lang::tr{lc($$hash{$key}[4])}";
2608 print "$ipfireiface $$hash{$key}[4]";
2613 &getsrcport
(\
%$hash,$key);
2614 #Is this a SNAT rule?
2615 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2616 my $net=&get_name
($$hash{$key}[29]);
2617 if ( ! $net){ $net=$$hash{$key}[29];}
2619 if ($$hash{$key}[30] ne ''){
2620 print": $$hash{$key}[30]";
2623 if ($$hash{$key}[17] eq 'ON'){
2624 $log="/images/on.gif";
2626 $log="/images/off.gif";
2632 <form method='POST' action=''>
2633 <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 ;'/>
2634 <input type='hidden' name='key' value='$key' />
2635 <input type='hidden' name='config' value='$config' />
2636 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2641 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2643 <td align='center' $tdcolor>
2645 #Is this a DNAT rule?
2647 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2648 if ($$hash{$key}[29] eq 'Default IP'){$$hash{$key}[29]=$Lang::tr
{'red1'};}
2649 if ($$hash{$key}[29] eq 'AUTO'){
2650 my @src_addresses=&fwlib
::get_addresses
(\
%$hash,$key,'src');
2652 foreach my $val (@src_addresses){
2653 push (@nat_ifaces,&fwlib
::get_nat_address
($$hash{$key}[29],$val));
2655 @nat_ifaces=&del_double
(@nat_ifaces);
2658 $natstring = "($$hash{$key}[29])";
2660 print "$Lang::tr{'firewall'} $natstring";
2661 if($$hash{$key}[30] ne ''){
2662 $$hash{$key}[30]=~ tr/|/,/;
2663 print": $$hash{$key}[30]";
2667 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire'){
2668 if ($$hash{$key}[6] eq 'RED1'){
2669 print "$Lang::tr{'red1'}";
2670 }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')
2672 print &get_name
($$hash{$key}[6]);
2674 print $$hash{$key}[6];
2676 }elsif ($$hash{$key}[5] eq 'cust_geoip_tgt') {
2677 my ($split1,$split2) = split(":", $$hash{$key}[6]);
2681 print "$Lang::tr{'geoip'}: $$hash{$key}[6]\n";
2683 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2684 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2685 if ($split2 eq '32'){
2688 print $$hash{$key}[6];
2691 print "$$hash{$key}[6]";
2695 &gettgtport
(\
%$hash,$key);
2698 if($$hash{$key}[2] eq 'ON'){
2699 $gif="/images/on.gif"
2701 $gif="/images/off.gif"
2704 <td width='3%' align='center'>
2705 <form method='POST' action=''>
2706 <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;' />
2707 <input type='hidden' name='key' value='$key' />
2708 <input type='hidden' name='config' value='$config' />
2709 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2712 <td width='3%' align='center'>
2713 <form method='POST' action=''>
2714 <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;' />
2715 <input type='hidden' name='key' value='$key' />
2716 <input type='hidden' name='config' value='$config' />
2717 <input type='hidden' name='ACTION' value='editrule' />
2720 <td width='3%' align='center'>
2721 <form method='POST' action=''>
2722 <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;' />
2723 <input type='hidden' name='key' value='$key' />
2724 <input type='hidden' name='config' value='$config' />
2725 <input type='hidden' name='ACTION' value='copyrule' />
2728 <td width='3%' align='center'>
2729 <form method='POST' action=''>
2730 <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;' />
2731 <input type='hidden' name='key' value='$key' />
2732 <input type='hidden' name='config' value='$config' />
2733 <input type='hidden' name='ACTION' value='deleterule' />
2737 if (exists $$hash{$key-1}){
2739 <td width='3%' align='center'>
2740 <form method='POST' action=''>
2741 <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;' />
2742 <input type='hidden' name='key' value='$key' />
2743 <input type='hidden' name='config' value='$config' />
2744 <input type='hidden' name='ACTION' value='moveup' />
2749 print"<td width='3%'></td>";
2752 if (exists $$hash{$key+1}){
2754 <td width='3%' align='center'>
2755 <form method='POST' action=''>
2756 <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;' />
2757 <input type='hidden' name='key' value='$key' />
2758 <input type='hidden' name='config' value='$config' />
2759 <input type='hidden' name='ACTION' value='movedown' />
2765 print"<td width='3%'></td></tr>";
2768 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2770 <tr bgcolor='$color'>
2772 <td bgcolor='$rulecolor'></td>
2774 <em>$$hash{$key}[16]</em>
2780 if ($$hash{$key}[18] eq 'ON'){
2782 if ($$hash{$key}[18] eq 'ON'){
2784 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2785 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2786 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2787 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2788 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2789 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2790 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2791 my $weekdays=join(",",@days);
2793 print"<tr bgcolor='$color'>";
2794 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27]</td></tr>";
2798 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2800 } elsif ($optionsfw{'SHOWTABLES'} eq 'on') {
2803 <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td>
2809 my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'};
2810 my $colour = "bgcolor='green'";
2811 if ($fwdfwsettings{'POLICY'} eq 'MODE1') {
2812 $colour = "bgcolor='darkred'";
2816 if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) {
2819 <td colspan='13'> </td>
2822 <td colspan='13' style="padding-left:0px;padding-right:0px">
2823 <table width="100%" border='1' rules="cols" cellspacing='0'>
2830 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2833 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2834 ($Lang::tr{'fwdfw pol allow'})
2838 if (&Header
::orange_used
()) {
2841 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2842 ($Lang::tr{'fwdfw pol allow'})
2847 if (&Header
::blue_used
()) {
2850 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2851 ($Lang::tr{'fwdfw pol allow'})
2859 if (&Header
::orange_used
()) {
2862 <td align='center' width='20%'>
2863 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2866 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2867 ($Lang::tr{'fwdfw pol allow'})
2870 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2871 ($Lang::tr{'fwdfw pol block'})
2875 if (&Header
::blue_used
()) {
2878 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2879 ($Lang::tr{'fwdfw pol block'})
2887 if (&Header
::blue_used
()) {
2891 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2894 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2895 ($Lang::tr{'fwdfw pol allow'})
2899 if (&Header
::orange_used
()) {
2902 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2903 ($Lang::tr{'fwdfw pol block'})
2910 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2911 ($Lang::tr{'fwdfw pol block'})
2923 $message = $Lang::tr
{'fwdfw pol allow'};
2925 } elsif ($config eq '/var/ipfire/firewall/outgoing' && ($fwdfwsettings{'POLICY1'} ne 'MODE1')) {
2926 $message = $Lang::tr
{'fwdfw pol allow'};
2927 $colour = "bgcolor='green'";
2929 $message = $Lang::tr
{'fwdfw pol block'};
2930 $colour = "bgcolor='darkred'";
2936 <td $colour align='center' colspan='13'>
2937 <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font>
2946 &Header
::closebox
();
2949 &Header
::closebigbox
();
2950 &Header
::closepage
();