]>
git.ipfire.org Git - people/stevee/ipfire-2.x.git/blob - html/cgi-bin/firewall.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
25 use feature
'unicode_strings';
27 no warnings
'uninitialized';
29 # enable only the following on debugging purpose
31 #use CGI::Carp 'fatalsToBrowser';
33 require '/var/ipfire/general-functions.pl';
34 require "${General::swroot}/lang.pl";
35 require "${General::swroot}/header.pl";
36 require "/usr/lib/firewall/firewall-lib.pl";
38 unless (-d
"${General::swroot}/firewall") { system("mkdir ${General::swroot}/firewall"); }
39 unless (-e
"${General::swroot}/firewall/settings") { system("touch ${General::swroot}/firewall/settings"); }
40 unless (-e
"${General::swroot}/firewall/config") { system("touch ${General::swroot}/firewall/config"); }
41 unless (-e
"${General::swroot}/firewall/input") { system("touch ${General::swroot}/firewall/input"); }
42 unless (-e
"${General::swroot}/firewall/outgoing") { system("touch ${General::swroot}/firewall/outgoing"); }
46 my %defaultNetworks=();
50 my %customnetworks=();
52 my %customservicegrp=();
58 my %configoutgoingfw=();
71 my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE","IPv6","IPIP");
74 my $confignet = "${General::swroot}/fwhosts/customnetworks";
75 my $confighost = "${General::swroot}/fwhosts/customhosts";
76 my $configgrp = "${General::swroot}/fwhosts/customgroups";
77 my $configsrv = "${General::swroot}/fwhosts/customservices";
78 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
79 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
80 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
81 my $configipsec = "${General::swroot}/vpn/config";
82 my $configipsecrw = "${General::swroot}/vpn/settings";
83 my $configfwdfw = "${General::swroot}/firewall/config";
84 my $configinput = "${General::swroot}/firewall/input";
85 my $configoutgoing = "${General::swroot}/firewall/outgoing";
86 my $configovpn = "${General::swroot}/ovpn/settings";
87 my $fwoptions = "${General::swroot}/optionsfw/settings";
88 my $ifacesettings = "${General::swroot}/ethernet/settings";
91 my $ipgrp="${General::swroot}/outgoing/groups";
95 &General
::readhash
("${General::swroot}/firewall/settings", \
%fwdfwsettings);
96 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
97 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
98 &General
::readhash
($fwoptions, \
%optionsfw);
99 &General
::readhash
($ifacesettings, \
%ifaces);
100 &General
::readhash
("$configovpn", \
%ovpnsettings);
101 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
102 &General
::readhasharray
("$configipsec", \
%ipsecconf);
103 &Header
::showhttpheaders
();
104 &Header
::getcgihash
(\
%fwdfwsettings);
105 &Header
::openpage
($Lang::tr
{'firewall rules'}, 1, '');
106 &Header
::openbigbox
('100%', 'center',$errormessage);
107 #### JAVA SCRIPT ####
110 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
112 var update_protocol = function() {
113 var protocol = \$("#protocol").val();
115 if (protocol === undefined)
118 // Check if a template is/should be used.
119 if (protocol === "template") {
120 \$("#PROTOCOL_TEMPLATE").show();
122 \$("#PROTOCOL_TEMPLATE").hide();
125 // Check if we are dealing with a protocol, that knows ports.
126 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
127 \$("#PROTOCOL_PORTS").show();
129 \$("#PROTOCOL_PORTS").hide();
133 if (protocol === "ICMP") {
134 \$("#PROTOCOL_ICMP_TYPES").show();
136 \$("#PROTOCOL_ICMP_TYPES").hide();
140 \$(document).ready(function() {
141 \$("#protocol").change(update_protocol);
144 // Show/Hide elements when NAT checkbox is checked.
145 if (\$("#USE_NAT").attr("checked")) {
146 \$("#actions").hide();
151 // Show NAT area when "use nat" checkbox is clicked
152 \$("#USE_NAT").change(function() {
154 \$("#actions").toggle();
157 // Hide SNAT items when DNAT is selected and vice versa.
158 if (\$('input[name=nat]:checked').val() == 'dnat') {
164 // Show/Hide elements when SNAT/DNAT get changed.
165 \$('input[name=nat]').change(function() {
166 \$('.snat').toggle();
167 \$('.dnat').toggle();
171 if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) {
172 \$("#TIME_CONSTRAINTS").hide();
174 \$("#USE_TIME_CONSTRAINTS").change(function() {
175 \$("#TIME_CONSTRAINTS").toggle();
178 // Limit concurrent connections per ip
179 if(!\$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").attr("checked")) {
180 \$("#LIMIT_CON").hide();
182 \$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").change(function() {
183 \$("#LIMIT_CON").toggle();
186 // Rate-limit new connections
187 if(!\$("#USE_RATELIMIT").attr("checked")) {
188 \$("#RATELIMIT").hide();
190 \$("#USE_RATELIMIT").change(function() {
191 \$("#RATELIMIT").toggle();
194 // Automatically select radio buttons when corresponding
195 // dropdown menu changes.
196 \$("select").change(function() {
197 var id = \$(this).attr("name");
198 \$('#' + id).prop("checked", true);
206 if ($fwdfwsettings{'ACTION'} eq 'saverule')
208 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
209 &General
::readhasharray
("$configinput", \
%configinputfw);
210 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
212 #Set Variables according to the JQuery code in protocol section
213 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')
215 if ($fwdfwsettings{'SRC_PORT'} ne '')
217 $fwdfwsettings{'USE_SRC_PORT'} = 'ON';
219 if ($fwdfwsettings{'TGT_PORT'} ne '')
221 $fwdfwsettings{'USESRV'} = 'ON';
222 $fwdfwsettings{'grp3'} = 'TGT_PORT';
225 if ($fwdfwsettings{'PROT'} eq 'template')
227 $fwdfwsettings{'USESRV'} = 'ON';
229 $errormessage=&checksource
;
230 if(!$errormessage){&checktarget
;}
231 if(!$errormessage){&checkrule
;}
233 #check if manual ip (source) is orange network
234 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
235 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
236 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
241 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
242 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
244 #check if we try to break rules
245 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
246 $errormessage=$Lang::tr
{'fwdfw err same'};
249 if ($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
250 $fwdfwsettings{'config'}=$configinput;
251 $fwdfwsettings{'chain'} = 'INPUTFW';
252 $maxkey=&General
::findhasharraykey
(\
%configinputfw);
253 %rulehash=%configinputfw;
254 }elsif ($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
256 $fwdfwsettings{'config'}=$configoutgoing;
257 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
258 $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
259 %rulehash=%configoutgoingfw;
262 $fwdfwsettings{'config'}=$configfwdfw;
263 $fwdfwsettings{'chain'} = 'FORWARDFW';
264 $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
265 %rulehash=%configfwdfw;
267 #check if we have an identical rule already
268 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
269 foreach my $key (sort keys %rulehash){
270 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'}"
271 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]"){
272 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
273 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
274 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
276 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
279 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
280 $fwdfwsettings{'nosave'} = 'on';
285 #check Rulepos on new Rule
286 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
287 $fwdfwsettings{'oldrulenumber'}=$maxkey;
288 foreach my $key (sort keys %rulehash){
289 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'}"
290 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]"){
291 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
295 #check if we just close a rule
296 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'}){
297 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
298 $fwdfwsettings{'nosave2'} = 'on';
302 #check max concurrent connections per ip address
303 if ($fwdfwsettings{'LIMIT_CON_CON'} eq 'ON'){
304 if (!($fwdfwsettings{'concon'} =~ /^(\d+)$/)) {
305 $errormessage.=$Lang::tr
{'fwdfw err concon'};
308 $fwdfwsettings{'concon'}='';
310 #check ratelimit value
311 if ($fwdfwsettings{'RATE_LIMIT'} eq 'ON'){
312 if (!($fwdfwsettings{'ratecon'} =~ /^(\d+)$/)) {
313 $errormessage.=$Lang::tr
{'fwdfw err ratecon'};
316 $fwdfwsettings{'ratecon'}='';
320 if ($fwdfwsettings{'nosave2'} ne 'on'){
321 &saverule
(\
%rulehash,$fwdfwsettings{'config'});
327 if($fwdfwsettings{'nosave2'} ne 'on'){
328 &General
::firewall_config_changed
();
333 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
337 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
340 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
341 foreach my $key (sort keys %togglehash){
342 if ($key eq $fwdfwsettings{'key'}){
343 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
346 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
347 &General
::firewall_config_changed
();
350 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
353 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
354 foreach my $key (sort keys %togglehash){
355 if ($key eq $fwdfwsettings{'key'}){
356 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
359 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
360 &General
::firewall_config_changed
();
363 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
365 &General
::firewall_reload
();
368 if ($fwdfwsettings{'ACTION'} eq 'editrule')
370 $fwdfwsettings{'updatefwrule'}='on';
373 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
377 if ($fwdfwsettings{'ACTION'} eq 'moveup')
382 if ($fwdfwsettings{'ACTION'} eq 'movedown')
387 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
389 $fwdfwsettings{'copyfwrule'}='on';
392 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
401 &Header
::openbox
('100%', 'left', "");
403 <form method="POST" action="">
404 <table border='0' width="100%">
407 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'>
410 if (&General
::firewall_needs_reload
()) {
412 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'>
436 $fwdfwsettings{'updatefwrule'}='';
437 $fwdfwsettings{'config'}=$oldchain;
438 $fwdfwsettings{'nobase'}='on';
444 #check ip-address if manual
445 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
446 #check if ip with subnet
447 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
448 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
449 $subnet = &General
::iporsubtocidr
($subnet);
450 $fwdfwsettings{'isip'}='on';
453 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
454 $ip=$fwdfwsettings{'src_addr'};
456 $fwdfwsettings{'isip'}='on';
459 if ($fwdfwsettings{'isip'} ne 'on'){
460 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
461 $fwdfwsettings{'ismac'}='on';
464 if ($fwdfwsettings{'isip'} eq 'on'){
465 ##check if ip is valid
466 if (! &General
::validip
($ip)){
467 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
468 return $errormessage;
470 #check and form valid IP
471 $ip=&General
::ip2dec
($ip);
472 $ip=&General
::dec2ip
($ip);
473 #check if net or broadcast
474 $fwdfwsettings{'src_addr'}="$ip/$subnet";
475 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
476 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
477 return $errormessage;
480 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
481 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
482 return $errormessage;
484 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
485 $fwdfwsettings{'grp1'}='std_net_src';
486 $fwdfwsettings{$fwdfwsettings{'grp1'}} = 'ALL';
490 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
491 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
492 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
496 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
498 #change dashes with :
501 push(@values,"1:65535");
504 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
505 push(@values,"1:$2");
508 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
509 push(@values,"$1:65535");
512 $errormessage .= &General
::validportrange
($_, 'destination');
517 if (&General
::validport
($_)){
524 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
526 return $errormessage;
531 &General
::readhasharray
("$configsrv", \
%customservice);
532 #check DNAT settings (has to be single Host and single Port or portrange)
533 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
534 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
535 #check if manual ip is a single Host (if set)
536 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
537 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
538 my @tmp1= split ("/",$tmp[3]);
539 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
541 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
542 return $errormessage;
545 #check if Port is a single Port or portrange
546 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
547 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
548 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
549 return $errormessage;
551 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
552 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
553 return $errormessage;
557 if ($fwdfwsettings{'grp2'} ne 'ipfire'){
558 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
559 return $errormessage;
563 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
564 #check if ip with subnet
565 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
566 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
567 $subnet = &General
::iporsubtocidr
($subnet);
570 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
571 $ip=$fwdfwsettings{'tgt_addr'};
574 #check if ip is valid
575 if (! &General
::validip
($ip)){
576 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
577 return $errormessage;
579 #check and form valid IP
580 $ip=&General
::ip2dec
($ip);
581 $ip=&General
::dec2ip
($ip);
582 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
583 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
584 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
585 return $errormessage;
587 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
588 $fwdfwsettings{'grp2'}='std_net_tgt';
589 $fwdfwsettings{$fwdfwsettings{'grp2'}} = 'ALL';
591 #check for mac in targetgroup
592 if ($fwdfwsettings{'grp2'} eq 'cust_grp_tgt'){
593 &General
::readhasharray
("$configgrp", \
%customgrp);
594 &General
::readhasharray
("$confighost", \
%customhost);
595 foreach my $grpkey (sort keys %customgrp){
596 foreach my $hostkey (sort keys %customhost){
597 if ($customgrp{$grpkey}[2] eq $customhost{$hostkey}[0] && $customhost{$hostkey}[1] eq 'mac'){
598 $hint=$Lang::tr
{'fwdfw hint mac'};
605 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
607 if ($fwdfwsettings{'USESRV'} eq 'ON'){
608 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
609 $fwdfwsettings{'TGT_PROT'}='';
610 $fwdfwsettings{'ICMP_TGT'}='';
611 $fwdfwsettings{'TGT_PORT'}='';
613 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
614 $fwdfwsettings{'TGT_PROT'}='';
615 $fwdfwsettings{'ICMP_TGT'}='';
616 $fwdfwsettings{'TGT_PORT'}='';
617 #check target service
618 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
619 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
622 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
623 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
624 if ($fwdfwsettings{'TGT_PORT'} ne ''){
625 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
626 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
627 return $errormessage;
629 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
633 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
635 #change dashes with :
638 push(@values,"1:65535");
641 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
642 push(@values,"1:$2");
645 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
646 push(@values,"$1:65535");
649 $errormessage .= &General
::validportrange
($_, 'destination');
654 if (&General
::validport
($_)){
657 $errormessage=$Lang::tr
{'fwdfw err tgt_port'};
658 return $errormessage;
662 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
664 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
665 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
666 $fwdfwsettings{'TGT_PORT'} = '';
667 $fwdfwsettings{'ICMP_TGT'} = '';
668 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
669 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
670 $fwdfwsettings{'TGT_PORT'} = '';
671 $fwdfwsettings{'ICMP_TGT'}='';
672 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
673 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
674 $fwdfwsettings{'TGT_PORT'} = '';
675 $fwdfwsettings{'ICMP_TGT'}='';
676 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
677 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
678 $fwdfwsettings{'TGT_PORT'} = '';
683 if ($fwdfwsettings{'USESRV'} ne 'ON'){
684 $fwdfwsettings{'grp3'}='';
685 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
686 $fwdfwsettings{'ICMP_TGT'}='';
689 if($fwdfwsettings{'TIME'} eq 'ON'){
690 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 ''){
691 $errormessage=$Lang::tr
{'fwdfw err time'};
692 return $errormessage;
695 return $errormessage;
700 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
701 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
702 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
703 if ($fwdfwsettings{'dnatport'} eq "*") {
704 $fwdfwsettings{'dnatport'}="1:65535";
706 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
707 $fwdfwsettings{'dnatport'} = "1:$2";
709 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
710 $fwdfwsettings{'dnatport'} ="$1:65535";
715 if ($val =~ "," || $val>65536 || $val<0){
722 #check valid port for NAT
723 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
724 #RULE_ACTION must be ACCEPT if we use NAT
725 $fwdfwsettings{'RULE_ACTION'} = 'ACCEPT';
727 #if no dnat or snat selected errormessage
728 if ($fwdfwsettings{'nat'} eq ''){
729 $errormessage=$Lang::tr
{'fwdfw dnat nochoice'};
733 #if using snat, the external port has to be empty
734 if ($fwdfwsettings{'nat'} eq 'snat' && $fwdfwsettings{'dnatport'} ne ''){
735 $errormessage=$Lang::tr
{'fwdfw dnat extport'};
738 #if no dest port is given in nat area, take target host port
739 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
740 if($fwdfwsettings{'TGT_PORT'} eq '' && $fwdfwsettings{'dnatport'} ne '' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')){
741 $errormessage=$Lang::tr
{'fwdfw dnat porterr2'};
744 #check if port given in nat area is a single valid port or portrange
745 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
746 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
747 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
749 #get service Protocol and Port
750 foreach my $key (sort keys %customservice){
751 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
752 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
753 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
755 $custsrvport= $customservice{$key}[1];
758 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
760 #check if DNAT port is multiple
761 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
762 my @parts=split(",",$fwdfwsettings{'dnatport'});
766 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
768 #change dashes with :
771 push(@values,"1:65535");
774 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
775 push(@values,"1:$2");
778 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
779 push(@values,"$1:65535");
782 $errormessage .= &General
::validportrange
($_, 'destination');
787 if (&General
::validport
($_)){
794 $fwdfwsettings{'dnatport'}=join("|",@values);
796 #check if a rule with prot tcp or udp and ports is edited and now prot is "all", then delete all ports
797 if($fwdfwsettings{'PROT'} eq ''){
798 $fwdfwsettings{'dnatport'}='';
802 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
803 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
805 #check if source and target identical
806 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL' && $fwdfwsettings{'grp2'} ne 'ipfire'){
807 $errormessage=$Lang::tr
{'fwdfw err same'};
808 return $errormessage;
810 #get source and targetip address if possible
811 my ($sip,$scidr,$tip,$tcidr);
812 ($sip,$scidr)=&get_ip
("src","grp1");
813 ($tip,$tcidr)=&get_ip
("tgt","grp2");
814 #check same iprange in source and target
815 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
816 my $networkip1=&General
::getnetworkip
($sip,$scidr);
817 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
818 if ($scidr gt $tcidr){
819 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
820 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
822 }elsif($scidr eq $tcidr && $scidr eq '32'){
823 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
824 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
825 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
826 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
827 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
830 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
831 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
835 #when icmp selected, no source and targetport allowed
836 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')){
837 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
840 #change protocol if prot not equal dest single service
841 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
842 foreach my $key (sort keys %customservice){
843 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
844 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
845 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
851 #check source and destination protocol if source manual and dest servicegroup
852 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
853 $fwdfwsettings{'PROT'} = '';
855 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
856 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
858 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
859 $fwdfwsettings{'USE_SRC_PORT'}='';
860 $fwdfwsettings{'SRC_PORT'}='';
861 #$fwdfwsettings{'USESRV'}='';
862 $fwdfwsettings{'TGT_PORT'}='';
863 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
864 foreach my $key (keys %icmptypes){
865 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
866 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
869 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
870 $fwdfwsettings{'USE_SRC_PORT'}='';
871 $fwdfwsettings{'SRC_PORT'}='';
872 $fwdfwsettings{'ICMP_TYPES'}='';
873 $fwdfwsettings{'USESRV'}='';
874 $fwdfwsettings{'TGT_PORT'}='';
875 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
876 $fwdfwsettings{'USE_SRC_PORT'}='';
877 $fwdfwsettings{'SRC_PORT'}='';
878 $fwdfwsettings{'ICMP_TYPES'}='';
879 $fwdfwsettings{'USESRV'}='';
880 $fwdfwsettings{'TGT_PORT'}='';
881 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
882 $fwdfwsettings{'USE_SRC_PORT'}='';
883 $fwdfwsettings{'SRC_PORT'}='';
884 $fwdfwsettings{'ICMP_TYPES'}='';
885 $fwdfwsettings{'USESRV'}='';
886 $fwdfwsettings{'TGT_PORT'}='';
887 }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){
888 $fwdfwsettings{'USE_SRC_PORT'}='';
889 $fwdfwsettings{'SRC_PORT'}='';
890 $fwdfwsettings{'ICMP_TYPES'}='';
891 $fwdfwsettings{'USESRV'}='';
892 $fwdfwsettings{'TGT_PORT'}='';
893 }elsif($fwdfwsettings{'PROT'} eq 'IPv6'){
894 $fwdfwsettings{'USE_SRC_PORT'}='';
895 $fwdfwsettings{'SRC_PORT'}='';
896 $fwdfwsettings{'ICMP_TYPES'}='';
897 $fwdfwsettings{'USESRV'}='';
898 $fwdfwsettings{'TGT_PORT'}='';
899 }elsif($fwdfwsettings{'PROT'} eq 'IPIP'){
900 $fwdfwsettings{'USE_SRC_PORT'}='';
901 $fwdfwsettings{'SRC_PORT'}='';
902 $fwdfwsettings{'ICMP_TYPES'}='';
903 $fwdfwsettings{'USESRV'}='';
904 $fwdfwsettings{'TGT_PORT'}='';
905 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP'){
906 $fwdfwsettings{'ICMP_TYPES'}='';
907 $fwdfwsettings{'SRC_PORT'}='';
908 $fwdfwsettings{'TGT_PORT'}='';
909 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
910 $fwdfwsettings{'ICMP_TYPES'}='';
916 #Test if manual IP is part of static OpenVPN networks
917 &General
::readhasharray
("$configccdnet", \
%ccdnet);
918 foreach my $key (sort keys %ccdnet){
919 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
920 my $sub=&General
::iporsubtodec
($vpnsubnet);
921 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
925 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
926 # because if one creates a custom host with the ip, we need to check the color there!
927 # It does not make sense to check this here
929 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
930 # Is also checked in getcolor
932 # Test if manual ip is part of an IPsec Network is also checked in getcolor
942 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
943 foreach my $key (sort {$a <=> $b} keys %delhash){
944 if ($key >= $fwdfwsettings{'key'}) {
946 if (exists $delhash{$next}) {
947 foreach my $i (0 .. $#{$delhash{$next}}) {
948 $delhash{$key}[$i] = $delhash{$next}[$i];
953 # Remove the very last entry.
954 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
955 delete $delhash{$last_key};
957 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
958 &General
::firewall_config_changed
();
960 if($fwdfwsettings{'nobase'} ne 'on'){
973 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
974 foreach my $key (sort keys %configfwdfw){
976 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
979 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
980 &General
::firewall_config_changed
();
985 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
986 print "<class name='base'>$errormessage\n";
987 print " </class>\n";
996 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
997 if($hash{$key}[0] eq $val){
998 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1000 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1010 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1011 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1012 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1013 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1014 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1015 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1016 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1017 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1018 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1019 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1020 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1021 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1022 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1023 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1024 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1025 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1026 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1027 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1028 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1030 <table width='100%' border='0'>
1031 <tr><td width='50%' valign='top'>
1032 <table width='95%' border='0'>
1033 <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;'>
1035 foreach my $network (sort keys %defaultNetworks)
1037 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1038 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1039 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1040 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1041 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1042 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1043 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1044 if ($ifaces{$defnet}){
1045 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1047 print ">$network</option>";
1050 print"</select></td></tr>";
1052 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1053 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;'>";
1054 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1055 print"</select></td>";
1058 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1059 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;'>";
1060 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1061 print"</select></td>";
1064 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1065 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;'>";
1066 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1067 if($helper ne $customgrp{$key}[0] && $customgrp{$key}[2] ne 'none'){
1069 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1070 print ">$customgrp{$key}[0]</option>";
1072 $helper=$customgrp{$key}[0];
1074 print"</select></td>";
1076 #End left table. start right table (vpn)
1077 print"</tr></table></td><td valign='top'><table width='95%' border='0' align='right'><tr>";
1079 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1080 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;'>";
1081 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1082 print"</select></td></tr>";
1085 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1086 if ($ccdhost{$key}[33] ne '' ){
1087 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 '');
1089 print "<option value='$ccdhost{$key}[1]'";
1090 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1091 print ">$ccdhost{$key}[1]</option>";
1094 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1095 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>" ;
1097 if ($show eq '1'){$show='';print"</select></td></tr>";}
1099 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1100 if ($ccdhost{$key}[3] eq 'net'){
1101 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 '');
1103 print "<option value='$ccdhost{$key}[1]'";
1104 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1105 print ">$ccdhost{$key}[1]</option>";
1108 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1109 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>" ;
1111 if ($show eq '1'){$show='';print"</select></td></tr>";}
1113 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1114 if ($ipsecconf{$key}[3] eq 'net' || ($optionsfw{'SHOWDROPDOWN'} eq 'on' && $ipsecconf{$key}[3] ne 'host')){
1115 print"<tr><td valign='top'><input type='radio' name='$grp' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'>" if ($show eq '');
1118 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1119 print ">$ipsecconf{$key}[1]</option>";
1122 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1123 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>";
1125 if ($show eq '1'){$show='';print"</select></td></tr>";}
1128 print"</td></tr></table><br>";
1136 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1137 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1138 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1139 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1140 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1141 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1142 $a=$netsettings{'GREEN_NETADDRESS'};
1143 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1144 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1145 $a=$netsettings{'ORANGE_NETADDRESS'};
1146 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1147 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1148 $a=$netsettings{'BLUE_NETADDRESS'};
1149 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1150 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1151 &General
::readhash
("$configovpn",\
%ovpnsettings);
1152 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1153 $b=&General
::iporsubtocidr
($b);
1155 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1156 &General
::readhasharray
("$confignet", \
%customnetwork);
1157 foreach my $key (keys %customnetwork){
1158 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1159 $a=$customnetwork{$key}[1];
1160 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1163 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1164 &General
::readhasharray
("$confighost", \
%customhost);
1165 foreach my $key (keys %customhost){
1166 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1167 if ($customhost{$key}[1] eq 'ip'){
1168 ($a,$b)=split (/\//,$customhost{$key}[2]);
1169 $b=&General
::iporsubtocidr
($b);
1171 if ($grp eq 'grp2'){
1172 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1184 &General
::setup_default_networks
(\
%defaultNetworks);
1185 foreach my $network (sort keys %defaultNetworks)
1187 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1192 my %hash=%{(shift)};
1194 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1195 $hash{$key}[10]=~ s/\|/,/g;
1196 print": $hash{$key}[10]";
1197 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1198 print": <br>$hash{$key}[9] ";
1203 my %hash=%{(shift)};
1207 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1208 if($hash{$key}[14] eq 'cust_srv'){
1209 &General
::readhasharray
("$configsrv", \
%customservice);
1210 foreach my $i (sort keys %customservice){
1211 if($customservice{$i}[0] eq $hash{$key}[15]){
1212 $service = $customservice{$i}[0];
1215 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1216 $service=$hash{$key}[15];
1217 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1218 $hash{$key}[15]=~ s/\|/,/g;
1219 $service=$hash{$key}[15];
1226 sub get_serviceports
1230 &General
::readhasharray
("$configsrv", \
%customservice);
1231 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1233 my @specprot=("IPIP","IPV6","IGMP","GRE","AH","ESP");
1234 if($type eq 'service'){
1235 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1236 if ($customservice{$key}[0] eq $name){
1237 push (@protocols,$customservice{$key}[2]);
1240 }elsif($type eq 'group'){
1241 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1242 if ($customservicegrp{$key}[0] eq $name){
1243 if ($customservicegrp{$key}[2] ~~ @specprot){
1244 push (@protocols," ".$customservicegrp{$key}[2]);
1246 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1247 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1248 if (!grep(/$customservice{$key1}[2]/, @protocols)){
1249 push (@protocols,$customservice{$key1}[2]);}
1257 # Sort protocols alphabetically.
1258 @protocols = sort(@protocols);
1267 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1268 # Don't colourise MAC addresses
1269 if (&General
::validmac
($val)) {
1275 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1276 foreach my $key (sort keys %$hash){
1277 if ($$hash{$key}[0] eq $val){
1278 $val=$$hash{$key}[2];
1283 if ($val eq 'GREEN'){
1284 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1286 }elsif ($val eq 'ORANGE'){
1287 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1289 }elsif ($val eq 'BLUE'){
1290 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1292 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1293 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1295 }elsif ($val eq 'IPFire' ){
1296 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1298 }elsif ($val eq 'OpenVPN-Dyn' ){
1299 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1301 }elsif ($val eq 'IPsec RW' ){
1302 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1304 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1305 my ($sip,$scidr) = split ("/",$val);
1306 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1307 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1310 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1311 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1314 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1315 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1318 }elsif ($val eq 'Default IP'){
1319 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1322 #Check if a manual IP or custom host is part of a VPN
1323 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1324 #Check if IP is part of OpenVPN dynamic subnet
1325 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1326 my ($c,$d) = split("/",$val);
1327 if (&General
::IpInSubnet
($c,$a,$b)){
1328 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1331 #Check if IP is part of OpenVPN static subnet
1332 foreach my $key (sort keys %ccdnet){
1333 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1334 $b =&General
::iporsubtodec
($b);
1335 if (&General
::IpInSubnet
($c,$a,$b)){
1336 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1340 #Check if IP is part of OpenVPN N2N subnet
1341 foreach my $key (sort keys %ccdhost){
1342 if ($ccdhost{$key}[3] eq 'net'){
1343 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1344 if (&General
::IpInSubnet
($c,$a,$b)){
1345 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1350 #Check if IP is part of IPsec RW network
1351 if ($ipsecsettings{'RW_NET'} ne ''){
1352 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1353 $b=&General
::iporsubtodec
($b);
1354 if (&General
::IpInSubnet
($c,$a,$b)){
1355 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1359 #Check if IP is part of a IPsec N2N network
1360 foreach my $key (sort keys %ipsecconf){
1361 if ($ipsecconf{$key}[11]){
1362 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1363 $b=&General
::iporsubtodec
($b);
1364 if (&General
::IpInSubnet
($c,$a,$b)){
1365 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1372 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'){
1373 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1376 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1377 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1381 foreach my $alias (sort keys %aliases)
1383 if ($val eq $alias){
1384 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1395 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1396 print "<class name='base'>$hint\n";
1397 print " </class>\n";
1398 &Header
::closebox
();
1404 &General
::setup_default_networks
(\
%defaultNetworks);
1405 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1406 #read all configfiles
1407 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1408 &General
::readhasharray
("$confignet", \
%customnetwork);
1409 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1410 &General
::readhasharray
("$confighost", \
%customhost);
1411 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1412 &General
::readhasharray
("$configgrp", \
%customgrp);
1413 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1414 &General
::get_aliases
(\
%aliases);
1418 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1419 my $config=$fwdfwsettings{'config'};
1422 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1423 my $redip = <CONN1
>;
1425 if (! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE2'){
1426 $fwdfwsettings{'RULE_ACTION'}='DROP';
1427 }elsif(! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE1'){
1428 $fwdfwsettings{'RULE_ACTION'}='ACCEPT';
1430 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1431 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1432 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1433 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1434 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1435 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1436 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1437 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1438 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1439 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1440 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1441 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1442 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1443 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1444 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1445 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1446 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1447 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1448 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1449 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1450 #check if update and get values
1451 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1452 &General
::readhasharray
("$config", \
%hash);
1453 foreach my $key (sort keys %hash){
1455 if ($key eq $fwdfwsettings{'key'}){
1456 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1457 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1458 $fwdfwsettings{'chain'} = $hash{$key}[1];
1459 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1460 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1461 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1462 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1463 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1464 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1465 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1466 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1467 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1468 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1469 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1470 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1471 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1472 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1473 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1474 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1475 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1476 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1477 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1478 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1479 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1480 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1481 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1482 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1483 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1484 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1485 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1486 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1487 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1488 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1489 $fwdfwsettings{'LIMIT_CON_CON'} = $hash{$key}[32];
1490 $fwdfwsettings{'concon'} = $hash{$key}[33];
1491 $fwdfwsettings{'RATE_LIMIT'} = $hash{$key}[34];
1492 $fwdfwsettings{'ratecon'} = $hash{$key}[35];
1493 $fwdfwsettings{'RATETIME'} = $hash{$key}[36];
1494 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1495 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1496 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1497 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1498 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1499 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1500 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1501 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1502 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1503 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1504 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1505 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1506 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1507 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1508 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1509 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1510 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1511 $checked{'LIMIT_CON_CON'}{$fwdfwsettings{'LIMIT_CON_CON'}} = 'CHECKED';
1512 $checked{'RATE_LIMIT'}{$fwdfwsettings{'RATE_LIMIT'}} = 'CHECKED';
1513 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1514 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1515 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1516 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1517 $selected{'dnat'}{$fwdfwsettings{'dnat'}} ='selected';
1518 $selected{'snat'}{$fwdfwsettings{'snat'}} ='selected';
1519 $selected{'RATETIME'}{$fwdfwsettings{'RATETIME'}} ='selected';
1522 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1523 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1524 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1525 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1526 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1527 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1528 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1529 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1530 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1531 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1532 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1533 $fwdfwsettings{'olduseratelimit'}=$fwdfwsettings{'RATE_LIMIT'};
1534 $fwdfwsettings{'olduseratelimitamount'}=$fwdfwsettings{'ratecon'};
1535 $fwdfwsettings{'oldratelimittime'}=$fwdfwsettings{'RATETIME'};
1537 #check if manual ip (source) is orange network
1538 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1539 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1540 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1541 $fwdfwsettings{'oldorange'} ='on';
1545 $fwdfwsettings{'ACTIVE'}='ON';
1546 $fwdfwsettings{'nat'} = 'dnat';
1547 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1548 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1549 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1550 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1551 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1552 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1553 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1554 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1555 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1556 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1557 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1558 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1559 #check if manual ip (source) is orange network
1560 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1561 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1562 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1563 $fwdfwsettings{'oldorange'} ='on';
1567 # Split manual source and target address and delete the subnet
1568 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1569 if ($scidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp1'}}=$sip;}
1570 my ($dip,$dcidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp2'}});
1571 if ($dcidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp2'}}=$dip;}
1572 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1573 #------SOURCE-------------------------------------------------------
1574 print "<form method='post'>";
1576 <table width='100%' border='0'>
1577 <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>
1579 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1580 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1581 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1582 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1583 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1584 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1585 if (! -z
"${General::swroot}/ethernet/aliases"){
1586 foreach my $alias (sort keys %aliases)
1588 print "<option value='$alias' $selected{'ipfire_src'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1593 <tr><td><br></td></tr>
1596 &gen_dd_block
('src','grp1');
1597 &Header
::closebox
();
1599 #---SNAT / DNAT ------------------------------------------------
1600 &Header
::openbox
('100%', 'left', 'NAT');
1603 <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}>
1604 $Lang::tr{'fwdfw use nat'}
1607 <table class='fw-nat' width='100%' border='0'>
1609 <td width='5%'></td>
1612 <input type='radio' name='nat' value='dnat' $checked{'nat'}{'dnat'}>
1613 $Lang::tr{'fwdfw dnat'}
1619 <td width='25%' align='right'><span class='dnat'>$Lang::tr{'dnat address'}:</span></td>
1621 <select name='dnat' class='dnat' style='width: 100%;'>
1622 <option value='AUTO' $selected{'dnat'}{'AUTO'}>- $Lang::tr{'automatic'} -</option>
1623 <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'red1'} ($redip)</option>
1626 foreach my $alias (sort keys %aliases) {
1627 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1631 foreach my $network (sort keys %defaultNetworks)
1633 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1634 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1635 print " selected='selected'" if ($fwdfwsettings{'dnat'} eq $defaultNetworks{$network}{'NAME'});
1636 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1645 <td width='5%'></td>
1648 <input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}>
1649 $Lang::tr{'fwdfw snat'}
1652 <td width='25%' align='right'><span class='snat'>$Lang::tr{'snat new source ip address'}:</span></td>
1654 <select name='snat' class='snat' style='width: 100%;'>
1657 foreach my $alias (sort keys %aliases) {
1658 print "<option value='$alias' $selected{'snat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1661 foreach my $network (sort keys %defaultNetworks) {
1662 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1663 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1664 print " selected='selected'" if ($fwdfwsettings{'snat'} eq $defaultNetworks{$network}{'NAME'});
1665 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1675 &Header
::closebox
();
1677 #---TARGET------------------------------------------------------
1678 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1680 <table width='100%' border='0'>
1681 <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>
1683 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1684 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1685 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1686 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1687 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1688 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1689 if (! -z
"${General::swroot}/ethernet/aliases"){
1690 foreach my $alias (sort keys %aliases)
1692 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1697 <tr><td><br></td></tr></table>
1699 &gen_dd_block
('tgt','grp2');
1701 #---PROTOCOL------------------------------------------------------
1702 $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
1703 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1704 $fwdfwsettings{'dnatport'} =~ tr/|/,/;
1706 # The dnatport may be empty, if it matches TGT_PORT
1707 if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
1708 $fwdfwsettings{'dnatport'} = "";
1711 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1712 #Fix Protocol for JQuery
1713 if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
1714 $fwdfwsettings{'PROT'} = 'template';
1717 <table width='100%' border='0'>
1720 <select name='PROT' id='protocol' style="width: 95px;">
1722 print "<option value=\"\"";
1723 if ($fwdfwsettings{'PROT'} eq '') {
1724 print " selected=\"selected\"";
1726 print ">$Lang::tr{'all'}</option>";
1728 print "<option value=\"template\"";
1729 print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp');
1730 print ">- $Lang::tr{'template'} -</option>";
1732 foreach (@PROTOCOLS) {
1733 print"<option value=\"$_\"";
1734 if ($_ eq $fwdfwsettings{'PROT'}) {
1735 print " selected=\"selected\"";
1738 print ">$Lang::tr{'fwdfw prot41'}</option>";
1740 print ">$_</option>";
1748 <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES">
1750 <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
1752 <select name='ICMP_TYPES' style='min-width:230px;'>
1754 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1755 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1756 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1757 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1758 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1760 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1770 <table width="100%" border="0" id="PROTOCOL_PORTS">
1772 <!-- #SOURCEPORT -->
1774 $Lang::tr{'fwdfw use srcport'}
1777 <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
1782 <!-- #TARGETPORT -->
1784 $Lang::tr{'fwdfw use srv'}
1788 <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
1792 <td colspan='3'></td>
1793 <td>$Lang::tr{'fwdfw external port nat'}:</td>
1795 <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
1800 <table width="100%" border="0" id="PROTOCOL_TEMPLATE">
1803 <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
1804 $Lang::tr{'fwhost cust service'}
1807 <select name='cust_srv' style='min-width: 230px;'>
1810 &General
::readhasharray
("$configsrv", \
%customservice);
1811 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1813 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1814 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1823 <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
1824 $Lang::tr{'fwhost cust srvgrp'}
1827 <select name='cust_srvgrp' style='min-width:230px;'>
1830 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1832 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1833 if ($helper ne $customservicegrp{$key}[0] && $customservicegrp{$key}[2] ne 'none'){
1835 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1836 print">$customservicegrp{$key}[0]</option>";
1838 $helper=$customservicegrp{$key}[0];
1852 $checked{"RULE_ACTION"}{$fwdfwsettings{'RULE_ACTION'}} = 'CHECKED';
1855 <table width="80%" class='tbl' id='actions'>
1857 <td width="33%" align="center" bgcolor="$color{'color17'}">
1860 <td width="33%" align="center" bgcolor="$color{'color25'}">
1863 <td width="33%" align="center" bgcolor="$color{'color16'}">
1868 <td width="33%" align="center">
1870 <input type="radio" name="RULE_ACTION" value="ACCEPT" $checked{"RULE_ACTION"}{"ACCEPT"}>
1871 <strong>$Lang::tr{'fwdfw ACCEPT'}</strong>
1874 <td width="33%" align="center">
1876 <input type="radio" name="RULE_ACTION" value="DROP" $checked{"RULE_ACTION"}{"DROP"}>
1877 <strong>$Lang::tr{'fwdfw DROP'}</strong>
1880 <td width="33%" align="center">
1882 <input type="radio" name="RULE_ACTION" value="REJECT" $checked{"RULE_ACTION"}{"REJECT"}>
1883 <strong>$Lang::tr{'fwdfw REJECT'}</strong>
1892 #---Activate/logging/remark-------------------------------------
1893 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1895 <table width='100%' border='0'>
1897 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>";
1898 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1899 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1900 for (my $count =1; $count <= $sum; $count++){
1901 print"<option value='$count' ";
1902 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1903 print">$count</option>";
1905 print"</select></td></tr>";
1907 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1912 <table width='100%'>
1916 if ($fwdfwsettings{'updatefwrule'} eq 'on') {
1919 <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}>
1921 <td>$Lang::tr{'fwdfw rule activate'}</td>
1926 <input type="hidden" name="ACTIVE" value="ON">
1935 <input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'}>
1937 <td>$Lang::tr{'fwdfw log rule'}</td>
1941 <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}>
1943 <td>$Lang::tr{'fwdfw timeframe'}</td>
1945 <tr id="TIME_CONSTRAINTS">
1947 <table width="66%" border="0">
1949 <td width="8em"> </td>
1950 <td align="center">$Lang::tr{'advproxy monday'}</td>
1951 <td align="center">$Lang::tr{'advproxy tuesday'}</td>
1952 <td align="center">$Lang::tr{'advproxy wednesday'}</td>
1953 <td align="center">$Lang::tr{'advproxy thursday'}</td>
1954 <td align="center">$Lang::tr{'advproxy friday'}</td>
1955 <td align="center">$Lang::tr{'advproxy saturday'}</td>
1956 <td align="center">$Lang::tr{'advproxy sunday'}</td>
1960 <td width="8em"> </td>
1961 <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
1962 <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
1963 <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
1964 <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
1965 <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
1966 <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
1967 <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
1969 <select name='TIME_FROM'>
1971 for (my $i=0;$i<=23;$i++) {
1972 $i = sprintf("%02s",$i);
1973 for (my $j=0;$j<=45;$j+=15) {
1974 $j = sprintf("%02s",$j);
1975 my $time = $i.":".$j;
1976 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1981 <select name='TIME_TO'>
1983 for (my $i=0;$i<=23;$i++) {
1984 $i = sprintf("%02s",$i);
1985 for (my $j=0;$j<=45;$j+=15) {
1986 $j = sprintf("%02s",$j);
1987 my $time = $i.":".$j;
1988 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
2000 <input type='checkbox' name='LIMIT_CON_CON' id="USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP" value='ON' $checked{'LIMIT_CON_CON'}{'ON'}>
2002 <td>$Lang::tr{'fwdfw limitconcon'}</td>
2006 <table width='66%' border='0'>
2008 <td width="20em"> </td>
2009 <td>$Lang::tr{'fwdfw maxconcon'}: <input type='text' name='concon' size='2' value="$fwdfwsettings{'concon'}"></td>
2016 <input type='checkbox' name='RATE_LIMIT' id="USE_RATELIMIT" value='ON' $checked{'RATE_LIMIT'}{'ON'}>
2018 <td>$Lang::tr{'fwdfw ratelimit'}</td>
2022 <table width='66%' border='0'>
2024 <td width="20em"> </td>
2025 <td>$Lang::tr{'fwdfw numcon'}: <input type='text' name='ratecon' size='2' value="$fwdfwsettings{'ratecon'}"> /
2026 <select name='RATETIME' style='width:100px;'>
2027 <option value='second' $selected{'RATETIME'}{'second'}>$Lang::tr{'age second'}</option>
2028 <option value='minute' $selected{'RATETIME'}{'minute'}>$Lang::tr{'minute'}</option>
2029 <option value='hour' $selected{'RATETIME'}{'hour'}>$Lang::tr{'hour'}</option>
2040 #---ACTION------------------------------------------------------
2041 if($fwdfwsettings{'updatefwrule'} ne 'on'){
2043 <table border='0' width='100%'>
2044 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
2045 <input type='hidden' name='config' value='$config' >
2046 <input type='hidden' name='ACTION' value='saverule' ></form>
2047 <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>
2053 <table border='0' width='100%'>
2054 <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'}'>
2055 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
2056 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
2057 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
2058 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
2059 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
2060 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
2061 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
2062 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
2063 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
2064 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
2065 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
2066 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
2067 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
2068 <input type='hidden' name='oldconcon' value='$fwdfwsettings{'oldconcon'}' />
2069 <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>
2073 &Header
::closebox
();
2079 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
2080 foreach my $key (sort keys %uphash){
2081 if ($key eq $fwdfwsettings{'key'}) {
2083 if (exists $uphash{$last}){
2085 foreach my $y (0 .. $#{$uphash{$last}}) {
2086 $tmp{0}[$y] = $uphash{$last}[$y];
2088 #copy active rule to last
2089 foreach my $i (0 .. $#{$uphash{$last}}) {
2090 $uphash{$last}[$i] = $uphash{$key}[$i];
2092 #copy saved rule to actual position
2093 foreach my $x (0 .. $#{$tmp{0}}) {
2094 $uphash{$key}[$x] = $tmp{0}[$x];
2099 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
2100 &General
::firewall_config_changed
();
2106 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
2107 foreach my $key (sort keys %downhash){
2108 if ($key eq $fwdfwsettings{'key'}) {
2109 my $next = $key + 1;
2110 if (exists $downhash{$next}){
2112 foreach my $y (0 .. $#{$downhash{$next}}) {
2113 $tmp{0}[$y] = $downhash{$next}[$y];
2115 #copy active rule to next
2116 foreach my $i (0 .. $#{$downhash{$next}}) {
2117 $downhash{$next}[$i] = $downhash{$key}[$i];
2119 #copy saved rule to actual position
2120 foreach my $x (0 .. $#{$tmp{0}}) {
2121 $downhash{$key}[$x] = $tmp{0}[$x];
2126 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
2127 &General
::firewall_config_changed
();
2133 &General
::readhasharray
("$config", $hash);
2134 if (!$errormessage){
2135 ################################################################
2136 #check if we change an INPUT rule to a OUTGOING
2137 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2138 &changerule
($configinput);
2141 #check if we change an INPUT rule to a FORWARD
2142 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2143 &changerule
($configinput);
2146 ################################################################
2147 #check if we change an OUTGOING rule to an INPUT
2148 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2149 &changerule
($configoutgoing);
2152 #check if we change an OUTGOING rule to a FORWARD
2153 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2154 &changerule
($configoutgoing);
2157 ################################################################
2158 #check if we change a FORWARD rule to an INPUT
2159 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2160 &changerule
($configfwdfw);
2163 #check if we change a FORWARD rule to an OUTGOING
2164 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2165 &changerule
($configfwdfw);
2168 $fwdfwsettings{'ruleremark'}=~ s/,/;/g;
2169 utf8
::decode
($fwdfwsettings{'ruleremark'});
2170 $fwdfwsettings{'ruleremark'}=&Header
::escape
($fwdfwsettings{'ruleremark'});
2171 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2172 my $key = &General
::findhasharraykey
($hash);
2173 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2174 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2175 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2176 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2177 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2178 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2179 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2180 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2181 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2182 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2183 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2184 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2185 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2186 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2187 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2188 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2189 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2190 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2191 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2192 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2193 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2194 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2195 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2196 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2197 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2198 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2199 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2200 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2201 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2202 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2203 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2204 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2205 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2206 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2207 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2208 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2209 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2210 &General
::writehasharray
("$config", $hash);
2212 foreach my $key (sort {$a <=> $b} keys %$hash){
2213 if($key eq $fwdfwsettings{'key'}){
2214 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2215 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2216 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2217 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2218 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2219 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2220 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2221 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2222 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2223 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2224 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2225 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2226 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2227 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2228 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2229 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2230 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2231 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2232 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2233 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2234 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2235 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2236 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2237 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2238 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2239 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2240 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2241 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2242 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2243 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2244 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2245 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2246 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2247 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2248 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2249 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2250 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2255 &General
::writehasharray
("$config", $hash);
2256 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2258 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2259 for (my $z=0;$z<$val;$z++){
2260 foreach my $key (sort {$a <=> $b} keys %$hash){
2261 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2263 if (exists $$hash{$last}){
2265 foreach my $y (0 .. $#{$$hash{$last}}) {
2266 $tmp{0}[$y] = $$hash{$last}[$y];
2268 #copy active rule to last
2269 foreach my $i (0 .. $#{$$hash{$last}}) {
2270 $$hash{$last}[$i] = $$hash{$key}[$i];
2272 #copy saved rule to actual position
2273 foreach my $x (0 .. $#{$tmp{0}}) {
2274 $$hash{$key}[$x] = $tmp{0}[$x];
2279 $fwdfwsettings{'oldrulenumber'}--;
2281 &General
::writehasharray
("$config", $hash);
2282 &General
::firewall_config_changed
();
2283 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2285 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2286 for (my $z=0;$z<$val;$z++){
2287 foreach my $key (sort {$a <=> $b} keys %$hash){
2288 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2289 my $next = $key + 1;
2290 if (exists $$hash{$next}){
2292 foreach my $y (0 .. $#{$$hash{$next}}) {
2293 $tmp{0}[$y] = $$hash{$next}[$y];
2295 #copy active rule to next
2296 foreach my $i (0 .. $#{$$hash{$next}}) {
2297 $$hash{$next}[$i] = $$hash{$key}[$i];
2299 #copy saved rule to actual position
2300 foreach my $x (0 .. $#{$tmp{0}}) {
2301 $$hash{$key}[$x] = $tmp{0}[$x];
2306 $fwdfwsettings{'oldrulenumber'}++;
2308 &General
::writehasharray
("$config", $hash);
2309 &General
::firewall_config_changed
();
2315 # Checks a hostname against RFC1035
2318 # Try to decode $remark into UTF-8. If this doesn't work,
2319 # we assume that the string it not sane.
2320 if (!utf8
::decode
($remark)) {
2324 # Check if the string only contains of printable characters.
2325 if ($remark =~ /^[[:print:]]*$/) {
2332 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2334 &viewtablenew
(\
%configfwdfw, $configfwdfw, $Lang::tr
{'firewall rules'});
2335 &viewtablenew
(\
%configinputfw, $configinput, $Lang::tr
{'incoming firewall access'});
2336 &viewtablenew
(\
%configoutgoingfw, $configoutgoing, $Lang::tr
{'outgoing firewall access'});
2345 my $show_box = (! -z
$config) || ($optionsfw{'SHOWTABLES'} eq 'on');
2346 return if (!$show_box);
2348 &General
::get_aliases
(\
%aliases);
2349 &General
::readhasharray
("$confighost", \
%customhost);
2350 &General
::readhasharray
("$config", $hash);
2351 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2352 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2353 &General
::readhasharray
("$configgrp", \
%customgrp);
2354 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2356 &Header
::openbox
('100%', 'left', $title);
2357 print "<table width='100%' cellspacing='0' class='tbl'>";
2371 <th align='right' width='3%'>
2374 <th width='2%'></th>
2376 <b>$Lang::tr{'protocol'}</b>
2378 <th align='center' width='30%'>
2379 <b>$Lang::tr{'fwdfw source'}</b>
2382 <b>$Lang::tr{'fwdfw log'}</b>
2384 <th align='center' width='30%'>
2385 <b>$Lang::tr{'fwdfw target'}</b>
2387 <th align='center' colspan='6' width='18%'>
2388 <b>$Lang::tr{'fwdfw action'}</b>
2393 foreach my $key (sort {$a <=> $b} keys %$hash){
2397 #check if vpn hosts/nets have been deleted
2398 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2399 push (@tmpsrc,$$hash{$key}[4]);
2401 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2402 push (@tmptgt,$$hash{$key}[6]);
2404 foreach my $host (@tmpsrc){
2405 if($$hash{$key}[3] eq 'ipsec_net_src'){
2406 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2409 }elsif($$hash{$key}[3] eq 'ovpn_net_src'){
2410 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2413 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src'){
2414 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2417 }elsif($$hash{$key}[3] eq 'ovpn_host_src'){
2418 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2423 foreach my $host (@tmptgt){
2424 if($$hash{$key}[5] eq 'ipsec_net_tgt'){
2425 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2428 }elsif($$hash{$key}[5] eq 'ovpn_net_tgt'){
2429 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2432 }elsif($$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2433 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2436 }elsif($$hash{$key}[5] eq 'ovpn_host_tgt'){
2437 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2442 #check if networkgroups or servicegroups are empty
2443 foreach my $netgroup (sort keys %customgrp){
2444 if(($$hash{$key}[4] eq $customgrp{$netgroup}[0] || $$hash{$key}[6] eq $customgrp{$netgroup}[0]) && $customgrp{$netgroup}[2] eq 'none'){
2448 foreach my $srvgroup (sort keys %customservicegrp){
2449 if($$hash{$key}[15] eq $customservicegrp{$srvgroup}[0] && $customservicegrp{$srvgroup}[2] eq 'none'){
2453 $$hash{'ACTIVE'}=$$hash{$key}[2];
2455 if($coloryellow eq 'on'){
2456 $color="$color{'color14'}";
2458 }elsif($coloryellow eq ''){
2460 $color="$color{'color22'}";
2463 $color="$color{'color20'}";
2467 <tr bgcolor='$color'>
2468 <td align='right' width='3%'>
2474 if ($$hash{$key}[0] eq 'ACCEPT'){
2477 $rulecolor=$color{'color17'};
2478 }elsif($$hash{$key}[0] eq 'DROP'){
2481 $rulecolor=$color{'color25'};
2482 }elsif($$hash{$key}[0] eq 'REJECT'){
2485 $rulecolor=$color{'color16'};
2489 <td bgcolor='$rulecolor' align='center' width='2%'>
2490 <span title='$tooltip'> </span>
2496 if ($$hash{$key}[8]){
2497 if ($$hash{$key}[8] eq "IPv6"){
2498 push (@protocols,$Lang::tr
{'fwdfw prot41 short'})
2500 push (@protocols,$$hash{$key}[8]);
2502 }elsif($$hash{$key}[14] eq 'cust_srv'){
2503 &get_serviceports
("service",$$hash{$key}[15]);
2504 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2505 &get_serviceports
("group",$$hash{$key}[15]);
2507 push (@protocols,$Lang::tr
{'all'});
2510 my $protz=join(", ",@protocols);
2511 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2512 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2513 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2514 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2515 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2519 }elsif($#protocols gt '3'){
2520 print"<td align='center'><span title='$protz'>$Lang::tr{'fwdfw many'}</span></td>";
2522 print"<td align='center'>$protz</td>";
2527 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2528 print"<td align='center' width='30%' $tdcolor>";
2529 if ($$hash{$key}[3] eq 'ipfire_src'){
2530 $ipfireiface=$Lang::tr
{'fwdfw iface'};
2532 if ($$hash{$key}[3] eq 'std_net_src'){
2533 print &get_name
($$hash{$key}[4]);
2534 }elsif ($$hash{$key}[3] eq 'src_addr'){
2535 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2536 if ($split2 eq '32'){
2539 print $$hash{$key}[4];
2541 }elsif ($$hash{$key}[4] eq 'RED1'){
2542 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2543 }elsif ($$hash{$key}[4] eq 'ALL'){
2544 print "$ipfireiface $Lang::tr{'all'}";
2546 if ($$hash{$key}[4] eq 'GREEN' || $$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE' || $$hash{$key}[4] eq 'RED'){
2547 print "$ipfireiface $Lang::tr{lc($$hash{$key}[4])}";
2549 print "$ipfireiface $$hash{$key}[4]";
2554 &getsrcport
(\
%$hash,$key);
2555 #Is this a SNAT rule?
2556 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2557 my $net=&get_name
($$hash{$key}[29]);
2558 if ( ! $net){ $net=$$hash{$key}[29];}
2560 if ($$hash{$key}[30] ne ''){
2561 print": $$hash{$key}[30]";
2564 if ($$hash{$key}[17] eq 'ON'){
2565 $log="/images/on.gif";
2567 $log="/images/off.gif";
2573 <form method='POST' action=''>
2574 <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 ;'/>
2575 <input type='hidden' name='key' value='$key' />
2576 <input type='hidden' name='config' value='$config' />
2577 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2582 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2584 <td align='center' $tdcolor>
2586 #Is this a DNAT rule?
2588 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2589 if ($$hash{$key}[29] eq 'Default IP'){$$hash{$key}[29]=$Lang::tr
{'red1'};}
2590 if ($$hash{$key}[29] eq 'AUTO'){
2591 my @src_addresses=&fwlib
::get_addresses
(\
%$hash,$key,'src');
2593 foreach my $val (@src_addresses){
2594 push (@nat_ifaces,&fwlib
::get_nat_address
($$hash{$key}[29],$val));
2596 @nat_ifaces=&del_double
(@nat_ifaces);
2599 $natstring = "($$hash{$key}[29])";
2601 print "$Lang::tr{'firewall'} $natstring";
2602 if($$hash{$key}[30] ne ''){
2603 $$hash{$key}[30]=~ tr/|/,/;
2604 print": $$hash{$key}[30]";
2608 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire'){
2609 if ($$hash{$key}[6] eq 'RED1'){
2610 print "$Lang::tr{'red1'}";
2611 }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')
2613 print &get_name
($$hash{$key}[6]);
2615 print $$hash{$key}[6];
2617 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2618 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2619 if ($split2 eq '32'){
2622 print $$hash{$key}[6];
2625 print "$$hash{$key}[6]";
2629 &gettgtport
(\
%$hash,$key);
2632 if($$hash{$key}[2] eq 'ON'){
2633 $gif="/images/on.gif"
2636 $gif="/images/off.gif"
2639 <td width='3%' align='center'>
2640 <form method='POST' action=''>
2641 <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;' />
2642 <input type='hidden' name='key' value='$key' />
2643 <input type='hidden' name='config' value='$config' />
2644 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2647 <td width='3%' align='center'>
2648 <form method='POST' action=''>
2649 <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;' />
2650 <input type='hidden' name='key' value='$key' />
2651 <input type='hidden' name='config' value='$config' />
2652 <input type='hidden' name='ACTION' value='editrule' />
2655 <td width='3%' align='center'>
2656 <form method='POST' action=''>
2657 <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;' />
2658 <input type='hidden' name='key' value='$key' />
2659 <input type='hidden' name='config' value='$config' />
2660 <input type='hidden' name='ACTION' value='copyrule' />
2663 <td width='3%' align='center'>
2664 <form method='POST' action=''>
2665 <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;' />
2666 <input type='hidden' name='key' value='$key' />
2667 <input type='hidden' name='config' value='$config' />
2668 <input type='hidden' name='ACTION' value='deleterule' />
2672 if (exists $$hash{$key-1}){
2674 <td width='3%' align='center'>
2675 <form method='POST' action=''>
2676 <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;' />
2677 <input type='hidden' name='key' value='$key' />
2678 <input type='hidden' name='config' value='$config' />
2679 <input type='hidden' name='ACTION' value='moveup' />
2684 print"<td width='3%'></td>";
2687 if (exists $$hash{$key+1}){
2689 <td width='3%' align='center'>
2690 <form method='POST' action=''>
2691 <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;' />
2692 <input type='hidden' name='key' value='$key' />
2693 <input type='hidden' name='config' value='$config' />
2694 <input type='hidden' name='ACTION' value='movedown' />
2700 print"<td width='3%'></td></tr>";
2703 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2705 <tr bgcolor='$color'>
2707 <td bgcolor='$rulecolor'></td>
2709 <em>$$hash{$key}[16]</em>
2715 if ($$hash{$key}[18] eq 'ON'){
2717 if ($$hash{$key}[18] eq 'ON'){
2719 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2720 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2721 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2722 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2723 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2724 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2725 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2726 my $weekdays=join(",",@days);
2728 print"<tr bgcolor='$color'>";
2729 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27]</td></tr>";
2733 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2735 } elsif ($optionsfw{'SHOWTABLES'} eq 'on') {
2738 <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td>
2744 my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'};
2745 my $colour = "bgcolor='green'";
2746 if ($fwdfwsettings{'POLICY'} eq 'MODE1') {
2747 $colour = "bgcolor='darkred'";
2751 if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) {
2754 <td colspan='13'> </td>
2757 <td colspan='13' style="padding-left:0px;padding-right:0px">
2758 <table width="100%" border='1' rules="cols" cellspacing='0'>
2765 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2768 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2769 ($Lang::tr{'fwdfw pol allow'})
2773 if (&Header
::orange_used
()) {
2776 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2777 ($Lang::tr{'fwdfw pol allow'})
2782 if (&Header
::blue_used
()) {
2785 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2786 ($Lang::tr{'fwdfw pol allow'})
2794 if (&Header
::orange_used
()) {
2797 <td align='center' width='20%'>
2798 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2801 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2802 ($Lang::tr{'fwdfw pol allow'})
2805 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2806 ($Lang::tr{'fwdfw pol block'})
2810 if (&Header
::blue_used
()) {
2813 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2814 ($Lang::tr{'fwdfw pol block'})
2822 if (&Header
::blue_used
()) {
2826 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2829 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2830 ($Lang::tr{'fwdfw pol allow'})
2834 if (&Header
::orange_used
()) {
2837 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2838 ($Lang::tr{'fwdfw pol block'})
2845 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2846 ($Lang::tr{'fwdfw pol block'})
2858 $message = $Lang::tr
{'fwdfw pol allow'};
2860 } elsif ($config eq '/var/ipfire/firewall/outgoing' && ($fwdfwsettings{'POLICY1'} ne 'MODE1')) {
2861 $message = $Lang::tr
{'fwdfw pol allow'};
2862 $colour = "bgcolor='green'";
2864 $message = $Lang::tr
{'fwdfw pol block'};
2865 $colour = "bgcolor='darkred'";
2871 <td $colour align='center' colspan='13'>
2872 <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font>
2881 &Header
::closebox
();
2884 &Header
::closebigbox
();
2885 &Header
::closepage
();