]>
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 '/var/ipfire/network-functions.pl';
35 require "${General::swroot}/lang.pl";
36 require "${General::swroot}/header.pl";
37 require "${General::swroot}/geoip-functions.pl";
38 require "/usr/lib/firewall/firewall-lib.pl";
40 unless (-d
"${General::swroot}/firewall") { system("mkdir ${General::swroot}/firewall"); }
41 unless (-e
"${General::swroot}/firewall/settings") { system("touch ${General::swroot}/firewall/settings"); }
42 unless (-e
"${General::swroot}/firewall/config") { system("touch ${General::swroot}/firewall/config"); }
43 unless (-e
"${General::swroot}/firewall/input") { system("touch ${General::swroot}/firewall/input"); }
44 unless (-e
"${General::swroot}/firewall/outgoing") { system("touch ${General::swroot}/firewall/outgoing"); }
48 my %defaultNetworks=();
52 my %customgeoipgrp=();
53 my %customnetworks=();
55 my %customservicegrp=();
61 my %configoutgoingfw=();
74 my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE","IPv6","IPIP");
77 my $confignet = "${General::swroot}/fwhosts/customnetworks";
78 my $confighost = "${General::swroot}/fwhosts/customhosts";
79 my $configgrp = "${General::swroot}/fwhosts/customgroups";
80 my $configgeoipgrp = "${General::swroot}/fwhosts/customgeoipgrp";
81 my $configsrv = "${General::swroot}/fwhosts/customservices";
82 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
83 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
84 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
85 my $configipsec = "${General::swroot}/vpn/config";
86 my $configipsecrw = "${General::swroot}/vpn/settings";
87 my $configfwdfw = "${General::swroot}/firewall/config";
88 my $configinput = "${General::swroot}/firewall/input";
89 my $configoutgoing = "${General::swroot}/firewall/outgoing";
90 my $configovpn = "${General::swroot}/ovpn/settings";
91 my $fwoptions = "${General::swroot}/optionsfw/settings";
92 my $ifacesettings = "${General::swroot}/ethernet/settings";
95 my $ipgrp="${General::swroot}/outgoing/groups";
99 &General
::readhash
("${General::swroot}/firewall/settings", \
%fwdfwsettings);
100 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
101 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
102 &General
::readhash
($fwoptions, \
%optionsfw);
103 &General
::readhash
($ifacesettings, \
%ifaces);
104 &General
::readhash
("$configovpn", \
%ovpnsettings);
105 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
106 &General
::readhasharray
("$configipsec", \
%ipsecconf);
107 &Header
::showhttpheaders
();
108 &Header
::getcgihash
(\
%fwdfwsettings);
109 &Header
::openpage
($Lang::tr
{'firewall rules'}, 1, '');
110 &Header
::openbigbox
('100%', 'center',$errormessage);
111 #### JAVA SCRIPT ####
114 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
116 var update_protocol = function() {
117 var protocol = \$("#protocol").val();
119 if (protocol === undefined)
122 // Check if a template is/should be used.
123 if (protocol === "template") {
124 \$("#PROTOCOL_TEMPLATE").show();
126 \$("#PROTOCOL_TEMPLATE").hide();
129 // Check if we are dealing with a protocol, that knows ports.
130 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
131 \$("#PROTOCOL_PORTS").show();
133 \$("#PROTOCOL_PORTS").hide();
137 if (protocol === "ICMP") {
138 \$("#PROTOCOL_ICMP_TYPES").show();
140 \$("#PROTOCOL_ICMP_TYPES").hide();
144 \$(document).ready(function() {
145 \$("#protocol").change(update_protocol);
148 // Show/Hide elements when NAT checkbox is checked.
149 if (\$("#USE_NAT").attr("checked")) {
150 \$("#actions").hide();
155 // Show NAT area when "use nat" checkbox is clicked
156 \$("#USE_NAT").change(function() {
158 \$("#actions").toggle();
161 // Hide SNAT items when DNAT is selected and vice versa.
162 if (\$('input[name=nat]:checked').val() == 'dnat') {
168 // Show/Hide elements when SNAT/DNAT get changed.
169 \$('input[name=nat]').change(function() {
170 \$('.snat').toggle();
171 \$('.dnat').toggle();
175 if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) {
176 \$("#TIME_CONSTRAINTS").hide();
178 \$("#USE_TIME_CONSTRAINTS").change(function() {
179 \$("#TIME_CONSTRAINTS").toggle();
182 // Limit concurrent connections per ip
183 if(!\$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").attr("checked")) {
184 \$("#LIMIT_CON").hide();
186 \$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").change(function() {
187 \$("#LIMIT_CON").toggle();
190 // Rate-limit new connections
191 if(!\$("#USE_RATELIMIT").attr("checked")) {
192 \$("#RATELIMIT").hide();
194 \$("#USE_RATELIMIT").change(function() {
195 \$("#RATELIMIT").toggle();
198 // Automatically select radio buttons when corresponding
199 // dropdown menu changes.
200 \$("select").change(function() {
201 var id = \$(this).attr("name");
202 \$('#' + id).prop("checked", true);
210 if ($fwdfwsettings{'ACTION'} eq 'saverule')
212 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
213 &General
::readhasharray
("$configinput", \
%configinputfw);
214 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
216 #Set Variables according to the JQuery code in protocol section
217 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')
219 if ($fwdfwsettings{'SRC_PORT'} ne '')
221 $fwdfwsettings{'USE_SRC_PORT'} = 'ON';
223 if ($fwdfwsettings{'TGT_PORT'} ne '')
225 $fwdfwsettings{'USESRV'} = 'ON';
226 $fwdfwsettings{'grp3'} = 'TGT_PORT';
229 if ($fwdfwsettings{'PROT'} eq 'template')
231 $fwdfwsettings{'USESRV'} = 'ON';
233 $errormessage=&checksource
;
234 if(!$errormessage){&checktarget
;}
235 if(!$errormessage){&checkrule
;}
237 #check if manual ip (source) is orange network
238 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
239 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
240 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
245 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
246 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
248 #check if we try to break rules
249 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
250 $errormessage=$Lang::tr
{'fwdfw err same'};
253 if ($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
254 $fwdfwsettings{'config'}=$configinput;
255 $fwdfwsettings{'chain'} = 'INPUTFW';
256 $maxkey=&General
::findhasharraykey
(\
%configinputfw);
257 %rulehash=%configinputfw;
258 }elsif ($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
260 $fwdfwsettings{'config'}=$configoutgoing;
261 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
262 $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
263 %rulehash=%configoutgoingfw;
266 $fwdfwsettings{'config'}=$configfwdfw;
267 $fwdfwsettings{'chain'} = 'FORWARDFW';
268 $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
269 %rulehash=%configfwdfw;
271 #check if we have an identical rule already
272 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
273 foreach my $key (sort keys %rulehash){
274 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'}"
275 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]"){
276 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
277 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
278 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
280 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
283 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
284 $fwdfwsettings{'nosave'} = 'on';
289 #check Rulepos on new Rule
290 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
291 $fwdfwsettings{'oldrulenumber'}=$maxkey;
292 foreach my $key (sort keys %rulehash){
293 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'}"
294 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]"){
295 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
299 #check if we just close a rule
300 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'}){
301 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
302 $fwdfwsettings{'nosave2'} = 'on';
306 #check max concurrent connections per ip address
307 if ($fwdfwsettings{'LIMIT_CON_CON'} eq 'ON'){
308 if (!($fwdfwsettings{'concon'} =~ /^(\d+)$/)) {
309 $errormessage.=$Lang::tr
{'fwdfw err concon'};
312 $fwdfwsettings{'concon'}='';
314 #check ratelimit value
315 if ($fwdfwsettings{'RATE_LIMIT'} eq 'ON'){
316 if (!($fwdfwsettings{'ratecon'} =~ /^(\d+)$/)) {
317 $errormessage.=$Lang::tr
{'fwdfw err ratecon'};
320 $fwdfwsettings{'ratecon'}='';
324 if ($fwdfwsettings{'nosave2'} ne 'on'){
325 &saverule
(\
%rulehash,$fwdfwsettings{'config'});
331 if($fwdfwsettings{'nosave2'} ne 'on'){
332 &General
::firewall_config_changed
();
337 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
341 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
344 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
345 foreach my $key (sort keys %togglehash){
346 if ($key eq $fwdfwsettings{'key'}){
347 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
350 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
351 &General
::firewall_config_changed
();
354 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
357 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
358 foreach my $key (sort keys %togglehash){
359 if ($key eq $fwdfwsettings{'key'}){
360 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
363 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
364 &General
::firewall_config_changed
();
367 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
369 &General
::firewall_reload
();
372 if ($fwdfwsettings{'ACTION'} eq 'editrule')
374 $fwdfwsettings{'updatefwrule'}='on';
377 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
381 if ($fwdfwsettings{'ACTION'} eq 'moveup')
386 if ($fwdfwsettings{'ACTION'} eq 'movedown')
391 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
393 $fwdfwsettings{'copyfwrule'}='on';
396 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
405 &Header
::openbox
('100%', 'left', "");
407 <form method="POST" action="">
408 <table border='0' width="100%">
411 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'>
414 if (&General
::firewall_needs_reload
()) {
416 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'>
440 $fwdfwsettings{'updatefwrule'}='';
441 $fwdfwsettings{'config'}=$oldchain;
442 $fwdfwsettings{'nobase'}='on';
448 #check ip-address if manual
449 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
450 #check if ip with subnet
451 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
452 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
453 $subnet = &General
::iporsubtocidr
($subnet);
454 $fwdfwsettings{'isip'}='on';
457 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
458 $ip=$fwdfwsettings{'src_addr'};
460 $fwdfwsettings{'isip'}='on';
463 if ($fwdfwsettings{'isip'} ne 'on'){
464 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
465 $fwdfwsettings{'ismac'}='on';
468 if ($fwdfwsettings{'isip'} eq 'on'){
470 $ip = &Network
::ip_remove_zero
($ip);
472 ##check if ip is valid
473 if (! &General
::validip
($ip)){
474 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
475 return $errormessage;
477 #check and form valid IP
478 $ip=&General
::ip2dec
($ip);
479 $ip=&General
::dec2ip
($ip);
480 #check if net or broadcast
481 $fwdfwsettings{'src_addr'}="$ip/$subnet";
482 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
483 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
484 return $errormessage;
487 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
488 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
489 return $errormessage;
491 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
492 $fwdfwsettings{'grp1'}='std_net_src';
493 $fwdfwsettings{$fwdfwsettings{'grp1'}} = 'ALL';
497 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
498 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
499 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
503 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
505 #change dashes with :
508 push(@values,"1:65535");
511 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
512 push(@values,"1:$2");
515 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
516 push(@values,"$1:65535");
519 $errormessage .= &General
::validportrange
($_, 'destination');
524 if (&General
::validport
($_)){
531 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
533 return $errormessage;
538 &General
::readhasharray
("$configsrv", \
%customservice);
539 #check DNAT settings (has to be single Host and single Port or portrange)
540 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
541 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
542 #check if Port is a single Port or portrange
543 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
544 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
545 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
546 return $errormessage;
548 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
549 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
550 return $errormessage;
554 if ($fwdfwsettings{'grp2'} ne 'ipfire'){
555 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
556 return $errormessage;
560 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
561 #check if ip with subnet
562 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
563 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
564 $subnet = &General
::iporsubtocidr
($subnet);
568 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
569 $ip=$fwdfwsettings{'tgt_addr'};
573 $ip = &Network
::ip_remove_zero
($ip);
575 #check if ip is valid
576 if (! &General
::validip
($ip)){
577 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
578 return $errormessage;
580 #check and form valid IP
581 $ip=&General
::ip2dec
($ip);
582 $ip=&General
::dec2ip
($ip);
583 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
584 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
585 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
586 return $errormessage;
588 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
589 $fwdfwsettings{'grp2'}='std_net_tgt';
590 $fwdfwsettings{$fwdfwsettings{'grp2'}} = 'ALL';
592 #check for mac in targetgroup
593 if ($fwdfwsettings{'grp2'} eq 'cust_grp_tgt'){
594 &General
::readhasharray
("$configgrp", \
%customgrp);
595 &General
::readhasharray
("$confighost", \
%customhost);
596 foreach my $grpkey (sort keys %customgrp){
597 foreach my $hostkey (sort keys %customhost){
598 if ($customgrp{$grpkey}[2] eq $customhost{$hostkey}[0] && $customgrp{$grpkey}[2] eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $customhost{$hostkey}[1] eq 'mac'){
599 $hint=$Lang::tr
{'fwdfw hint mac'};
606 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
608 if ($fwdfwsettings{'USESRV'} eq 'ON'){
609 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
610 $fwdfwsettings{'TGT_PROT'}='';
611 $fwdfwsettings{'ICMP_TGT'}='';
612 $fwdfwsettings{'TGT_PORT'}='';
614 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
615 $fwdfwsettings{'TGT_PROT'}='';
616 $fwdfwsettings{'ICMP_TGT'}='';
617 $fwdfwsettings{'TGT_PORT'}='';
618 #check target service
619 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
620 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
623 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
624 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
625 if ($fwdfwsettings{'TGT_PORT'} ne ''){
626 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
627 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
628 return $errormessage;
630 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
634 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
636 #change dashes with :
639 push(@values,"1:65535");
642 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
643 push(@values,"1:$2");
646 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
647 push(@values,"$1:65535");
650 $errormessage .= &General
::validportrange
($_, 'destination');
655 if (&General
::validport
($_)){
658 $errormessage=$Lang::tr
{'fwdfw err tgt_port'};
659 return $errormessage;
663 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
665 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
666 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
667 $fwdfwsettings{'TGT_PORT'} = '';
668 $fwdfwsettings{'ICMP_TGT'} = '';
669 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
670 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
671 $fwdfwsettings{'TGT_PORT'} = '';
672 $fwdfwsettings{'ICMP_TGT'}='';
673 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
674 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
675 $fwdfwsettings{'TGT_PORT'} = '';
676 $fwdfwsettings{'ICMP_TGT'}='';
677 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
678 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
679 $fwdfwsettings{'TGT_PORT'} = '';
684 if ($fwdfwsettings{'USESRV'} ne 'ON'){
685 $fwdfwsettings{'grp3'}='';
686 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
687 $fwdfwsettings{'ICMP_TGT'}='';
690 if($fwdfwsettings{'TIME'} eq 'ON'){
691 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 ''){
692 $errormessage=$Lang::tr
{'fwdfw err time'};
693 return $errormessage;
696 return $errormessage;
701 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
702 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
703 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
704 if ($fwdfwsettings{'dnatport'} eq "*") {
705 $fwdfwsettings{'dnatport'}="1:65535";
707 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
708 $fwdfwsettings{'dnatport'} = "1:$2";
710 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
711 $fwdfwsettings{'dnatport'} ="$1:65535";
716 if ($val =~ "," || $val>65536 || $val<0){
723 #check valid port for NAT
724 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
725 #RULE_ACTION must be ACCEPT if we use NAT
726 $fwdfwsettings{'RULE_ACTION'} = 'ACCEPT';
728 #if no dnat or snat selected errormessage
729 if ($fwdfwsettings{'nat'} eq ''){
730 $errormessage=$Lang::tr
{'fwdfw dnat nochoice'};
734 #if using snat, the external port has to be empty
735 if ($fwdfwsettings{'nat'} eq 'snat' && $fwdfwsettings{'dnatport'} ne ''){
736 $errormessage=$Lang::tr
{'fwdfw dnat extport'};
739 #if no dest port is given in nat area, take target host port
740 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
741 if($fwdfwsettings{'TGT_PORT'} eq '' && $fwdfwsettings{'dnatport'} ne '' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')){
742 $errormessage=$Lang::tr
{'fwdfw dnat porterr2'};
745 #check if port given in nat area is a single valid port or portrange
746 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
747 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
748 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
750 #get service Protocol and Port
751 foreach my $key (sort keys %customservice){
752 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
753 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
754 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
756 $custsrvport= $customservice{$key}[1];
759 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
761 #check if DNAT port is multiple
762 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
763 my @parts=split(",",$fwdfwsettings{'dnatport'});
767 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
769 #change dashes with :
772 push(@values,"1:65535");
775 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
776 push(@values,"1:$2");
779 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
780 push(@values,"$1:65535");
783 $errormessage .= &General
::validportrange
($_, 'destination');
788 if (&General
::validport
($_)){
795 $fwdfwsettings{'dnatport'}=join("|",@values);
797 #check if a rule with prot tcp or udp and ports is edited and now prot is "all", then delete all ports
798 if($fwdfwsettings{'PROT'} eq ''){
799 $fwdfwsettings{'dnatport'}='';
803 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
804 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
806 #check if source and target identical
807 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL' && $fwdfwsettings{'grp2'} ne 'ipfire'){
808 $errormessage=$Lang::tr
{'fwdfw err same'};
809 return $errormessage;
811 #get source and targetip address if possible
812 my ($sip,$scidr,$tip,$tcidr);
813 ($sip,$scidr)=&get_ip
("src","grp1");
814 ($tip,$tcidr)=&get_ip
("tgt","grp2");
815 #check same iprange in source and target
816 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
817 my $networkip1=&General
::getnetworkip
($sip,$scidr);
818 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
819 if ($scidr gt $tcidr){
820 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
821 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
823 }elsif($scidr eq $tcidr && $scidr eq '32'){
824 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
825 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
826 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
827 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
828 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
831 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
832 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
836 #when icmp selected, no source and targetport allowed
837 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')){
838 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
841 #change protocol if prot not equal dest single service
842 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
843 foreach my $key (sort keys %customservice){
844 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
845 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
846 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
852 #check source and destination protocol if source manual and dest servicegroup
853 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
854 $fwdfwsettings{'PROT'} = '';
856 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
857 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
859 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
860 $fwdfwsettings{'USE_SRC_PORT'}='';
861 $fwdfwsettings{'SRC_PORT'}='';
862 #$fwdfwsettings{'USESRV'}='';
863 $fwdfwsettings{'TGT_PORT'}='';
864 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
865 foreach my $key (keys %icmptypes){
866 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
867 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
870 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
871 $fwdfwsettings{'USE_SRC_PORT'}='';
872 $fwdfwsettings{'SRC_PORT'}='';
873 $fwdfwsettings{'ICMP_TYPES'}='';
874 $fwdfwsettings{'USESRV'}='';
875 $fwdfwsettings{'TGT_PORT'}='';
876 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
877 $fwdfwsettings{'USE_SRC_PORT'}='';
878 $fwdfwsettings{'SRC_PORT'}='';
879 $fwdfwsettings{'ICMP_TYPES'}='';
880 $fwdfwsettings{'USESRV'}='';
881 $fwdfwsettings{'TGT_PORT'}='';
882 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
883 $fwdfwsettings{'USE_SRC_PORT'}='';
884 $fwdfwsettings{'SRC_PORT'}='';
885 $fwdfwsettings{'ICMP_TYPES'}='';
886 $fwdfwsettings{'USESRV'}='';
887 $fwdfwsettings{'TGT_PORT'}='';
888 }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){
889 $fwdfwsettings{'USE_SRC_PORT'}='';
890 $fwdfwsettings{'SRC_PORT'}='';
891 $fwdfwsettings{'ICMP_TYPES'}='';
892 $fwdfwsettings{'USESRV'}='';
893 $fwdfwsettings{'TGT_PORT'}='';
894 }elsif($fwdfwsettings{'PROT'} eq 'IPv6'){
895 $fwdfwsettings{'USE_SRC_PORT'}='';
896 $fwdfwsettings{'SRC_PORT'}='';
897 $fwdfwsettings{'ICMP_TYPES'}='';
898 $fwdfwsettings{'USESRV'}='';
899 $fwdfwsettings{'TGT_PORT'}='';
900 }elsif($fwdfwsettings{'PROT'} eq 'IPIP'){
901 $fwdfwsettings{'USE_SRC_PORT'}='';
902 $fwdfwsettings{'SRC_PORT'}='';
903 $fwdfwsettings{'ICMP_TYPES'}='';
904 $fwdfwsettings{'USESRV'}='';
905 $fwdfwsettings{'TGT_PORT'}='';
906 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP'){
907 $fwdfwsettings{'ICMP_TYPES'}='';
908 $fwdfwsettings{'SRC_PORT'}='';
909 $fwdfwsettings{'TGT_PORT'}='';
910 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
911 $fwdfwsettings{'ICMP_TYPES'}='';
917 #Test if manual IP is part of static OpenVPN networks
918 &General
::readhasharray
("$configccdnet", \
%ccdnet);
919 foreach my $key (sort keys %ccdnet){
920 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
921 my $sub=&General
::iporsubtodec
($vpnsubnet);
922 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
926 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
927 # because if one creates a custom host with the ip, we need to check the color there!
928 # It does not make sense to check this here
930 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
931 # Is also checked in getcolor
933 # Test if manual ip is part of an IPsec Network is also checked in getcolor
943 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
944 foreach my $key (sort {$a <=> $b} keys %delhash){
945 if ($key >= $fwdfwsettings{'key'}) {
947 if (exists $delhash{$next}) {
948 foreach my $i (0 .. $#{$delhash{$next}}) {
949 $delhash{$key}[$i] = $delhash{$next}[$i];
954 # Remove the very last entry.
955 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
956 delete $delhash{$last_key};
958 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
959 &General
::firewall_config_changed
();
961 if($fwdfwsettings{'nobase'} ne 'on'){
974 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
975 foreach my $key (sort keys %configfwdfw){
977 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
980 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
981 &General
::firewall_config_changed
();
986 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
987 print "<class name='base'>$errormessage\n";
988 print " </class>\n";
997 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
998 if($hash{$key}[0] eq $val){
999 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1001 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1011 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1012 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1013 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1014 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1015 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1016 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1017 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1018 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1019 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1020 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1021 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1022 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1023 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1024 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1025 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1026 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1027 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1028 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1029 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1031 <table width='100%' border='0'>
1032 <tr><td width='50%' valign='top'>
1033 <table width='95%' border='0'>
1034 <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;'>
1036 foreach my $network (sort keys %defaultNetworks)
1038 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1039 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1040 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1041 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1042 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1043 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1044 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1045 if ($ifaces{$defnet}){
1046 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1048 print ">$network</option>";
1051 print"</select></td></tr>";
1053 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1054 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;'>";
1055 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1056 print"</select></td>";
1059 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1060 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;'>";
1061 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1062 print"</select></td>";
1065 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1066 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;'>";
1067 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1068 if($helper ne $customgrp{$key}[0] && $customgrp{$key}[2] ne 'none'){
1070 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1071 print ">$customgrp{$key}[0]</option>";
1073 $helper=$customgrp{$key}[0];
1075 print"</select></td>";
1077 # geoip locations / groups.
1078 my @geoip_locations = &fwlib
::get_geoip_locations
();
1081 print "<td valign='top'><input type='radio' name='$grp' id='cust_geoip_$srctgt' value='cust_geoip_$srctgt' $checked{$grp}{'cust_geoip_'.$srctgt}></td>\n";
1082 print "<td>$Lang::tr{'geoip'}</td>\n";
1083 print "<td align='right'><select name='cust_geoip_$srctgt' style='width:200px;'>\n";
1085 # Add GeoIP groups to dropdown.
1086 if (!-z
$configgeoipgrp) {
1087 print "<optgroup label='$Lang::tr{'fwhost cust geoipgroup'}'>\n";
1088 foreach my $key (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) } keys %customgeoipgrp) {
1091 # Generate stored value for select detection.
1092 my $stored = join(':', "group",$customgeoipgrp{$key}[0]);
1094 # Only show a group once and group with elements.
1095 if($helper ne $customgeoipgrp{$key}[0] && $customgeoipgrp{$key}[2] ne 'none') {
1096 # Mark current entry as selected.
1097 if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $stored) {
1098 $selected = "selected='selected'";
1100 print"<option $selected value='group:$customgeoipgrp{$key}[0]'>$customgeoipgrp{$key}[0]</option>\n";
1102 $helper=$customgeoipgrp{$key}[0];
1104 print "</optgroup>\n";
1108 print "<optgroup label='$Lang::tr{'fwhost cust geoiplocation'}'>\n";
1109 foreach my $location (@geoip_locations) {
1111 my $country_name = &GeoIP
::get_full_country_name
($location);
1113 # Mark current entry as selected.
1115 if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $location) {
1116 $selected = "selected='selected'";
1118 print "<option $selected value='$location'>$location - $country_name</option>\n";
1120 print "</optgroup>\n";
1122 # Close GeoIP dropdown.
1123 print "</select></td>\n";
1125 #End left table. start right table (vpn)
1126 print"</tr></table></td><td valign='top'><table width='95%' border='0' align='right'><tr>";
1128 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1129 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;'>";
1130 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1131 print"</select></td></tr>";
1134 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1135 if ($ccdhost{$key}[33] ne '' ){
1136 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 '');
1138 print "<option value='$ccdhost{$key}[1]'";
1139 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1140 print ">$ccdhost{$key}[1]</option>";
1143 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1144 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>" ;
1146 if ($show eq '1'){$show='';print"</select></td></tr>";}
1148 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1149 if ($ccdhost{$key}[3] eq 'net'){
1150 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 '');
1152 print "<option value='$ccdhost{$key}[1]'";
1153 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1154 print ">$ccdhost{$key}[1]</option>";
1157 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1158 print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_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>" ;
1160 if ($show eq '1'){$show='';print"</select></td></tr>";}
1162 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1163 if ($ipsecconf{$key}[3] eq 'net' || ($optionsfw{'SHOWDROPDOWN'} eq 'on' && $ipsecconf{$key}[3] ne 'host')){
1164 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;'>" if ($show eq '');
1167 #Check if we have more than one REMOTE subnet in config
1168 my @arr1 = split /\|/, $ipsecconf{$key}[11];
1172 print "value=$ipsecconf{$key}[1]";
1173 print " selected " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq "$ipsecconf{$key}[1]");
1174 print ">$ipsecconf{$key}[1] ";
1175 print "($Lang::tr{'fwdfw all subnets'})" if $cnt1 > 1; #If this Conenction has more than one subnet, print one option for all subnets
1179 foreach my $val (@arr1){
1180 #normalize subnet to cidr notation
1181 my ($val1,$val2) = split /\//, $val;
1182 my $val3 = &General
::iporsubtocidr
($val2);
1184 print "value='$ipsecconf{$key}[1]|$val1/$val3'";
1185 print "selected " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq "$ipsecconf{$key}[1]|$val1/$val3");
1186 print ">$ipsecconf{$key}[1] ($val1/$val3)</option>";
1191 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1192 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>";
1194 if ($show eq '1'){$show='';print"</select></td></tr>";}
1197 print"</td></tr></table><br>";
1205 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1206 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1207 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1208 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1209 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1210 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1211 $a=$netsettings{'GREEN_NETADDRESS'};
1212 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1213 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1214 $a=$netsettings{'ORANGE_NETADDRESS'};
1215 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1216 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1217 $a=$netsettings{'BLUE_NETADDRESS'};
1218 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1219 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1220 &General
::readhash
("$configovpn",\
%ovpnsettings);
1221 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1222 $b=&General
::iporsubtocidr
($b);
1224 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1225 &General
::readhasharray
("$confignet", \
%customnetwork);
1226 foreach my $key (keys %customnetwork){
1227 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1228 $a=$customnetwork{$key}[1];
1229 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1232 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1233 &General
::readhasharray
("$confighost", \
%customhost);
1234 foreach my $key (keys %customhost){
1235 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1236 if ($customhost{$key}[1] eq 'ip'){
1237 ($a,$b)=split (/\//,$customhost{$key}[2]);
1238 $b=&General
::iporsubtocidr
($b);
1240 if ($grp eq 'grp2'){
1241 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1253 &General
::setup_default_networks
(\
%defaultNetworks);
1254 foreach my $network (sort keys %defaultNetworks)
1256 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1261 my %hash=%{(shift)};
1263 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1264 $hash{$key}[10]=~ s/\|/,/g;
1265 print": $hash{$key}[10]";
1266 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1267 print": <br>$hash{$key}[9] ";
1272 my %hash=%{(shift)};
1276 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1277 if($hash{$key}[14] eq 'cust_srv'){
1278 &General
::readhasharray
("$configsrv", \
%customservice);
1279 foreach my $i (sort keys %customservice){
1280 if($customservice{$i}[0] eq $hash{$key}[15]){
1281 $service = $customservice{$i}[0];
1284 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1285 $service=$hash{$key}[15];
1286 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1287 $hash{$key}[15]=~ s/\|/,/g;
1288 $service=$hash{$key}[15];
1295 sub get_serviceports
1299 &General
::readhasharray
("$configsrv", \
%customservice);
1300 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1302 my @specprot=("IPIP","IPV6","IGMP","GRE","AH","ESP");
1303 if($type eq 'service'){
1304 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1305 if ($customservice{$key}[0] eq $name){
1306 push (@protocols,$customservice{$key}[2]);
1309 }elsif($type eq 'group'){
1310 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1311 if ($customservicegrp{$key}[0] eq $name){
1312 if ($customservicegrp{$key}[2] ~~ @specprot){
1313 push (@protocols," ".$customservicegrp{$key}[2]);
1315 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1316 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1317 if (!grep(/$customservice{$key1}[2]/, @protocols)){
1318 push (@protocols,$customservice{$key1}[2]);}
1326 # Sort protocols alphabetically.
1327 @protocols = sort(@protocols);
1336 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1337 # Don't colourise MAC addresses
1338 if (&General
::validmac
($val)) {
1344 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1345 foreach my $key (sort keys %$hash){
1346 if ($$hash{$key}[0] eq $val){
1347 $val=$$hash{$key}[2];
1352 if ($val eq 'GREEN'){
1353 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1355 }elsif ($val eq 'ORANGE'){
1356 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1358 }elsif ($val eq 'BLUE'){
1359 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1361 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1362 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1364 }elsif ($val eq 'IPFire' ){
1365 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1367 }elsif ($val eq 'OpenVPN-Dyn' ){
1368 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1370 }elsif ($val eq 'IPsec RW' ){
1371 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1373 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1374 my ($sip,$scidr) = split ("/",$val);
1375 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1376 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1379 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1380 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1383 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1384 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1387 }elsif ($val eq 'Default IP'){
1388 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1391 #Check if a manual IP or custom host is part of a VPN
1392 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1393 #Check if IP is part of OpenVPN dynamic subnet
1394 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1395 my ($c,$d) = split("/",$val);
1396 if (&General
::IpInSubnet
($c,$a,$b)){
1397 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1400 #Check if IP is part of OpenVPN static subnet
1401 foreach my $key (sort keys %ccdnet){
1402 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1403 $b =&General
::iporsubtodec
($b);
1404 if (&General
::IpInSubnet
($c,$a,$b)){
1405 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1409 #Check if IP is part of OpenVPN N2N subnet
1410 foreach my $key (sort keys %ccdhost){
1411 if ($ccdhost{$key}[3] eq 'net'){
1412 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1413 if (&General
::IpInSubnet
($c,$a,$b)){
1414 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1419 #Check if IP is part of IPsec RW network
1420 if ($ipsecsettings{'RW_NET'} ne ''){
1421 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1422 $b=&General
::iporsubtodec
($b);
1423 if (&General
::IpInSubnet
($c,$a,$b)){
1424 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1428 #Check if IP is part of a IPsec N2N network
1429 foreach my $key (sort keys %ipsecconf){
1430 if ($ipsecconf{$key}[11]){
1431 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1432 $b=&General
::iporsubtodec
($b);
1433 if (&General
::IpInSubnet
($c,$a,$b)){
1434 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1441 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'){
1442 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1445 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1446 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1450 foreach my $alias (sort keys %aliases)
1452 if ($val eq $alias){
1453 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1464 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1465 print "<class name='base'>$hint\n";
1466 print " </class>\n";
1467 &Header
::closebox
();
1473 &General
::setup_default_networks
(\
%defaultNetworks);
1474 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1475 #read all configfiles
1476 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1477 &General
::readhasharray
("$confignet", \
%customnetwork);
1478 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1479 &General
::readhasharray
("$confighost", \
%customhost);
1480 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1481 &General
::readhasharray
("$configgrp", \
%customgrp);
1482 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
1483 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1484 &General
::get_aliases
(\
%aliases);
1488 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1489 my $config=$fwdfwsettings{'config'};
1492 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1493 my $redip = <CONN1
>;
1495 if (! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE2'){
1496 $fwdfwsettings{'RULE_ACTION'}='DROP';
1497 }elsif(! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE1'){
1498 $fwdfwsettings{'RULE_ACTION'}='ACCEPT';
1500 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1501 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1502 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1503 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1504 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1505 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1506 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1507 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1508 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1509 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1510 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1511 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1512 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1513 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1514 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1515 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1516 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1517 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1518 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1519 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1520 #check if update and get values
1521 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1522 &General
::readhasharray
("$config", \
%hash);
1523 foreach my $key (sort keys %hash){
1525 if ($key eq $fwdfwsettings{'key'}){
1526 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1527 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1528 $fwdfwsettings{'chain'} = $hash{$key}[1];
1529 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1530 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1531 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1532 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1533 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1534 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1535 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1536 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1537 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1538 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1539 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1540 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1541 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1542 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1543 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1544 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1545 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1546 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1547 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1548 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1549 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1550 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1551 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1552 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1553 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1554 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1555 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1556 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1557 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1558 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1559 $fwdfwsettings{'LIMIT_CON_CON'} = $hash{$key}[32];
1560 $fwdfwsettings{'concon'} = $hash{$key}[33];
1561 $fwdfwsettings{'RATE_LIMIT'} = $hash{$key}[34];
1562 $fwdfwsettings{'ratecon'} = $hash{$key}[35];
1563 $fwdfwsettings{'RATETIME'} = $hash{$key}[36];
1564 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1565 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1566 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1567 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1568 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1569 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1570 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1571 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1572 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1573 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1574 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1575 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1576 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1577 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1578 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1579 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1580 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1581 $checked{'LIMIT_CON_CON'}{$fwdfwsettings{'LIMIT_CON_CON'}} = 'CHECKED';
1582 $checked{'RATE_LIMIT'}{$fwdfwsettings{'RATE_LIMIT'}} = 'CHECKED';
1583 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1584 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1585 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1586 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1587 $selected{'dnat'}{$fwdfwsettings{'dnat'}} ='selected';
1588 $selected{'snat'}{$fwdfwsettings{'snat'}} ='selected';
1589 $selected{'RATETIME'}{$fwdfwsettings{'RATETIME'}} ='selected';
1592 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1593 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1594 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1595 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1596 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1597 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1598 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1599 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1600 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1601 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1602 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1603 $fwdfwsettings{'olduseratelimit'}=$fwdfwsettings{'RATE_LIMIT'};
1604 $fwdfwsettings{'olduseratelimitamount'}=$fwdfwsettings{'ratecon'};
1605 $fwdfwsettings{'oldratelimittime'}=$fwdfwsettings{'RATETIME'};
1607 #check if manual ip (source) is orange network
1608 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1609 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1610 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1611 $fwdfwsettings{'oldorange'} ='on';
1615 $fwdfwsettings{'ACTIVE'}='ON';
1616 $fwdfwsettings{'nat'} = 'dnat';
1617 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1618 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1619 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1620 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1621 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1622 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1623 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1624 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1625 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1626 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1627 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1628 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1629 #check if manual ip (source) is orange network
1630 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1631 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1632 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1633 $fwdfwsettings{'oldorange'} ='on';
1637 # Split manual source and target address and delete the subnet
1638 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1639 if ($scidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp1'}}=$sip;}
1640 my ($dip,$dcidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp2'}});
1641 if ($dcidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp2'}}=$dip;}
1642 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1643 #------SOURCE-------------------------------------------------------
1644 print "<form method='post'>";
1646 <table width='100%' border='0'>
1647 <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>
1649 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1650 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1651 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1652 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1653 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1654 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1655 if (! -z
"${General::swroot}/ethernet/aliases"){
1656 foreach my $alias (sort keys %aliases)
1658 print "<option value='$alias' $selected{'ipfire_src'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1663 <tr><td><br></td></tr>
1666 &gen_dd_block
('src','grp1');
1667 &Header
::closebox
();
1669 #---SNAT / DNAT ------------------------------------------------
1670 &Header
::openbox
('100%', 'left', 'NAT');
1673 <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}>
1674 $Lang::tr{'fwdfw use nat'}
1677 <table class='fw-nat' width='100%' border='0'>
1679 <td width='5%'></td>
1682 <input type='radio' name='nat' value='dnat' $checked{'nat'}{'dnat'}>
1683 $Lang::tr{'fwdfw dnat'}
1689 <td width='25%' align='right'><span class='dnat'>$Lang::tr{'dnat address'}:</span></td>
1691 <select name='dnat' class='dnat' style='width: 100%;'>
1692 <option value='AUTO' $selected{'dnat'}{'AUTO'}>- $Lang::tr{'automatic'} -</option>
1693 <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'red1'} ($redip)</option>
1696 foreach my $alias (sort keys %aliases) {
1697 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1701 foreach my $network (sort keys %defaultNetworks)
1703 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1704 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1705 print " selected='selected'" if ($fwdfwsettings{'dnat'} eq $defaultNetworks{$network}{'NAME'});
1706 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1715 <td width='5%'></td>
1718 <input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}>
1719 $Lang::tr{'fwdfw snat'}
1722 <td width='25%' align='right'><span class='snat'>$Lang::tr{'snat new source ip address'}:</span></td>
1724 <select name='snat' class='snat' style='width: 100%;'>
1727 foreach my $alias (sort keys %aliases) {
1728 print "<option value='$alias' $selected{'snat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1731 foreach my $network (sort keys %defaultNetworks) {
1732 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1733 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1734 print " selected='selected'" if ($fwdfwsettings{'snat'} eq $defaultNetworks{$network}{'NAME'});
1735 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1745 &Header
::closebox
();
1747 #---TARGET------------------------------------------------------
1748 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1750 <table width='100%' border='0'>
1751 <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>
1753 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1754 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1755 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1756 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1757 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1758 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1759 if (! -z
"${General::swroot}/ethernet/aliases"){
1760 foreach my $alias (sort keys %aliases)
1762 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1767 <tr><td><br></td></tr></table>
1769 &gen_dd_block
('tgt','grp2');
1771 #---PROTOCOL------------------------------------------------------
1772 $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
1773 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1774 $fwdfwsettings{'dnatport'} =~ tr/|/,/;
1776 # The dnatport may be empty, if it matches TGT_PORT
1777 if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
1778 $fwdfwsettings{'dnatport'} = "";
1781 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1782 #Fix Protocol for JQuery
1783 if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
1784 $fwdfwsettings{'PROT'} = 'template';
1787 <table width='100%' border='0'>
1790 <select name='PROT' id='protocol' style="width: 95px;">
1792 print "<option value=\"\"";
1793 if ($fwdfwsettings{'PROT'} eq '') {
1794 print " selected=\"selected\"";
1796 print ">$Lang::tr{'all'}</option>";
1798 print "<option value=\"template\"";
1799 print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp');
1800 print ">- $Lang::tr{'template'} -</option>";
1802 foreach (@PROTOCOLS) {
1803 print"<option value=\"$_\"";
1804 if ($_ eq $fwdfwsettings{'PROT'}) {
1805 print " selected=\"selected\"";
1808 print ">$Lang::tr{'fwdfw prot41'}</option>";
1810 print ">$_</option>";
1818 <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES">
1820 <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
1822 <select name='ICMP_TYPES' style='min-width:230px;'>
1824 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1825 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1826 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1827 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1828 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1830 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1840 <table width="100%" border="0" id="PROTOCOL_PORTS">
1842 <!-- #SOURCEPORT -->
1844 $Lang::tr{'fwdfw use srcport'}
1847 <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
1852 <!-- #TARGETPORT -->
1854 $Lang::tr{'fwdfw use srv'}
1858 <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
1862 <td colspan='3'></td>
1863 <td>$Lang::tr{'fwdfw external port nat'}:</td>
1865 <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
1870 <table width="100%" border="0" id="PROTOCOL_TEMPLATE">
1873 <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
1874 $Lang::tr{'fwhost cust service'}
1877 <select name='cust_srv' style='min-width: 230px;'>
1880 &General
::readhasharray
("$configsrv", \
%customservice);
1881 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1883 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1884 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1893 <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
1894 $Lang::tr{'fwhost cust srvgrp'}
1897 <select name='cust_srvgrp' style='min-width:230px;'>
1900 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1902 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1903 if ($helper ne $customservicegrp{$key}[0] && $customservicegrp{$key}[2] ne 'none'){
1905 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1906 print">$customservicegrp{$key}[0]</option>";
1908 $helper=$customservicegrp{$key}[0];
1922 $checked{"RULE_ACTION"}{$fwdfwsettings{'RULE_ACTION'}} = 'CHECKED';
1925 <table width="80%" class='tbl' id='actions'>
1927 <td width="33%" align="center" bgcolor="$color{'color17'}">
1930 <td width="33%" align="center" bgcolor="$color{'color25'}">
1933 <td width="33%" align="center" bgcolor="$color{'color16'}">
1938 <td width="33%" align="center">
1940 <input type="radio" name="RULE_ACTION" value="ACCEPT" $checked{"RULE_ACTION"}{"ACCEPT"}>
1941 <strong>$Lang::tr{'fwdfw ACCEPT'}</strong>
1944 <td width="33%" align="center">
1946 <input type="radio" name="RULE_ACTION" value="DROP" $checked{"RULE_ACTION"}{"DROP"}>
1947 <strong>$Lang::tr{'fwdfw DROP'}</strong>
1950 <td width="33%" align="center">
1952 <input type="radio" name="RULE_ACTION" value="REJECT" $checked{"RULE_ACTION"}{"REJECT"}>
1953 <strong>$Lang::tr{'fwdfw REJECT'}</strong>
1962 #---Activate/logging/remark-------------------------------------
1963 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1965 <table width='100%' border='0'>
1967 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>";
1968 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1969 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1970 for (my $count =1; $count <= $sum; $count++){
1971 print"<option value='$count' ";
1972 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1973 print">$count</option>";
1975 print"</select></td></tr>";
1977 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1982 <table width='100%'>
1986 if ($fwdfwsettings{'updatefwrule'} eq 'on') {
1989 <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}>
1991 <td>$Lang::tr{'fwdfw rule activate'}</td>
1996 <input type="hidden" name="ACTIVE" value="ON">
2005 <input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'}>
2007 <td>$Lang::tr{'fwdfw log rule'}</td>
2011 <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}>
2013 <td>$Lang::tr{'fwdfw timeframe'}</td>
2015 <tr id="TIME_CONSTRAINTS">
2017 <table width="66%" border="0">
2019 <td width="8em"> </td>
2020 <td align="center">$Lang::tr{'advproxy monday'}</td>
2021 <td align="center">$Lang::tr{'advproxy tuesday'}</td>
2022 <td align="center">$Lang::tr{'advproxy wednesday'}</td>
2023 <td align="center">$Lang::tr{'advproxy thursday'}</td>
2024 <td align="center">$Lang::tr{'advproxy friday'}</td>
2025 <td align="center">$Lang::tr{'advproxy saturday'}</td>
2026 <td align="center">$Lang::tr{'advproxy sunday'}</td>
2030 <td width="8em"> </td>
2031 <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
2032 <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
2033 <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
2034 <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
2035 <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
2036 <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
2037 <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
2039 <select name='TIME_FROM'>
2041 for (my $i=0;$i<=23;$i++) {
2042 $i = sprintf("%02s",$i);
2043 for (my $j=0;$j<=45;$j+=15) {
2044 $j = sprintf("%02s",$j);
2045 my $time = $i.":".$j;
2046 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
2051 <select name='TIME_TO'>
2053 for (my $i=0;$i<=23;$i++) {
2054 $i = sprintf("%02s",$i);
2055 for (my $j=0;$j<=45;$j+=15) {
2056 $j = sprintf("%02s",$j);
2057 my $time = $i.":".$j;
2058 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
2070 <input type='checkbox' name='LIMIT_CON_CON' id="USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP" value='ON' $checked{'LIMIT_CON_CON'}{'ON'}>
2072 <td>$Lang::tr{'fwdfw limitconcon'}</td>
2076 <table width='66%' border='0'>
2078 <td width="20em"> </td>
2079 <td>$Lang::tr{'fwdfw maxconcon'}: <input type='text' name='concon' size='2' value="$fwdfwsettings{'concon'}"></td>
2086 <input type='checkbox' name='RATE_LIMIT' id="USE_RATELIMIT" value='ON' $checked{'RATE_LIMIT'}{'ON'}>
2088 <td>$Lang::tr{'fwdfw ratelimit'}</td>
2092 <table width='66%' border='0'>
2094 <td width="20em"> </td>
2095 <td>$Lang::tr{'fwdfw numcon'}: <input type='text' name='ratecon' size='2' value="$fwdfwsettings{'ratecon'}"> /
2096 <select name='RATETIME' style='width:100px;'>
2097 <option value='second' $selected{'RATETIME'}{'second'}>$Lang::tr{'age second'}</option>
2098 <option value='minute' $selected{'RATETIME'}{'minute'}>$Lang::tr{'minute'}</option>
2099 <option value='hour' $selected{'RATETIME'}{'hour'}>$Lang::tr{'hour'}</option>
2110 #---ACTION------------------------------------------------------
2111 if($fwdfwsettings{'updatefwrule'} ne 'on'){
2113 <table border='0' width='100%'>
2114 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
2115 <input type='hidden' name='config' value='$config' >
2116 <input type='hidden' name='ACTION' value='saverule' ></form>
2117 <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>
2123 <table border='0' width='100%'>
2124 <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'}'>
2125 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
2126 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
2127 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
2128 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
2129 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
2130 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
2131 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
2132 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
2133 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
2134 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
2135 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
2136 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
2137 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
2138 <input type='hidden' name='oldconcon' value='$fwdfwsettings{'oldconcon'}' />
2139 <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>
2143 &Header
::closebox
();
2149 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
2150 foreach my $key (sort keys %uphash){
2151 if ($key eq $fwdfwsettings{'key'}) {
2153 if (exists $uphash{$last}){
2155 foreach my $y (0 .. $#{$uphash{$last}}) {
2156 $tmp{0}[$y] = $uphash{$last}[$y];
2158 #copy active rule to last
2159 foreach my $i (0 .. $#{$uphash{$last}}) {
2160 $uphash{$last}[$i] = $uphash{$key}[$i];
2162 #copy saved rule to actual position
2163 foreach my $x (0 .. $#{$tmp{0}}) {
2164 $uphash{$key}[$x] = $tmp{0}[$x];
2169 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
2170 &General
::firewall_config_changed
();
2176 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
2177 foreach my $key (sort keys %downhash){
2178 if ($key eq $fwdfwsettings{'key'}) {
2179 my $next = $key + 1;
2180 if (exists $downhash{$next}){
2182 foreach my $y (0 .. $#{$downhash{$next}}) {
2183 $tmp{0}[$y] = $downhash{$next}[$y];
2185 #copy active rule to next
2186 foreach my $i (0 .. $#{$downhash{$next}}) {
2187 $downhash{$next}[$i] = $downhash{$key}[$i];
2189 #copy saved rule to actual position
2190 foreach my $x (0 .. $#{$tmp{0}}) {
2191 $downhash{$key}[$x] = $tmp{0}[$x];
2196 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
2197 &General
::firewall_config_changed
();
2203 &General
::readhasharray
("$config", $hash);
2204 if (!$errormessage){
2205 ################################################################
2206 #check if we change an INPUT rule to a OUTGOING
2207 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2208 &changerule
($configinput);
2211 #check if we change an INPUT rule to a FORWARD
2212 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2213 &changerule
($configinput);
2216 ################################################################
2217 #check if we change an OUTGOING rule to an INPUT
2218 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2219 &changerule
($configoutgoing);
2222 #check if we change an OUTGOING rule to a FORWARD
2223 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2224 &changerule
($configoutgoing);
2227 ################################################################
2228 #check if we change a FORWARD rule to an INPUT
2229 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2230 &changerule
($configfwdfw);
2233 #check if we change a FORWARD rule to an OUTGOING
2234 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2235 &changerule
($configfwdfw);
2238 $fwdfwsettings{'ruleremark'}=~ s/,/;/g;
2239 utf8
::decode
($fwdfwsettings{'ruleremark'});
2240 $fwdfwsettings{'ruleremark'}=&Header
::escape
($fwdfwsettings{'ruleremark'});
2241 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2242 my $key = &General
::findhasharraykey
($hash);
2243 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2244 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2245 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2246 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2247 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2248 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2249 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2250 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2251 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2252 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2253 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2254 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2255 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2256 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2257 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2258 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2259 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2260 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2261 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2262 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2263 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2264 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2265 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2266 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2267 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2268 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2269 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2270 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2271 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2272 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2273 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2274 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2275 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2276 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2277 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2278 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2279 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2280 &General
::writehasharray
("$config", $hash);
2282 foreach my $key (sort {$a <=> $b} keys %$hash){
2283 if($key eq $fwdfwsettings{'key'}){
2284 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2285 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2286 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2287 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2288 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2289 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2290 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2291 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2292 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2293 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2294 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2295 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2296 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2297 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2298 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2299 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2300 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2301 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2302 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2303 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2304 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2305 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2306 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2307 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2308 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2309 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2310 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2311 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2312 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2313 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2314 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2315 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2316 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2317 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2318 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2319 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2320 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2325 &General
::writehasharray
("$config", $hash);
2326 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2328 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2329 for (my $z=0;$z<$val;$z++){
2330 foreach my $key (sort {$a <=> $b} keys %$hash){
2331 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2333 if (exists $$hash{$last}){
2335 foreach my $y (0 .. $#{$$hash{$last}}) {
2336 $tmp{0}[$y] = $$hash{$last}[$y];
2338 #copy active rule to last
2339 foreach my $i (0 .. $#{$$hash{$last}}) {
2340 $$hash{$last}[$i] = $$hash{$key}[$i];
2342 #copy saved rule to actual position
2343 foreach my $x (0 .. $#{$tmp{0}}) {
2344 $$hash{$key}[$x] = $tmp{0}[$x];
2349 $fwdfwsettings{'oldrulenumber'}--;
2351 &General
::writehasharray
("$config", $hash);
2352 &General
::firewall_config_changed
();
2353 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2355 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2356 for (my $z=0;$z<$val;$z++){
2357 foreach my $key (sort {$a <=> $b} keys %$hash){
2358 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2359 my $next = $key + 1;
2360 if (exists $$hash{$next}){
2362 foreach my $y (0 .. $#{$$hash{$next}}) {
2363 $tmp{0}[$y] = $$hash{$next}[$y];
2365 #copy active rule to next
2366 foreach my $i (0 .. $#{$$hash{$next}}) {
2367 $$hash{$next}[$i] = $$hash{$key}[$i];
2369 #copy saved rule to actual position
2370 foreach my $x (0 .. $#{$tmp{0}}) {
2371 $$hash{$key}[$x] = $tmp{0}[$x];
2376 $fwdfwsettings{'oldrulenumber'}++;
2378 &General
::writehasharray
("$config", $hash);
2379 &General
::firewall_config_changed
();
2385 # Checks a hostname against RFC1035
2388 # Try to decode $remark into UTF-8. If this doesn't work,
2389 # we assume that the string it not sane.
2390 if (!utf8
::decode
($remark)) {
2394 # Check if the string only contains of printable characters.
2395 if ($remark =~ /^[[:print:]]*$/) {
2402 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2404 &viewtablenew
(\
%configfwdfw, $configfwdfw, $Lang::tr
{'firewall rules'});
2405 &viewtablenew
(\
%configinputfw, $configinput, $Lang::tr
{'incoming firewall access'});
2406 &viewtablenew
(\
%configoutgoingfw, $configoutgoing, $Lang::tr
{'outgoing firewall access'});
2415 my $show_box = (! -z
$config) || ($optionsfw{'SHOWTABLES'} eq 'on');
2416 return if (!$show_box);
2418 &General
::get_aliases
(\
%aliases);
2419 &General
::readhasharray
("$confighost", \
%customhost);
2420 &General
::readhasharray
("$config", $hash);
2421 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2422 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2423 &General
::readhasharray
("$configgrp", \
%customgrp);
2424 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2426 &Header
::openbox
('100%', 'left', $title);
2427 print "<table width='100%' cellspacing='0' class='tbl'>";
2441 <th align='right' width='3%'>
2444 <th width='2%'></th>
2446 <b>$Lang::tr{'protocol'}</b>
2448 <th align='center' width='30%'>
2449 <b>$Lang::tr{'fwdfw source'}</b>
2452 <b>$Lang::tr{'fwdfw log'}</b>
2454 <th align='center' width='30%'>
2455 <b>$Lang::tr{'fwdfw target'}</b>
2457 <th align='center' colspan='6' width='18%'>
2458 <b>$Lang::tr{'fwdfw action'}</b>
2463 foreach my $key (sort {$a <=> $b} keys %$hash){
2467 #check if vpn hosts/nets have been deleted
2468 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2469 push (@tmpsrc,$$hash{$key}[4]);
2471 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2472 push (@tmptgt,$$hash{$key}[6]);
2474 foreach my $host (@tmpsrc){
2475 if($$hash{$key}[3] eq 'ipsec_net_src'){
2476 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2479 }elsif($$hash{$key}[3] eq 'ovpn_net_src'){
2480 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2483 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src'){
2484 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2487 }elsif($$hash{$key}[3] eq 'ovpn_host_src'){
2488 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2493 foreach my $host (@tmptgt){
2494 if($$hash{$key}[5] eq 'ipsec_net_tgt'){
2495 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2498 }elsif($$hash{$key}[5] eq 'ovpn_net_tgt'){
2499 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2502 }elsif($$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2503 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2506 }elsif($$hash{$key}[5] eq 'ovpn_host_tgt'){
2507 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2512 #check if networkgroups or servicegroups are empty
2513 foreach my $netgroup (sort keys %customgrp){
2514 if(($$hash{$key}[4] eq $customgrp{$netgroup}[0] || $$hash{$key}[6] eq $customgrp{$netgroup}[0]) && $customgrp{$netgroup}[2] eq 'none'){
2518 foreach my $srvgroup (sort keys %customservicegrp){
2519 if($$hash{$key}[15] eq $customservicegrp{$srvgroup}[0] && $customservicegrp{$srvgroup}[2] eq 'none'){
2523 $$hash{'ACTIVE'}=$$hash{$key}[2];
2525 if($coloryellow eq 'on'){
2526 $color="$color{'color14'}";
2528 }elsif($coloryellow eq ''){
2530 $color="$color{'color22'}";
2533 $color="$color{'color20'}";
2537 <tr bgcolor='$color'>
2538 <td align='right' width='3%'>
2544 if ($$hash{$key}[0] eq 'ACCEPT'){
2547 $rulecolor=$color{'color17'};
2548 }elsif($$hash{$key}[0] eq 'DROP'){
2551 $rulecolor=$color{'color25'};
2552 }elsif($$hash{$key}[0] eq 'REJECT'){
2555 $rulecolor=$color{'color16'};
2559 <td bgcolor='$rulecolor' align='center' width='2%'>
2560 <span title='$tooltip'> </span>
2566 if ($$hash{$key}[8]){
2567 if ($$hash{$key}[8] eq "IPv6"){
2568 push (@protocols,$Lang::tr
{'fwdfw prot41 short'})
2570 push (@protocols,$$hash{$key}[8]);
2572 }elsif($$hash{$key}[14] eq 'cust_srv'){
2573 &get_serviceports
("service",$$hash{$key}[15]);
2574 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2575 &get_serviceports
("group",$$hash{$key}[15]);
2577 push (@protocols,$Lang::tr
{'all'});
2580 my $protz=join(", ",@protocols);
2581 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2582 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2583 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2584 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2585 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2589 }elsif($#protocols gt '3'){
2590 print"<td align='center'><span title='$protz'>$Lang::tr{'fwdfw many'}</span></td>";
2592 print"<td align='center'>$protz</td>";
2597 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2598 # Check SRC Host and replace "|" with space
2599 if ($$hash{$key}[4] =~ /\|/){
2600 $$hash{$key}[4] =~ s/\|/ (/g;
2601 $$hash{$key}[4] = $$hash{$key}[4].")";
2603 print"<td align='center' width='30%' $tdcolor>";
2604 if ($$hash{$key}[3] eq 'ipfire_src'){
2605 $ipfireiface=$Lang::tr
{'fwdfw iface'};
2607 if ($$hash{$key}[3] eq 'std_net_src'){
2608 print &get_name
($$hash{$key}[4]);
2609 }elsif ($$hash{$key}[3] eq 'src_addr'){
2610 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2611 if ($split2 eq '32'){
2614 print $$hash{$key}[4];
2616 }elsif ($$hash{$key}[3] eq 'cust_geoip_src') {
2617 my ($split1,$split2) = split(":", $$hash{$key}[4]);
2621 print "$Lang::tr{'geoip'}: $$hash{$key}[4]\n";
2623 }elsif ($$hash{$key}[4] eq 'RED1'){
2624 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2625 }elsif ($$hash{$key}[4] eq 'ALL'){
2626 print "$ipfireiface $Lang::tr{'all'}";
2628 if ($$hash{$key}[4] eq 'GREEN' || $$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE' || $$hash{$key}[4] eq 'RED'){
2629 print "$ipfireiface $Lang::tr{lc($$hash{$key}[4])}";
2631 print "$ipfireiface $$hash{$key}[4]";
2636 &getsrcport
(\
%$hash,$key);
2637 #Is this a SNAT rule?
2638 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2639 my $net=&get_name
($$hash{$key}[29]);
2640 if ( ! $net){ $net=$$hash{$key}[29];}
2642 if ($$hash{$key}[30] ne ''){
2643 print": $$hash{$key}[30]";
2646 if ($$hash{$key}[17] eq 'ON'){
2647 $log="/images/on.gif";
2649 $log="/images/off.gif";
2655 <form method='POST' action=''>
2656 <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 ;'/>
2657 <input type='hidden' name='key' value='$key' />
2658 <input type='hidden' name='config' value='$config' />
2659 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2664 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2666 <td align='center' $tdcolor>
2668 # Check TGT Host and replace "|" with space
2669 if ($$hash{$key}[6] =~ /\|/){
2670 $$hash{$key}[6] =~ s/\|/ (/g;
2671 $$hash{$key}[6] = $$hash{$key}[6].")";
2673 #Is this a DNAT rule?
2675 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2676 if ($$hash{$key}[29] eq 'Default IP'){$$hash{$key}[29]=$Lang::tr
{'red1'};}
2677 if ($$hash{$key}[29] eq 'AUTO'){
2678 my @src_addresses=&fwlib
::get_addresses
(\
%$hash,$key,'src');
2680 foreach my $val (@src_addresses){
2681 push (@nat_ifaces,&fwlib
::get_nat_address
($$hash{$key}[29],$val));
2683 @nat_ifaces=&del_double
(@nat_ifaces);
2686 $natstring = "($$hash{$key}[29])";
2688 print "$Lang::tr{'firewall'} $natstring";
2689 if($$hash{$key}[30] ne ''){
2690 $$hash{$key}[30]=~ tr/|/,/;
2691 print": $$hash{$key}[30]";
2695 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire'){
2696 if ($$hash{$key}[6] eq 'RED1'){
2697 print "$Lang::tr{'red1'}";
2698 }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')
2700 print &get_name
($$hash{$key}[6]);
2702 print $$hash{$key}[6];
2704 }elsif ($$hash{$key}[5] eq 'cust_geoip_tgt') {
2705 my ($split1,$split2) = split(":", $$hash{$key}[6]);
2709 print "$Lang::tr{'geoip'}: $$hash{$key}[6]\n";
2711 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2712 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2713 if ($split2 eq '32'){
2716 print $$hash{$key}[6];
2719 print "$$hash{$key}[6]";
2723 &gettgtport
(\
%$hash,$key);
2726 if($$hash{$key}[2] eq 'ON'){
2727 $gif="/images/on.gif"
2729 $gif="/images/off.gif"
2732 <td width='3%' align='center'>
2733 <form method='POST' action=''>
2734 <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;' />
2735 <input type='hidden' name='key' value='$key' />
2736 <input type='hidden' name='config' value='$config' />
2737 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2740 <td width='3%' align='center'>
2741 <form method='POST' action=''>
2742 <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;' />
2743 <input type='hidden' name='key' value='$key' />
2744 <input type='hidden' name='config' value='$config' />
2745 <input type='hidden' name='ACTION' value='editrule' />
2748 <td width='3%' align='center'>
2749 <form method='POST' action=''>
2750 <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;' />
2751 <input type='hidden' name='key' value='$key' />
2752 <input type='hidden' name='config' value='$config' />
2753 <input type='hidden' name='ACTION' value='copyrule' />
2756 <td width='3%' align='center'>
2757 <form method='POST' action=''>
2758 <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;' />
2759 <input type='hidden' name='key' value='$key' />
2760 <input type='hidden' name='config' value='$config' />
2761 <input type='hidden' name='ACTION' value='deleterule' />
2765 if (exists $$hash{$key-1}){
2767 <td width='3%' align='center'>
2768 <form method='POST' action=''>
2769 <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;' />
2770 <input type='hidden' name='key' value='$key' />
2771 <input type='hidden' name='config' value='$config' />
2772 <input type='hidden' name='ACTION' value='moveup' />
2777 print"<td width='3%'></td>";
2780 if (exists $$hash{$key+1}){
2782 <td width='3%' align='center'>
2783 <form method='POST' action=''>
2784 <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;' />
2785 <input type='hidden' name='key' value='$key' />
2786 <input type='hidden' name='config' value='$config' />
2787 <input type='hidden' name='ACTION' value='movedown' />
2793 print"<td width='3%'></td></tr>";
2796 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2798 <tr bgcolor='$color'>
2800 <td bgcolor='$rulecolor'></td>
2802 <em>$$hash{$key}[16]</em>
2808 if ($$hash{$key}[18] eq 'ON'){
2810 if ($$hash{$key}[18] eq 'ON'){
2812 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2813 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2814 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2815 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2816 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2817 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2818 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2819 my $weekdays=join(",",@days);
2821 print"<tr bgcolor='$color'>";
2822 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27]</td></tr>";
2826 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2828 } elsif ($optionsfw{'SHOWTABLES'} eq 'on') {
2831 <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td>
2837 my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'};
2838 my $colour = "bgcolor='green'";
2839 if ($fwdfwsettings{'POLICY'} eq 'MODE1') {
2840 $colour = "bgcolor='darkred'";
2844 if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) {
2847 <td colspan='13'> </td>
2850 <td colspan='13' style="padding-left:0px;padding-right:0px">
2851 <table width="100%" border='1' rules="cols" cellspacing='0'>
2858 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2861 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2862 ($Lang::tr{'fwdfw pol allow'})
2866 if (&Header
::orange_used
()) {
2869 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2870 ($Lang::tr{'fwdfw pol allow'})
2875 if (&Header
::blue_used
()) {
2878 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2879 ($Lang::tr{'fwdfw pol allow'})
2887 if (&Header
::orange_used
()) {
2890 <td align='center' width='20%'>
2891 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2894 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2895 ($Lang::tr{'fwdfw pol allow'})
2898 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2899 ($Lang::tr{'fwdfw pol block'})
2903 if (&Header
::blue_used
()) {
2906 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2907 ($Lang::tr{'fwdfw pol block'})
2915 if (&Header
::blue_used
()) {
2919 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2922 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2923 ($Lang::tr{'fwdfw pol allow'})
2927 if (&Header
::orange_used
()) {
2930 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2931 ($Lang::tr{'fwdfw pol block'})
2938 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2939 ($Lang::tr{'fwdfw pol block'})
2951 $message = $Lang::tr
{'fwdfw pol allow'};
2953 } elsif ($config eq '/var/ipfire/firewall/outgoing' && ($fwdfwsettings{'POLICY1'} ne 'MODE1')) {
2954 $message = $Lang::tr
{'fwdfw pol allow'};
2955 $colour = "bgcolor='green'";
2957 $message = $Lang::tr
{'fwdfw pol block'};
2958 $colour = "bgcolor='darkred'";
2964 <td $colour align='center' colspan='13'>
2965 <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font>
2974 &Header
::closebox
();
2977 &Header
::closebigbox
();
2978 &Header
::closepage
();