]>
git.ipfire.org Git - people/ms/ipfire-2.x.git/blob - html/cgi-bin/forwardfw.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
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 ###############################################################################
22 # Hi folks! I hope this code is useful for all. I needed something to handle #
23 # my VPN Connections in a comfortable way. As a prerequisite i needed #
24 # something that makes sure the vpn roadwarrior are able to have a fixed #
25 # ip-address. So i developed the ccd extension for the vpn server. #
27 # Now that the ccd extension is ready i am able to develop the main request. #
28 # Any feedback is appreciated. #
31 ###############################################################################
34 no warnings
'uninitialized';
35 # enable only the following on debugging purpose
37 #use CGI::Carp 'fatalsToBrowser';
39 require '/var/ipfire/general-functions.pl';
40 require "${General::swroot}/lang.pl";
41 require "${General::swroot}/header.pl";
42 require "${General::swroot}/forward/bin/firewall-lib.pl";
44 unless (-d
"${General::swroot}/forward") { system("mkdir ${General::swroot}/forward"); }
45 unless (-e
"${General::swroot}/forward/settings") { system("touch ${General::swroot}/forward/settings"); }
46 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
47 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
48 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
49 unless (-e
"${General::swroot}/forward/dmz") { system("touch ${General::swroot}/forward/dmz"); }
50 unless (-e
"${General::swroot}/forward/nat") { system("touch ${General::swroot}/forward/nat"); }
54 my %defaultNetworks=();
58 my %customnetworks=();
60 my %customservicegrp=();
66 my %configoutgoingfw=();
80 my $VERSION='0.9.8.7';
82 my $confignet = "${General::swroot}/fwhosts/customnetworks";
83 my $confighost = "${General::swroot}/fwhosts/customhosts";
84 my $configgrp = "${General::swroot}/fwhosts/customgroups";
85 my $configsrv = "${General::swroot}/fwhosts/customservices";
86 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
87 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
88 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
89 my $configipsec = "${General::swroot}/vpn/config";
90 my $configipsecrw = "${General::swroot}/vpn/settings";
91 my $configfwdfw = "${General::swroot}/forward/config";
92 my $configinput = "${General::swroot}/forward/input";
93 my $configoutgoing = "${General::swroot}/forward/outgoing";
94 my $configdmz = "${General::swroot}/forward/dmz";
95 my $confignat = "${General::swroot}/forward/nat";
96 my $configovpn = "${General::swroot}/ovpn/settings";
97 my $fwoptions = "${General::swroot}/optionsfw/settings";
98 my $ifacesettings = "${General::swroot}/ethernet/settings";
101 my $ipgrp="${General::swroot}/outgoing/groups";
105 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
106 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
107 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
108 &General
::readhash
($fwoptions, \
%optionsfw);
109 &General
::readhash
($ifacesettings, \
%ifaces);
111 &Header
::showhttpheaders
();
112 &Header
::getcgihash
(\
%fwdfwsettings);
113 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
114 &Header
::openbigbox
('100%', 'center',$errormessage);
117 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
119 my $MODE = $fwdfwsettings{'POLICY'};
120 my $MODE1 = $fwdfwsettings{'POLICY1'};
122 $fwdfwsettings{'POLICY'} = "$MODE";
123 $fwdfwsettings{'POLICY1'} = "$MODE1";
124 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
127 if ($fwdfwsettings{'ACTION'} eq 'saverule')
129 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
130 &General
::readhasharray
("$configinput", \
%configinputfw);
131 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
132 &General
::readhasharray
("$confignat", \
%confignatfw);
133 $errormessage=&checksource
;
134 if(!$errormessage){&checktarget
;}
135 if(!$errormessage){&checkrule
;}
136 #check if manual ip (source) is orange network
137 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
138 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
139 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
144 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
145 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
147 #check if we try to break rules
148 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire'){
149 $errormessage.=$Lang::tr
{'fwdfw err same'};
152 if ($fwdfwsettings{'USE_NAT'} eq 'ON'){
153 $fwdfwsettings{'config'}=$confignat;
154 if ($fwdfwsettings{'nat'} eq 'dnat'){
155 $fwdfwsettings{'chain'} = 'NAT_DESTINATION';
157 $fwdfwsettings{'chain'} = 'NAT_SOURCE';
159 my $maxkey=&General
::findhasharraykey
(\
%confignatfw);
160 #check if we have an identical rule already
161 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
162 foreach my $key (sort keys %confignatfw){
163 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{'snatport'},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"
164 eq "$confignatfw{$key}[0],$confignatfw{$key}[2],$confignatfw{$key}[3],$confignatfw{$key}[4],$confignatfw{$key}[5],$confignatfw{$key}[6],$confignatfw{$key}[7],$confignatfw{$key}[8],$confignatfw{$key}[9],$confignatfw{$key}[10],$confignatfw{$key}[11],$confignatfw{$key}[12],$confignatfw{$key}[13],$confignatfw{$key}[14],$confignatfw{$key}[15],$confignatfw{$key}[17],$confignatfw{$key}[19],$confignatfw{$key}[20],$confignatfw{$key}[21],$confignatfw{$key}[22],$confignatfw{$key}[23],$confignatfw{$key}[24],$confignatfw{$key}[25],$confignatfw{$key}[26],$confignatfw{$key}[27],$confignatfw{$key}[28],$confignatfw{$key}[29],$confignatfw{$key}[30],$confignatfw{$key}[31],$confignatfw{$key}[32]"){
165 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
166 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
168 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
169 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
171 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
172 $fwdfwsettings{'nosave'} = 'on';
177 #check Rulepos on new Rule
178 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
179 $fwdfwsettings{'oldrulenumber'}=$maxkey;
180 foreach my $key (sort keys %confignatfw){
181 print"$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{'snatport'},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}<br>";
182 print"$confignatfw{$key}[0],$confignatfw{$key}[2],$confignatfw{$key}[3],$confignatfw{$key}[4],$confignatfw{$key}[5],$confignatfw{$key}[6],$confignatfw{$key}[7],$confignatfw{$key}[8],$confignatfw{$key}[9],$confignatfw{$key}[10],$confignatfw{$key}[11],$confignatfw{$key}[12],$confignatfw{$key}[13],$confignatfw{$key}[14],$confignatfw{$key}[15],$confignatfw{$key}[17],$confignatfw{$key}[19],$confignatfw{$key}[20],$confignatfw{$key}[21],$confignatfw{$key}[22],$confignatfw{$key}[23],$confignatfw{$key}[24],$confignatfw{$key}[25],$confignatfw{$key}[26],$confignatfw{$key}[27],$confignatfw{$key}[28],$confignatfw{$key}[29],$confignatfw{$key}[30],$confignatfw{$key}[31],$confignatfw{$key}[32]<br>";
183 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{'snatport'},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"
184 eq "$confignatfw{$key}[0],$confignatfw{$key}[2],$confignatfw{$key}[3],$confignatfw{$key}[4],$confignatfw{$key}[5],$confignatfw{$key}[6],$confignatfw{$key}[7],$confignatfw{$key}[8],$confignatfw{$key}[9],$confignatfw{$key}[10],$confignatfw{$key}[11],$confignatfw{$key}[12],$confignatfw{$key}[13],$confignatfw{$key}[14],$confignatfw{$key}[15],$confignatfw{$key}[17],$confignatfw{$key}[19],$confignatfw{$key}[20],$confignatfw{$key}[21],$confignatfw{$key}[22],$confignatfw{$key}[23],$confignatfw{$key}[24],$confignatfw{$key}[25],$confignatfw{$key}[26],$confignatfw{$key}[27],$confignatfw{$key}[28],$confignatfw{$key}[29],$confignatfw{$key}[30],$confignatfw{$key}[31],$confignatfw{$key}[32]"){
185 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
189 #check if we just close a rule
190 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'}) {
191 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
193 $fwdfwsettings{'nosave2'} = 'on';
196 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
197 if ($fwdfwsettings{'nobase'} ne 'on'){
198 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
200 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
201 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
202 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
203 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
204 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
205 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
207 if($fwdfwsettings{'nosave2'} ne 'on'){
208 &saverule
(\
%confignatfw,$confignat);
211 }elsif ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on'){
212 $fwdfwsettings{'config'}=$configdmz;
213 $fwdfwsettings{'chain'} = 'FORWARDFW';
214 my $maxkey=&General
::findhasharraykey
(\
%configdmzfw);
215 #check if we have an identical rule already
216 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
217 foreach my $key (sort keys %configdmzfw){
218 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{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
219 eq "$configdmzfw{$key}[0],$configdmzfw{$key}[2],$configdmzfw{$key}[3],$configdmzfw{$key}[4],$configdmzfw{$key}[5],$configdmzfw{$key}[6],$configdmzfw{$key}[7],$configdmzfw{$key}[8],$configdmzfw{$key}[9],$configdmzfw{$key}[10],$configdmzfw{$key}[11],$configdmzfw{$key}[12],$configdmzfw{$key}[13],$configdmzfw{$key}[14],$configdmzfw{$key}[15],$configdmzfw{$key}[17],$configdmzfw{$key}[18],$configdmzfw{$key}[19],$configdmzfw{$key}[20],$configdmzfw{$key}[21],$configdmzfw{$key}[22],$configdmzfw{$key}[23],$configdmzfw{$key}[24],$configdmzfw{$key}[25],$configdmzfw{$key}[26],$configdmzfw{$key}[27]"){
220 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
221 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
223 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
224 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
226 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
227 $fwdfwsettings{'nosave'} = 'on';
232 #check Rulepos on new Rule
233 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
234 $fwdfwsettings{'oldrulenumber'}=$maxkey;
235 foreach my $key (sort keys %configdmzfw){
236 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{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
237 eq "$configdmzfw{$key}[0],$configdmzfw{$key}[2],$configdmzfw{$key}[3],$configdmzfw{$key}[4],$configdmzfw{$key}[5],$configdmzfw{$key}[6],$configdmzfw{$key}[7],$configdmzfw{$key}[8],$configdmzfw{$key}[9],$configdmzfw{$key}[10],$configdmzfw{$key}[11],$configdmzfw{$key}[12],$configdmzfw{$key}[13],$configdmzfw{$key}[14],$configdmzfw{$key}[15],$configdmzfw{$key}[17],$configdmzfw{$key}[18],$configdmzfw{$key}[19],$configdmzfw{$key}[20],$configdmzfw{$key}[21],$configdmzfw{$key}[22],$configdmzfw{$key}[23],$configdmzfw{$key}[24],$configdmzfw{$key}[25],$configdmzfw{$key}[26],$configdmzfw{$key}[27]"){
238 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
242 #check if we just close a rule
243 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'}) {
244 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
246 $fwdfwsettings{'nosave2'} = 'on';
249 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
250 if ($fwdfwsettings{'nobase'} ne 'on'){
251 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
253 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
254 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
255 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
256 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
257 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
258 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
260 if($fwdfwsettings{'nosave2'} ne 'on'){
261 &saverule
(\
%configdmzfw,$configdmz);
264 }elsif($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
265 $fwdfwsettings{'config'}=$configinput;
266 $fwdfwsettings{'chain'} = 'INPUTFW';
267 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
268 #check if we have an identical rule already
269 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
270 foreach my $key (sort keys %configinputfw){
271 if ("$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
272 eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27]"){
273 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
274 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
276 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
277 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
279 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
280 $fwdfwsettings{'nosave'} = 'on';
285 #check Rulepos on new Rule
286 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
287 $fwdfwsettings{'oldrulenumber'}=$maxkey;
288 foreach my $key (sort keys %configinputfw){
289 if ("$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
290 eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27]"){
291 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
295 #check if we just close a rule
296 if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'}) {
297 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
299 $fwdfwsettings{'nosave2'} = 'on';
302 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
303 if ($fwdfwsettings{'nobase'} ne 'on'){
304 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
306 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
307 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
308 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
309 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
310 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
311 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
313 if($fwdfwsettings{'nosave2'} ne 'on'){
314 &saverule
(\
%configinputfw,$configinput);
316 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
317 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
318 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
319 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
320 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
321 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
322 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
323 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
324 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
325 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
326 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
327 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
328 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
329 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
330 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
331 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
333 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
334 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
335 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
336 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
337 }elsif($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' ){
339 $fwdfwsettings{'config'}=$configoutgoing;
340 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
341 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
342 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
343 foreach my $key (sort keys %configoutgoingfw){
344 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{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
345 eq "$configoutgoingfw{$key}[0],$configoutgoingfw{$key}[2],$configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],$configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],$configoutgoingfw{$key}[7],$configoutgoingfw{$key}[8],$configoutgoingfw{$key}[9],$configoutgoingfw{$key}[10],$configoutgoingfw{$key}[11],$configoutgoingfw{$key}[12],$configoutgoingfw{$key}[13],$configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],$configoutgoingfw{$key}[17],$configoutgoingfw{$key}[18],$configoutgoingfw{$key}[19],$configoutgoingfw{$key}[20],$configoutgoingfw{$key}[21],$configoutgoingfw{$key}[22],$configoutgoingfw{$key}[23],$configoutgoingfw{$key}[24],$configoutgoingfw{$key}[25],$configoutgoingfw{$key}[26],$configoutgoingfw{$key}[27]"){
346 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
347 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
349 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
350 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
352 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
353 $fwdfwsettings{'nosave'} = 'on';
358 #check Rulepos on new Rule
359 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
360 print"CHECK OUTGOING DOPPELTE REGEL<br>";
361 $fwdfwsettings{'oldrulenumber'}=$maxkey;
362 foreach my $key (sort keys %configoutgoingfw){
363 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{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
364 eq "$configoutgoingfw{$key}[0],$configoutgoingfw{$key}[2],$configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],$configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],$configoutgoingfw{$key}[7],$configoutgoingfw{$key}[8],$configoutgoingfw{$key}[9],$configoutgoingfw{$key}[10],$configoutgoingfw{$key}[11],$configoutgoingfw{$key}[12],$configoutgoingfw{$key}[13],$configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],$configoutgoingfw{$key}[17],$configoutgoingfw{$key}[18],$configoutgoingfw{$key}[19],$configoutgoingfw{$key}[20],$configoutgoingfw{$key}[21],$configoutgoingfw{$key}[22],$configoutgoingfw{$key}[23],$configoutgoingfw{$key}[24],$configoutgoingfw{$key}[25],$configoutgoingfw{$key}[26],$configoutgoingfw{$key}[27]"){
365 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
369 #check if we just close a rule
370 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'}) {
371 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
372 $fwdfwsettings{'nosave2'} = 'on';
377 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
378 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
379 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
380 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
381 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
382 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
383 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
384 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
386 if ($fwdfwsettings{'nobase'} eq 'on'){
387 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
389 if ($fwdfwsettings{'nosave2'} ne 'on'){
390 &saverule
(\
%configoutgoingfw,$configoutgoing);
394 $fwdfwsettings{'config'}=$configfwdfw;
395 $fwdfwsettings{'chain'} = 'FORWARDFW';
396 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
397 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
398 #check if we have an identical rule already
399 foreach my $key (sort keys %configfwdfw){
400 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'}"
401 eq "$configfwdfw{$key}[0],$configfwdfw{$key}[2],$configfwdfw{$key}[3],$configfwdfw{$key}[4],$configfwdfw{$key}[5],$configfwdfw{$key}[6],$configfwdfw{$key}[7],$configfwdfw{$key}[8],$configfwdfw{$key}[9],$configfwdfw{$key}[10],$configfwdfw{$key}[11],$configfwdfw{$key}[12],$configfwdfw{$key}[13],$configfwdfw{$key}[14],$configfwdfw{$key}[15],$configfwdfw{$key}[17],$configfwdfw{$key}[19],$configfwdfw{$key}[20],$configfwdfw{$key}[21],$configfwdfw{$key}[22],$configfwdfw{$key}[23],$configfwdfw{$key}[24],$configfwdfw{$key}[25],$configfwdfw{$key}[26],$configfwdfw{$key}[27]"){
402 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
403 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
405 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
406 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
408 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
409 $fwdfwsettings{'nosave'} = 'on';
414 #check Rulepos on new Rule
415 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
416 $fwdfwsettings{'oldrulenumber'}=$maxkey;
417 foreach my $key (sort keys %configfwdfw){
418 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'}"
419 eq "$configfwdfw{$key}[0],$configfwdfw{$key}[2],$configfwdfw{$key}[3],$configfwdfw{$key}[4],$configfwdfw{$key}[5],$configfwdfw{$key}[6],$configfwdfw{$key}[7],$configfwdfw{$key}[8],$configfwdfw{$key}[9],$configfwdfw{$key}[10],$configfwdfw{$key}[11],$configfwdfw{$key}[12],$configfwdfw{$key}[13],$configfwdfw{$key}[14],$configfwdfw{$key}[15],$configfwdfw{$key}[17],$configfwdfw{$key}[19],$configfwdfw{$key}[20],$configfwdfw{$key}[21],$configfwdfw{$key}[22],$configfwdfw{$key}[23],$configfwdfw{$key}[24],$configfwdfw{$key}[25],$configfwdfw{$key}[26],$configfwdfw{$key}[27]"){
420 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
424 #check if we just close a rule
425 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'} ) {
426 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
427 $fwdfwsettings{'nosave2'} = 'on';
432 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
433 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
434 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
435 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
436 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
437 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
438 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
439 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
441 if ($fwdfwsettings{'nobase'} eq 'on'){
442 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
444 if ($fwdfwsettings{'nosave2'} ne 'on'){
445 &saverule
(\
%configfwdfw,$configfwdfw);
447 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
448 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
449 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
450 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
451 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
452 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
453 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
454 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
455 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
456 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
457 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
458 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
459 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
460 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
461 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
462 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
464 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
465 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
466 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
467 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
472 if($fwdfwsettings{'nosave2'} ne 'on'){
478 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
480 if($fwdfwsettings{'poltype'} eq 'forward'){
481 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
482 foreach my $key (sort keys %configfwdfw){
483 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
484 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
485 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
487 #&General::readhasharray("$configinput", \%configinputfw);
488 #foreach my $key (sort keys %configinputfw){
489 # &checkcounter($configinputfw{$key}[3],$configinputfw{$key}[4],,);
490 # &checkcounter($configinputfw{$key}[5],$configinputfw{$key}[6],,);
491 # &checkcounter($configinputfw{$key}[14],$configinputfw{$key}[15],,);
494 system("rm ${General::swroot}/forward/config");
495 #system("rm ${General::swroot}/forward/input");
496 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
497 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
498 #unless (-e "${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
499 my $MODE1=$fwdfwsettings{'POLICY1'};
501 $fwdfwsettings{'POLICY'}='MODE2';
502 $fwdfwsettings{'POLICY1'}=$MODE1;
503 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
506 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
507 foreach my $key (sort keys %configoutgoingfw){
508 &checkcounter
($configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],,);
509 &checkcounter
($configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],,);
510 &checkcounter
($configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],,);
512 system("rm ${General::swroot}/forward/outgoing");
513 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
514 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
515 my $MODE=$fwdfwsettings{'POLICY'};
517 $fwdfwsettings{'POLICY'}=$MODE;
518 $fwdfwsettings{'POLICY1'}='MODE2';
519 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
523 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
527 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
530 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
531 foreach my $key (sort keys %togglehash){
532 if ($key eq $fwdfwsettings{'key'}){
533 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
536 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
540 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
543 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
544 foreach my $key (sort keys %togglehash){
545 if ($key eq $fwdfwsettings{'key'}){
546 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
549 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
553 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
558 if ($fwdfwsettings{'ACTION'} eq 'editrule')
560 $fwdfwsettings{'updatefwrule'}='on';
563 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
567 if ($fwdfwsettings{'ACTION'} eq 'moveup')
572 if ($fwdfwsettings{'ACTION'} eq 'movedown')
577 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
579 $fwdfwsettings{'copyfwrule'}='on';
580 #$fwdfwsettings{'updatefwrule'}='on';
583 if ($fwdfwsettings{'ACTION'} eq '')
591 if (-f
"${General::swroot}/forward/reread"){
592 print "<table border='0'><form method='post'><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: red; font-weight: bold;'>$Lang::tr{'fwhost reread'}</td></tr></table></form><hr><br>";
594 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
595 print "<form method='post'>";
596 print "<table border='0'>";
597 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
598 print"</tr></table></form><hr>";
604 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
605 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
606 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){ $selected{'POLICY1'}{'MODE1'} = 'selected'; } else { $selected{'POLICY1'}{'MODE1'} = ''; }
607 if ($fwdfwsettings{'POLICY1'} eq 'MODE2'){ $selected{'POLICY1'}{'MODE2'} = 'selected'; } else { $selected{'POLICY1'}{'MODE2'} = ''; }
611 &Header
::openbox
('100%', 'center', $Lang::tr
{'fwdfw pol title'});
613 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
614 <table width='100%' border='0'>
615 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>FORWARD </td></tr>
616 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text'}</td></tr>
617 <tr><td colspan='3'><hr /></td></tr>
618 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
619 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
620 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
621 <input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td><td width='45%' align='right'>
624 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='forward' /></td></tr>";
625 print "</table></form>";
628 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
629 <table width='100%' border='0'>
630 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>OUTGOING </td></tr>
631 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text1'}</td></tr>
632 <tr><td colspan='3'><hr /></td></tr>
633 <tr><td width='15%' align='left'> <select name='POLICY1' style="width: 100px">
634 <option value='MODE1' $selected{'POLICY1'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
635 <option value='MODE2' $selected{'POLICY1'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
636 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td><td width='45%' align='right'>
639 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='outgoing' /></tr>";
640 print "</table></form>";
642 print "<br><br><div align='right'><font size='1' color='grey'>Version: $VERSION</font></div>";
647 $fwdfwsettings{'updatefwrule'}='';
648 $fwdfwsettings{'config'}=$oldchain;
649 $fwdfwsettings{'nobase'}='on';
651 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
652 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
658 #check ip-address if manual
659 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
660 #check if ip with subnet
661 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
662 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
663 $subnet = &General
::iporsubtocidr
($subnet);
664 $fwdfwsettings{'isip'}='on';
667 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
668 $ip=$fwdfwsettings{'src_addr'};
670 $fwdfwsettings{'isip'}='on';
673 if ($fwdfwsettings{'isip'} ne 'on'){
674 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
676 if ($fwdfwsettings{'isip'} eq 'on'){
677 #check and form valid IP
678 $ip=&General
::ip2dec
($ip);
679 $ip=&General
::dec2ip
($ip);
680 #check if net or broadcast
681 my @tmp= split (/\./,$ip);
682 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
684 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
686 $fwdfwsettings{'src_addr'}="$ip/$subnet";
688 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
689 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
692 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
693 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
695 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
696 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
697 return $errormessage;
701 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
703 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
704 $fwdfwsettings{'SRC_PORT'}='';
705 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
706 foreach my $key (keys %icmptypes){
707 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
708 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
711 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
712 $fwdfwsettings{'SRC_PORT'}='';
713 $fwdfwsettings{'ICMP_TYPES'}='';
714 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
715 $fwdfwsettings{'SRC_PORT'}='';
716 $fwdfwsettings{'ICMP_TYPES'}='';
717 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
718 $fwdfwsettings{'SRC_PORT'}='';
719 $fwdfwsettings{'ICMP_TYPES'}='';
720 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
721 $fwdfwsettings{'ICMP_TYPES'}='';
723 $fwdfwsettings{'ICMP_TYPES'}='';
724 $fwdfwsettings{'SRC_PORT'}='';
725 $fwdfwsettings{'PROT'}='';
728 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
729 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
733 if ($_ =~ /^(\d+)\:(\d+)$/) {
735 #change dashes with :
738 push(@values,"1:65535");
741 if ($_ =~ /^(\D)\:(\d+)$/) {
742 push(@values,"1:$2");
745 if ($_ =~ /^(\d+)\:(\D)$/) {
746 push(@values,"$1:65535");
749 $errormessage .= &General
::validportrange
($_, 'destination');
754 if (&General
::validport
($_)){
761 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
762 return $errormessage;
768 &General
::readhasharray
("$configsrv", \
%customservice);
769 #check DNAT settings (has to be single Host and single Port)
770 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
771 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
772 if ($fwdfwsettings{'USESRV'} eq ''){
773 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
775 #check if manual ip is a single Host (if set)
776 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
777 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
778 my @tmp1= split ("/",$tmp[3]);
779 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
781 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
784 #check if Port is a single Port
785 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
786 if(($fwdfwsettings{'TGT_PROT'} ne 'TCP'|| $fwdfwsettings{'TGT_PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
787 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
789 if (($fwdfwsettings{'TGT_PROT'} eq 'TCP'|| $fwdfwsettings{'TGT_PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
790 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
794 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
797 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
798 #check if ip with subnet
799 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
800 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
801 $subnet = &General
::iporsubtocidr
($subnet);
804 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
805 $ip=$fwdfwsettings{'tgt_addr'};
808 #check and form valid IP
809 $ip=&General
::ip2dec
($ip);
810 $ip=&General
::dec2ip
($ip);
812 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
813 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
814 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
816 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
817 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
818 return $errormessage;
821 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
823 if ($fwdfwsettings{'USESRV'} eq 'ON'){
824 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
825 $fwdfwsettings{'TGT_PROT'}='';
826 $fwdfwsettings{'ICMP_TGT'}='';
828 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
829 $fwdfwsettings{'TGT_PROT'}='';
830 $fwdfwsettings{'ICMP_TGT'}='';
831 #check target service
832 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
833 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
836 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
837 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
838 if ($fwdfwsettings{'TGT_PORT'} ne ''){
839 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
843 if ($_ =~ /^(\d+)\:(\d+)$/) {
845 #change dashes with :
848 push(@values,"1:65535");
851 if ($_ =~ /^(\D)\:(\d+)$/) {
852 push(@values,"1:$2");
855 if ($_ =~ /^(\d+)\:(\D)$/) {
856 push(@values,"$1:65535");
859 $errormessage .= &General
::validportrange
($_, 'destination');
864 if (&General
::validport
($_)){
871 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
873 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
874 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
875 $fwdfwsettings{'TGT_PORT'} = '';
876 $fwdfwsettings{'ICMP_TGT'} = '';
877 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
878 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
879 $fwdfwsettings{'TGT_PORT'} = '';
880 $fwdfwsettings{'ICMP_TGT'}='';
881 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
882 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
883 $fwdfwsettings{'TGT_PORT'} = '';
884 $fwdfwsettings{'ICMP_TGT'}='';
885 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
886 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
887 $fwdfwsettings{'TGT_PORT'} = '';
888 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
889 foreach my $key (keys %icmptypes){
891 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
892 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
900 if ($fwdfwsettings{'USESRV'} ne 'ON'){
901 $fwdfwsettings{'grp3'}='';
902 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
903 $fwdfwsettings{'TGT_PROT'}='';
904 $fwdfwsettings{'ICMP_TGT'}='';
907 if($fwdfwsettings{'TIME'} eq 'ON'){
908 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 ''){
909 $errormessage=$Lang::tr
{'fwdfw err time'};
912 return $errormessage;
917 if ($val =~ "," || $val =~ ":" || $val>65536 || $val<0){
924 #check valid port for NAT
925 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
926 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
927 if($fwdfwsettings{'nat'} eq 'dnat' && !&check_natport
($fwdfwsettings{'dnatport'})){
928 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
930 elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
932 #get servcie Protocol and Port
933 foreach my $key (sort keys %customservice){
934 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
935 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
936 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
938 $custsrvport= $customservice{$key}[1];
941 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
945 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
946 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
948 #check if source and target identical
949 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
950 $errormessage.=$Lang::tr
{'fwdfw err same'};
951 return $errormessage;
953 #get source and targetip address if possible
954 my ($sip,$scidr,$tip,$tcidr);
955 ($sip,$scidr)=&get_ip
("src","grp1");
956 ($tip,$tcidr)=&get_ip
("tgt","grp2");
957 #check same iprange in source and target
958 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
959 my $networkip1=&General
::getnetworkip
($sip,$scidr);
960 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
961 if ($scidr gt $tcidr){
962 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
963 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
965 }elsif($scidr eq $tcidr && $scidr eq '32'){
966 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
967 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
968 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
969 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
970 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
973 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
974 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
978 #check source and destination protocol if manual
979 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
980 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
981 $errormessage.=$Lang::tr
{'fwdfw err prot'};
983 #check source and destination protocol if source manual and dest servicegrp
984 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
985 foreach my $key (sort keys %customservice){
986 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
987 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
988 $errormessage.=$Lang::tr
{'fwdfw err prot'};
998 my ($base1,$val1,$base2,$val2) = @_;
1000 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
1001 &dec_counter
($confignet,\
%customnetwork,$val1);
1002 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
1003 &dec_counter
($confighost,\
%customhost,$val1);
1004 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
1005 &dec_counter
($configgrp,\
%customgrp,$val1);
1006 }elsif($base1 eq 'cust_srv'){
1007 &dec_counter
($configsrv,\
%customservice,$val1);
1008 }elsif($base1 eq 'cust_srvgrp'){
1009 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
1012 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
1013 &inc_counter
($confignet,\
%customnetwork,$val2);
1014 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
1015 &inc_counter
($confighost,\
%customhost,$val2);
1016 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
1017 &inc_counter
($configgrp,\
%customgrp,$val2);
1018 }elsif($base2 eq 'cust_srv'){
1019 &inc_counter
($configsrv,\
%customservice,$val2);
1020 }elsif($base2 eq 'cust_srvgrp'){
1021 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
1027 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
1028 foreach my $key (sort {$a <=> $b} keys %delhash){
1029 if ($key == $fwdfwsettings{'key'}){
1030 #check hosts/net and groups
1031 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
1032 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
1033 #check services and groups
1034 if ($delhash{$key}[11] eq 'ON'){
1035 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
1038 if ($key >= $fwdfwsettings{'key'}) {
1039 my $next = $key + 1;
1040 if (exists $delhash{$next}) {
1041 foreach my $i (0 .. $#{$delhash{$next}}) {
1042 $delhash{$key}[$i] = $delhash{$next}[$i];
1047 # Remove the very last entry.
1048 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
1049 delete $delhash{$last_key};
1051 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
1054 if($fwdfwsettings{'nobase'} ne 'on'){
1061 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
1062 foreach my $key (sort keys %configfwdfw){
1063 if ($key eq $key1 ){
1064 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
1067 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
1073 my %hash=%{(shift)};
1076 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
1077 &General
::readhasharray
($config, \
%hash);
1078 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1079 if($hash{$key}[0] eq $val){
1080 $pos=$#{$hash{$key}};
1081 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
1084 &General
::writehasharray
($config, \
%hash);
1088 if ($errormessage) {
1089 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1090 print "<class name='base'>$errormessage\n";
1091 print " </class>\n";
1092 &Header
::closebox
();
1098 my %hash=%{(shift)};
1101 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1102 if($hash{$key}[0] eq $val){
1103 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1105 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1115 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1116 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1117 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1118 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1119 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1120 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1121 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1122 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1123 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1124 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1125 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1126 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1127 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1128 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1129 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1130 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1131 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1132 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1134 <table width='100%' border='0'>
1135 <tr><td width='50%' valign='top'>
1136 <table width='100%' border='0'>
1137 <tr><td width='1%'><input type='radio' name='$grp' 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;'>
1139 foreach my $network (sort keys %defaultNetworks)
1141 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1142 next if($defaultNetworks{$network}{'NAME'} eq "IPFire" && $srctgt eq 'tgt');
1143 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1144 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1145 print ">$network</option>";
1147 print"</select></td></tr>";
1149 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1150 print"<tr><td><input type='radio' name='$grp' 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;'>";
1151 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1152 print"</select></td>";
1155 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1156 print"<tr><td><input type='radio' name='$grp' 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;'>";
1157 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1158 print"</select></td>";
1161 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1162 print"<tr><td valign='top'><input type='radio' name='$grp' 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;'>";
1163 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1164 if($helper ne $customgrp{$key}[0]){
1166 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1167 print ">$customgrp{$key}[0]</option>";
1169 $helper=$customgrp{$key}[0];
1171 print"</select></td>";
1173 #End left table. start right table (vpn)
1174 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1176 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1177 print"<td width='1%'><input type='radio' name='$grp' 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;'>";
1178 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1179 print"</select></td></tr>";
1182 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1183 if ($ccdhost{$key}[33] ne '' ){
1184 print"<tr><td width='1%'><input type='radio' name='$grp' 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 '');
1186 print "<option value='$ccdhost{$key}[1]'";
1187 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1188 print ">$ccdhost{$key}[1]</option>";
1191 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1192 print"<tr><td width='1%'><input type='radio' name='$grp' 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>" ;
1194 if ($show eq '1'){$show='';print"</select></td></tr>";}
1196 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1197 if ($ccdhost{$key}[3] eq 'net'){
1198 print"<tr><td width='1%'><input type='radio' name='$grp' 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 '');
1200 print "<option value='$ccdhost{$key}[1]'";
1201 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1202 print ">$ccdhost{$key}[1]</option>";
1205 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1206 print"<tr><td width='1%'><input type='radio' name='$grp' 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>" ;
1208 if ($show eq '1'){$show='';print"</select></td></tr>";}
1210 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1211 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1212 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 '');
1215 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1216 print ">$ipsecconf{$key}[1]</option>";
1219 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1220 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;'><select></td></tr>";
1222 if ($show eq '1'){$show='';print"</select></td></tr>";}
1224 print"</tr></table>";
1225 print"</td></tr></table><br>";
1233 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1234 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1235 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1236 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1237 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1238 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1239 $a=$netsettings{'GREEN_NETADDRESS'};
1240 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1241 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1242 $a=$netsettings{'ORANGE_NETADDRESS'};
1243 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1244 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1245 $a=$netsettings{'BLUE_NETADDRESS'};
1246 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1247 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1248 &General
::readhash
("$configovpn",\
%ovpnsettings);
1249 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1250 $b=&General
::iporsubtocidr
($b);
1252 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1253 &General
::readhasharray
("$confignet", \
%customnetwork);
1254 foreach my $key (keys %customnetwork){
1255 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1256 $a=$customnetwork{$key}[1];
1257 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1260 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1261 &General
::readhasharray
("$confighost", \
%customhost);
1262 foreach my $key (keys %customhost){
1263 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1264 if ($customhost{$key}[1] eq 'ip'){
1265 ($a,$b)=split (/\//,$customhost{$key}[2]);
1266 $b=&General
::iporsubtocidr
($b);
1268 if ($grp eq 'grp2'){
1269 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1281 &General
::setup_default_networks
(\
%defaultNetworks);
1282 foreach my $network (sort keys %defaultNetworks)
1284 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1289 my %hash=%{(shift)};
1291 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1292 $hash{$key}[10]=~ s/\|/,/g;
1293 print": $hash{$key}[10]";
1294 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1295 print": <br>$hash{$key}[9] ";
1300 my %hash=%{(shift)};
1304 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1305 if($hash{$key}[14] eq 'cust_srv'){
1306 &General
::readhasharray
("$configsrv", \
%customservice);
1307 foreach my $i (sort keys %customservice){
1308 if($customservice{$i}[0] eq $hash{$key}[15]){
1309 $service = $customservice{$i}[0];
1312 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1313 $service=$hash{$key}[15];
1314 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1315 $hash{$key}[15]=~ s/\|/,/g;
1316 $service=$hash{$key}[15];
1321 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1322 print":<br>$hash{$key}[13]";
1325 sub get_serviceports
1329 &General
::readhasharray
("$configsrv", \
%customservice);
1330 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1335 if($type eq 'service'){
1336 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1337 if ($customservice{$key}[0] eq $name){
1338 push (@protocols,$customservice{$key}[2]);
1341 }elsif($type eq 'group'){
1342 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1343 if ($customservicegrp{$key}[0] eq $name){
1344 foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1345 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1346 if($customservice{$key1}[2] eq 'TCP'){
1348 }elsif($customservice{$key1}[2] eq 'ICMP'){
1350 }elsif($customservice{$key1}[2] eq 'UDP'){
1358 if($tcp && $udp && $icmp){
1359 push (@protocols,"All");
1363 push (@protocols,"TCP");
1366 push (@protocols,"UDP");
1369 push (@protocols,"ICMP");
1378 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1380 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'){
1381 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1384 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1385 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1389 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1390 foreach my $key (sort keys %$hash){
1391 if ($$hash{$key}[0] eq $val){
1392 $val=$$hash{$key}[2];
1397 foreach my $alias (sort keys %aliases)
1399 if ($val eq $alias){
1400 $tdcolor="style='border: 1px solid $Header::colourred;'";
1405 if ($val eq 'GREEN'){
1406 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1407 }elsif ($val eq 'ORANGE'){
1408 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1409 }elsif ($val eq 'BLUE'){
1410 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1411 }elsif ($val eq 'RED'){
1412 $tdcolor="style='border: 1px solid $Header::colourred;'";
1413 }elsif ($val eq 'IPFire' ){
1414 $tdcolor="style='border: 1px solid $Header::colourred;'";
1415 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1416 my ($sip,$scidr) = split ("/",$val);
1417 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1418 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1420 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1421 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1423 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1424 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1426 }elsif ($val eq 'Default IP'){
1427 $tdcolor="style='border: 1px solid $Header::colourred;'";
1436 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1437 print "<class name='base'>$hint\n";
1438 print " </class>\n";
1439 &Header
::closebox
();
1446 my %hash=%{(shift)};
1450 &General
::readhasharray
($config, \
%hash);
1451 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1452 if($hash{$key}[0] eq $val){
1453 $pos=$#{$hash{$key}};
1454 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1457 &General
::writehasharray
($config, \
%hash);
1462 &General
::setup_default_networks
(\
%defaultNetworks);
1463 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1464 #read all configfiles
1465 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1466 &General
::readhasharray
("$confignet", \
%customnetwork);
1467 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1468 &General
::readhasharray
("$confighost", \
%customhost);
1469 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1470 &General
::readhasharray
("$configgrp", \
%customgrp);
1471 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1472 &General
::get_aliases
(\
%aliases);
1476 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1477 my $config=$fwdfwsettings{'config'};
1479 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1480 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1481 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1482 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1483 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1484 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1485 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1486 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1487 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1488 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1489 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1490 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1491 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1492 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1493 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1494 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1495 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1496 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1497 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1498 #check if update and get values
1499 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1500 &General
::readhasharray
("$config", \
%hash);
1501 foreach my $key (sort keys %hash){
1503 if ($key eq $fwdfwsettings{'key'}){
1504 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1505 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1506 $fwdfwsettings{'chain'} = $hash{$key}[1];
1507 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1508 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1509 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1510 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1511 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1512 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1513 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1514 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1515 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1516 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1517 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1518 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1519 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1520 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1521 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1522 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1523 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1524 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1525 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1526 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1527 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1528 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1529 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1530 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1531 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1532 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1533 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1534 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1535 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1536 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1537 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1538 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1539 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1540 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1541 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1542 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1543 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1544 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1545 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1546 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1547 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1548 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1549 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1550 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1551 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1552 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1553 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1554 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1555 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1556 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1557 $selected{'dnat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1558 $selected{'snat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1561 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1562 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1563 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1564 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1565 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1566 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1567 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1568 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1569 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1570 if ($fwdfwsettings{'config'} eq "${General::swroot}/forward/dmz"){
1571 $fwdfwsettings{'oldruletype'}='DMZ';
1573 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1575 #check if manual ip (source) is orange network
1576 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1577 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1578 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1579 $fwdfwsettings{'oldorange'} ='on';
1583 $fwdfwsettings{'ACTIVE'}='ON';
1584 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1585 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1586 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1587 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1588 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1589 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1590 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1591 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1592 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1593 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1594 #check if manual ip (source) is orange network
1595 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1596 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1597 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1598 $fwdfwsettings{'oldorange'} ='on';
1602 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1603 if ($fwdfwsettings{'TIME'} eq 'ON'){
1604 $fwdfwsettings{'TIME_FROM'} = &timeconvert
($fwdfwsettings{'TIME_FROM'},'');
1605 $fwdfwsettings{'TIME_TO'} = &timeconvert
($fwdfwsettings{'TIME_TO'},'');
1607 print "<form method='post'>";
1608 &Header
::closebox
();
1609 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1610 #------SOURCE-------------------------------------------------------
1612 <table width='100%' border='0'>
1613 <tr><td width='1%'><input type='radio' name='grp1' value='src_addr' checked></td><td colspan='5'>$Lang::tr{'fwdfw sourceip'}<input type='TEXT' name='src_addr' value='$fwdfwsettings{'src_addr'}' size='16' maxlength='17'></td></tr>
1614 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1617 &gen_dd_block
('src','grp1');
1619 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1620 <table width='100%' border='0'>
1621 <tr><td width='1%'><input type='checkbox' name='USE_SRC_PORT' value='ON' $checked{'USE_SRC_PORT'}{'ON'}></td><td width='51%' colspan='3'>$Lang::tr{'fwdfw use srcport'}</td>
1622 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1624 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1626 if ($_ eq $fwdfwsettings{'PROT'})
1628 print"<option selected>$_</option>";
1630 print"<option>$_</option>";
1633 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1635 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1636 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES' style='width:230px;'>
1638 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1639 print"<option>All ICMP-Types</option>";
1640 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1641 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1642 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1644 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1648 </select></td></tr></table><br><hr>
1650 &Header
::closebox
();
1652 #---TARGET------------------------------------------------------
1653 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1655 <table width='100%' border='0'>
1656 <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td width='57%' nowrap='nowrap'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16' maxlength='17'><td width='1%'><input type='radio' name='grp2' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>IPFire</b></td>
1658 if (! -z
"${General::swroot}/ethernet/aliases"){
1659 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1660 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1662 foreach my $alias (sort keys %aliases)
1664 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1668 print"<td style='width:200px;'><input type='hidden' name ='ipfire' value='Default IP'>";
1672 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1674 &gen_dd_block
('tgt','grp2');
1676 <b>$Lang::tr{'fwhost attention'}:</b><br>
1677 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1678 <table width='100%' border='0'>
1679 <tr><td width='1%'><input type='checkbox' name='USESRV' value='ON' $checked{'USESRV'}{'ON'} ></td><td width='48%'>$Lang::tr{'fwdfw use srv'}</td><td width='1%'><input type='radio' name='grp3' value='cust_srv' checked></td><td nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td width='1%' colspan='2'><select name='cust_srv'style='min-width:230px;' >
1681 &General
::readhasharray
("$configsrv", \
%customservice);
1682 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1684 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1685 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1689 <tr><td colspan='2'></td><td><input type='radio' name='grp3' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}></td><td nowrap='nowrap'>$Lang::tr{'fwhost cust srvgrp'}:</td><td colspan='2'><select name='cust_srvgrp' style='min-width:230px;' >
1691 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1693 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1694 if ($helper ne $customservicegrp{$key}[0]){
1696 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1697 print">$customservicegrp{$key}[0]</option>";
1699 $helper=$customservicegrp{$key}[0];
1703 <tr><td colspan='2'></td><td><input type='radio' name='grp3' value='TGT_PORT' $checked{'grp3'}{'TGT_PORT'}></td><td>$Lang::tr{'fwdfw man port'}</td><td><select name='TGT_PROT'>
1705 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1707 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1709 print"<option selected>$_</option>";
1711 print"<option>$_</option>";
1714 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1716 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1717 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT' style='min-width:230px;'>
1719 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1720 print"<option>All ICMP-Types</option>";
1721 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1722 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1723 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1725 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1734 #---SNAT / DNAT ------------------------------------------------
1735 &Header
::openbox
('100%', 'left', 'NAT');
1737 <table width='100%' border='0'>
1738 <tr><td width='1%'><input type='checkbox' name='USE_NAT' value='ON' $checked{'USE_NAT'}{'ON'}></td><td width='15%'>$Lang::tr{'fwdfw use nat'}</td><td colspan='5'></td></tr>
1739 <tr><td colspan='2'></td><td width='1%'><input type='radio' name='nat' value='dnat' checked ></td><td width='50%'>$Lang::tr{'fwdfw dnat'}</td>
1741 if (! -z
"${General::swroot}/ethernet/aliases"){
1742 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
1743 print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
1744 print "<option value='Default IP' $selected{'dnat'}{'Default IP'}>Default IP</option>";
1746 foreach my $alias (sort keys %aliases)
1748 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
1751 print"<td></td><td style='width:200px;'><input type='hidden' name ='ipfire' value='Default IP'>";
1754 print"<tr><td colspan='4'></td><td>Port: </td><td align='right'><input type='text' name='dnatport' style='width:130px;' value=$fwdfwsettings{'dnatport'}> </td></tr>";
1755 print"<tr><td colspan='8'><br></td></tr>";
1757 print"<tr><td colspan='2'></td><td width='1%'><input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}></td><td width='20%'>$Lang::tr{'fwdfw snat'}</td>";
1758 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
1759 print "<option value='Default IP' $selected{'snat'}{'Default IP'}>Default IP</option>";
1760 foreach my $alias (sort keys %aliases)
1762 print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
1764 foreach my $network (sort keys %defaultNetworks)
1766 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1767 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1768 next if($defaultNetworks{$network}{'NAME'} eq "ALL");
1769 next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
1770 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1771 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
1772 print ">$network</option>";
1776 &Header
::closebox
();
1777 #---Activate/logging/remark-------------------------------------
1778 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1780 <table width='100%' border='0'>
1781 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1783 foreach ("ACCEPT","DROP","REJECT")
1785 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1786 print"<option value='$_'";
1787 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1788 print">$Lang::tr{'fwdfw '.$_}</option>";
1790 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1791 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1793 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1795 print"<option value='$_' selected>$Lang::tr{'fwdfw '.$_}</option>";
1797 print"<option value='$_'>$Lang::tr{'fwdfw '.$_}</option>";
1801 print"</select></td></tr>";
1802 print"<tr><td width='12%'>$Lang::tr{'remark'}:</td><td align='left'><input type='text' name='ruleremark' size='40' maxlength='255' value='$fwdfwsettings{'ruleremark'}'></td></tr>";
1803 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1804 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1805 for (my $count =1; $count <= $sum; $count++){
1806 print"<option value='$count' ";
1807 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1808 print">$count</option>";
1810 print"</select></td></tr>";
1812 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1816 </table><table width='100%'>
1817 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1818 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1821 &Header
::closebox
();
1822 #---ADD TIMEFRAME-----------------------------------------------
1823 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1825 <table width='70%' border='0'>
1826 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1827 <tr><td colspan='7'> </td></tr>
1829 <td align='left'>$Lang::tr{'time'}:</td>
1830 <td width='30%' align='left'>$Lang::tr{'advproxy monday'} $Lang::tr{'advproxy tuesday'} $Lang::tr{'advproxy wednesday'} $Lang::tr{'advproxy thursday'} $Lang::tr{'advproxy friday'} $Lang::tr{'advproxy saturday'} $Lang::tr{'advproxy sunday'}</td>
1831 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1832 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1835 <td align='right'></td>
1836 <td width='30%' align='left'>
1837 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1838 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1839 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1840 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1841 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1842 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1843 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1845 <td><select name='TIME_FROM'>
1847 for (my $i=0;$i<=23;$i++) {
1848 $i = sprintf("%02s",$i);
1849 for (my $j=0;$j<=45;$j+=15) {
1850 $j = sprintf("%02s",$j);
1851 my $time = $i.":".$j;
1852 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1857 <td><select name='TIME_TO'>
1859 for (my $i=0;$i<=23;$i++) {
1860 $i = sprintf("%02s",$i);
1861 for (my $j=0;$j<=45;$j+=15) {
1862 $j = sprintf("%02s",$j);
1863 my $time = $i.":".$j;
1864 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1871 #---ACTION------------------------------------------------------
1872 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1874 <table border='0' width='100%'>
1875 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1876 <input type='hidden' name='config' value='$config' >
1877 <input type='hidden' name='ACTION' value='saverule' >
1878 </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>
1883 <table border='0' width='100%'>
1884 <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'}'>
1885 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1886 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1887 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1888 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1889 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1890 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1891 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1892 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1893 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1894 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1895 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1896 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
1897 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
1898 <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>
1902 &Header
::closebox
();
1908 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1909 foreach my $key (sort keys %uphash){
1910 if ($key eq $fwdfwsettings{'key'}) {
1912 if (exists $uphash{$last}){
1914 foreach my $y (0 .. $#{$uphash{$last}}) {
1915 $tmp{0}[$y] = $uphash{$last}[$y];
1917 #copy active rule to last
1918 foreach my $i (0 .. $#{$uphash{$last}}) {
1919 $uphash{$last}[$i] = $uphash{$key}[$i];
1921 #copy saved rule to actual position
1922 foreach my $x (0 .. $#{$tmp{0}}) {
1923 $uphash{$key}[$x] = $tmp{0}[$x];
1928 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1935 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1936 foreach my $key (sort keys %downhash){
1937 if ($key eq $fwdfwsettings{'key'}) {
1938 my $next = $key + 1;
1939 if (exists $downhash{$next}){
1941 foreach my $y (0 .. $#{$downhash{$next}}) {
1942 $tmp{0}[$y] = $downhash{$next}[$y];
1944 #copy active rule to next
1945 foreach my $i (0 .. $#{$downhash{$next}}) {
1946 $downhash{$next}[$i] = $downhash{$key}[$i];
1948 #copy saved rule to actual position
1949 foreach my $x (0 .. $#{$tmp{0}}) {
1950 $downhash{$key}[$x] = $tmp{0}[$x];
1955 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1960 if (!-f
"${General::swroot}/forward/reread"){
1961 system("touch ${General::swroot}/forward/reread");
1962 system("touch ${General::swroot}/fwhosts/reread");
1967 system("/usr/local/bin/forwardfwctrl");
1968 if ( -f
"${General::swroot}/forward/reread"){
1969 system("rm ${General::swroot}/forward/reread");
1970 system("rm ${General::swroot}/fwhosts/reread");
1977 &General
::readhasharray
("$config", $hash);
1978 if (!$errormessage){
1979 #check if we change a NAT to a FORWARD/DMZ
1980 if(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'FORWARDFW'){
1981 &changerule
($confignat);
1984 #check if we change a NAT to a INPUT (external access)
1985 elsif(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'INPUTFW'){
1986 &changerule
($confignat);
1989 #check if we change a NAT to a OUTGOING
1990 elsif(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
1991 &changerule
($confignat);
1994 ################################################################
1995 #check if we change a DMZ to a NAT
1996 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
1997 &changerule
($configdmz);
2000 #check if we change a DMZ to an OUTGOING
2001 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2002 &changerule
($configdmz);
2005 #check if we change a DMZ to an INPUT
2006 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2007 &changerule
($configdmz);
2010 #check if we change a DMZ to a FORWARD/DMZ
2011 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2012 &changerule
($configdmz);
2015 ################################################################
2016 #check if we change an INPUT rule to a NAT
2017 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2018 &changerule
($configinput);
2021 #check if we change an INPUT rule to a OUTGOING
2022 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2023 &changerule
($configinput);
2026 #check if we change an INPUT rule to a FORWARD/DMZ
2027 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2028 &changerule
($configinput);
2031 ################################################################
2032 #check if we change an OUTGOING rule to an INPUT
2033 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2034 &changerule
($configoutgoing);
2037 #check if we change an OUTGOING rule to a FORWARD/DMZ
2038 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2039 &changerule
($configoutgoing);
2042 #check if we change an OUTGOING rule to a NAT
2043 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2044 &changerule
($configoutgoing);
2047 ################################################################
2048 #check if we change a FORWARD rule to an INPUT
2049 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2050 &changerule
($configfwdfw);
2053 #check if we change a FORWARD rule to an DMZ
2054 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on'){
2055 &changerule
($configfwdfw);
2058 #check if we change a FORWARD rule to an OUTGOING
2059 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2060 &changerule
($configfwdfw);
2063 #check if we change a FORWARD rule to an NAT
2064 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2065 &changerule
($configfwdfw);
2068 #Cleanup some values for NAT if they are not used
2069 if($fwdfwsettings{'nat'} eq 'dnat'){
2070 $fwdfwsettings{'snatport'}='';
2072 $fwdfwsettings{'dnatport'}='';
2074 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2075 my $key = &General
::findhasharraykey
($hash);
2076 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2077 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2078 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2079 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2080 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2081 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2082 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2083 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2084 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2085 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2086 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2087 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2088 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2089 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2090 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2091 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2092 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2093 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2094 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2095 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2096 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2097 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2098 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2099 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2100 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2101 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2102 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2103 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2104 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
2105 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2106 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2107 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2108 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2110 &General
::writehasharray
("$config", $hash);
2112 foreach my $key (sort {$a <=> $b} keys %$hash){
2113 if($key eq $fwdfwsettings{'key'}){
2114 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2115 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2116 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2117 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2118 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2119 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2120 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2121 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2122 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2123 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2124 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2125 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2126 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2127 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2128 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2129 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2130 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2131 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2132 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2133 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2134 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2135 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2136 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2137 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2138 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2139 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2140 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2141 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2142 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
2143 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2144 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2145 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2146 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2152 &General
::writehasharray
("$config", $hash);
2153 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2155 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2156 for (my $z=0;$z<$val;$z++){
2157 foreach my $key (sort {$a <=> $b} keys %$hash){
2158 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2160 if (exists $$hash{$last}){
2162 foreach my $y (0 .. $#{$$hash{$last}}) {
2163 $tmp{0}[$y] = $$hash{$last}[$y];
2165 #copy active rule to last
2166 foreach my $i (0 .. $#{$$hash{$last}}) {
2167 $$hash{$last}[$i] = $$hash{$key}[$i];
2169 #copy saved rule to actual position
2170 foreach my $x (0 .. $#{$tmp{0}}) {
2171 $$hash{$key}[$x] = $tmp{0}[$x];
2176 $fwdfwsettings{'oldrulenumber'}--;
2178 &General
::writehasharray
("$config", $hash);
2180 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2182 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2183 for (my $z=0;$z<$val;$z++){
2184 foreach my $key (sort {$a <=> $b} keys %$hash){
2185 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2186 my $next = $key + 1;
2187 if (exists $$hash{$next}){
2189 foreach my $y (0 .. $#{$$hash{$next}}) {
2190 $tmp{0}[$y] = $$hash{$next}[$y];
2192 #copy active rule to next
2193 foreach my $i (0 .. $#{$$hash{$next}}) {
2194 $$hash{$next}[$i] = $$hash{$key}[$i];
2196 #copy saved rule to actual position
2197 foreach my $x (0 .. $#{$tmp{0}}) {
2198 $$hash{$key}[$x] = $tmp{0}[$x];
2203 $fwdfwsettings{'oldrulenumber'}++;
2205 &General
::writehasharray
("$config", $hash);
2212 # Checks a hostname against RFC1035
2215 # Each part should be at least two characters in length
2216 # but no more than 63 characters
2217 if (length ($remark) < 1 || length ($remark) > 255) {
2219 # Only valid characters are a-z, A-Z, 0-9 and -
2220 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2222 # First character can only be a letter or a digit
2223 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2225 # Last character can only be a letter or a digit
2226 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2232 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2233 &viewtablenew
(\
%configdmzfw,$configdmz,$Lang::tr
{'fwdfw rules'},"DMZ" );
2234 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
2235 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
2236 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
2237 &viewtablenew
(\
%confignatfw,$confignat,"","NAT" );
2246 &General
::get_aliases
(\
%aliases);
2247 &General
::readhasharray
("$confighost", \
%customhost);
2248 &General
::readhasharray
("$config", $hash);
2250 &Header
::openbox
('100%', 'left',$title);
2258 print"<b>$title1</b><br>";
2259 print"<table width='100%' cellspacing='0' cellpadding='0'>";
2260 print"<tr><td align='center'><b>#</td><td ></td><td align='center'><b>$Lang::tr{'fwdfw source'}</td><td><b>Log</td><td align='center'><b>$Lang::tr{'fwdfw target'}</td><td align='center'><b>$Lang::tr{'protocol'}</b></td><td align='center'><b>$Lang::tr{'fwdfw time'}</td><td align='center' colspan='6'><b>$Lang::tr{'fwdfw action'}</td></tr>";
2261 foreach my $key (sort {$a <=> $b} keys %$hash){
2264 #check if vpn hosts/nets have been deleted
2265 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2266 push (@tmpsrc,$$hash{$key}[4]);
2268 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2269 push (@tmpsrc,$$hash{$key}[6]);
2271 foreach my $host (@tmpsrc){
2272 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2273 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2275 &disable_rule
($key);
2278 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2279 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2281 &disable_rule
($key);
2284 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2285 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2287 &disable_rule
($key);
2290 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2291 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2293 &disable_rule
($key);
2298 $$hash{'ACTIVE'}=$$hash{$key}[2];
2300 if($coloryellow eq 'on'){
2301 print"<tr bgcolor='$color{'color14'}' >";
2303 }elsif($coloryellow eq ''){
2305 $color="$color{'color22'}";
2308 $color="$color{'color20'}";
2311 print"<tr bgcolor='$color' >";
2313 <td align='right' width='15'><b>$key</b></td>
2315 if ($$hash{$key}[0] eq 'ACCEPT'){
2318 $rulecolor=$color{'color17'};
2319 }elsif($$hash{$key}[0] eq 'DROP'){
2322 $rulecolor=$color{'color25'};
2323 }elsif($$hash{$key}[0] eq 'REJECT'){
2326 $rulecolor=$color{'color16'};
2328 if($$hash{$key}[28] eq 'ON'){
2329 print"<td bgcolor='$color' align='center' width='20'></td>";
2332 print"<td bgcolor='$rulecolor' align='center' width='20'><span title='$tooltip'><b>$ruletype</b></span></td>";
2334 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2335 print"<td align='center' width='160' $tdcolor>";
2336 if ($$hash{$key}[3] eq 'std_net_src'){
2337 print &get_name
($$hash{$key}[4]);
2339 print $$hash{$key}[4];
2342 &getsrcport
(\
%$hash,$key);
2343 #Is this a SNAT rule?
2344 if ($$hash{$key}[31] eq 'snat'){
2345 print"<br>SNAT -> $$hash{$key}[29]";
2346 if ($$hash{$key}[30] ne ''){
2347 print": $$hash{$key}[30]";
2350 if ($$hash{$key}[17] eq 'ON'){
2351 $log="/images/on.gif";
2353 $log="/images/off.gif";
2357 <form method='post'>
2358 <td align='left' width='25'><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 ;'/>
2359 <input type='hidden' name='key' value='$key' />
2360 <input type='hidden' name='config' value='$config' />
2361 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2364 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2366 <td align='center' width='160' $tdcolor>
2368 #Is this a DNAT rule?
2369 if ($$hash{$key}[31] eq 'dnat'){
2370 print "IPFire ($$hash{$key}[29])";
2371 if($$hash{$key}[30] ne ''){
2372 print": $$hash{$key}[30]";
2376 if ($$hash{$key}[5] eq 'std_net_tgt'){
2377 print &get_name
($$hash{$key}[6]);
2379 print $$hash{$key}[6];
2382 &gettgtport
(\
%$hash,$key);
2386 if ($$hash{$key}[12]){ #target prot if manual
2387 push (@protocols,$$hash{$key}[12]);
2388 }elsif($$hash{$key}[8]){ #source prot if manual
2389 push (@protocols,$$hash{$key}[8]);
2390 }elsif($$hash{$key}[14] eq 'cust_srv'){
2391 &get_serviceports
("service",$$hash{$key}[15]);
2392 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2393 &get_serviceports
("group",$$hash{$key}[15]);
2395 push (@protocols,$Lang::tr
{'all'});
2397 my $protz=join(",",@protocols);
2398 print"<td align='center'>$protz</td>";
2400 if ($$hash{$key}[18] eq 'ON'){
2402 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2403 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2404 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2405 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2406 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2407 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2408 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2409 my $weekdays=join(",",@days);
2411 print"<td align='center' width='100'>$weekdays   $$hash{$key}[26] - $$hash{$key}[27] </td>";
2414 print"<td align='center'>24/7</td>";
2416 if($$hash{$key}[2] eq 'ON'){
2417 $gif="/images/on.gif"
2420 $gif="/images/off.gif"
2423 <form method='post'>
2424 <td width='25'><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;' />
2425 <input type='hidden' name='key' value='$key' />
2426 <input type='hidden' name='config' value='$config' />
2427 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2429 <form method='post'>
2430 <td width='25' ><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;' />
2431 <input type='hidden' name='key' value='$key' />
2432 <input type='hidden' name='config' value='$config' />
2433 <input type='hidden' name='ACTION' value='editrule' />
2435 <form method='post'>
2436 <td width='25'><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;' />
2437 <input type='hidden' name='key' value='$key' />
2438 <input type='hidden' name='config' value='$config' />
2439 <input type='hidden' name='ACTION' value='copyrule' />
2441 <form method='post'>
2442 <td width='25' ><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;' />
2443 <input type='hidden' name='key' value='$key' />
2444 <input type='hidden' name='config' value='$config' />
2445 <input type='hidden' name='ACTION' value='deleterule' />
2448 if (exists $$hash{$key-1}){
2450 <form method='post'>
2451 <td width='25'><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;' />
2452 <input type='hidden' name='key' value='$key' />
2453 <input type='hidden' name='config' value='$config' />
2454 <input type='hidden' name='ACTION' value='moveup' />
2458 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2460 if (exists $$hash{$key+1}){
2462 <form method='post'>
2463 <td width='25' ><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;' />
2464 <input type='hidden' name='key' value='$key' />
2465 <input type='hidden' name='config' value='$config' />
2466 <input type='hidden' name='ACTION' value='movedown' />
2467 </td></form></td></tr>
2470 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2473 if ($optionsfw{'SHOWREMARK'} eq 'on'){
2474 print"<tr bgcolor='$color'>";
2475 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='11'>  $$hash{$key}[16]</td></tr>";
2477 print"<tr bgcolor='$color'><td height='1'></td><td bgcolor='$rulecolor'></td><td colspan='11'></td></tr>";
2480 &Header
::closebox
();
2484 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2485 print "<b>$title1</b><br>";
2486 print"<table width='100%' border='0' rules='none'><tr><td height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td></tr></table><br><br>";
2492 &Header
::closebigbox
();
2493 &Header
::closepage
();