]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/firewall.cgi
eea66369f428580d87ab7a67e0dd81aaa8b3f1bc
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
25 use feature
'unicode_strings';
27 no warnings
'uninitialized';
29 # enable only the following on debugging purpose
31 #use CGI::Carp 'fatalsToBrowser';
33 require '/var/ipfire/general-functions.pl';
34 require "${General::swroot}/lang.pl";
35 require "${General::swroot}/header.pl";
36 require "/usr/lib/firewall/firewall-lib.pl";
38 unless (-d
"${General::swroot}/firewall") { system("mkdir ${General::swroot}/firewall"); }
39 unless (-e
"${General::swroot}/firewall/settings") { system("touch ${General::swroot}/firewall/settings"); }
40 unless (-e
"${General::swroot}/firewall/config") { system("touch ${General::swroot}/firewall/config"); }
41 unless (-e
"${General::swroot}/firewall/input") { system("touch ${General::swroot}/firewall/input"); }
42 unless (-e
"${General::swroot}/firewall/outgoing") { system("touch ${General::swroot}/firewall/outgoing"); }
46 my %defaultNetworks=();
50 my %customnetworks=();
52 my %customservicegrp=();
58 my %configoutgoingfw=();
71 my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE","IPv6","IPIP");
74 my $confignet = "${General::swroot}/fwhosts/customnetworks";
75 my $confighost = "${General::swroot}/fwhosts/customhosts";
76 my $configgrp = "${General::swroot}/fwhosts/customgroups";
77 my $configsrv = "${General::swroot}/fwhosts/customservices";
78 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
79 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
80 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
81 my $configipsec = "${General::swroot}/vpn/config";
82 my $configipsecrw = "${General::swroot}/vpn/settings";
83 my $configfwdfw = "${General::swroot}/firewall/config";
84 my $configinput = "${General::swroot}/firewall/input";
85 my $configoutgoing = "${General::swroot}/firewall/outgoing";
86 my $configovpn = "${General::swroot}/ovpn/settings";
87 my $fwoptions = "${General::swroot}/optionsfw/settings";
88 my $ifacesettings = "${General::swroot}/ethernet/settings";
91 my $ipgrp="${General::swroot}/outgoing/groups";
95 &General
::readhash
("${General::swroot}/firewall/settings", \
%fwdfwsettings);
96 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
97 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
98 &General
::readhash
($fwoptions, \
%optionsfw);
99 &General
::readhash
($ifacesettings, \
%ifaces);
100 &General
::readhash
("$configovpn", \
%ovpnsettings);
101 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
102 &General
::readhasharray
("$configipsec", \
%ipsecconf);
103 &Header
::showhttpheaders
();
104 &Header
::getcgihash
(\
%fwdfwsettings);
105 &Header
::openpage
($Lang::tr
{'firewall rules'}, 1, '');
106 &Header
::openbigbox
('100%', 'center',$errormessage);
107 #### JAVA SCRIPT ####
110 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
112 var update_protocol = function() {
113 var protocol = \$("#protocol").val();
115 if (protocol === undefined)
118 // Check if a template is/should be used.
119 if (protocol === "template") {
120 \$("#PROTOCOL_TEMPLATE").show();
122 \$("#PROTOCOL_TEMPLATE").hide();
125 // Check if we are dealing with a protocol, that knows ports.
126 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
127 \$("#PROTOCOL_PORTS").show();
129 \$("#PROTOCOL_PORTS").hide();
133 if (protocol === "ICMP") {
134 \$("#PROTOCOL_ICMP_TYPES").show();
136 \$("#PROTOCOL_ICMP_TYPES").hide();
140 \$(document).ready(function() {
141 \$("#protocol").change(update_protocol);
144 // Show/Hide elements when NAT checkbox is checked.
145 if (\$("#USE_NAT").attr("checked")) {
146 \$("#actions").hide();
151 // Show NAT area when "use nat" checkbox is clicked
152 \$("#USE_NAT").change(function() {
154 \$("#actions").toggle();
158 if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) {
159 \$("#TIME_CONSTRAINTS").hide();
161 \$("#USE_TIME_CONSTRAINTS").change(function() {
162 \$("#TIME_CONSTRAINTS").toggle();
165 // Limit concurrent connections per ip
166 if(!\$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").attr("checked")) {
167 \$("#LIMIT_CON").hide();
169 \$("#USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP").change(function() {
170 \$("#LIMIT_CON").toggle();
173 // Rate-limit new connections
174 if(!\$("#USE_RATELIMIT").attr("checked")) {
175 \$("#RATELIMIT").hide();
177 \$("#USE_RATELIMIT").change(function() {
178 \$("#RATELIMIT").toggle();
181 // Automatically select radio buttons when corresponding
182 // dropdown menu changes.
183 \$("select").change(function() {
184 var id = \$(this).attr("name");
185 \$('#' + id).prop("checked", true);
193 if ($fwdfwsettings{'ACTION'} eq 'saverule')
195 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
196 &General
::readhasharray
("$configinput", \
%configinputfw);
197 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
199 #Set Variables according to the JQuery code in protocol section
200 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')
202 if ($fwdfwsettings{'SRC_PORT'} ne '')
204 $fwdfwsettings{'USE_SRC_PORT'} = 'ON';
206 if ($fwdfwsettings{'TGT_PORT'} ne '')
208 $fwdfwsettings{'USESRV'} = 'ON';
209 $fwdfwsettings{'grp3'} = 'TGT_PORT';
212 if ($fwdfwsettings{'PROT'} eq 'template')
214 $fwdfwsettings{'USESRV'} = 'ON';
216 $errormessage=&checksource
;
217 if(!$errormessage){&checktarget
;}
218 if(!$errormessage){&checkrule
;}
220 #check if manual ip (source) is orange network
221 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
222 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
223 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
228 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
229 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
231 #check if we try to break rules
232 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
233 $errormessage=$Lang::tr
{'fwdfw err same'};
236 if ($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
237 $fwdfwsettings{'config'}=$configinput;
238 $fwdfwsettings{'chain'} = 'INPUTFW';
239 $maxkey=&General
::findhasharraykey
(\
%configinputfw);
240 %rulehash=%configinputfw;
241 }elsif ($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
243 $fwdfwsettings{'config'}=$configoutgoing;
244 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
245 $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
246 %rulehash=%configoutgoingfw;
249 $fwdfwsettings{'config'}=$configfwdfw;
250 $fwdfwsettings{'chain'} = 'FORWARDFW';
251 $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
252 %rulehash=%configfwdfw;
254 #check if we have an identical rule already
255 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
256 foreach my $key (sort keys %rulehash){
257 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'}"
258 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]"){
259 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
260 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
261 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
263 if($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && &validremark
($fwdfwsettings{'ruleremark'})){
266 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
267 $fwdfwsettings{'nosave'} = 'on';
272 #check Rulepos on new Rule
273 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
274 $fwdfwsettings{'oldrulenumber'}=$maxkey;
275 foreach my $key (sort keys %rulehash){
276 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'}"
277 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]"){
278 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
282 #check if we just close a rule
283 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'}){
284 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
285 $fwdfwsettings{'nosave2'} = 'on';
289 #check max concurrent connections per ip address
290 if ($fwdfwsettings{'LIMIT_CON_CON'} eq 'ON'){
291 if (!($fwdfwsettings{'concon'} =~ /^(\d+)$/)) {
292 $errormessage.=$Lang::tr
{'fwdfw err concon'};
295 $fwdfwsettings{'concon'}='';
297 #check ratelimit value
298 if ($fwdfwsettings{'RATE_LIMIT'} eq 'ON'){
299 if (!($fwdfwsettings{'ratecon'} =~ /^(\d+)$/)) {
300 $errormessage.=$Lang::tr
{'fwdfw err ratecon'};
303 $fwdfwsettings{'ratecon'}='';
307 if ($fwdfwsettings{'nosave2'} ne 'on'){
308 &saverule
(\
%rulehash,$fwdfwsettings{'config'});
314 if($fwdfwsettings{'nosave2'} ne 'on'){
315 &General
::firewall_config_changed
();
320 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
324 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
327 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
328 foreach my $key (sort keys %togglehash){
329 if ($key eq $fwdfwsettings{'key'}){
330 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
333 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
334 &General
::firewall_config_changed
();
337 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
340 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
341 foreach my $key (sort keys %togglehash){
342 if ($key eq $fwdfwsettings{'key'}){
343 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
346 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
347 &General
::firewall_config_changed
();
350 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
352 &General
::firewall_reload
();
355 if ($fwdfwsettings{'ACTION'} eq 'editrule')
357 $fwdfwsettings{'updatefwrule'}='on';
360 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
364 if ($fwdfwsettings{'ACTION'} eq 'moveup')
369 if ($fwdfwsettings{'ACTION'} eq 'movedown')
374 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
376 $fwdfwsettings{'copyfwrule'}='on';
379 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
388 &Header
::openbox
('100%', 'left', "");
390 <form method="POST" action="">
391 <table border='0' width="100%">
394 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'>
397 if (&General
::firewall_needs_reload
()) {
399 <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'>
423 $fwdfwsettings{'updatefwrule'}='';
424 $fwdfwsettings{'config'}=$oldchain;
425 $fwdfwsettings{'nobase'}='on';
431 #check ip-address if manual
432 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
433 #check if ip with subnet
434 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
435 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
436 $subnet = &General
::iporsubtocidr
($subnet);
437 $fwdfwsettings{'isip'}='on';
440 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
441 $ip=$fwdfwsettings{'src_addr'};
443 $fwdfwsettings{'isip'}='on';
446 if ($fwdfwsettings{'isip'} ne 'on'){
447 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
448 $fwdfwsettings{'ismac'}='on';
451 if ($fwdfwsettings{'isip'} eq 'on'){
452 ##check if ip is valid
453 if (! &General
::validip
($ip)){
454 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
455 return $errormessage;
457 #check and form valid IP
458 $ip=&General
::ip2dec
($ip);
459 $ip=&General
::dec2ip
($ip);
460 #check if net or broadcast
461 $fwdfwsettings{'src_addr'}="$ip/$subnet";
462 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
463 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
464 return $errormessage;
467 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
468 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
469 return $errormessage;
471 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
472 $fwdfwsettings{'grp1'}='std_net_src';
473 $fwdfwsettings{$fwdfwsettings{'grp1'}} = 'ALL';
477 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
478 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
479 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
483 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
485 #change dashes with :
488 push(@values,"1:65535");
491 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
492 push(@values,"1:$2");
495 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
496 push(@values,"$1:65535");
499 $errormessage .= &General
::validportrange
($_, 'destination');
504 if (&General
::validport
($_)){
511 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
513 return $errormessage;
518 &General
::readhasharray
("$configsrv", \
%customservice);
519 #check DNAT settings (has to be single Host and single Port or portrange)
520 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
521 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
522 #check if manual ip is a single Host (if set)
523 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
524 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
525 my @tmp1= split ("/",$tmp[3]);
526 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
528 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
529 return $errormessage;
532 #check if Port is a single Port or portrange
533 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
534 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
535 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
536 return $errormessage;
538 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
539 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
540 return $errormessage;
544 if ($fwdfwsettings{'grp2'} ne 'ipfire'){
545 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
546 return $errormessage;
550 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
551 #check if ip with subnet
552 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
553 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
554 $subnet = &General
::iporsubtocidr
($subnet);
557 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
558 $ip=$fwdfwsettings{'tgt_addr'};
561 #check if ip is valid
562 if (! &General
::validip
($ip)){
563 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
564 return $errormessage;
566 #check and form valid IP
567 $ip=&General
::ip2dec
($ip);
568 $ip=&General
::dec2ip
($ip);
569 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
570 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
571 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
572 return $errormessage;
574 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
575 $fwdfwsettings{'grp2'}='std_net_tgt';
576 $fwdfwsettings{$fwdfwsettings{'grp2'}} = 'ALL';
578 #check for mac in targetgroup
579 if ($fwdfwsettings{'grp2'} eq 'cust_grp_tgt'){
580 &General
::readhasharray
("$configgrp", \
%customgrp);
581 &General
::readhasharray
("$confighost", \
%customhost);
582 foreach my $grpkey (sort keys %customgrp){
583 foreach my $hostkey (sort keys %customhost){
584 if ($customgrp{$grpkey}[2] eq $customhost{$hostkey}[0] && $customhost{$hostkey}[1] eq 'mac'){
585 $hint=$Lang::tr
{'fwdfw hint mac'};
592 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
594 if ($fwdfwsettings{'USESRV'} eq 'ON'){
595 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
596 $fwdfwsettings{'TGT_PROT'}='';
597 $fwdfwsettings{'ICMP_TGT'}='';
598 $fwdfwsettings{'TGT_PORT'}='';
600 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
601 $fwdfwsettings{'TGT_PROT'}='';
602 $fwdfwsettings{'ICMP_TGT'}='';
603 $fwdfwsettings{'TGT_PORT'}='';
604 #check target service
605 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
606 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
609 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
610 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
611 if ($fwdfwsettings{'TGT_PORT'} ne ''){
612 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
613 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
614 return $errormessage;
616 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
620 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
622 #change dashes with :
625 push(@values,"1:65535");
628 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
629 push(@values,"1:$2");
632 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
633 push(@values,"$1:65535");
636 $errormessage .= &General
::validportrange
($_, 'destination');
641 if (&General
::validport
($_)){
644 $errormessage=$Lang::tr
{'fwdfw err tgt_port'};
645 return $errormessage;
649 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
651 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
652 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
653 $fwdfwsettings{'TGT_PORT'} = '';
654 $fwdfwsettings{'ICMP_TGT'} = '';
655 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
656 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
657 $fwdfwsettings{'TGT_PORT'} = '';
658 $fwdfwsettings{'ICMP_TGT'}='';
659 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
660 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
661 $fwdfwsettings{'TGT_PORT'} = '';
662 $fwdfwsettings{'ICMP_TGT'}='';
663 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
664 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
665 $fwdfwsettings{'TGT_PORT'} = '';
670 if ($fwdfwsettings{'USESRV'} ne 'ON'){
671 $fwdfwsettings{'grp3'}='';
672 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
673 $fwdfwsettings{'ICMP_TGT'}='';
676 if($fwdfwsettings{'TIME'} eq 'ON'){
677 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 ''){
678 $errormessage=$Lang::tr
{'fwdfw err time'};
679 return $errormessage;
682 return $errormessage;
687 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
688 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
689 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
690 if ($fwdfwsettings{'dnatport'} eq "*") {
691 $fwdfwsettings{'dnatport'}="1:65535";
693 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
694 $fwdfwsettings{'dnatport'} = "1:$2";
696 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
697 $fwdfwsettings{'dnatport'} ="$1:65535";
702 if ($val =~ "," || $val>65536 || $val<0){
709 #check valid port for NAT
710 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
711 #RULE_ACTION must be ACCEPT if we use NAT
712 $fwdfwsettings{'RULE_ACTION'} = 'ACCEPT';
714 #if no dnat or snat selected errormessage
715 if ($fwdfwsettings{'nat'} eq ''){
716 $errormessage=$Lang::tr
{'fwdfw dnat nochoice'};
720 #if using snat, the external port has to be empty
721 if ($fwdfwsettings{'nat'} eq 'snat' && $fwdfwsettings{'dnatport'} ne ''){
722 $errormessage=$Lang::tr
{'fwdfw dnat extport'};
725 #if no dest port is given in nat area, take target host port
726 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
727 if($fwdfwsettings{'TGT_PORT'} eq '' && $fwdfwsettings{'dnatport'} ne '' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')){
728 $errormessage=$Lang::tr
{'fwdfw dnat porterr2'};
731 #check if port given in nat area is a single valid port or portrange
732 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
733 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
734 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
736 #get service Protocol and Port
737 foreach my $key (sort keys %customservice){
738 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
739 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
740 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
742 $custsrvport= $customservice{$key}[1];
745 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
747 #check if DNAT port is multiple
748 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
749 my @parts=split(",",$fwdfwsettings{'dnatport'});
753 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
755 #change dashes with :
758 push(@values,"1:65535");
761 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
762 push(@values,"1:$2");
765 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
766 push(@values,"$1:65535");
769 $errormessage .= &General
::validportrange
($_, 'destination');
774 if (&General
::validport
($_)){
781 $fwdfwsettings{'dnatport'}=join("|",@values);
783 #check if a rule with prot tcp or udp and ports is edited and now prot is "all", then delete all ports
784 if($fwdfwsettings{'PROT'} eq ''){
785 $fwdfwsettings{'dnatport'}='';
789 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
790 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
792 #check if source and target identical
793 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL' && $fwdfwsettings{'grp2'} ne 'ipfire'){
794 $errormessage=$Lang::tr
{'fwdfw err same'};
795 return $errormessage;
797 #get source and targetip address if possible
798 my ($sip,$scidr,$tip,$tcidr);
799 ($sip,$scidr)=&get_ip
("src","grp1");
800 ($tip,$tcidr)=&get_ip
("tgt","grp2");
801 #check same iprange in source and target
802 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
803 my $networkip1=&General
::getnetworkip
($sip,$scidr);
804 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
805 if ($scidr gt $tcidr){
806 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
807 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
809 }elsif($scidr eq $tcidr && $scidr eq '32'){
810 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
811 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
812 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
813 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
814 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
817 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
818 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
822 #when icmp selected, no source and targetport allowed
823 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')){
824 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
827 #change protocol if prot not equal dest single service
828 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
829 foreach my $key (sort keys %customservice){
830 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
831 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
832 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
838 #check source and destination protocol if source manual and dest servicegroup
839 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
840 $fwdfwsettings{'PROT'} = '';
842 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
843 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
845 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
846 $fwdfwsettings{'USE_SRC_PORT'}='';
847 $fwdfwsettings{'SRC_PORT'}='';
848 #$fwdfwsettings{'USESRV'}='';
849 $fwdfwsettings{'TGT_PORT'}='';
850 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
851 foreach my $key (keys %icmptypes){
852 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
853 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
856 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
857 $fwdfwsettings{'USE_SRC_PORT'}='';
858 $fwdfwsettings{'SRC_PORT'}='';
859 $fwdfwsettings{'ICMP_TYPES'}='';
860 $fwdfwsettings{'USESRV'}='';
861 $fwdfwsettings{'TGT_PORT'}='';
862 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
863 $fwdfwsettings{'USE_SRC_PORT'}='';
864 $fwdfwsettings{'SRC_PORT'}='';
865 $fwdfwsettings{'ICMP_TYPES'}='';
866 $fwdfwsettings{'USESRV'}='';
867 $fwdfwsettings{'TGT_PORT'}='';
868 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
869 $fwdfwsettings{'USE_SRC_PORT'}='';
870 $fwdfwsettings{'SRC_PORT'}='';
871 $fwdfwsettings{'ICMP_TYPES'}='';
872 $fwdfwsettings{'USESRV'}='';
873 $fwdfwsettings{'TGT_PORT'}='';
874 }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){
875 $fwdfwsettings{'USE_SRC_PORT'}='';
876 $fwdfwsettings{'SRC_PORT'}='';
877 $fwdfwsettings{'ICMP_TYPES'}='';
878 $fwdfwsettings{'USESRV'}='';
879 $fwdfwsettings{'TGT_PORT'}='';
880 }elsif($fwdfwsettings{'PROT'} eq 'IPv6'){
881 $fwdfwsettings{'USE_SRC_PORT'}='';
882 $fwdfwsettings{'SRC_PORT'}='';
883 $fwdfwsettings{'ICMP_TYPES'}='';
884 $fwdfwsettings{'USESRV'}='';
885 $fwdfwsettings{'TGT_PORT'}='';
886 }elsif($fwdfwsettings{'PROT'} eq 'IPIP'){
887 $fwdfwsettings{'USE_SRC_PORT'}='';
888 $fwdfwsettings{'SRC_PORT'}='';
889 $fwdfwsettings{'ICMP_TYPES'}='';
890 $fwdfwsettings{'USESRV'}='';
891 $fwdfwsettings{'TGT_PORT'}='';
892 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP'){
893 $fwdfwsettings{'ICMP_TYPES'}='';
894 $fwdfwsettings{'SRC_PORT'}='';
895 $fwdfwsettings{'TGT_PORT'}='';
896 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
897 $fwdfwsettings{'ICMP_TYPES'}='';
903 #Test if manual IP is part of static OpenVPN networks
904 &General
::readhasharray
("$configccdnet", \
%ccdnet);
905 foreach my $key (sort keys %ccdnet){
906 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
907 my $sub=&General
::iporsubtodec
($vpnsubnet);
908 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
912 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
913 # because if one creates a custom host with the ip, we need to check the color there!
914 # It does not make sense to check this here
916 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
917 # Is also checked in getcolor
919 # Test if manual ip is part of an IPsec Network is also checked in getcolor
929 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
930 foreach my $key (sort {$a <=> $b} keys %delhash){
931 if ($key >= $fwdfwsettings{'key'}) {
933 if (exists $delhash{$next}) {
934 foreach my $i (0 .. $#{$delhash{$next}}) {
935 $delhash{$key}[$i] = $delhash{$next}[$i];
940 # Remove the very last entry.
941 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
942 delete $delhash{$last_key};
944 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
945 &General
::firewall_config_changed
();
947 if($fwdfwsettings{'nobase'} ne 'on'){
960 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
961 foreach my $key (sort keys %configfwdfw){
963 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
966 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
967 &General
::firewall_config_changed
();
972 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
973 print "<class name='base'>$errormessage\n";
974 print " </class>\n";
983 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
984 if($hash{$key}[0] eq $val){
985 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
987 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
997 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
998 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
999 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1000 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1001 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1002 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1003 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1004 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1005 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1006 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1007 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1008 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1009 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1010 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1011 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1012 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1013 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1014 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1015 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1017 <table width='100%' border='0'>
1018 <tr><td width='50%' valign='top'>
1019 <table width='95%' border='0'>
1020 <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;'>
1022 foreach my $network (sort keys %defaultNetworks)
1024 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1025 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1026 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1027 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1028 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1029 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1030 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1031 if ($ifaces{$defnet}){
1032 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1034 print ">$network</option>";
1037 print"</select></td></tr>";
1039 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1040 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;'>";
1041 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1042 print"</select></td>";
1045 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1046 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;'>";
1047 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1048 print"</select></td>";
1051 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1052 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;'>";
1053 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1054 if($helper ne $customgrp{$key}[0] && $customgrp{$key}[2] ne 'none'){
1056 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1057 print ">$customgrp{$key}[0]</option>";
1059 $helper=$customgrp{$key}[0];
1061 print"</select></td>";
1063 #End left table. start right table (vpn)
1064 print"</tr></table></td><td valign='top'><table width='95%' border='0' align='right'><tr>";
1066 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1067 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;'>";
1068 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1069 print"</select></td></tr>";
1072 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1073 if ($ccdhost{$key}[33] ne '' ){
1074 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 '');
1076 print "<option value='$ccdhost{$key}[1]'";
1077 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1078 print ">$ccdhost{$key}[1]</option>";
1081 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1082 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>" ;
1084 if ($show eq '1'){$show='';print"</select></td></tr>";}
1086 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1087 if ($ccdhost{$key}[3] eq 'net'){
1088 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 '');
1090 print "<option value='$ccdhost{$key}[1]'";
1091 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1092 print ">$ccdhost{$key}[1]</option>";
1095 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1096 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>" ;
1098 if ($show eq '1'){$show='';print"</select></td></tr>";}
1100 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1101 if ($ipsecconf{$key}[3] eq 'net' || ($optionsfw{'SHOWDROPDOWN'} eq 'on' && $ipsecconf{$key}[3] ne 'host')){
1102 print"<tr><td valign='top'><input type='radio' name='$grp' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'>" if ($show eq '');
1105 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1106 print ">$ipsecconf{$key}[1]</option>";
1109 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1110 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>";
1112 if ($show eq '1'){$show='';print"</select></td></tr>";}
1115 print"</td></tr></table><br>";
1123 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1124 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1125 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1126 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1127 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1128 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1129 $a=$netsettings{'GREEN_NETADDRESS'};
1130 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1131 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1132 $a=$netsettings{'ORANGE_NETADDRESS'};
1133 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1134 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1135 $a=$netsettings{'BLUE_NETADDRESS'};
1136 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1137 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1138 &General
::readhash
("$configovpn",\
%ovpnsettings);
1139 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1140 $b=&General
::iporsubtocidr
($b);
1142 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1143 &General
::readhasharray
("$confignet", \
%customnetwork);
1144 foreach my $key (keys %customnetwork){
1145 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1146 $a=$customnetwork{$key}[1];
1147 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1150 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1151 &General
::readhasharray
("$confighost", \
%customhost);
1152 foreach my $key (keys %customhost){
1153 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1154 if ($customhost{$key}[1] eq 'ip'){
1155 ($a,$b)=split (/\//,$customhost{$key}[2]);
1156 $b=&General
::iporsubtocidr
($b);
1158 if ($grp eq 'grp2'){
1159 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1171 &General
::setup_default_networks
(\
%defaultNetworks);
1172 foreach my $network (sort keys %defaultNetworks)
1174 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1179 my %hash=%{(shift)};
1181 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1182 $hash{$key}[10]=~ s/\|/,/g;
1183 print": $hash{$key}[10]";
1184 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1185 print": <br>$hash{$key}[9] ";
1190 my %hash=%{(shift)};
1194 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1195 if($hash{$key}[14] eq 'cust_srv'){
1196 &General
::readhasharray
("$configsrv", \
%customservice);
1197 foreach my $i (sort keys %customservice){
1198 if($customservice{$i}[0] eq $hash{$key}[15]){
1199 $service = $customservice{$i}[0];
1202 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1203 $service=$hash{$key}[15];
1204 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1205 $hash{$key}[15]=~ s/\|/,/g;
1206 $service=$hash{$key}[15];
1213 sub get_serviceports
1217 &General
::readhasharray
("$configsrv", \
%customservice);
1218 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1220 my @specprot=("IPIP","IPV6","IGMP","GRE","AH","ESP");
1221 if($type eq 'service'){
1222 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1223 if ($customservice{$key}[0] eq $name){
1224 push (@protocols,$customservice{$key}[2]);
1227 }elsif($type eq 'group'){
1228 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1229 if ($customservicegrp{$key}[0] eq $name){
1230 if ($customservicegrp{$key}[2] ~~ @specprot){
1231 push (@protocols," ".$customservicegrp{$key}[2]);
1233 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1234 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1235 if (!grep(/$customservice{$key1}[2]/, @protocols)){
1236 push (@protocols,$customservice{$key1}[2]);}
1244 # Sort protocols alphabetically.
1245 @protocols = sort(@protocols);
1254 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1255 # Don't colourise MAC addresses
1256 if (&General
::validmac
($val)) {
1262 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1263 foreach my $key (sort keys %$hash){
1264 if ($$hash{$key}[0] eq $val){
1265 $val=$$hash{$key}[2];
1270 if ($val eq 'GREEN'){
1271 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1273 }elsif ($val eq 'ORANGE'){
1274 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1276 }elsif ($val eq 'BLUE'){
1277 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1279 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1280 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1282 }elsif ($val eq 'IPFire' ){
1283 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1285 }elsif ($val eq 'OpenVPN-Dyn' ){
1286 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1288 }elsif ($val eq 'IPsec RW' ){
1289 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1291 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1292 my ($sip,$scidr) = split ("/",$val);
1293 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1294 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1297 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1298 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1301 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1302 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1305 }elsif ($val eq 'Default IP'){
1306 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1309 #Check if a manual IP or custom host is part of a VPN
1310 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1311 #Check if IP is part of OpenVPN dynamic subnet
1312 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1313 my ($c,$d) = split("/",$val);
1314 if (&General
::IpInSubnet
($c,$a,$b)){
1315 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1318 #Check if IP is part of OpenVPN static subnet
1319 foreach my $key (sort keys %ccdnet){
1320 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1321 $b =&General
::iporsubtodec
($b);
1322 if (&General
::IpInSubnet
($c,$a,$b)){
1323 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1327 #Check if IP is part of OpenVPN N2N subnet
1328 foreach my $key (sort keys %ccdhost){
1329 if ($ccdhost{$key}[3] eq 'net'){
1330 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1331 if (&General
::IpInSubnet
($c,$a,$b)){
1332 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1337 #Check if IP is part of IPsec RW network
1338 if ($ipsecsettings{'RW_NET'} ne ''){
1339 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1340 $b=&General
::iporsubtodec
($b);
1341 if (&General
::IpInSubnet
($c,$a,$b)){
1342 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1346 #Check if IP is part of a IPsec N2N network
1347 foreach my $key (sort keys %ipsecconf){
1348 if ($ipsecconf{$key}[11]){
1349 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1350 $b=&General
::iporsubtodec
($b);
1351 if (&General
::IpInSubnet
($c,$a,$b)){
1352 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1359 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'){
1360 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1363 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1364 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1368 foreach my $alias (sort keys %aliases)
1370 if ($val eq $alias){
1371 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1382 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1383 print "<class name='base'>$hint\n";
1384 print " </class>\n";
1385 &Header
::closebox
();
1391 &General
::setup_default_networks
(\
%defaultNetworks);
1392 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1393 #read all configfiles
1394 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1395 &General
::readhasharray
("$confignet", \
%customnetwork);
1396 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1397 &General
::readhasharray
("$confighost", \
%customhost);
1398 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1399 &General
::readhasharray
("$configgrp", \
%customgrp);
1400 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1401 &General
::get_aliases
(\
%aliases);
1405 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1406 my $config=$fwdfwsettings{'config'};
1409 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1410 my $redip = <CONN1
>;
1412 if (! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE2'){
1413 $fwdfwsettings{'RULE_ACTION'}='DROP';
1414 }elsif(! $fwdfwsettings{'RULE_ACTION'} && $fwdfwsettings{'POLICY'} eq 'MODE1'){
1415 $fwdfwsettings{'RULE_ACTION'}='ACCEPT';
1417 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1418 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1419 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1420 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1421 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1422 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1423 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1424 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1425 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1426 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1427 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1428 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1429 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1430 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1431 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1432 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1433 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1434 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1435 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1436 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1437 #check if update and get values
1438 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1439 &General
::readhasharray
("$config", \
%hash);
1440 foreach my $key (sort keys %hash){
1442 if ($key eq $fwdfwsettings{'key'}){
1443 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1444 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1445 $fwdfwsettings{'chain'} = $hash{$key}[1];
1446 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1447 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1448 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1449 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1450 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1451 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1452 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1453 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1454 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1455 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1456 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1457 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1458 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1459 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1460 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1461 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1462 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1463 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1464 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1465 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1466 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1467 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1468 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1469 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1470 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1471 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1472 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1473 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1474 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1475 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1476 $fwdfwsettings{'LIMIT_CON_CON'} = $hash{$key}[32];
1477 $fwdfwsettings{'concon'} = $hash{$key}[33];
1478 $fwdfwsettings{'RATE_LIMIT'} = $hash{$key}[34];
1479 $fwdfwsettings{'ratecon'} = $hash{$key}[35];
1480 $fwdfwsettings{'RATETIME'} = $hash{$key}[36];
1481 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1482 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1483 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1484 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1485 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1486 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1487 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1488 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1489 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1490 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1491 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1492 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1493 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1494 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1495 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1496 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1497 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1498 $checked{'LIMIT_CON_CON'}{$fwdfwsettings{'LIMIT_CON_CON'}} = 'CHECKED';
1499 $checked{'RATE_LIMIT'}{$fwdfwsettings{'RATE_LIMIT'}} = 'CHECKED';
1500 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1501 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1502 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1503 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1504 $selected{'dnat'}{$fwdfwsettings{'dnat'}} ='selected';
1505 $selected{'snat'}{$fwdfwsettings{'snat'}} ='selected';
1506 $selected{'RATETIME'}{$fwdfwsettings{'RATETIME'}} ='selected';
1509 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1510 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1511 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1512 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1513 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1514 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1515 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1516 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1517 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1518 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1519 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1520 $fwdfwsettings{'olduseratelimit'}=$fwdfwsettings{'RATE_LIMIT'};
1521 $fwdfwsettings{'olduseratelimitamount'}=$fwdfwsettings{'ratecon'};
1522 $fwdfwsettings{'oldratelimittime'}=$fwdfwsettings{'RATETIME'};
1524 #check if manual ip (source) is orange network
1525 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1526 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1527 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1528 $fwdfwsettings{'oldorange'} ='on';
1532 $fwdfwsettings{'ACTIVE'}='ON';
1533 $fwdfwsettings{'nat'} = 'dnat';
1534 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1535 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1536 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1537 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1538 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1539 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1540 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1541 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1542 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1543 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1544 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1545 $fwdfwsettings{'oldconcon'}=$fwdfwsettings{'LIMIT_CON_CON'};
1546 #check if manual ip (source) is orange network
1547 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1548 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1549 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1550 $fwdfwsettings{'oldorange'} ='on';
1554 # Split manual source and target address and delete the subnet
1555 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1556 if ($scidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp1'}}=$sip;}
1557 my ($dip,$dcidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp2'}});
1558 if ($dcidr eq '32'){$fwdfwsettings{$fwdfwsettings{'grp2'}}=$dip;}
1559 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1560 #------SOURCE-------------------------------------------------------
1561 print "<form method='post'>";
1563 <table width='100%' border='0'>
1564 <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>
1566 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1567 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1568 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1569 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1570 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1571 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1572 if (! -z
"${General::swroot}/ethernet/aliases"){
1573 foreach my $alias (sort keys %aliases)
1575 print "<option value='$alias' $selected{'ipfire_src'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1580 <tr><td><br></td></tr>
1583 &gen_dd_block
('src','grp1');
1584 &Header
::closebox
();
1586 #---SNAT / DNAT ------------------------------------------------
1587 &Header
::openbox
('100%', 'left', 'NAT');
1590 <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}>
1591 $Lang::tr{'fwdfw use nat'}
1594 <table width='100%' border='0'>
1596 <td width='5%'></td>
1599 <input type='radio' name='nat' value='dnat' $checked{'nat'}{'dnat'}>
1600 $Lang::tr{'fwdfw dnat'}
1606 <td width='25%' align='right'>$Lang::tr{'dnat address'}:</td>
1608 <select name='dnat' style='width: 100%;'>
1609 <option value='AUTO' $selected{'dnat'}{'AUTO'}>- $Lang::tr{'automatic'} -</option>
1610 <option value='Default IP' $selected{'dnat'}{'Default IP'}>$Lang::tr{'red1'} ($redip)</option>
1613 foreach my $alias (sort keys %aliases) {
1614 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1618 foreach my $network (sort keys %defaultNetworks)
1620 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1621 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1622 print " selected='selected'" if ($fwdfwsettings{'dnat'} eq $defaultNetworks{$network}{'NAME'});
1623 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1632 <td width='5%'></td>
1635 <input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}>
1636 $Lang::tr{'fwdfw snat'}
1639 <td width='25%' align='right'>$Lang::tr{'snat new source ip address'}:</td>
1641 <select name='snat' style='width: 100%;'>
1644 foreach my $alias (sort keys %aliases) {
1645 print "<option value='$alias' $selected{'snat'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1648 foreach my $network (sort keys %defaultNetworks) {
1649 if ($defaultNetworks{$network}{'NAME'} eq 'BLUE'||$defaultNetworks{$network}{'NAME'} eq 'GREEN' ||$defaultNetworks{$network}{'NAME'} eq 'ORANGE'){
1650 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1651 print " selected='selected'" if ($fwdfwsettings{'snat'} eq $defaultNetworks{$network}{'NAME'});
1652 print ">$network ($defaultNetworks{$network}{'NET'})</option>";
1662 &Header
::closebox
();
1664 #---TARGET------------------------------------------------------
1665 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1667 <table width='100%' border='0'>
1668 <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>
1670 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1671 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1672 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1673 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1674 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1675 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1676 if (! -z
"${General::swroot}/ethernet/aliases"){
1677 foreach my $alias (sort keys %aliases)
1679 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias ($aliases{$alias}{'IPT'})</option>";
1684 <tr><td><br></td></tr></table>
1686 &gen_dd_block
('tgt','grp2');
1688 #---PROTOCOL------------------------------------------------------
1689 $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
1690 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1691 $fwdfwsettings{'dnatport'} =~ tr/|/,/;
1693 # The dnatport may be empty, if it matches TGT_PORT
1694 if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
1695 $fwdfwsettings{'dnatport'} = "";
1698 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1699 #Fix Protocol for JQuery
1700 if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
1701 $fwdfwsettings{'PROT'} = 'template';
1704 <table width='100%' border='0'>
1707 <select name='PROT' id='protocol' style="width: 95px;">
1709 print "<option value=\"\"";
1710 if ($fwdfwsettings{'PROT'} eq '') {
1711 print " selected=\"selected\"";
1713 print ">$Lang::tr{'all'}</option>";
1715 print "<option value=\"template\"";
1716 print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp');
1717 print ">- $Lang::tr{'template'} -</option>";
1719 foreach (@PROTOCOLS) {
1720 print"<option value=\"$_\"";
1721 if ($_ eq $fwdfwsettings{'PROT'}) {
1722 print " selected=\"selected\"";
1725 print ">$Lang::tr{'fwdfw prot41'}</option>";
1727 print ">$_</option>";
1735 <table width='100%' border='0' id="PROTOCOL_ICMP_TYPES">
1737 <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
1739 <select name='ICMP_TYPES' style='min-width:230px;'>
1741 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1742 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1743 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1744 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1745 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1747 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1757 <table width="100%" border="0" id="PROTOCOL_PORTS">
1759 <!-- #SOURCEPORT -->
1761 $Lang::tr{'fwdfw use srcport'}
1764 <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
1769 <!-- #TARGETPORT -->
1771 $Lang::tr{'fwdfw use srv'}
1775 <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
1779 <td colspan='3'></td>
1780 <td>$Lang::tr{'fwdfw external port nat'}:</td>
1782 <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
1787 <table width="100%" border="0" id="PROTOCOL_TEMPLATE">
1790 <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
1791 $Lang::tr{'fwhost cust service'}
1794 <select name='cust_srv' style='min-width: 230px;'>
1797 &General
::readhasharray
("$configsrv", \
%customservice);
1798 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1800 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1801 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1810 <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
1811 $Lang::tr{'fwhost cust srvgrp'}
1814 <select name='cust_srvgrp' style='min-width:230px;'>
1817 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1819 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1820 if ($helper ne $customservicegrp{$key}[0] && $customservicegrp{$key}[2] ne 'none'){
1822 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1823 print">$customservicegrp{$key}[0]</option>";
1825 $helper=$customservicegrp{$key}[0];
1839 $checked{"RULE_ACTION"}{$fwdfwsettings{'RULE_ACTION'}} = 'CHECKED';
1842 <table width="80%" class='tbl' id='actions'>
1844 <td width="33%" align="center" bgcolor="$color{'color17'}">
1847 <td width="33%" align="center" bgcolor="$color{'color25'}">
1850 <td width="33%" align="center" bgcolor="$color{'color16'}">
1855 <td width="33%" align="center">
1857 <input type="radio" name="RULE_ACTION" value="ACCEPT" $checked{"RULE_ACTION"}{"ACCEPT"}>
1858 <strong>$Lang::tr{'fwdfw ACCEPT'}</strong>
1861 <td width="33%" align="center">
1863 <input type="radio" name="RULE_ACTION" value="DROP" $checked{"RULE_ACTION"}{"DROP"}>
1864 <strong>$Lang::tr{'fwdfw DROP'}</strong>
1867 <td width="33%" align="center">
1869 <input type="radio" name="RULE_ACTION" value="REJECT" $checked{"RULE_ACTION"}{"REJECT"}>
1870 <strong>$Lang::tr{'fwdfw REJECT'}</strong>
1879 #---Activate/logging/remark-------------------------------------
1880 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1882 <table width='100%' border='0'>
1884 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>";
1885 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1886 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1887 for (my $count =1; $count <= $sum; $count++){
1888 print"<option value='$count' ";
1889 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1890 print">$count</option>";
1892 print"</select></td></tr>";
1894 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1899 <table width='100%'>
1903 if ($fwdfwsettings{'updatefwrule'} eq 'on') {
1906 <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}>
1908 <td>$Lang::tr{'fwdfw rule activate'}</td>
1913 <input type="hidden" name="ACTIVE" value="ON">
1922 <input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'}>
1924 <td>$Lang::tr{'fwdfw log rule'}</td>
1928 <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}>
1930 <td>$Lang::tr{'fwdfw timeframe'}</td>
1932 <tr id="TIME_CONSTRAINTS">
1934 <table width="66%" border="0">
1936 <td width="8em"> </td>
1937 <td align="center">$Lang::tr{'advproxy monday'}</td>
1938 <td align="center">$Lang::tr{'advproxy tuesday'}</td>
1939 <td align="center">$Lang::tr{'advproxy wednesday'}</td>
1940 <td align="center">$Lang::tr{'advproxy thursday'}</td>
1941 <td align="center">$Lang::tr{'advproxy friday'}</td>
1942 <td align="center">$Lang::tr{'advproxy saturday'}</td>
1943 <td align="center">$Lang::tr{'advproxy sunday'}</td>
1947 <td width="8em"> </td>
1948 <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
1949 <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
1950 <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
1951 <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
1952 <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
1953 <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
1954 <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
1956 <select name='TIME_FROM'>
1958 for (my $i=0;$i<=23;$i++) {
1959 $i = sprintf("%02s",$i);
1960 for (my $j=0;$j<=45;$j+=15) {
1961 $j = sprintf("%02s",$j);
1962 my $time = $i.":".$j;
1963 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1968 <select name='TIME_TO'>
1970 for (my $i=0;$i<=23;$i++) {
1971 $i = sprintf("%02s",$i);
1972 for (my $j=0;$j<=45;$j+=15) {
1973 $j = sprintf("%02s",$j);
1974 my $time = $i.":".$j;
1975 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1987 <input type='checkbox' name='LIMIT_CON_CON' id="USE_LIMIT_CONCURRENT_CONNECTIONS_PER_IP" value='ON' $checked{'LIMIT_CON_CON'}{'ON'}>
1989 <td>$Lang::tr{'fwdfw limitconcon'}</td>
1993 <table width='66%' border='0'>
1995 <td width="20em"> </td>
1996 <td>$Lang::tr{'fwdfw maxconcon'}: <input type='text' name='concon' size='2' value="$fwdfwsettings{'concon'}"></td>
2003 <input type='checkbox' name='RATE_LIMIT' id="USE_RATELIMIT" value='ON' $checked{'RATE_LIMIT'}{'ON'}>
2005 <td>$Lang::tr{'fwdfw ratelimit'}</td>
2009 <table width='66%' border='0'>
2011 <td width="20em"> </td>
2012 <td>$Lang::tr{'fwdfw numcon'}: <input type='text' name='ratecon' size='2' value="$fwdfwsettings{'ratecon'}"> /
2013 <select name='RATETIME' style='width:100px;'>
2014 <option value='second' $selected{'RATETIME'}{'second'}>$Lang::tr{'age second'}</option>
2015 <option value='minute' $selected{'RATETIME'}{'minute'}>$Lang::tr{'minute'}</option>
2016 <option value='hour' $selected{'RATETIME'}{'hour'}>$Lang::tr{'hour'}</option>
2027 #---ACTION------------------------------------------------------
2028 if($fwdfwsettings{'updatefwrule'} ne 'on'){
2030 <table border='0' width='100%'>
2031 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
2032 <input type='hidden' name='config' value='$config' >
2033 <input type='hidden' name='ACTION' value='saverule' ></form>
2034 <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>
2040 <table border='0' width='100%'>
2041 <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'}'>
2042 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
2043 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
2044 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
2045 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
2046 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
2047 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
2048 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
2049 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
2050 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
2051 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
2052 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
2053 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
2054 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
2055 <input type='hidden' name='oldconcon' value='$fwdfwsettings{'oldconcon'}' />
2056 <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>
2060 &Header
::closebox
();
2066 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
2067 foreach my $key (sort keys %uphash){
2068 if ($key eq $fwdfwsettings{'key'}) {
2070 if (exists $uphash{$last}){
2072 foreach my $y (0 .. $#{$uphash{$last}}) {
2073 $tmp{0}[$y] = $uphash{$last}[$y];
2075 #copy active rule to last
2076 foreach my $i (0 .. $#{$uphash{$last}}) {
2077 $uphash{$last}[$i] = $uphash{$key}[$i];
2079 #copy saved rule to actual position
2080 foreach my $x (0 .. $#{$tmp{0}}) {
2081 $uphash{$key}[$x] = $tmp{0}[$x];
2086 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
2087 &General
::firewall_config_changed
();
2093 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
2094 foreach my $key (sort keys %downhash){
2095 if ($key eq $fwdfwsettings{'key'}) {
2096 my $next = $key + 1;
2097 if (exists $downhash{$next}){
2099 foreach my $y (0 .. $#{$downhash{$next}}) {
2100 $tmp{0}[$y] = $downhash{$next}[$y];
2102 #copy active rule to next
2103 foreach my $i (0 .. $#{$downhash{$next}}) {
2104 $downhash{$next}[$i] = $downhash{$key}[$i];
2106 #copy saved rule to actual position
2107 foreach my $x (0 .. $#{$tmp{0}}) {
2108 $downhash{$key}[$x] = $tmp{0}[$x];
2113 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
2114 &General
::firewall_config_changed
();
2120 &General
::readhasharray
("$config", $hash);
2121 if (!$errormessage){
2122 ################################################################
2123 #check if we change an INPUT rule to a OUTGOING
2124 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2125 &changerule
($configinput);
2128 #check if we change an INPUT rule to a FORWARD
2129 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2130 &changerule
($configinput);
2133 ################################################################
2134 #check if we change an OUTGOING rule to an INPUT
2135 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2136 &changerule
($configoutgoing);
2139 #check if we change an OUTGOING rule to a FORWARD
2140 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2141 &changerule
($configoutgoing);
2144 ################################################################
2145 #check if we change a FORWARD rule to an INPUT
2146 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2147 &changerule
($configfwdfw);
2150 #check if we change a FORWARD rule to an OUTGOING
2151 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2152 &changerule
($configfwdfw);
2155 $fwdfwsettings{'ruleremark'}=~ s/,/;/g;
2156 utf8
::decode
($fwdfwsettings{'ruleremark'});
2157 $fwdfwsettings{'ruleremark'}=&Header
::escape
($fwdfwsettings{'ruleremark'});
2158 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2159 my $key = &General
::findhasharraykey
($hash);
2160 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2161 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2162 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2163 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2164 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2165 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2166 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2167 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2168 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2169 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2170 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2171 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2172 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2173 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2174 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2175 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2176 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2177 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2178 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2179 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2180 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2181 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2182 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2183 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2184 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2185 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2186 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2187 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2188 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2189 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2190 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2191 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2192 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2193 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2194 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2195 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2196 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2197 &General
::writehasharray
("$config", $hash);
2199 foreach my $key (sort {$a <=> $b} keys %$hash){
2200 if($key eq $fwdfwsettings{'key'}){
2201 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2202 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2203 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2204 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2205 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2206 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2207 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2208 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2209 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2210 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2211 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2212 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2213 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2214 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2215 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2216 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2217 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2218 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2219 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2220 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2221 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2222 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2223 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2224 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2225 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2226 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2227 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2228 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2229 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2230 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2231 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2232 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2233 $$hash{$key}[32] = $fwdfwsettings{'LIMIT_CON_CON'};
2234 $$hash{$key}[33] = $fwdfwsettings{'concon'};
2235 $$hash{$key}[34] = $fwdfwsettings{'RATE_LIMIT'};
2236 $$hash{$key}[35] = $fwdfwsettings{'ratecon'};
2237 $$hash{$key}[36] = $fwdfwsettings{'RATETIME'};
2242 &General
::writehasharray
("$config", $hash);
2243 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2245 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2246 for (my $z=0;$z<$val;$z++){
2247 foreach my $key (sort {$a <=> $b} keys %$hash){
2248 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2250 if (exists $$hash{$last}){
2252 foreach my $y (0 .. $#{$$hash{$last}}) {
2253 $tmp{0}[$y] = $$hash{$last}[$y];
2255 #copy active rule to last
2256 foreach my $i (0 .. $#{$$hash{$last}}) {
2257 $$hash{$last}[$i] = $$hash{$key}[$i];
2259 #copy saved rule to actual position
2260 foreach my $x (0 .. $#{$tmp{0}}) {
2261 $$hash{$key}[$x] = $tmp{0}[$x];
2266 $fwdfwsettings{'oldrulenumber'}--;
2268 &General
::writehasharray
("$config", $hash);
2269 &General
::firewall_config_changed
();
2270 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2272 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2273 for (my $z=0;$z<$val;$z++){
2274 foreach my $key (sort {$a <=> $b} keys %$hash){
2275 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2276 my $next = $key + 1;
2277 if (exists $$hash{$next}){
2279 foreach my $y (0 .. $#{$$hash{$next}}) {
2280 $tmp{0}[$y] = $$hash{$next}[$y];
2282 #copy active rule to next
2283 foreach my $i (0 .. $#{$$hash{$next}}) {
2284 $$hash{$next}[$i] = $$hash{$key}[$i];
2286 #copy saved rule to actual position
2287 foreach my $x (0 .. $#{$tmp{0}}) {
2288 $$hash{$key}[$x] = $tmp{0}[$x];
2293 $fwdfwsettings{'oldrulenumber'}++;
2295 &General
::writehasharray
("$config", $hash);
2296 &General
::firewall_config_changed
();
2302 # Checks a hostname against RFC1035
2305 # Try to decode $remark into UTF-8. If this doesn't work,
2306 # we assume that the string it not sane.
2307 if (!utf8
::decode
($remark)) {
2311 # Check if the string only contains of printable characters.
2312 if ($remark =~ /^[[:print:]]*$/) {
2319 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2321 &viewtablenew
(\
%configfwdfw, $configfwdfw, $Lang::tr
{'firewall rules'});
2322 &viewtablenew
(\
%configinputfw, $configinput, $Lang::tr
{'incoming firewall access'});
2323 &viewtablenew
(\
%configoutgoingfw, $configoutgoing, $Lang::tr
{'outgoing firewall access'});
2332 my $show_box = (! -z
$config) || ($optionsfw{'SHOWTABLES'} eq 'on');
2333 return if (!$show_box);
2335 &General
::get_aliases
(\
%aliases);
2336 &General
::readhasharray
("$confighost", \
%customhost);
2337 &General
::readhasharray
("$config", $hash);
2338 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2339 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2340 &General
::readhasharray
("$configgrp", \
%customgrp);
2341 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2343 &Header
::openbox
('100%', 'left', $title);
2344 print "<table width='100%' cellspacing='0' class='tbl'>";
2358 <th align='right' width='3%'>
2361 <th width='2%'></th>
2363 <b>$Lang::tr{'protocol'}</b>
2365 <th align='center' width='30%'>
2366 <b>$Lang::tr{'fwdfw source'}</b>
2369 <b>$Lang::tr{'fwdfw log'}</b>
2371 <th align='center' width='30%'>
2372 <b>$Lang::tr{'fwdfw target'}</b>
2374 <th align='center' colspan='6' width='18%'>
2375 <b>$Lang::tr{'fwdfw action'}</b>
2380 foreach my $key (sort {$a <=> $b} keys %$hash){
2384 #check if vpn hosts/nets have been deleted
2385 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2386 push (@tmpsrc,$$hash{$key}[4]);
2388 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2389 push (@tmptgt,$$hash{$key}[6]);
2391 foreach my $host (@tmpsrc){
2392 if($$hash{$key}[3] eq 'ipsec_net_src'){
2393 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2396 }elsif($$hash{$key}[3] eq 'ovpn_net_src'){
2397 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2400 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src'){
2401 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2404 }elsif($$hash{$key}[3] eq 'ovpn_host_src'){
2405 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2410 foreach my $host (@tmptgt){
2411 if($$hash{$key}[5] eq 'ipsec_net_tgt'){
2412 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2415 }elsif($$hash{$key}[5] eq 'ovpn_net_tgt'){
2416 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2419 }elsif($$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2420 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2423 }elsif($$hash{$key}[5] eq 'ovpn_host_tgt'){
2424 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2429 #check if networkgroups or servicegroups are empty
2430 foreach my $netgroup (sort keys %customgrp){
2431 if(($$hash{$key}[4] eq $customgrp{$netgroup}[0] || $$hash{$key}[6] eq $customgrp{$netgroup}[0]) && $customgrp{$netgroup}[2] eq 'none'){
2435 foreach my $srvgroup (sort keys %customservicegrp){
2436 if($$hash{$key}[15] eq $customservicegrp{$srvgroup}[0] && $customservicegrp{$srvgroup}[2] eq 'none'){
2440 $$hash{'ACTIVE'}=$$hash{$key}[2];
2442 if($coloryellow eq 'on'){
2443 $color="$color{'color14'}";
2445 }elsif($coloryellow eq ''){
2447 $color="$color{'color22'}";
2450 $color="$color{'color20'}";
2454 <tr bgcolor='$color'>
2455 <td align='right' width='3%'>
2461 if ($$hash{$key}[0] eq 'ACCEPT'){
2464 $rulecolor=$color{'color17'};
2465 }elsif($$hash{$key}[0] eq 'DROP'){
2468 $rulecolor=$color{'color25'};
2469 }elsif($$hash{$key}[0] eq 'REJECT'){
2472 $rulecolor=$color{'color16'};
2476 <td bgcolor='$rulecolor' align='center' width='2%'>
2477 <span title='$tooltip'> </span>
2483 if ($$hash{$key}[8]){
2484 if ($$hash{$key}[8] eq "IPv6"){
2485 push (@protocols,$Lang::tr
{'fwdfw prot41 short'})
2487 push (@protocols,$$hash{$key}[8]);
2489 }elsif($$hash{$key}[14] eq 'cust_srv'){
2490 &get_serviceports
("service",$$hash{$key}[15]);
2491 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2492 &get_serviceports
("group",$$hash{$key}[15]);
2494 push (@protocols,$Lang::tr
{'all'});
2497 my $protz=join(", ",@protocols);
2498 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2499 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2500 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2501 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2502 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2506 }elsif($#protocols gt '3'){
2507 print"<td align='center'><span title='$protz'>$Lang::tr{'fwdfw many'}</span></td>";
2509 print"<td align='center'>$protz</td>";
2514 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2515 print"<td align='center' width='30%' $tdcolor>";
2516 if ($$hash{$key}[3] eq 'ipfire_src'){
2517 $ipfireiface=$Lang::tr
{'fwdfw iface'};
2519 if ($$hash{$key}[3] eq 'std_net_src'){
2520 print &get_name
($$hash{$key}[4]);
2521 }elsif ($$hash{$key}[3] eq 'src_addr'){
2522 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2523 if ($split2 eq '32'){
2526 print $$hash{$key}[4];
2528 }elsif ($$hash{$key}[4] eq 'RED1'){
2529 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2530 }elsif ($$hash{$key}[4] eq 'ALL'){
2531 print "$ipfireiface $Lang::tr{'all'}";
2533 if ($$hash{$key}[4] eq 'GREEN' || $$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE' || $$hash{$key}[4] eq 'RED'){
2534 print "$ipfireiface $Lang::tr{lc($$hash{$key}[4])}";
2536 print "$ipfireiface $$hash{$key}[4]";
2541 &getsrcport
(\
%$hash,$key);
2542 #Is this a SNAT rule?
2543 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2544 my $net=&get_name
($$hash{$key}[29]);
2545 if ( ! $net){ $net=$$hash{$key}[29];}
2547 if ($$hash{$key}[30] ne ''){
2548 print": $$hash{$key}[30]";
2551 if ($$hash{$key}[17] eq 'ON'){
2552 $log="/images/on.gif";
2554 $log="/images/off.gif";
2560 <form method='POST' action=''>
2561 <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 ;'/>
2562 <input type='hidden' name='key' value='$key' />
2563 <input type='hidden' name='config' value='$config' />
2564 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2569 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2571 <td align='center' $tdcolor>
2573 #Is this a DNAT rule?
2575 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2576 if ($$hash{$key}[29] eq 'Default IP'){$$hash{$key}[29]=$Lang::tr
{'red1'};}
2577 if ($$hash{$key}[29] eq 'AUTO'){
2578 my @src_addresses=&fwlib
::get_addresses
(\
%$hash,$key,'src');
2580 foreach my $val (@src_addresses){
2581 push (@nat_ifaces,&fwlib
::get_nat_address
($$hash{$key}[29],$val));
2583 @nat_ifaces=&del_double
(@nat_ifaces);
2586 $natstring = "($$hash{$key}[29])";
2588 print "$Lang::tr{'firewall'} $natstring";
2589 if($$hash{$key}[30] ne ''){
2590 $$hash{$key}[30]=~ tr/|/,/;
2591 print": $$hash{$key}[30]";
2595 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire'){
2596 if ($$hash{$key}[6] eq 'RED1'){
2597 print "$Lang::tr{'red1'}";
2598 }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')
2600 print &get_name
($$hash{$key}[6]);
2602 print $$hash{$key}[6];
2604 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2605 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2606 if ($split2 eq '32'){
2609 print $$hash{$key}[6];
2612 print "$$hash{$key}[6]";
2616 &gettgtport
(\
%$hash,$key);
2619 if($$hash{$key}[2] eq 'ON'){
2620 $gif="/images/on.gif"
2623 $gif="/images/off.gif"
2626 <td width='3%' align='center'>
2627 <form method='POST' action=''>
2628 <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;' />
2629 <input type='hidden' name='key' value='$key' />
2630 <input type='hidden' name='config' value='$config' />
2631 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2634 <td width='3%' align='center'>
2635 <form method='POST' action=''>
2636 <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;' />
2637 <input type='hidden' name='key' value='$key' />
2638 <input type='hidden' name='config' value='$config' />
2639 <input type='hidden' name='ACTION' value='editrule' />
2642 <td width='3%' align='center'>
2643 <form method='POST' action=''>
2644 <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;' />
2645 <input type='hidden' name='key' value='$key' />
2646 <input type='hidden' name='config' value='$config' />
2647 <input type='hidden' name='ACTION' value='copyrule' />
2650 <td width='3%' align='center'>
2651 <form method='POST' action=''>
2652 <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;' />
2653 <input type='hidden' name='key' value='$key' />
2654 <input type='hidden' name='config' value='$config' />
2655 <input type='hidden' name='ACTION' value='deleterule' />
2659 if (exists $$hash{$key-1}){
2661 <td width='3%' align='center'>
2662 <form method='POST' action=''>
2663 <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;' />
2664 <input type='hidden' name='key' value='$key' />
2665 <input type='hidden' name='config' value='$config' />
2666 <input type='hidden' name='ACTION' value='moveup' />
2671 print"<td width='3%'></td>";
2674 if (exists $$hash{$key+1}){
2676 <td width='3%' align='center'>
2677 <form method='POST' action=''>
2678 <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;' />
2679 <input type='hidden' name='key' value='$key' />
2680 <input type='hidden' name='config' value='$config' />
2681 <input type='hidden' name='ACTION' value='movedown' />
2687 print"<td width='3%'></td></tr>";
2690 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2692 <tr bgcolor='$color'>
2694 <td bgcolor='$rulecolor'></td>
2696 <em>$$hash{$key}[16]</em>
2702 if ($$hash{$key}[18] eq 'ON'){
2704 if ($$hash{$key}[18] eq 'ON'){
2706 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2707 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2708 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2709 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2710 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2711 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2712 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2713 my $weekdays=join(",",@days);
2715 print"<tr bgcolor='$color'>";
2716 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27]</td></tr>";
2720 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2722 } elsif ($optionsfw{'SHOWTABLES'} eq 'on') {
2725 <td colspan='7' height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td>
2731 my $policy = 'fwdfw ' . $fwdfwsettings{'POLICY'};
2732 my $colour = "bgcolor='green'";
2733 if ($fwdfwsettings{'POLICY'} eq 'MODE1') {
2734 $colour = "bgcolor='darkred'";
2738 if (($config eq '/var/ipfire/firewall/config') && ($fwdfwsettings{'POLICY'} ne 'MODE1')) {
2741 <td colspan='13'> </td>
2744 <td colspan='13' style="padding-left:0px;padding-right:0px">
2745 <table width="100%" border='1' rules="cols" cellspacing='0'>
2752 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2755 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2756 ($Lang::tr{'fwdfw pol allow'})
2760 if (&Header
::orange_used
()) {
2763 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2764 ($Lang::tr{'fwdfw pol allow'})
2769 if (&Header
::blue_used
()) {
2772 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2773 ($Lang::tr{'fwdfw pol allow'})
2781 if (&Header
::orange_used
()) {
2784 <td align='center' width='20%'>
2785 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2788 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2789 ($Lang::tr{'fwdfw pol allow'})
2792 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2793 ($Lang::tr{'fwdfw pol block'})
2797 if (&Header
::blue_used
()) {
2800 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2801 ($Lang::tr{'fwdfw pol block'})
2809 if (&Header
::blue_used
()) {
2813 <font color="$Header::colourblue">$Lang::tr{'blue'}</font>
2816 <font color="$Header::colourred">$Lang::tr{'red'}</font>
2817 ($Lang::tr{'fwdfw pol allow'})
2821 if (&Header
::orange_used
()) {
2824 <font color="$Header::colourorange">$Lang::tr{'orange'}</font>
2825 ($Lang::tr{'fwdfw pol block'})
2832 <font color="$Header::colourgreen">$Lang::tr{'green'}</font>
2833 ($Lang::tr{'fwdfw pol block'})
2845 $message = $Lang::tr
{'fwdfw pol allow'};
2847 } elsif ($config eq '/var/ipfire/firewall/outgoing' && ($fwdfwsettings{'POLICY1'} ne 'MODE1')) {
2848 $message = $Lang::tr
{'fwdfw pol allow'};
2849 $colour = "bgcolor='green'";
2851 $message = $Lang::tr
{'fwdfw pol block'};
2852 $colour = "bgcolor='darkred'";
2858 <td $colour align='center' colspan='13'>
2859 <font color='#FFFFFF'>$Lang::tr{'policy'}: $message</font>
2868 &Header
::closebox
();
2871 &Header
::closebigbox
();
2872 &Header
::closepage
();