]>
git.ipfire.org Git - 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';
26 use experimental
'smartmatch';
28 no warnings
'uninitialized';
30 # enable only the following on debugging purpose
32 #use CGI::Carp 'fatalsToBrowser';
34 require '/var/ipfire/general-functions.pl';
35 require '/var/ipfire/network-functions.pl';
36 require "${General::swroot}/lang.pl";
37 require "${General::swroot}/header.pl";
38 require "${General::swroot}/location-functions.pl";
39 require "/usr/lib/firewall/firewall-lib.pl";
41 unless (-d
"${General::swroot}/firewall") { &General
::system("mkdir", "${General::swroot}/firewall"); }
42 unless (-e
"${General::swroot}/firewall/settings") { &General
::system("touch", "${General::swroot}/firewall/settings"); }
43 unless (-e
"${General::swroot}/firewall/config") { &General
::system("touch", "${General::swroot}/firewall/config"); }
44 unless (-e
"${General::swroot}/firewall/input") { &General
::system("touch", "${General::swroot}/firewall/input"); }
45 unless (-e
"${General::swroot}/firewall/outgoing") { &General
::system("touch", "${General::swroot}/firewall/outgoing"); }
49 my %defaultNetworks=();
53 my %customlocationgrp=();
54 my %customnetworks=();
56 my %customservicegrp=();
62 my %configoutgoingfw=();
75 my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE","IPv6","IPIP");
78 my $confignet = "${General::swroot}/fwhosts/customnetworks";
79 my $confighost = "${General::swroot}/fwhosts/customhosts";
80 my $configgrp = "${General::swroot}/fwhosts/customgroups";
81 my $configlocationgrp = "${General::swroot}/fwhosts/customlocationgrp";
82 my $configsrv = "${General::swroot}/fwhosts/customservices";
83 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
84 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
85 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
86 my $configipsec = "${General::swroot}/vpn/config";
87 my $configipsecrw = "${General::swroot}/vpn/settings";
88 my $configfwdfw = "${General::swroot}/firewall/config";
89 my $configinput = "${General::swroot}/firewall/input";
90 my $configoutgoing = "${General::swroot}/firewall/outgoing";
91 my $configovpn = "${General::swroot}/ovpn/settings";
92 my $fwoptions = "${General::swroot}/optionsfw/settings";
93 my $ifacesettings = "${General::swroot}/ethernet/settings";
96 my $ipgrp="${General::swroot}/outgoing/groups";
100 &General
::readhash
("${General::swroot}/firewall/settings", \
%fwdfwsettings);
101 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
102 &General
::readhash
("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \
%color);
103 &General
::readhash
($fwoptions, \
%optionsfw);
104 &General
::readhash
($ifacesettings, \
%ifaces);
105 &General
::readhash
("$configovpn", \
%ovpnsettings);
106 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
107 &General
::readhasharray
("$configipsec", \
%ipsecconf);
108 &Header
::showhttpheaders
();
109 &Header
::getcgihash
(\
%fwdfwsettings);
110 &Header
::openpage
($Lang::tr
{'firewall rules'}, 1, '');
111 &Header
::openbigbox
('100%', 'center',$errormessage);
112 #### JAVA SCRIPT ####
115 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
117 var update_protocol = function() {
118 var protocol = \$("#protocol").val();
120 if (protocol === undefined)
123 // Check if a template is/should be used.
124 if (protocol === "template") {
125 \$("#PROTOCOL_TEMPLATE").show();
127 \$("#PROTOCOL_TEMPLATE").hide();
130 // Check if we are dealing with a protocol, that knows ports.
131 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
132 \$("#PROTOCOL_PORTS").show();
134 \$("#PROTOCOL_PORTS").hide();
138 if (protocol === "ICMP") {
139 \$("#PROTOCOL_ICMP_TYPES").show();
141 \$("#PROTOCOL_ICMP_TYPES").hide();
145 \$(document).ready(function() {
146 \$("#protocol").change(update_protocol);
149 // Show/Hide elements when NAT checkbox is checked.
150 if (\$("#USE_NAT").attr("checked")) {
151 \$("#actions").hide();
156 // Show NAT area when "use nat" checkbox is clicked
157 \$("#USE_NAT").change(function() {
159 \$("#actions").toggle();
162 // Hide SNAT items when DNAT is selected and vice versa.
163 if (\$('input[name=nat]:checked').val() == 'dnat') {
169 // Show/Hide elements when SNAT/DNAT get changed.
170 \$('input[name=nat]').change(function() {
171 \$('.snat').toggle();
172 \$('.dnat').toggle();
176 if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) {
177 \$("#TIME_CONSTRAINTS").hide();
179 \$("#USE_TIME_CONSTRAINTS").change(function() {
180 \$("#TIME_CONSTRAINTS").toggle();
183 // Limit concurrent connections per ip
184 if(!\$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").attr("checked")) {
185 \$("#LIMIT_CON").hide();
187 \$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").change(function() {
188 \$("#LIMIT_CON").toggle();
191 // Rate-limit new connections
192 if(!\$("#USE_RATELIMIT").attr("checked")) {
193 \$("#RATELIMIT").hide();
195 \$("#USE_RATELIMIT").change(function() {
196 \$("#RATELIMIT").toggle();
199 // Automatically select radio buttons when corresponding
200 // dropdown menu changes.
201 \$("select").change(function() {
202 var id = \$(this).attr("name");
203 \$('#' + id).prop("checked", true);
211 if ($fwdfwsettings{'ACTION'} eq 'saverule')
213 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
214 &General
::readhasharray
("$configinput", \
%configinputfw);
215 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
217 #Set Variables according to the JQuery code in protocol section
218 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')
220 if ($fwdfwsettings{'SRC_PORT'} ne '')
222 $fwdfwsettings{'USE_SRC_PORT'} = 'ON';
224 if ($fwdfwsettings{'TGT_PORT'} ne '')
226 $fwdfwsettings{'USESRV'} = 'ON';
227 $fwdfwsettings{'grp3'} = 'TGT_PORT';
230 if ($fwdfwsettings{'PROT'} eq 'template')
232 $fwdfwsettings{'USESRV'} = 'ON';
234 $errormessage=&checksource
;
235 if(!$errormessage){&checktarget
;}
236 if(!$errormessage){&checkrule
;}
238 #check if manual ip (source) is orange network
239 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
240 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
241 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
245 #check if we try to break rules
246 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
247 $errormessage=$Lang::tr
{'fwdfw err same'};
250 if ($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
251 $fwdfwsettings{'config'}=$configinput;
252 $fwdfwsettings{'chain'} = 'INPUTFW';
253 $maxkey=&General
::findhasharraykey
(\
%configinputfw);
254 %rulehash=%configinputfw;
255 }elsif ($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
257 $fwdfwsettings{'config'}=$configoutgoing;
258 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
259 $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
260 %rulehash=%configoutgoingfw;
263 $fwdfwsettings{'config'}=$configfwdfw;
264 $fwdfwsettings{'chain'} = 'FORWARDFW';
265 $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
266 %rulehash=%configfwdfw;
268 #check if we have an identical rule already
269 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
270 foreach my $key (sort keys %rulehash){
271 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'}"
272 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]"){
273 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
274 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
275 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
277 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
280 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
281 $fwdfwsettings{'nosave'} = 'on';
286 #check Rulepos on new Rule
287 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
288 $fwdfwsettings{'oldrulenumber'}=$maxkey;
289 foreach my $key (sort keys %rulehash){
290 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'}"
291 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]"){
292 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
296 #check if we just close a rule
297 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'}){
298 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
299 $fwdfwsettings{'nosave2'} = 'on';
303 #check max concurrent connections per ip address
304 if ($fwdfwsettings{'LIMIT_CON_CON'} eq 'ON'){
305 if (!($fwdfwsettings{'concon'} =~ /^(\d+)$/)) {
306 $errormessage.=$Lang::tr
{'fwdfw err concon'};
309 $fwdfwsettings{'concon'}='';
311 #check ratelimit value
312 if ($fwdfwsettings{'RATE_LIMIT'} eq 'ON'){
313 if (!($fwdfwsettings{'ratecon'} =~ /^(\d+)$/)) {
314 $errormessage.=$Lang::tr
{'fwdfw err ratecon'};
317 $fwdfwsettings{'ratecon'}='';
321 if ($fwdfwsettings{'nosave2'} ne 'on'){
322 &saverule
(\
%rulehash,$fwdfwsettings{'config'});
328 if($fwdfwsettings{'nosave2'} ne 'on'){
329 &General
::firewall_config_changed
();
334 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
338 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
341 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
342 foreach my $key (sort keys %togglehash){
343 if ($key eq $fwdfwsettings{'key'}){
344 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
347 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
348 &General
::firewall_config_changed
();
351 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
354 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
355 foreach my $key (sort keys %togglehash){
356 if ($key eq $fwdfwsettings{'key'}){
357 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
360 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
361 &General
::firewall_config_changed
();
364 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
366 &General
::firewall_reload
();
369 if ($fwdfwsettings{'ACTION'} eq 'editrule')
371 $fwdfwsettings{'updatefwrule'}='on';
374 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
378 if ($fwdfwsettings{'ACTION'} eq 'moveup')
383 if ($fwdfwsettings{'ACTION'} eq 'movedown')
388 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
390 $fwdfwsettings{'copyfwrule'}='on';
393 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
402 &Header
::openbox
('100%', 'left', "");
404 <form method="POST" action="">
405 <table border='0' width="100%">
408 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'>
411 if (&General
::firewall_needs_reload
()) {
413 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'>
437 $fwdfwsettings{'updatefwrule'}='';
438 $fwdfwsettings{'config'}=$oldchain;
439 $fwdfwsettings{'nobase'}='on';
445 #check ip-address if manual
446 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
447 #check if ip with subnet
448 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
449 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
450 $subnet = &General
::iporsubtocidr
($subnet);
451 $fwdfwsettings{'isip'}='on';
454 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
455 $ip=$fwdfwsettings{'src_addr'};
457 $fwdfwsettings{'isip'}='on';
460 if ($fwdfwsettings{'isip'} ne 'on'){
461 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
462 $fwdfwsettings{'ismac'}='on';
465 if ($fwdfwsettings{'isip'} eq 'on'){
467 $ip = &Network
::ip_remove_zero
($ip);
469 ##check if ip is valid
470 if (! &General
::validip
($ip)){
471 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
472 return $errormessage;
474 #check and form valid IP
475 $ip=&General
::ip2dec
($ip);
476 $ip=&General
::dec2ip
($ip);
477 #check if net or broadcast
478 $fwdfwsettings{'src_addr'}="$ip/$subnet";
479 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
480 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
481 return $errormessage;
484 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
485 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
486 return $errormessage;
488 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
489 $fwdfwsettings{'grp1'}='std_net_src';
490 $fwdfwsettings{$fwdfwsettings{'grp1'}} = 'ALL';
494 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
495 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
496 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
500 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
502 #change dashes with :
505 push(@values,"1:65535");
508 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
509 push(@values,"1:$2");
512 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
513 push(@values,"$1:65535");
516 $errormessage .= &General
::validportrange
($_, 'destination');
521 if (&General
::validport
($_)){
528 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
530 return $errormessage;
535 &General
::readhasharray
("$configsrv", \
%customservice);
536 #check DNAT settings (has to be single Host and single Port or portrange)
537 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
538 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
539 #check if Port is a single Port or portrange
540 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
541 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
542 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
543 return $errormessage;
545 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
546 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
547 return $errormessage;
551 if ($fwdfwsettings{'grp2'} ne 'ipfire'){
552 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
553 return $errormessage;
557 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
558 #check if ip with subnet
559 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
560 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
561 $subnet = &General
::iporsubtocidr
($subnet);
565 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
566 $ip=$fwdfwsettings{'tgt_addr'};
570 $ip = &Network
::ip_remove_zero
($ip);
572 #check if ip is valid
573 if (! &General
::validip
($ip)){
574 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
575 return $errormessage;
577 #check and form valid IP
578 $ip=&General
::ip2dec
($ip);
579 $ip=&General
::dec2ip
($ip);
580 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
581 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
582 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
583 return $errormessage;
585 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
586 $fwdfwsettings{'grp2'}='std_net_tgt';
587 $fwdfwsettings{$fwdfwsettings{'grp2'}} = 'ALL';
589 #check for mac in targetgroup
590 if ($fwdfwsettings{'grp2'} eq 'cust_grp_tgt'){
591 &General
::readhasharray
("$configgrp", \
%customgrp);
592 &General
::readhasharray
("$confighost", \
%customhost);
593 foreach my $grpkey (sort keys %customgrp){
594 foreach my $hostkey (sort keys %customhost){
595 if ($customgrp{$grpkey}[2] eq $customhost{$hostkey}[0] && $customgrp{$grpkey}[2] eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $customhost{$hostkey}[1] eq 'mac'){
596 $hint=$Lang::tr
{'fwdfw hint mac'};
603 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
605 if ($fwdfwsettings{'USESRV'} eq 'ON'){
606 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
607 $fwdfwsettings{'TGT_PROT'}='';
608 $fwdfwsettings{'ICMP_TGT'}='';
609 $fwdfwsettings{'TGT_PORT'}='';
611 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
612 $fwdfwsettings{'TGT_PROT'}='';
613 $fwdfwsettings{'ICMP_TGT'}='';
614 $fwdfwsettings{'TGT_PORT'}='';
615 #check target service
616 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
617 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
620 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
621 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
622 if ($fwdfwsettings{'TGT_PORT'} ne ''){
623 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
624 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
625 return $errormessage;
627 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
631 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
633 #change dashes with :
636 push(@values,"1:65535");
639 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
640 push(@values,"1:$2");
643 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
644 push(@values,"$1:65535");
647 $errormessage .= &General
::validportrange
($_, 'destination');
652 if (&General
::validport
($_)){
655 $errormessage=$Lang::tr
{'fwdfw err tgt_port'};
656 return $errormessage;
660 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
662 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
663 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
664 $fwdfwsettings{'TGT_PORT'} = '';
665 $fwdfwsettings{'ICMP_TGT'} = '';
666 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
667 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
668 $fwdfwsettings{'TGT_PORT'} = '';
669 $fwdfwsettings{'ICMP_TGT'}='';
670 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
671 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
672 $fwdfwsettings{'TGT_PORT'} = '';
673 $fwdfwsettings{'ICMP_TGT'}='';
674 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
675 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
676 $fwdfwsettings{'TGT_PORT'} = '';
681 if ($fwdfwsettings{'USESRV'} ne 'ON'){
682 $fwdfwsettings{'grp3'}='';
683 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
684 $fwdfwsettings{'ICMP_TGT'}='';
687 if($fwdfwsettings{'TIME'} eq 'ON'){
688 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 ''){
689 $errormessage=$Lang::tr
{'fwdfw err time'};
690 return $errormessage;
693 return $errormessage;
698 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
699 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
700 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
701 if ($fwdfwsettings{'dnatport'} eq "*") {
702 $fwdfwsettings{'dnatport'}="1:65535";
704 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
705 $fwdfwsettings{'dnatport'} = "1:$2";
707 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
708 $fwdfwsettings{'dnatport'} ="$1:65535";
713 if ($val =~ "," || $val>65536 || $val<0){
720 #check valid port for NAT
721 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
722 #RULE_ACTION must be ACCEPT if we use NAT
723 $fwdfwsettings{'RULE_ACTION'} = 'ACCEPT';
725 #if no dnat or snat selected errormessage
726 if ($fwdfwsettings{'nat'} eq ''){
727 $errormessage=$Lang::tr
{'fwdfw dnat nochoice'};
731 #if using snat, the external port has to be empty
732 if ($fwdfwsettings{'nat'} eq 'snat' && $fwdfwsettings{'dnatport'} ne ''){
733 $errormessage=$Lang::tr
{'fwdfw dnat extport'};
736 #if no dest port is given in nat area, take target host port
737 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
738 if($fwdfwsettings{'TGT_PORT'} eq '' && $fwdfwsettings{'dnatport'} ne '' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')){
739 $errormessage=$Lang::tr
{'fwdfw dnat porterr2'};
742 #check if port given in nat area is a single valid port or portrange
743 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
744 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
745 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
747 #get service Protocol and Port
748 foreach my $key (sort keys %customservice){
749 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
750 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
751 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
753 $custsrvport= $customservice{$key}[1];
756 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
758 #check if DNAT port is multiple
759 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
760 my @parts=split(",",$fwdfwsettings{'dnatport'});
764 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
766 #change dashes with :
769 push(@values,"1:65535");
772 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
773 push(@values,"1:$2");
776 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
777 push(@values,"$1:65535");
780 $errormessage .= &General
::validportrange
($_, 'destination');
785 if (&General
::validport
($_)){
792 $fwdfwsettings{'dnatport'}=join("|",@values);
794 #check if a rule with prot tcp or udp and ports is edited and now prot is "all", then delete all ports
795 if($fwdfwsettings{'PROT'} eq ''){
796 $fwdfwsettings{'dnatport'}='';
800 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
801 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
803 #check if source and target identical
804 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL' && $fwdfwsettings{'grp2'} ne 'ipfire'){
805 $errormessage=$Lang::tr
{'fwdfw err same'};
806 return $errormessage;
808 #get source and targetip address if possible
809 my ($sip,$scidr,$tip,$tcidr);
810 ($sip,$scidr)=&get_ip
("src","grp1");
811 ($tip,$tcidr)=&get_ip
("tgt","grp2");
812 #check same iprange in source and target
813 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
814 my $networkip1=&General
::getnetworkip
($sip,$scidr);
815 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
816 if ($scidr gt $tcidr){
817 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
818 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
820 }elsif($scidr eq $tcidr && $scidr eq '32'){
821 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
822 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
823 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
824 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
825 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
828 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
829 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
833 #when icmp selected, no source and targetport allowed
834 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')){
835 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
838 #change protocol if prot not equal dest single service
839 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
840 foreach my $key (sort keys %customservice){
841 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
842 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
843 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
849 #check source and destination protocol if source manual and dest servicegroup
850 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
851 $fwdfwsettings{'PROT'} = '';
853 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
854 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
856 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
857 $fwdfwsettings{'USE_SRC_PORT'}='';
858 $fwdfwsettings{'SRC_PORT'}='';
859 #$fwdfwsettings{'USESRV'}='';
860 $fwdfwsettings{'TGT_PORT'}='';
861 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
862 foreach my $key (keys %icmptypes){
863 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
864 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
867 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
868 $fwdfwsettings{'USE_SRC_PORT'}='';
869 $fwdfwsettings{'SRC_PORT'}='';
870 $fwdfwsettings{'ICMP_TYPES'}='';
871 $fwdfwsettings{'USESRV'}='';
872 $fwdfwsettings{'TGT_PORT'}='';
873 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
874 $fwdfwsettings{'USE_SRC_PORT'}='';
875 $fwdfwsettings{'SRC_PORT'}='';
876 $fwdfwsettings{'ICMP_TYPES'}='';
877 $fwdfwsettings{'USESRV'}='';
878 $fwdfwsettings{'TGT_PORT'}='';
879 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
880 $fwdfwsettings{'USE_SRC_PORT'}='';
881 $fwdfwsettings{'SRC_PORT'}='';
882 $fwdfwsettings{'ICMP_TYPES'}='';
883 $fwdfwsettings{'USESRV'}='';
884 $fwdfwsettings{'TGT_PORT'}='';
885 }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){
886 $fwdfwsettings{'USE_SRC_PORT'}='';
887 $fwdfwsettings{'SRC_PORT'}='';
888 $fwdfwsettings{'ICMP_TYPES'}='';
889 $fwdfwsettings{'USESRV'}='';
890 $fwdfwsettings{'TGT_PORT'}='';
891 }elsif($fwdfwsettings{'PROT'} eq 'IPv6'){
892 $fwdfwsettings{'USE_SRC_PORT'}='';
893 $fwdfwsettings{'SRC_PORT'}='';
894 $fwdfwsettings{'ICMP_TYPES'}='';
895 $fwdfwsettings{'USESRV'}='';
896 $fwdfwsettings{'TGT_PORT'}='';
897 }elsif($fwdfwsettings{'PROT'} eq 'IPIP'){
898 $fwdfwsettings{'USE_SRC_PORT'}='';
899 $fwdfwsettings{'SRC_PORT'}='';
900 $fwdfwsettings{'ICMP_TYPES'}='';
901 $fwdfwsettings{'USESRV'}='';
902 $fwdfwsettings{'TGT_PORT'}='';
903 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP'){
904 $fwdfwsettings{'ICMP_TYPES'}='';
905 $fwdfwsettings{'SRC_PORT'}='';
906 $fwdfwsettings{'TGT_PORT'}='';
907 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
908 $fwdfwsettings{'ICMP_TYPES'}='';
914 #Test if manual IP is part of static OpenVPN networks
915 &General
::readhasharray
("$configccdnet", \
%ccdnet);
916 foreach my $key (sort keys %ccdnet){
917 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
918 my $sub=&General
::iporsubtodec
($vpnsubnet);
919 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
923 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
924 # because if one creates a custom host with the ip, we need to check the color there!
925 # It does not make sense to check this here
927 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
928 # Is also checked in getcolor
930 # Test if manual ip is part of an IPsec Network is also checked in getcolor
940 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
941 foreach my $key (sort {$a <=> $b} keys %delhash){
942 if ($key >= $fwdfwsettings{'key'}) {
944 if (exists $delhash{$next}) {
945 foreach my $i (0 .. $#{$delhash{$next}}) {
946 $delhash{$key}[$i] = $delhash{$next}[$i];
951 # Remove the very last entry.
952 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
953 delete $delhash{$last_key};
955 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
956 &General
::firewall_config_changed
();
958 if($fwdfwsettings{'nobase'} ne 'on'){
971 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
972 foreach my $key (sort keys %configfwdfw){
974 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
977 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
978 &General
::firewall_config_changed
();
983 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
984 print "<class name='base'>$errormessage\n";
985 print " </class>\n";
994 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
995 if($hash{$key}[0] eq $val){
996 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
998 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1012 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1013 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1014 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1015 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1016 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1017 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1018 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1019 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1020 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1021 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1022 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1023 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1024 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1025 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1026 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1027 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1028 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = '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'}'";
1040 # Check if the the key handles a standard network.
1041 if ( grep(/std_net_/, $fwdfwsettings{$grp}) ) {
1042 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1045 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1046 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1047 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1048 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1049 if ($ifaces{$defnet}){
1050 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1052 print ">$network</option>";
1055 print"</select></td></tr>";
1057 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1058 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;'>";
1059 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1060 print"</select></td>";
1063 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1064 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;'>";
1065 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1066 print"</select></td>";
1069 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1070 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;'>";
1071 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1072 if($helper ne $customgrp{$key}[0] && $customgrp{$key}[2] ne 'none'){
1074 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1075 print ">$customgrp{$key}[0]</option>";
1077 $helper=$customgrp{$key}[0];
1079 print"</select></td>";
1081 # Locations / groups.
1082 my @locations = &fwlib
::get_locations
();
1085 print "<td valign='top'><input type='radio' name='$grp' id='cust_location_$srctgt' value='cust_location_$srctgt' $checked{$grp}{'cust_location_'.$srctgt}></td>\n";
1086 print "<td>$Lang::tr{'location'}</td>\n";
1087 print "<td align='right'><select name='cust_location_$srctgt' style='width:200px;'>\n";
1089 # Add Location groups to dropdown.
1090 if (!-z
$configlocationgrp) {
1091 print "<optgroup label='$Lang::tr{'fwhost cust locationgroup'}'>\n";
1092 foreach my $key (sort { ncmp
($customlocationgrp{$a}[0],$customlocationgrp{$b}[0]) } keys %customlocationgrp) {
1095 # Generate stored value for select detection.
1096 my $stored = join(':', "group",$customlocationgrp{$key}[0]);
1098 # Only show a group once and group with elements.
1099 if($helper ne $customlocationgrp{$key}[0] && $customlocationgrp{$key}[2] ne 'none') {
1100 # Mark current entry as selected.
1101 if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $stored) {
1102 $selected = "selected='selected'";
1104 print"<option $selected value='group:$customlocationgrp{$key}[0]'>$customlocationgrp{$key}[0]</option>\n";
1106 $helper=$customlocationgrp{$key}[0];
1108 print "</optgroup>\n";
1112 print "<optgroup label='$Lang::tr{'fwhost cust location'}'>\n";
1113 foreach my $location (@locations) {
1115 my $country_name = &Location
::Functions
::get_full_country_name
($location);
1117 # Mark current entry as selected.
1119 if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $location) {
1120 $selected = "selected='selected'";
1122 print "<option $selected value='$location'>$location - $country_name</option>\n";
1124 print "</optgroup>\n";
1126 # Close Locations dropdown.
1127 print "</select></td>\n";
1129 #End left table. start right table (vpn)
1130 print"</tr></table></td><td valign='top'><table width='95%' border='0' align='right'><tr>";
1132 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1133 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;'>";
1134 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1135 print"</select></td></tr>";
1138 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1139 if ($ccdhost{$key}[33] ne '' ){
1140 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 '');
1142 print "<option value='$ccdhost{$key}[1]'";
1143 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1144 print ">$ccdhost{$key}[1]</option>";
1147 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1148 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>" ;
1150 if ($show eq '1'){$show='';print"</select></td></tr>";}
1152 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1153 if ($ccdhost{$key}[3] eq 'net'){
1154 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 '');
1156 print "<option value='$ccdhost{$key}[1]'";
1157 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1158 print ">$ccdhost{$key}[1]</option>";
1161 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1162 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>" ;
1164 if ($show eq '1'){$show='';print"</select></td></tr>";}
1166 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1167 if ($ipsecconf{$key}[3] eq 'net' || ($optionsfw{'SHOWDROPDOWN'} eq 'on' && $ipsecconf{$key}[3] ne 'host')){
1168 print"<tr><td valign='top'><input type='radio' name='$grp' id='ipsec_net_$srctgt' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'>" if ($show eq '');
1171 #Check if we have more than one REMOTE subnet in config
1172 my @arr1 = split /\|/, $ipsecconf{$key}[11];
1176 print "value=$ipsecconf{$key}[1]";
1177 print " selected " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq "$ipsecconf{$key}[1]");
1178 print ">$ipsecconf{$key}[1] ";
1179 print "($Lang::tr{'fwdfw all subnets'})" if $cnt1 > 1; #If this Conenction has more than one subnet, print one option for all subnets
1183 foreach my $val (@arr1){
1184 #normalize subnet to cidr notation
1185 my ($val1,$val2) = split /\//, $val;
1186 my $val3 = &General
::iporsubtocidr
($val2);
1188 print "value='$ipsecconf{$key}[1]|$val1/$val3'";
1189 print "selected " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq "$ipsecconf{$key}[1]|$val1/$val3");
1190 print ">$ipsecconf{$key}[1] ($val1/$val3)</option>";
1195 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1196 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>";
1198 if ($show eq '1'){$show='';print"</select></td></tr>";}
1201 print"</td></tr></table><br>";
1209 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1210 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1211 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1212 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1213 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1214 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1215 $a=$netsettings{'GREEN_NETADDRESS'};
1216 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1217 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1218 $a=$netsettings{'ORANGE_NETADDRESS'};
1219 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1220 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1221 $a=$netsettings{'BLUE_NETADDRESS'};
1222 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1223 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1224 &General
::readhash
("$configovpn",\
%ovpnsettings);
1225 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1226 $b=&General
::iporsubtocidr
($b);
1228 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1229 &General
::readhasharray
("$confignet", \
%customnetwork);
1230 foreach my $key (keys %customnetwork){
1231 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1232 $a=$customnetwork{$key}[1];
1233 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1236 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1237 &General
::readhasharray
("$confighost", \
%customhost);
1238 foreach my $key (keys %customhost){
1239 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1240 if ($customhost{$key}[1] eq 'ip'){
1241 ($a,$b)=split (/\//,$customhost{$key}[2]);
1242 $b=&General
::iporsubtocidr
($b);
1244 if ($grp eq 'grp2'){
1245 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1257 &General
::setup_default_networks
(\
%defaultNetworks);
1258 foreach my $network (sort keys %defaultNetworks)
1260 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1265 my %hash=%{(shift)};
1267 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1268 $hash{$key}[10]=~ s/\|/,/g;
1269 print": $hash{$key}[10]";
1270 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1271 print": <br>$hash{$key}[9] ";
1276 my %hash=%{(shift)};
1280 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1281 if($hash{$key}[14] eq 'cust_srv'){
1282 &General
::readhasharray
("$configsrv", \
%customservice);
1283 foreach my $i (sort keys %customservice){
1284 if($customservice{$i}[0] eq $hash{$key}[15]){
1285 $service = $customservice{$i}[0];
1288 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1289 $service=$hash{$key}[15];
1290 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1291 $hash{$key}[15]=~ s/\|/,/g;
1292 $service=$hash{$key}[15];
1299 sub get_serviceports
1303 &General
::readhasharray
("$configsrv", \
%customservice);
1304 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1306 my @specprot=("IPIP","IPV6","IGMP","GRE","AH","ESP");
1307 if($type eq 'service'){
1308 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1309 if ($customservice{$key}[0] eq $name){
1310 push (@protocols,$customservice{$key}[2]);
1313 }elsif($type eq 'group'){
1314 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1315 if ($customservicegrp{$key}[0] eq $name){
1316 if ($customservicegrp{$key}[2] ~~ @specprot){
1317 push (@protocols," ".$customservicegrp{$key}[2]);
1319 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1320 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1321 if (!grep(/$customservice{$key1}[2]/, @protocols)){
1322 push (@protocols,$customservice{$key1}[2]);}
1330 # Sort protocols alphabetically.
1331 @protocols = sort(@protocols);
1340 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1341 # Don't colourise MAC addresses
1342 if (&General
::validmac
($val)) {
1348 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1349 foreach my $key (sort keys %$hash){
1350 if ($$hash{$key}[0] eq $val){
1351 $val=$$hash{$key}[2];
1356 if ($val eq 'GREEN'){
1357 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1359 }elsif ($val eq 'ORANGE'){
1360 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1362 }elsif ($val eq 'BLUE'){
1363 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1365 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1366 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1368 }elsif ($val eq 'IPFire' ){
1369 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1371 }elsif ($val eq 'OpenVPN-Dyn' ){
1372 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1374 }elsif ($val eq 'IPsec RW' ){
1375 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1377 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1378 my ($sip,$scidr) = split ("/",$val);
1379 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1380 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1383 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1384 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1387 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1388 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1391 }elsif ($val eq 'Default IP'){
1392 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1395 #Check if a manual IP or custom host is part of a VPN
1396 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1397 #Check if IP is part of OpenVPN dynamic subnet
1398 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1399 my ($c,$d) = split("/",$val);
1400 if (&General
::IpInSubnet
($c,$a,$b)){
1401 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1404 #Check if IP is part of OpenVPN static subnet
1405 foreach my $key (sort keys %ccdnet){
1406 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1407 $b =&General
::iporsubtodec
($b);
1408 if (&General
::IpInSubnet
($c,$a,$b)){
1409 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1413 #Check if IP is part of OpenVPN N2N subnet
1414 foreach my $key (sort keys %ccdhost){
1415 if ($ccdhost{$key}[3] eq 'net'){
1416 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1417 if (&General
::IpInSubnet
($c,$a,$b)){
1418 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1423 #Check if IP is part of IPsec RW network
1424 if ($ipsecsettings{'RW_NET'} ne ''){
1425 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1426 $b=&General
::iporsubtodec
($b);
1427 if (&General
::IpInSubnet
($c,$a,$b)){
1428 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1432 #Check if IP is part of a IPsec N2N network
1433 foreach my $key (sort keys %ipsecconf){
1434 if ($ipsecconf{$key}[11]){
1435 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1436 $b=&General
::iporsubtodec
($b);
1437 if (&General
::IpInSubnet
($c,$a,$b)){
1438 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1445 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'){
1446 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1449 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1450 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1454 foreach my $alias (sort keys %aliases)
1456 if ($val eq $alias){
1457 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1468 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1469 print "<class name='base'>$hint\n";
1470 print " </class>\n";
1471 &Header
::closebox
();
1477 &General
::setup_default_networks
(\
%defaultNetworks);
1478 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1479 #read all configfiles
1480 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1481 &General
::readhasharray
("$confignet", \
%customnetwork);
1482 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1483 &General
::readhasharray
("$confighost", \
%customhost);
1484 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1485 &General
::readhasharray
("$configgrp", \
%customgrp);
1486 &General
::readhasharray
("$configlocationgrp", \
%customlocationgrp);
1487 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1488 &General
::get_aliases
(\
%aliases);
1495 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1496 my $config=$fwdfwsettings{'config'};
1499 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1500 my $redip = <CONN1
>;
1502 if (! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE2'){
1503 $fwdfwsettings{'RULE_ACTION'}='DROP';
1504 }elsif(! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE1'){
1505 $fwdfwsettings{'RULE_ACTION'}='ACCEPT';
1507 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1508 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1509 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1510 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1511 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1512 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1513 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1514 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1515 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1516 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1517 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1518 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1519 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1520 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1521 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1522 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1523 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1524 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1525 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} = 'selected' if ($fwdfwsettings{'grp2'} eq "ipfire");
1526 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} = 'selected' if ($fwdfwsettings{'grp1'} eq "ipfire_src");
1527 #check if update and get values
1528 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1529 &General
::readhasharray
("$config", \
%hash);
1530 foreach my $key (sort keys %hash){
1532 if ($key eq $fwdfwsettings{'key'}){
1533 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1534 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1535 $fwdfwsettings{'chain'} = $hash{$key}[1];
1536 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1537 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1538 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1539 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1540 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1541 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1542 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1543 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1544 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1545 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1546 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1547 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1548 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1549 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1550 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1551 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1552 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1553 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1554 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1555 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1556 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1557 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1558 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1559 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1560 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1561 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1562 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1563 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1564 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1566 #When copying a DNAT Rule, the sourceport has to be empty at this point.
1567 if($hash{$key}[14] eq 'cust_srv' and $hash{$key}[31] eq 'dnat'){
1568 $hash{$key}[30] = '';
1570 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1571 $fwdfwsettings{'LIMIT_CON_CON'} = $hash{$key}[32];
1572 $fwdfwsettings{'concon'} = $hash{$key}[33];
1573 $fwdfwsettings{'RATE_LIMIT'} = $hash{$key}[34];
1574 $fwdfwsettings{'ratecon'} = $hash{$key}[35];
1575 $fwdfwsettings{'RATETIME'} = $hash{$key}[36];
1576 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1577 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1578 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1579 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1580 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1581 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1582 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1583 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1584 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1585 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1586 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1587 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1588 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1589 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1590 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1591 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1592 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1593 $checked{'LIMIT_CON_CON'}{$fwdfwsettings{'LIMIT_CON_CON'}} = 'CHECKED';
1594 $checked{'RATE_LIMIT'}{$fwdfwsettings{'RATE_LIMIT'}} = 'CHECKED';
1595 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1596 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1597 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} = 'selected' if ($fwdfwsettings{'grp2'} eq "ipfire");
1598 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} = 'selected' if ($fwdfwsettings{'grp1'} eq "ipfire_src");
1599 $selected{'dnat'}{$fwdfwsettings{'dnat'}} ='selected';
1600 $selected{'snat'}{$fwdfwsettings{'snat'}} ='selected';
1601 $selected{'RATETIME'}{$fwdfwsettings{'RATETIME'}} ='selected';
1604 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1605 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1606 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1607 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1608 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1609 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1610 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1611 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1612 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1613 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1614 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1615 $fwdfwsettings{'olduseratelimit'}=$fwdfwsettings{'RATE_LIMIT'};
1616 $fwdfwsettings{'olduseratelimitamount'}=$fwdfwsettings{'ratecon'};
1617 $fwdfwsettings{'oldratelimittime'}=$fwdfwsettings{'RATETIME'};
1619 #check if manual ip (source) is orange network
1620 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1621 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1622 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1623 $fwdfwsettings{'oldorange'} ='on';
1627 $fwdfwsettings{'ACTIVE'}='ON';
1628 $fwdfwsettings{'nat'} = 'dnat';
1629 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1630 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1631 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1632 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1633 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1634 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1635 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1636 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1637 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1638 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1639 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1640 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1641 #check if manual ip (source) is orange network
1642 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1643 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1644 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1645 $fwdfwsettings{'oldorange'} ='on';
1649 # Split manual source and target address and delete the subnet
1650 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1651 if ($scidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp1'}}=$sip;}
1652 my ($dip,$dcidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp2'}});
1653 if ($dcidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp2'}}=$dip;}
1654 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1655 #------SOURCE-------------------------------------------------------
1656 print "<form method='post'>";
1658 <table width='100%' border='0'>
1659 <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>
1661 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1662 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1663 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1664 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1665 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1666 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1667 if (! -z
"${General::swroot}/ethernet/aliases"){
1668 foreach my $alias (sort keys %aliases)
1670 print "<option value='$alias' $selected{'ipfire_src'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1675 <tr><td><br></td></tr>
1678 &gen_dd_block
('src','grp1');
1679 &Header
::closebox
();
1681 #---SNAT / DNAT ------------------------------------------------
1682 &Header
::openbox
('100%', 'left', 'NAT');
1685 <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}>
1686 $Lang::tr{'fwdfw use nat'}
1689 <table class='fw-nat' width='100%' border='0'>
1691 <td width='5%'></td>
1694 <input type='radio' name='nat' value='dnat' $checked{'nat'}{'dnat'}>
1695 $Lang::tr{'fwdfw dnat'}
1701 <td width='25%' align='right'><span class='dnat'>$Lang::tr{'dnat address'}:</span></td>
1703 <select name='dnat' class='dnat' style='width: 100%;'>
1704 <option value='AUTO' $selected{'dnat'}{'AUTO'}>- $Lang::tr{'automatic'} -</option>
1705 <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'red1'} ($redip)</option>
1708 foreach my $alias (sort keys %aliases) {
1709 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1713 foreach my $network (sort keys %defaultNetworks)
1715 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1716 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1717 print " selected='selected'" if ($fwdfwsettings{'dnat'} eq $defaultNetworks{$network}{'NAME'});
1718 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1727 <td width='5%'></td>
1730 <input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}>
1731 $Lang::tr{'fwdfw snat'}
1734 <td width='25%' align='right'><span class='snat'>$Lang::tr{'snat new source ip address'}:</span></td>
1736 <select name='snat' class='snat' style='width: 100%;'>
1737 <option value='RED' $selected{'snat'}{'RED'}>$Lang::tr{'red1'} ($redip)</option>
1740 foreach my $alias (sort keys %aliases) {
1741 print "<option value='$alias' $selected{'snat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1744 foreach my $network (sort keys %defaultNetworks) {
1745 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1746 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1747 print " selected='selected'" if ($fwdfwsettings{'snat'} eq $defaultNetworks{$network}{'NAME'});
1748 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1758 &Header
::closebox
();
1760 #---TARGET------------------------------------------------------
1761 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1763 <table width='100%' border='0'>
1764 <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>
1766 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1767 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1768 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1769 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1770 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1771 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1772 if (! -z
"${General::swroot}/ethernet/aliases"){
1773 foreach my $alias (sort keys %aliases)
1775 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1780 <tr><td><br></td></tr></table>
1782 &gen_dd_block
('tgt','grp2');
1784 #---PROTOCOL------------------------------------------------------
1785 $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
1786 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1787 $fwdfwsettings{'dnatport'} =~ tr/|/,/;
1789 # The dnatport may be empty, if it matches TGT_PORT
1790 if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
1791 $fwdfwsettings{'dnatport'} = "";
1794 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1795 #Fix Protocol for JQuery
1796 if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
1797 $fwdfwsettings{'PROT'} = 'template';
1800 <table width='100%' border='0'>
1803 <select name='PROT' id='protocol' style="width: 95px;">
1805 print "<option value=\"\"";
1806 if ($fwdfwsettings{'PROT'} eq '') {
1807 print " selected=\"selected\"";
1809 print ">$Lang::tr{'all'}</option>";
1811 print "<option value=\"template\"";
1812 print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp');
1813 print ">- $Lang::tr{'template'} -</option>";
1815 foreach (@PROTOCOLS) {
1816 print"<option value=\"$_\"";
1817 if ($_ eq $fwdfwsettings{'PROT'}) {
1818 print " selected=\"selected\"";
1821 print ">$Lang::tr{'fwdfw prot41'}</option>";
1823 print ">$_</option>";
1831 <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES">
1833 <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
1835 <select name='ICMP_TYPES' style='min-width:230px;'>
1837 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1838 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1839 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1840 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1841 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1843 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1853 <table width="100%" border="0" id="PROTOCOL_PORTS">
1855 <!-- #SOURCEPORT -->
1857 $Lang::tr{'fwdfw use srcport'}
1860 <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
1865 <!-- #TARGETPORT -->
1867 $Lang::tr{'fwdfw use srv'}
1871 <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
1875 <td colspan='3'></td>
1876 <td>$Lang::tr{'fwdfw external port nat'}:</td>
1878 <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
1883 <table width="100%" border="0" id="PROTOCOL_TEMPLATE">
1886 <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
1887 $Lang::tr{'fwhost cust service'}
1890 <select name='cust_srv' style='min-width: 230px;'>
1893 &General
::readhasharray
("$configsrv", \
%customservice);
1894 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1896 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1897 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1906 <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
1907 $Lang::tr{'fwhost cust srvgrp'}
1910 <select name='cust_srvgrp' style='min-width:230px;'>
1913 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1915 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1916 if ($helper ne $customservicegrp{$key}[0] && $customservicegrp{$key}[2] ne 'none'){
1918 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1919 print">$customservicegrp{$key}[0]</option>";
1921 $helper=$customservicegrp{$key}[0];
1935 $checked{"RULE_ACTION"}{$fwdfwsettings{'RULE_ACTION'}} = 'CHECKED';
1938 <table width="80%" class='tbl' id='actions'>
1940 <td width="33%" align="center" bgcolor="$color{'color17'}">
1943 <td width="33%" align="center" bgcolor="$color{'color25'}">
1946 <td width="33%" align="center" bgcolor="$color{'color16'}">
1951 <td width="33%" align="center">
1953 <input type="radio" name="RULE_ACTION" value="ACCEPT" $checked{"RULE_ACTION"}{"ACCEPT"}>
1954 <strong>$Lang::tr{'fwdfw ACCEPT'}</strong>
1957 <td width="33%" align="center">
1959 <input type="radio" name="RULE_ACTION" value="DROP" $checked{"RULE_ACTION"}{"DROP"}>
1960 <strong>$Lang::tr{'fwdfw DROP'}</strong>
1963 <td width="33%" align="center">
1965 <input type="radio" name="RULE_ACTION" value="REJECT" $checked{"RULE_ACTION"}{"REJECT"}>
1966 <strong>$Lang::tr{'fwdfw REJECT'}</strong>
1975 #---Activate/logging/remark-------------------------------------
1976 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1978 <table width='100%' border='0'>
1980 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>";
1981 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1982 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1983 for (my $count =1; $count <= $sum; $count++){
1984 print"<option value='$count' ";
1985 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1986 print">$count</option>";
1988 print"</select></td></tr>";
1990 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1995 <table width='100%'>
1999 if ($fwdfwsettings{'updatefwrule'} eq 'on') {
2002 <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}>
2004 <td>$Lang::tr{'fwdfw rule activate'}</td>
2009 <input type="hidden" name="ACTIVE" value="ON">
2018 <input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'}>
2020 <td>$Lang::tr{'fwdfw log rule'}</td>
2024 <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}>
2026 <td>$Lang::tr{'fwdfw timeframe'}</td>
2028 <tr id="TIME_CONSTRAINTS">
2030 <table width="66%" border="0">
2032 <td width="8em"> </td>
2033 <td align="center">$Lang::tr{'advproxy monday'}</td>
2034 <td align="center">$Lang::tr{'advproxy tuesday'}</td>
2035 <td align="center">$Lang::tr{'advproxy wednesday'}</td>
2036 <td align="center">$Lang::tr{'advproxy thursday'}</td>
2037 <td align="center">$Lang::tr{'advproxy friday'}</td>
2038 <td align="center">$Lang::tr{'advproxy saturday'}</td>
2039 <td align="center">$Lang::tr{'advproxy sunday'}</td>
2043 <td width="8em"> </td>
2044 <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
2045 <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
2046 <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
2047 <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
2048 <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
2049 <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
2050 <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
2052 <select name='TIME_FROM'>
2054 for (my $i=0;$i<=23;$i++) {
2055 $i = sprintf("%02s",$i);
2056 for (my $j=0;$j<=45;$j+=15) {
2057 $j = sprintf("%02s",$j);
2058 my $time = $i.":".$j;
2059 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
2064 <select name='TIME_TO'>
2066 for (my $i=0;$i<=23;$i++) {
2067 $i = sprintf("%02s",$i);
2068 for (my $j=0;$j<=45;$j+=15) {
2069 $j = sprintf("%02s",$j);
2070 my $time = $i.":".$j;
2071 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
2083 <input type='checkbox' name='LIMIT_CON_CON' id="USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP" value='ON' $checked{'LIMIT_CON_CON'}{'ON'}>
2085 <td>$Lang::tr{'fwdfw limitconcon'}</td>
2089 <table width='66%' border='0'>
2091 <td width="20em"> </td>
2092 <td>$Lang::tr{'fwdfw maxconcon'}: <input type='text' name='concon' size='2' value="$fwdfwsettings{'concon'}"></td>
2099 <input type='checkbox' name='RATE_LIMIT' id="USE_RATELIMIT" value='ON' $checked{'RATE_LIMIT'}{'ON'}>
2101 <td>$Lang::tr{'fwdfw ratelimit'}</td>
2105 <table width='66%' border='0'>
2107 <td width="20em"> </td>
2108 <td>$Lang::tr{'fwdfw numcon'}: <input type='text' name='ratecon' size='2' value="$fwdfwsettings{'ratecon'}"> /
2109 <select name='RATETIME' style='width:100px;'>
2110 <option value='second' $selected{'RATETIME'}{'second'}>$Lang::tr{'age second'}</option>
2111 <option value='minute' $selected{'RATETIME'}{'minute'}>$Lang::tr{'minute'}</option>
2112 <option value='hour' $selected{'RATETIME'}{'hour'}>$Lang::tr{'hour'}</option>
2123 #---ACTION------------------------------------------------------
2124 if($fwdfwsettings{'updatefwrule'} ne 'on'){
2126 <table border='0' width='100%'>
2127 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
2128 <input type='hidden' name='config' value='$config' >
2129 <input type='hidden' name='ACTION' value='saverule' ></form>
2130 <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>
2136 <table border='0' width='100%'>
2137 <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'}'>
2138 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
2139 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
2140 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
2141 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
2142 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
2143 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
2144 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
2145 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
2146 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
2147 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
2148 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
2149 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
2150 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
2151 <input type='hidden' name='oldconcon' value='$fwdfwsettings{'oldconcon'}' />
2152 <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>
2156 &Header
::closebox
();
2162 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
2163 foreach my $key (sort keys %uphash){
2164 if ($key eq $fwdfwsettings{'key'}) {
2166 if (exists $uphash{$last}){
2168 foreach my $y (0 .. $#{$uphash{$last}}) {
2169 $tmp{0}[$y] = $uphash{$last}[$y];
2171 #copy active rule to last
2172 foreach my $i (0 .. $#{$uphash{$last}}) {
2173 $uphash{$last}[$i] = $uphash{$key}[$i];
2175 #copy saved rule to actual position
2176 foreach my $x (0 .. $#{$tmp{0}}) {
2177 $uphash{$key}[$x] = $tmp{0}[$x];
2182 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
2183 &General
::firewall_config_changed
();
2189 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
2190 foreach my $key (sort keys %downhash){
2191 if ($key eq $fwdfwsettings{'key'}) {
2192 my $next = $key + 1;
2193 if (exists $downhash{$next}){
2195 foreach my $y (0 .. $#{$downhash{$next}}) {
2196 $tmp{0}[$y] = $downhash{$next}[$y];
2198 #copy active rule to next
2199 foreach my $i (0 .. $#{$downhash{$next}}) {
2200 $downhash{$next}[$i] = $downhash{$key}[$i];
2202 #copy saved rule to actual position
2203 foreach my $x (0 .. $#{$tmp{0}}) {
2204 $downhash{$key}[$x] = $tmp{0}[$x];
2209 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
2210 &General
::firewall_config_changed
();
2216 &General
::readhasharray
("$config", $hash);
2217 if (!$errormessage){
2218 ################################################################
2219 #check if we change an INPUT rule to a OUTGOING
2220 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2221 &changerule
($configinput);
2224 #check if we change an INPUT rule to a FORWARD
2225 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2226 &changerule
($configinput);
2229 ################################################################
2230 #check if we change an OUTGOING rule to an INPUT
2231 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2232 &changerule
($configoutgoing);
2235 #check if we change an OUTGOING rule to a FORWARD
2236 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2237 &changerule
($configoutgoing);
2240 ################################################################
2241 #check if we change a FORWARD rule to an INPUT
2242 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2243 &changerule
($configfwdfw);
2246 #check if we change a FORWARD rule to an OUTGOING
2247 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2248 &changerule
($configfwdfw);
2251 $fwdfwsettings{'ruleremark'}=~ s/,/;/g;
2252 utf8
::decode
($fwdfwsettings{'ruleremark'});
2253 $fwdfwsettings{'ruleremark'}=&Header
::escape
($fwdfwsettings{'ruleremark'});
2254 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2255 my $key = &General
::findhasharraykey
($hash);
2256 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2257 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2258 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2259 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2260 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2261 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2262 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2263 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2264 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2265 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2266 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2267 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2268 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2269 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2270 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2271 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2272 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2273 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2274 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2275 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2276 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2277 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2278 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2279 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2280 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2281 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2282 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2283 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2284 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2285 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2286 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2287 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2288 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2289 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2290 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2291 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2292 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2293 &General
::writehasharray
("$config", $hash);
2295 foreach my $key (sort {$a <=> $b} keys %$hash){
2296 if($key eq $fwdfwsettings{'key'}){
2297 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2298 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2299 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2300 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2301 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2302 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2303 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2304 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2305 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2306 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2307 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2308 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2309 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2310 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2311 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2312 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2313 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2314 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2315 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2316 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2317 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2318 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2319 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2320 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2321 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2322 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2323 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2324 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2325 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2326 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2327 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2328 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2329 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2330 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2331 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2332 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2333 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2338 &General
::writehasharray
("$config", $hash);
2339 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2341 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2342 for (my $z=0;$z<$val;$z++){
2343 foreach my $key (sort {$a <=> $b} keys %$hash){
2344 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2346 if (exists $$hash{$last}){
2348 foreach my $y (0 .. $#{$$hash{$last}}) {
2349 $tmp{0}[$y] = $$hash{$last}[$y];
2351 #copy active rule to last
2352 foreach my $i (0 .. $#{$$hash{$last}}) {
2353 $$hash{$last}[$i] = $$hash{$key}[$i];
2355 #copy saved rule to actual position
2356 foreach my $x (0 .. $#{$tmp{0}}) {
2357 $$hash{$key}[$x] = $tmp{0}[$x];
2362 $fwdfwsettings{'oldrulenumber'}--;
2364 &General
::writehasharray
("$config", $hash);
2365 &General
::firewall_config_changed
();
2366 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2368 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2369 for (my $z=0;$z<$val;$z++){
2370 foreach my $key (sort {$a <=> $b} keys %$hash){
2371 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2372 my $next = $key + 1;
2373 if (exists $$hash{$next}){
2375 foreach my $y (0 .. $#{$$hash{$next}}) {
2376 $tmp{0}[$y] = $$hash{$next}[$y];
2378 #copy active rule to next
2379 foreach my $i (0 .. $#{$$hash{$next}}) {
2380 $$hash{$next}[$i] = $$hash{$key}[$i];
2382 #copy saved rule to actual position
2383 foreach my $x (0 .. $#{$tmp{0}}) {
2384 $$hash{$key}[$x] = $tmp{0}[$x];
2389 $fwdfwsettings{'oldrulenumber'}++;
2391 &General
::writehasharray
("$config", $hash);
2392 &General
::firewall_config_changed
();
2398 # Checks a hostname against RFC1035
2401 # Try to decode $remark into UTF-8. If this doesn't work,
2402 # we assume that the string it not sane.
2403 if (!utf8
::decode
($remark)) {
2407 # Check if the string only contains of printable characters.
2408 if ($remark =~ /^[[:print:]]*$/) {
2415 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2417 &viewtablenew
(\
%configfwdfw, $configfwdfw, $Lang::tr
{'firewall rules'});
2418 &viewtablenew
(\
%configinputfw, $configinput, $Lang::tr
{'incoming firewall access'});
2419 &viewtablenew
(\
%configoutgoingfw, $configoutgoing, $Lang::tr
{'outgoing firewall access'});
2428 my $show_box = (! -z
$config) || ($optionsfw{'SHOWTABLES'} eq 'on');
2429 return if (!$show_box);
2431 &General
::get_aliases
(\
%aliases);
2432 &General
::readhasharray
("$confighost", \
%customhost);
2433 &General
::readhasharray
("$config", $hash);
2434 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2435 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2436 &General
::readhasharray
("$configgrp", \
%customgrp);
2437 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2439 &Header
::openbox
('100%', 'left', $title);
2440 print "<table width='100%' cellspacing='0' class='tbl'>";
2454 <th align='right' width='3%'>
2457 <th width='2%'></th>
2459 <b>$Lang::tr{'protocol'}</b>
2461 <th align='center' width='30%'>
2462 <b>$Lang::tr{'fwdfw source'}</b>
2465 <b>$Lang::tr{'fwdfw log'}</b>
2467 <th align='center' width='30%'>
2468 <b>$Lang::tr{'fwdfw target'}</b>
2470 <th align='center' colspan='6' width='18%'>
2471 <b>$Lang::tr{'fwdfw action'}</b>
2476 foreach my $key (sort {$a <=> $b} keys %$hash){
2480 #check if vpn hosts/nets have been deleted
2481 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2482 push (@tmpsrc,$$hash{$key}[4]);
2484 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2485 push (@tmptgt,$$hash{$key}[6]);
2487 foreach my $host (@tmpsrc){
2488 if($$hash{$key}[3] eq 'ipsec_net_src'){
2489 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2492 }elsif($$hash{$key}[3] eq 'ovpn_net_src'){
2493 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2496 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src'){
2497 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2500 }elsif($$hash{$key}[3] eq 'ovpn_host_src'){
2501 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2506 foreach my $host (@tmptgt){
2507 if($$hash{$key}[5] eq 'ipsec_net_tgt'){
2508 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2511 }elsif($$hash{$key}[5] eq 'ovpn_net_tgt'){
2512 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2515 }elsif($$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2516 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2519 }elsif($$hash{$key}[5] eq 'ovpn_host_tgt'){
2520 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2525 #check if networkgroups or servicegroups are empty
2526 foreach my $netgroup (sort keys %customgrp){
2527 if(($$hash{$key}[4] eq $customgrp{$netgroup}[0] || $$hash{$key}[6] eq $customgrp{$netgroup}[0]) && $customgrp{$netgroup}[2] eq 'none'){
2531 foreach my $srvgroup (sort keys %customservicegrp){
2532 if($$hash{$key}[15] eq $customservicegrp{$srvgroup}[0] && $customservicegrp{$srvgroup}[2] eq 'none'){
2536 $$hash{'ACTIVE'}=$$hash{$key}[2];
2538 if($coloryellow eq 'on'){
2539 $color="$color{'color14'}";
2541 }elsif($coloryellow eq ''){
2543 $color="$color{'color22'}";
2546 $color="$color{'color20'}";
2550 <tr bgcolor='$color'>
2551 <td align='right' width='3%'>
2557 if ($$hash{$key}[0] eq 'ACCEPT'){
2560 $rulecolor=$color{'color17'};
2561 }elsif($$hash{$key}[0] eq 'DROP'){
2564 $rulecolor=$color{'color25'};
2565 }elsif($$hash{$key}[0] eq 'REJECT'){
2568 $rulecolor=$color{'color16'};
2572 <td bgcolor='$rulecolor' align='center' width='2%'>
2573 <span title='$tooltip'> </span>
2579 if ($$hash{$key}[8]){
2580 if ($$hash{$key}[8] eq "IPv6"){
2581 push (@protocols,$Lang::tr
{'fwdfw prot41 short'})
2583 push (@protocols,$$hash{$key}[8]);
2585 }elsif($$hash{$key}[14] eq 'cust_srv'){
2586 &get_serviceports
("service",$$hash{$key}[15]);
2587 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2588 &get_serviceports
("group",$$hash{$key}[15]);
2590 push (@protocols,$Lang::tr
{'all'});
2593 my $protz=join(", ",@protocols);
2594 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2595 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2596 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2597 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2598 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2602 }elsif($#protocols gt '3'){
2603 print"<td align='center'><span title='$protz'>$Lang::tr{'fwdfw many'}</span></td>";
2605 print"<td align='center'>$protz</td>";
2610 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2611 # Check SRC Host and replace "|" with space
2612 if ($$hash{$key}[4] =~ /\|/){
2613 $$hash{$key}[4] =~ s/\|/ (/g;
2614 $$hash{$key}[4] = $$hash{$key}[4].")";
2616 print"<td align='center' width='30%' $tdcolor>";
2617 if ($$hash{$key}[3] eq 'ipfire_src'){
2618 $ipfireiface=$Lang::tr
{'fwdfw iface'};
2620 if ($$hash{$key}[3] eq 'std_net_src'){
2621 print &get_name
($$hash{$key}[4]);
2622 }elsif ($$hash{$key}[3] eq 'src_addr'){
2623 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2624 if ($split2 eq '32'){
2627 print $$hash{$key}[4];
2629 }elsif ($$hash{$key}[3] eq 'cust_location_src') {
2630 my ($split1,$split2) = split(":", $$hash{$key}[4]);
2634 print "$Lang::tr{'location'}: $$hash{$key}[4]\n";
2636 }elsif ($$hash{$key}[4] eq 'RED1'){
2637 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2638 }elsif ($$hash{$key}[4] eq 'ALL'){
2639 print "$ipfireiface $Lang::tr{'all'}";
2641 if ($$hash{$key}[4] eq 'GREEN' || $$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE' || $$hash{$key}[4] eq 'RED'){
2642 print "$ipfireiface $Lang::tr{lc($$hash{$key}[4])}";
2644 print "$ipfireiface $$hash{$key}[4]";
2649 &getsrcport
(\
%$hash,$key);
2650 #Is this a SNAT rule?
2651 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2652 my $net=&get_name
($$hash{$key}[29]);
2653 if ( ! $net){ $net=$$hash{$key}[29];}
2655 if ($$hash{$key}[30] ne ''){
2656 print": $$hash{$key}[30]";
2659 if ($$hash{$key}[17] eq 'ON'){
2660 $log="/images/on.gif";
2662 $log="/images/off.gif";
2668 <form method='POST' action=''>
2669 <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 ;'/>
2670 <input type='hidden' name='key' value='$key' />
2671 <input type='hidden' name='config' value='$config' />
2672 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2677 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2679 <td align='center' $tdcolor>
2681 # Check TGT Host and replace "|" with space
2682 if ($$hash{$key}[6] =~ /\|/){
2683 $$hash{$key}[6] =~ s/\|/ (/g;
2684 $$hash{$key}[6] = $$hash{$key}[6].")";
2686 #Is this a DNAT rule?
2688 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2689 if ($$hash{$key}[29] eq 'Default IP'){$$hash{$key}[29]=$Lang::tr
{'red1'};}
2690 if ($$hash{$key}[29] eq 'AUTO'){
2691 my @src_addresses=&fwlib
::get_addresses
(\
%$hash,$key,'src');
2693 foreach my $val (@src_addresses){
2694 push (@nat_ifaces,&fwlib
::get_nat_address
($$hash{$key}[29],$val));
2696 @nat_ifaces=&del_double
(@nat_ifaces);
2699 $natstring = "($$hash{$key}[29])";
2701 print "$Lang::tr{'firewall'} $natstring";
2702 if($$hash{$key}[30] ne ''){
2703 $$hash{$key}[30]=~ tr/|/,/;
2704 print": $$hash{$key}[30]";
2708 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire'){
2709 if ($$hash{$key}[6] eq 'RED1'){
2710 print "$Lang::tr{'red1'}";
2711 }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')
2713 print &get_name
($$hash{$key}[6]);
2715 print $$hash{$key}[6];
2717 }elsif ($$hash{$key}[5] eq 'cust_location_tgt') {
2718 my ($split1,$split2) = split(":", $$hash{$key}[6]);
2722 print "$Lang::tr{'location'}: $$hash{$key}[6]\n";
2724 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2725 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2726 if ($split2 eq '32'){
2729 print $$hash{$key}[6];
2732 print "$$hash{$key}[6]";
2736 &gettgtport
(\
%$hash,$key);
2739 if($$hash{$key}[2] eq 'ON'){
2740 $gif="/images/on.gif"
2742 $gif="/images/off.gif"
2745 <td width='3%' align='center'>
2746 <form method='POST' action=''>
2747 <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;' />
2748 <input type='hidden' name='key' value='$key' />
2749 <input type='hidden' name='config' value='$config' />
2750 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2753 <td width='3%' align='center'>
2754 <form method='POST' action=''>
2755 <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;' />
2756 <input type='hidden' name='key' value='$key' />
2757 <input type='hidden' name='config' value='$config' />
2758 <input type='hidden' name='ACTION' value='editrule' />
2761 <td width='3%' align='center'>
2762 <form method='POST' action=''>
2763 <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;' />
2764 <input type='hidden' name='key' value='$key' />
2765 <input type='hidden' name='config' value='$config' />
2766 <input type='hidden' name='ACTION' value='copyrule' />
2769 <td width='3%' align='center'>
2770 <form method='POST' action=''>
2771 <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;' />
2772 <input type='hidden' name='key' value='$key' />
2773 <input type='hidden' name='config' value='$config' />
2774 <input type='hidden' name='ACTION' value='deleterule' />
2778 if (exists $$hash{$key-1}){
2780 <td width='3%' align='center'>
2781 <form method='POST' action=''>
2782 <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;' />
2783 <input type='hidden' name='key' value='$key' />
2784 <input type='hidden' name='config' value='$config' />
2785 <input type='hidden' name='ACTION' value='moveup' />
2790 print"<td width='3%'></td>";
2793 if (exists $$hash{$key+1}){
2795 <td width='3%' align='center'>
2796 <form method='POST' action=''>
2797 <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;' />
2798 <input type='hidden' name='key' value='$key' />
2799 <input type='hidden' name='config' value='$config' />
2800 <input type='hidden' name='ACTION' value='movedown' />
2806 print"<td width='3%'></td></tr>";
2809 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2811 <tr bgcolor='$color'>
2813 <td bgcolor='$rulecolor'></td>
2815 <em>$$hash{$key}[16]</em>
2821 if ($$hash{$key}[18] eq 'ON'){
2823 if ($$hash{$key}[18] eq 'ON'){
2825 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2826 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2827 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2828 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2829 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2830 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2831 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2832 my $weekdays=join(",",@days);
2834 print"<tr bgcolor='$color'>";
2835 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27]</td></tr>";
2839 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2841 } elsif ($optionsfw{'SHOWTABLES'} eq 'on') {
2844 <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td>
2850 my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'};
2851 my $colour = "bgcolor='green'";
2852 if ($fwdfwsettings{'POLICY'} eq 'MODE1') {
2853 $colour = "bgcolor='darkred'";
2857 if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) {
2860 <td colspan='13'> </td>
2863 <td colspan='13' style="padding-left:0px;padding-right:0px">
2864 <table width="100%" border='1' rules="cols" cellspacing='0'>
2871 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2874 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2875 ($Lang::tr{'fwdfw pol allow'})
2879 if (&Header
::orange_used
()) {
2882 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2883 ($Lang::tr{'fwdfw pol allow'})
2888 if (&Header
::blue_used
()) {
2891 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2892 ($Lang::tr{'fwdfw pol allow'})
2900 if (&Header
::orange_used
()) {
2903 <td align='center' width='20%'>
2904 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2907 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2908 ($Lang::tr{'fwdfw pol allow'})
2911 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2912 ($Lang::tr{'fwdfw pol block'})
2916 if (&Header
::blue_used
()) {
2919 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2920 ($Lang::tr{'fwdfw pol block'})
2928 if (&Header
::blue_used
()) {
2932 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2935 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2936 ($Lang::tr{'fwdfw pol allow'})
2940 if (&Header
::orange_used
()) {
2943 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2944 ($Lang::tr{'fwdfw pol block'})
2951 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2952 ($Lang::tr{'fwdfw pol block'})
2964 $message = $Lang::tr
{'fwdfw pol allow'};
2966 } elsif ($config eq '/var/ipfire/firewall/outgoing' && ($fwdfwsettings{'POLICY1'} ne 'MODE1')) {
2967 $message = $Lang::tr
{'fwdfw pol allow'};
2968 $colour = "bgcolor='green'";
2970 $message = $Lang::tr
{'fwdfw pol block'};
2971 $colour = "bgcolor='darkred'";
2977 <td $colour align='center' colspan='13'>
2978 <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font>
2987 &Header
::closebox
();
2990 &Header
::closebigbox
();
2991 &Header
::closepage
();