]>
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.9.2';
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
;}
137 #check if manual ip (source) is orange network
138 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
139 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
140 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
145 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
146 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
148 #check if we try to break rules
149 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire'){
150 $errormessage.=$Lang::tr
{'fwdfw err same'};
153 if ($fwdfwsettings{'USE_NAT'} eq 'ON'){
154 $fwdfwsettings{'config'}=$confignat;
155 if ($fwdfwsettings{'nat'} eq 'dnat'){
156 $fwdfwsettings{'chain'} = 'NAT_DESTINATION';
158 $fwdfwsettings{'chain'} = 'NAT_SOURCE';
160 my $maxkey=&General
::findhasharraykey
(\
%confignatfw);
161 #check if we have an identical rule already
162 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
163 foreach my $key (sort keys %confignatfw){
164 if ("$confignatfw{$key}[0],$confignatfw{$key}[1],$confignatfw{$key}[2],$confignatfw{$key}[3],$confignatfw{$key}[4],$confignatfw{$key}[5],$confignatfw{$key}[6],$confignatfw{$key}[11],$confignatfw{$key}[12],$confignatfw{$key}[14],$confignatfw{$key}[15],$confignatfw{$key}[28],$confignatfw{$key}[29],$confignatfw{$key}[30],$confignatfw{$key}[31]"
165 eq "$fwdfwsettings{'RULE_ACTION'},NAT_DESTINATION,$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"){
166 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
167 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
169 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
170 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
172 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
173 $fwdfwsettings{'nosave'} = 'on';
179 #check Rulepos on new Rule
180 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
181 $fwdfwsettings{'oldrulenumber'}=$maxkey;
182 foreach my $key (sort keys %confignatfw){
183 #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>";
184 #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>";
185 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'}"
186 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]"){
187 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
191 #check if we just close a rule
192 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'}) {
193 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
195 $fwdfwsettings{'nosave2'} = 'on';
198 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
199 if ($fwdfwsettings{'nobase'} ne 'on'){
200 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
202 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
203 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
204 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
205 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
206 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
207 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
209 if($fwdfwsettings{'nosave2'} ne 'on'){
210 &saverule
(\
%confignatfw,$confignat);
213 }elsif ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on'){
214 $fwdfwsettings{'config'}=$configdmz;
215 $fwdfwsettings{'chain'} = 'FORWARDFW';
216 my $maxkey=&General
::findhasharraykey
(\
%configdmzfw);
217 #check if we have an identical rule already
218 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
219 foreach my $key (sort keys %configdmzfw){
220 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'}"
221 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]"){
222 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
223 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
225 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
226 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
228 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
229 $fwdfwsettings{'nosave'} = 'on';
234 #check Rulepos on new Rule
235 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
236 $fwdfwsettings{'oldrulenumber'}=$maxkey;
237 foreach my $key (sort keys %configdmzfw){
238 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'}"
239 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]"){
240 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
244 #check if we just close a rule
245 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'}) {
246 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
248 $fwdfwsettings{'nosave2'} = 'on';
251 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
252 if ($fwdfwsettings{'nobase'} ne 'on'){
253 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
255 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
256 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
257 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
258 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
259 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
260 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
262 if($fwdfwsettings{'nosave2'} ne 'on'){
263 &saverule
(\
%configdmzfw,$configdmz);
266 }elsif($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
267 $fwdfwsettings{'config'}=$configinput;
268 $fwdfwsettings{'chain'} = 'INPUTFW';
269 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
270 #check if we have an identical rule already
271 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
272 foreach my $key (sort keys %configinputfw){
273 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'}"
274 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]"){
275 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
276 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
278 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
279 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
281 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
282 $fwdfwsettings{'nosave'} = 'on';
287 #check Rulepos on new Rule
288 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
289 $fwdfwsettings{'oldrulenumber'}=$maxkey;
290 foreach my $key (sort keys %configinputfw){
291 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'}"
292 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]"){
293 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
297 #check if we just close a rule
298 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'}) {
299 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
301 $fwdfwsettings{'nosave2'} = 'on';
304 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
305 if ($fwdfwsettings{'nobase'} ne 'on'){
306 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
308 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
309 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
310 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
311 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
312 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
313 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
315 if($fwdfwsettings{'nosave2'} ne 'on'){
316 &saverule
(\
%configinputfw,$configinput);
318 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
319 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
320 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
321 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
322 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
323 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
324 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
325 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
326 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
327 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
328 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
329 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
330 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
331 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
332 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
333 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
335 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
336 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
337 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
338 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
339 }elsif($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' ){
341 $fwdfwsettings{'config'}=$configoutgoing;
342 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
343 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
344 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
345 foreach my $key (sort keys %configoutgoingfw){
346 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'}"
347 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]"){
348 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
349 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
351 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
352 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
354 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
355 $fwdfwsettings{'nosave'} = 'on';
360 #check Rulepos on new Rule
361 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
362 print"CHECK OUTGOING DOPPELTE REGEL<br>";
363 $fwdfwsettings{'oldrulenumber'}=$maxkey;
364 foreach my $key (sort keys %configoutgoingfw){
365 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'}"
366 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]"){
367 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
371 #check if we just close a rule
372 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'}) {
373 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
374 $fwdfwsettings{'nosave2'} = 'on';
379 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
380 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
381 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
382 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
383 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
384 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
385 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
386 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
388 if ($fwdfwsettings{'nobase'} eq 'on'){
389 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
391 if ($fwdfwsettings{'nosave2'} ne 'on'){
392 &saverule
(\
%configoutgoingfw,$configoutgoing);
396 $fwdfwsettings{'config'}=$configfwdfw;
397 $fwdfwsettings{'chain'} = 'FORWARDFW';
398 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
399 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
400 #check if we have an identical rule already
401 foreach my $key (sort keys %configfwdfw){
402 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'}"
403 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]"){
404 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
405 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
407 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
408 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
410 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
411 $fwdfwsettings{'nosave'} = 'on';
416 #check Rulepos on new Rule
417 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
418 $fwdfwsettings{'oldrulenumber'}=$maxkey;
419 foreach my $key (sort keys %configfwdfw){
420 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'}"
421 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]"){
422 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
426 #check if we just close a rule
427 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'} ) {
428 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
429 $fwdfwsettings{'nosave2'} = 'on';
434 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
435 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
436 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
437 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
438 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
439 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
440 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
441 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
443 if ($fwdfwsettings{'nobase'} eq 'on'){
444 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
446 if ($fwdfwsettings{'nosave2'} ne 'on'){
447 &saverule
(\
%configfwdfw,$configfwdfw);
449 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
450 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
451 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
452 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
453 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
454 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
455 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
456 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
457 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
458 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
459 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
460 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
461 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
462 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
463 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
464 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
466 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
467 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
468 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
469 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
474 if($fwdfwsettings{'nosave2'} ne 'on'){
480 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
482 if($fwdfwsettings{'poltype'} eq 'forward'){
483 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
484 foreach my $key (sort keys %configfwdfw){
485 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
486 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
487 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
489 #&General::readhasharray("$configinput", \%configinputfw);
490 #foreach my $key (sort keys %configinputfw){
491 # &checkcounter($configinputfw{$key}[3],$configinputfw{$key}[4],,);
492 # &checkcounter($configinputfw{$key}[5],$configinputfw{$key}[6],,);
493 # &checkcounter($configinputfw{$key}[14],$configinputfw{$key}[15],,);
496 system("rm ${General::swroot}/forward/config");
497 #system("rm ${General::swroot}/forward/input");
498 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
499 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
500 #unless (-e "${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
501 my $MODE1=$fwdfwsettings{'POLICY1'};
503 $fwdfwsettings{'POLICY'}='MODE2';
504 $fwdfwsettings{'POLICY1'}=$MODE1;
505 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
508 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
509 foreach my $key (sort keys %configoutgoingfw){
510 &checkcounter
($configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],,);
511 &checkcounter
($configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],,);
512 &checkcounter
($configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],,);
514 system("rm ${General::swroot}/forward/outgoing");
515 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
516 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
517 my $MODE=$fwdfwsettings{'POLICY'};
519 $fwdfwsettings{'POLICY'}=$MODE;
520 $fwdfwsettings{'POLICY1'}='MODE2';
521 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
525 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
529 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
532 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
533 foreach my $key (sort keys %togglehash){
534 if ($key eq $fwdfwsettings{'key'}){
535 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
538 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
542 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
545 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
546 foreach my $key (sort keys %togglehash){
547 if ($key eq $fwdfwsettings{'key'}){
548 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
551 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
555 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
560 if ($fwdfwsettings{'ACTION'} eq 'editrule')
562 $fwdfwsettings{'updatefwrule'}='on';
565 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
569 if ($fwdfwsettings{'ACTION'} eq 'moveup')
574 if ($fwdfwsettings{'ACTION'} eq 'movedown')
579 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
581 $fwdfwsettings{'copyfwrule'}='on';
582 #$fwdfwsettings{'updatefwrule'}='on';
585 if ($fwdfwsettings{'ACTION'} eq '')
593 if (-f
"${General::swroot}/forward/reread"){
594 print "<table border='0'><form method='post'><td><div style='font-size:11pt; font-weight: bold;vertical-align: middle; '><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: red; font-weight: bold; font-size: 14pt; text-decoration: blink;'>    $Lang::tr{'fwhost reread'}</div</td></tr></table></form><hr><br>";
596 &Header
::openbox
('100%', 'left', $Lang::tr
{'firewall'});
597 print "<form method='post'>";
598 print "<table border='0'>";
599 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
600 print"</tr></table></form><hr>";
606 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
607 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
608 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){ $selected{'POLICY1'}{'MODE1'} = 'selected'; } else { $selected{'POLICY1'}{'MODE1'} = ''; }
609 if ($fwdfwsettings{'POLICY1'} eq 'MODE2'){ $selected{'POLICY1'}{'MODE2'} = 'selected'; } else { $selected{'POLICY1'}{'MODE2'} = ''; }
613 &Header
::openbox
('100%', 'center', $Lang::tr
{'fwdfw pol title'});
615 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
616 <table width='100%' border='0'>
617 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>FORWARD </td></tr>
618 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text'}</td></tr>
619 <tr><td colspan='3'><hr /></td></tr>
620 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
621 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
622 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
623 <input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td><td width='45%' align='right'>
626 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='forward' /></td></tr>";
627 print "</table></form>";
630 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
631 <table width='100%' border='0'>
632 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>OUTGOING </td></tr>
633 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text1'}</td></tr>
634 <tr><td colspan='3'><hr /></td></tr>
635 <tr><td width='15%' align='left'> <select name='POLICY1' style="width: 100px">
636 <option value='MODE1' $selected{'POLICY1'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
637 <option value='MODE2' $selected{'POLICY1'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
638 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td><td width='45%' align='right'>
641 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='outgoing' /></tr>";
642 print "</table></form>";
644 print "<br><br><div align='right'><font size='1' color='grey'>Version: $VERSION</font></div>";
649 $fwdfwsettings{'updatefwrule'}='';
650 $fwdfwsettings{'config'}=$oldchain;
651 $fwdfwsettings{'nobase'}='on';
653 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
654 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
660 #check ip-address if manual
661 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
662 #check if ip with subnet
663 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
664 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
665 $subnet = &General
::iporsubtocidr
($subnet);
666 $fwdfwsettings{'isip'}='on';
669 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
670 $ip=$fwdfwsettings{'src_addr'};
672 $fwdfwsettings{'isip'}='on';
675 if ($fwdfwsettings{'isip'} ne 'on'){
676 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
678 if ($fwdfwsettings{'isip'} eq 'on'){
679 #check and form valid IP
680 $ip=&General
::ip2dec
($ip);
681 $ip=&General
::dec2ip
($ip);
682 #check if net or broadcast
683 my @tmp= split (/\./,$ip);
684 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
686 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
688 $fwdfwsettings{'src_addr'}="$ip/$subnet";
690 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
691 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
694 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
695 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
697 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
698 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
699 return $errormessage;
703 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
705 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
706 $fwdfwsettings{'SRC_PORT'}='';
707 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
708 foreach my $key (keys %icmptypes){
709 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
710 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
713 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
714 $fwdfwsettings{'SRC_PORT'}='';
715 $fwdfwsettings{'ICMP_TYPES'}='';
716 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
717 $fwdfwsettings{'SRC_PORT'}='';
718 $fwdfwsettings{'ICMP_TYPES'}='';
719 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
720 $fwdfwsettings{'SRC_PORT'}='';
721 $fwdfwsettings{'ICMP_TYPES'}='';
722 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
723 $fwdfwsettings{'ICMP_TYPES'}='';
725 $fwdfwsettings{'ICMP_TYPES'}='';
726 $fwdfwsettings{'SRC_PORT'}='';
727 $fwdfwsettings{'PROT'}='';
730 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
731 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
735 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
737 #change dashes with :
740 push(@values,"1:65535");
743 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
744 push(@values,"1:$2");
747 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
748 push(@values,"$1:65535");
751 $errormessage .= &General
::validportrange
($_, 'destination');
756 if (&General
::validport
($_)){
763 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
764 return $errormessage;
770 &General
::readhasharray
("$configsrv", \
%customservice);
771 #check DNAT settings (has to be single Host and single Port or portrange)
772 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
773 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
774 if ($fwdfwsettings{'USESRV'} eq ''){
775 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
777 #check if manual ip is a single Host (if set)
778 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
779 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
780 my @tmp1= split ("/",$tmp[3]);
781 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
783 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
786 #check if Port is a single Port or portrange
787 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
788 if(($fwdfwsettings{'TGT_PROT'} ne 'TCP'|| $fwdfwsettings{'TGT_PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
789 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
791 if (($fwdfwsettings{'TGT_PROT'} eq 'TCP'|| $fwdfwsettings{'TGT_PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
792 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
796 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
799 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
800 #check if ip with subnet
801 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
802 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
803 $subnet = &General
::iporsubtocidr
($subnet);
806 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
807 $ip=$fwdfwsettings{'tgt_addr'};
810 #check and form valid IP
811 $ip=&General
::ip2dec
($ip);
812 $ip=&General
::dec2ip
($ip);
814 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
815 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
816 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
818 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
819 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
820 return $errormessage;
823 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
825 if ($fwdfwsettings{'USESRV'} eq 'ON'){
826 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
827 $fwdfwsettings{'TGT_PROT'}='';
828 $fwdfwsettings{'ICMP_TGT'}='';
830 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
831 $fwdfwsettings{'TGT_PROT'}='';
832 $fwdfwsettings{'ICMP_TGT'}='';
833 #check target service
834 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
835 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
838 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
839 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
840 if ($fwdfwsettings{'TGT_PORT'} ne ''){
841 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'}) {
842 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
844 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
848 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
850 #change dashes with :
853 push(@values,"1:65535");
856 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
857 push(@values,"1:$2");
860 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
861 push(@values,"$1:65535");
864 $errormessage .= &General
::validportrange
($_, 'destination');
869 if (&General
::validport
($_)){
876 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
878 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
879 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
880 $fwdfwsettings{'TGT_PORT'} = '';
881 $fwdfwsettings{'ICMP_TGT'} = '';
882 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
883 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
884 $fwdfwsettings{'TGT_PORT'} = '';
885 $fwdfwsettings{'ICMP_TGT'}='';
886 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
887 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
888 $fwdfwsettings{'TGT_PORT'} = '';
889 $fwdfwsettings{'ICMP_TGT'}='';
890 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
891 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
892 $fwdfwsettings{'TGT_PORT'} = '';
893 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
894 foreach my $key (keys %icmptypes){
896 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
897 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
905 if ($fwdfwsettings{'USESRV'} ne 'ON'){
906 $fwdfwsettings{'grp3'}='';
907 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
908 $fwdfwsettings{'TGT_PROT'}='';
909 $fwdfwsettings{'ICMP_TGT'}='';
912 if($fwdfwsettings{'TIME'} eq 'ON'){
913 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 ''){
914 $errormessage=$Lang::tr
{'fwdfw err time'};
917 return $errormessage;
922 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
923 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
924 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
925 if ($fwdfwsettings{'dnatport'} eq "*") {
926 $fwdfwsettings{'dnatport'}="1:65535";
928 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
929 $fwdfwsettings{'dnatport'} = "1:$2";
931 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
932 $fwdfwsettings{'dnatport'} ="$1:65535";
937 if ($val =~ "," || $val>65536 || $val<0){
944 #check valid port for NAT
945 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
946 #if no port is given in nat area, take target host port
947 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
948 #check if port given in nat area is a single valid port or portrange
949 if($fwdfwsettings{'nat'} eq 'dnat' && !&check_natport
($fwdfwsettings{'dnatport'})){
950 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
952 elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
954 #get servcie Protocol and Port
955 foreach my $key (sort keys %customservice){
956 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
957 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
958 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
960 $custsrvport= $customservice{$key}[1];
963 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
967 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
968 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
970 #check if source and target identical
971 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
972 $errormessage.=$Lang::tr
{'fwdfw err same'};
973 return $errormessage;
975 #get source and targetip address if possible
976 my ($sip,$scidr,$tip,$tcidr);
977 ($sip,$scidr)=&get_ip
("src","grp1");
978 ($tip,$tcidr)=&get_ip
("tgt","grp2");
979 #check same iprange in source and target
980 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
981 my $networkip1=&General
::getnetworkip
($sip,$scidr);
982 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
983 if ($scidr gt $tcidr){
984 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
985 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
987 }elsif($scidr eq $tcidr && $scidr eq '32'){
988 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
989 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
990 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
991 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
992 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
995 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
996 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
1000 #check source and destination protocol if manual
1001 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
1002 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
1003 $errormessage.=$Lang::tr
{'fwdfw err prot'};
1005 #check source and destination protocol if source manual and dest servicegrp
1006 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
1007 foreach my $key (sort keys %customservice){
1008 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
1009 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
1010 $errormessage.=$Lang::tr
{'fwdfw err prot'};
1020 my ($base1,$val1,$base2,$val2) = @_;
1022 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
1023 &dec_counter
($confignet,\
%customnetwork,$val1);
1024 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
1025 &dec_counter
($confighost,\
%customhost,$val1);
1026 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
1027 &dec_counter
($configgrp,\
%customgrp,$val1);
1028 }elsif($base1 eq 'cust_srv'){
1029 &dec_counter
($configsrv,\
%customservice,$val1);
1030 }elsif($base1 eq 'cust_srvgrp'){
1031 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
1034 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
1035 &inc_counter
($confignet,\
%customnetwork,$val2);
1036 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
1037 &inc_counter
($confighost,\
%customhost,$val2);
1038 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
1039 &inc_counter
($configgrp,\
%customgrp,$val2);
1040 }elsif($base2 eq 'cust_srv'){
1041 &inc_counter
($configsrv,\
%customservice,$val2);
1042 }elsif($base2 eq 'cust_srvgrp'){
1043 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
1049 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
1050 foreach my $key (sort {$a <=> $b} keys %delhash){
1051 if ($key == $fwdfwsettings{'key'}){
1052 #check hosts/net and groups
1053 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
1054 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
1055 #check services and groups
1056 if ($delhash{$key}[11] eq 'ON'){
1057 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
1060 if ($key >= $fwdfwsettings{'key'}) {
1061 my $next = $key + 1;
1062 if (exists $delhash{$next}) {
1063 foreach my $i (0 .. $#{$delhash{$next}}) {
1064 $delhash{$key}[$i] = $delhash{$next}[$i];
1069 # Remove the very last entry.
1070 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
1071 delete $delhash{$last_key};
1073 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
1076 if($fwdfwsettings{'nobase'} ne 'on'){
1083 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
1084 foreach my $key (sort keys %configfwdfw){
1085 if ($key eq $key1 ){
1086 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
1089 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
1095 my %hash=%{(shift)};
1098 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
1099 &General
::readhasharray
($config, \
%hash);
1100 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1101 if($hash{$key}[0] eq $val){
1102 $pos=$#{$hash{$key}};
1103 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
1106 &General
::writehasharray
($config, \
%hash);
1110 if ($errormessage) {
1111 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1112 print "<class name='base'>$errormessage\n";
1113 print " </class>\n";
1114 &Header
::closebox
();
1120 my %hash=%{(shift)};
1123 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1124 if($hash{$key}[0] eq $val){
1125 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1127 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1137 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1138 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1139 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1140 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1141 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1142 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1143 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1144 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1145 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1146 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1147 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1148 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1149 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1150 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1151 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1152 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1153 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1154 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1156 <table width='100%' border='0'>
1157 <tr><td width='50%' valign='top'>
1158 <table width='100%' border='0'>
1159 <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;'>
1161 foreach my $network (sort keys %defaultNetworks)
1163 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1164 next if($defaultNetworks{$network}{'NAME'} eq "IPFire" && $srctgt eq 'tgt');
1165 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1166 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1167 print ">$network</option>";
1169 print"</select></td></tr>";
1171 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1172 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;'>";
1173 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1174 print"</select></td>";
1177 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1178 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;'>";
1179 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1180 print"</select></td>";
1183 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1184 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;'>";
1185 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1186 if($helper ne $customgrp{$key}[0]){
1188 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1189 print ">$customgrp{$key}[0]</option>";
1191 $helper=$customgrp{$key}[0];
1193 print"</select></td>";
1195 #End left table. start right table (vpn)
1196 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1198 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1199 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;'>";
1200 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1201 print"</select></td></tr>";
1204 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1205 if ($ccdhost{$key}[33] ne '' ){
1206 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 '');
1208 print "<option value='$ccdhost{$key}[1]'";
1209 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1210 print ">$ccdhost{$key}[1]</option>";
1213 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1214 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>" ;
1216 if ($show eq '1'){$show='';print"</select></td></tr>";}
1218 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1219 if ($ccdhost{$key}[3] eq 'net'){
1220 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 '');
1222 print "<option value='$ccdhost{$key}[1]'";
1223 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1224 print ">$ccdhost{$key}[1]</option>";
1227 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1228 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>" ;
1230 if ($show eq '1'){$show='';print"</select></td></tr>";}
1232 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1233 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1234 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 '');
1237 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1238 print ">$ipsecconf{$key}[1]</option>";
1241 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1242 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>";
1244 if ($show eq '1'){$show='';print"</select></td></tr>";}
1246 print"</tr></table>";
1247 print"</td></tr></table><br>";
1255 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1256 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1257 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1258 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1259 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1260 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1261 $a=$netsettings{'GREEN_NETADDRESS'};
1262 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1263 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1264 $a=$netsettings{'ORANGE_NETADDRESS'};
1265 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1266 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1267 $a=$netsettings{'BLUE_NETADDRESS'};
1268 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1269 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1270 &General
::readhash
("$configovpn",\
%ovpnsettings);
1271 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1272 $b=&General
::iporsubtocidr
($b);
1274 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1275 &General
::readhasharray
("$confignet", \
%customnetwork);
1276 foreach my $key (keys %customnetwork){
1277 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1278 $a=$customnetwork{$key}[1];
1279 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1282 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1283 &General
::readhasharray
("$confighost", \
%customhost);
1284 foreach my $key (keys %customhost){
1285 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1286 if ($customhost{$key}[1] eq 'ip'){
1287 ($a,$b)=split (/\//,$customhost{$key}[2]);
1288 $b=&General
::iporsubtocidr
($b);
1290 if ($grp eq 'grp2'){
1291 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1303 &General
::setup_default_networks
(\
%defaultNetworks);
1304 foreach my $network (sort keys %defaultNetworks)
1306 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1311 my %hash=%{(shift)};
1313 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1314 $hash{$key}[10]=~ s/\|/,/g;
1315 print": $hash{$key}[10]";
1316 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1317 print": <br>$hash{$key}[9] ";
1322 my %hash=%{(shift)};
1326 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1327 if($hash{$key}[14] eq 'cust_srv'){
1328 &General
::readhasharray
("$configsrv", \
%customservice);
1329 foreach my $i (sort keys %customservice){
1330 if($customservice{$i}[0] eq $hash{$key}[15]){
1331 $service = $customservice{$i}[0];
1334 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1335 $service=$hash{$key}[15];
1336 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1337 $hash{$key}[15]=~ s/\|/,/g;
1338 $service=$hash{$key}[15];
1343 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1344 print":<br>$hash{$key}[13]";
1347 sub get_serviceports
1351 &General
::readhasharray
("$configsrv", \
%customservice);
1352 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1357 if($type eq 'service'){
1358 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1359 if ($customservice{$key}[0] eq $name){
1360 push (@protocols,$customservice{$key}[2]);
1363 }elsif($type eq 'group'){
1364 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1365 if ($customservicegrp{$key}[0] eq $name){
1366 foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1367 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1368 if($customservice{$key1}[2] eq 'TCP'){
1370 }elsif($customservice{$key1}[2] eq 'ICMP'){
1372 }elsif($customservice{$key1}[2] eq 'UDP'){
1380 if($tcp && $udp && $icmp){
1381 push (@protocols,"All");
1385 push (@protocols,"TCP");
1388 push (@protocols,"UDP");
1391 push (@protocols,"ICMP");
1400 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1402 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'){
1403 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1406 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1407 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1411 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1412 foreach my $key (sort keys %$hash){
1413 if ($$hash{$key}[0] eq $val){
1414 $val=$$hash{$key}[2];
1419 foreach my $alias (sort keys %aliases)
1421 if ($val eq $alias){
1422 $tdcolor="style='border: 1px solid $Header::colourred;'";
1427 if ($val eq 'GREEN'){
1428 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1429 }elsif ($val eq 'ORANGE'){
1430 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1431 }elsif ($val eq 'BLUE'){
1432 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1433 }elsif ($val eq 'RED'){
1434 $tdcolor="style='border: 1px solid $Header::colourred;'";
1435 }elsif ($val eq 'IPFire' ){
1436 $tdcolor="style='border: 1px solid $Header::colourred;'";
1437 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1438 my ($sip,$scidr) = split ("/",$val);
1439 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1440 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1442 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1443 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1445 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1446 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1448 }elsif ($val eq 'Default IP'){
1449 $tdcolor="style='border: 1px solid $Header::colourred;'";
1458 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1459 print "<class name='base'>$hint\n";
1460 print " </class>\n";
1461 &Header
::closebox
();
1468 my %hash=%{(shift)};
1472 &General
::readhasharray
($config, \
%hash);
1473 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1474 if($hash{$key}[0] eq $val){
1475 $pos=$#{$hash{$key}};
1476 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1479 &General
::writehasharray
($config, \
%hash);
1484 &General
::setup_default_networks
(\
%defaultNetworks);
1485 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1486 #read all configfiles
1487 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1488 &General
::readhasharray
("$confignet", \
%customnetwork);
1489 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1490 &General
::readhasharray
("$confighost", \
%customhost);
1491 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1492 &General
::readhasharray
("$configgrp", \
%customgrp);
1493 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1494 &General
::get_aliases
(\
%aliases);
1498 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1499 my $config=$fwdfwsettings{'config'};
1501 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1502 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1503 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1504 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1505 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1506 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1507 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1508 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1509 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1510 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1511 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1512 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1513 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1514 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1515 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1516 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1517 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1518 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1519 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1520 #check if update and get values
1521 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1522 &General
::readhasharray
("$config", \
%hash);
1523 foreach my $key (sort keys %hash){
1525 if ($key eq $fwdfwsettings{'key'}){
1526 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1527 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1528 $fwdfwsettings{'chain'} = $hash{$key}[1];
1529 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1530 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1531 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1532 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1533 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1534 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1535 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1536 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1537 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1538 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1539 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1540 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1541 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1542 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1543 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1544 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1545 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1546 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1547 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1548 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1549 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1550 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1551 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1552 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1553 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1554 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1555 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1556 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1557 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1558 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1559 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1560 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1561 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1562 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1563 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1564 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1565 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1566 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1567 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1568 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1569 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1570 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1571 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1572 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1573 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1574 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1575 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1576 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1577 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1578 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1579 $selected{'dnat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1580 $selected{'snat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1583 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1584 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1585 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1586 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1587 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1588 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1589 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1590 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1591 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1592 if ($fwdfwsettings{'config'} eq "${General::swroot}/forward/dmz"){
1593 $fwdfwsettings{'oldruletype'}='DMZ';
1595 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1597 #check if manual ip (source) is orange network
1598 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1599 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1600 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1601 $fwdfwsettings{'oldorange'} ='on';
1605 $fwdfwsettings{'ACTIVE'}='ON';
1606 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1607 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1608 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1609 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1610 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1611 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1612 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1613 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1614 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1615 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1616 #check if manual ip (source) is orange network
1617 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1618 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1619 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1620 $fwdfwsettings{'oldorange'} ='on';
1624 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1625 if ($fwdfwsettings{'TIME'} eq 'ON'){
1626 $fwdfwsettings{'TIME_FROM'} = &timeconvert
($fwdfwsettings{'TIME_FROM'},'');
1627 $fwdfwsettings{'TIME_TO'} = &timeconvert
($fwdfwsettings{'TIME_TO'},'');
1629 print "<form method='post'>";
1630 &Header
::closebox
();
1631 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1632 #------SOURCE-------------------------------------------------------
1634 <table width='100%' border='0'>
1635 <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>
1636 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1639 &gen_dd_block
('src','grp1');
1641 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1642 <table width='100%' border='0'>
1643 <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>
1644 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1646 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1648 if ($_ eq $fwdfwsettings{'PROT'})
1650 print"<option selected>$_</option>";
1652 print"<option>$_</option>";
1655 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1657 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1658 <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;'>
1660 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1661 print"<option>All ICMP-Types</option>";
1662 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1663 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1664 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1666 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1670 </select></td></tr></table><br><hr>
1672 &Header
::closebox
();
1674 #---TARGET------------------------------------------------------
1675 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1677 <table width='100%' border='0'>
1678 <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>
1680 if (! -z
"${General::swroot}/ethernet/aliases"){
1681 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1682 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1684 foreach my $alias (sort keys %aliases)
1686 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1690 print"<td style='width:200px;'><input type='hidden' name ='ipfire' value='Default IP'>";
1694 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1696 &gen_dd_block
('tgt','grp2');
1698 <b>$Lang::tr{'fwhost attention'}:</b><br>
1699 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1700 <table width='100%' border='0'>
1701 <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;' >
1703 &General
::readhasharray
("$configsrv", \
%customservice);
1704 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1706 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1707 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1711 <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;' >
1713 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1715 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1716 if ($helper ne $customservicegrp{$key}[0]){
1718 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1719 print">$customservicegrp{$key}[0]</option>";
1721 $helper=$customservicegrp{$key}[0];
1725 <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'>
1727 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1729 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1731 print"<option selected>$_</option>";
1733 print"<option>$_</option>";
1736 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1738 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1739 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT' style='min-width:230px;'>
1741 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1742 print"<option>All ICMP-Types</option>";
1743 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1744 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1745 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1747 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1756 #---SNAT / DNAT ------------------------------------------------
1757 &Header
::openbox
('100%', 'left', 'NAT');
1759 <table width='100%' border='0'>
1760 <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>
1761 <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>
1763 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
1764 print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
1765 print "<option value='Default IP' $selected{'dnat'}{'Default IP'}>Default IP</option>";
1766 foreach my $alias (sort keys %aliases)
1768 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
1771 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>";
1772 print"<tr><td colspan='8'><br></td></tr>";
1774 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>";
1775 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
1776 print "<option value='Default IP' $selected{'snat'}{'Default IP'}>Default IP</option>";
1777 foreach my $alias (sort keys %aliases)
1779 print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
1781 foreach my $network (sort keys %defaultNetworks)
1783 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1784 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1785 next if($defaultNetworks{$network}{'NAME'} eq "ALL");
1786 next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
1787 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1788 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
1789 print ">$network</option>";
1793 &Header
::closebox
();
1794 #---Activate/logging/remark-------------------------------------
1795 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1797 <table width='100%' border='0'>
1798 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1800 foreach ("ACCEPT","DROP","REJECT")
1802 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1803 print"<option value='$_'";
1804 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1805 print">$Lang::tr{'fwdfw '.$_}</option>";
1807 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1808 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1810 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1812 print"<option value='$_' selected>$Lang::tr{'fwdfw '.$_}</option>";
1814 print"<option value='$_'>$Lang::tr{'fwdfw '.$_}</option>";
1818 print"</select></td></tr>";
1819 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>";
1820 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1821 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1822 for (my $count =1; $count <= $sum; $count++){
1823 print"<option value='$count' ";
1824 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1825 print">$count</option>";
1827 print"</select></td></tr>";
1829 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1833 </table><table width='100%'>
1834 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1835 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1838 &Header
::closebox
();
1839 #---ADD TIMEFRAME-----------------------------------------------
1840 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1842 <table width='70%' border='0'>
1843 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1844 <tr><td colspan='7'> </td></tr>
1846 <td align='left'>$Lang::tr{'time'}:</td>
1847 <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>
1848 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1849 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1852 <td align='right'></td>
1853 <td width='30%' align='left'>
1854 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1855 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1856 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1857 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1858 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1859 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1860 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1862 <td><select name='TIME_FROM'>
1864 for (my $i=0;$i<=23;$i++) {
1865 $i = sprintf("%02s",$i);
1866 for (my $j=0;$j<=45;$j+=15) {
1867 $j = sprintf("%02s",$j);
1868 my $time = $i.":".$j;
1869 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1874 <td><select name='TIME_TO'>
1876 for (my $i=0;$i<=23;$i++) {
1877 $i = sprintf("%02s",$i);
1878 for (my $j=0;$j<=45;$j+=15) {
1879 $j = sprintf("%02s",$j);
1880 my $time = $i.":".$j;
1881 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1888 #---ACTION------------------------------------------------------
1889 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1891 <table border='0' width='100%'>
1892 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1893 <input type='hidden' name='config' value='$config' >
1894 <input type='hidden' name='ACTION' value='saverule' >
1895 </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>
1900 <table border='0' width='100%'>
1901 <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'}'>
1902 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1903 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1904 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1905 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1906 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1907 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1908 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1909 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1910 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1911 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1912 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1913 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
1914 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
1915 <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>
1919 &Header
::closebox
();
1925 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1926 foreach my $key (sort keys %uphash){
1927 if ($key eq $fwdfwsettings{'key'}) {
1929 if (exists $uphash{$last}){
1931 foreach my $y (0 .. $#{$uphash{$last}}) {
1932 $tmp{0}[$y] = $uphash{$last}[$y];
1934 #copy active rule to last
1935 foreach my $i (0 .. $#{$uphash{$last}}) {
1936 $uphash{$last}[$i] = $uphash{$key}[$i];
1938 #copy saved rule to actual position
1939 foreach my $x (0 .. $#{$tmp{0}}) {
1940 $uphash{$key}[$x] = $tmp{0}[$x];
1945 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1952 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1953 foreach my $key (sort keys %downhash){
1954 if ($key eq $fwdfwsettings{'key'}) {
1955 my $next = $key + 1;
1956 if (exists $downhash{$next}){
1958 foreach my $y (0 .. $#{$downhash{$next}}) {
1959 $tmp{0}[$y] = $downhash{$next}[$y];
1961 #copy active rule to next
1962 foreach my $i (0 .. $#{$downhash{$next}}) {
1963 $downhash{$next}[$i] = $downhash{$key}[$i];
1965 #copy saved rule to actual position
1966 foreach my $x (0 .. $#{$tmp{0}}) {
1967 $downhash{$key}[$x] = $tmp{0}[$x];
1972 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1977 if (!-f
"${General::swroot}/forward/reread"){
1978 system("touch ${General::swroot}/forward/reread");
1979 system("touch ${General::swroot}/fwhosts/reread");
1984 system("/usr/local/bin/forwardfwctrl");
1985 if ( -f
"${General::swroot}/forward/reread"){
1986 system("rm ${General::swroot}/forward/reread");
1987 system("rm ${General::swroot}/fwhosts/reread");
1994 &General
::readhasharray
("$config", $hash);
1995 if (!$errormessage){
1996 #check if we change a NAT to a FORWARD/DMZ
1997 if(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'FORWARDFW'){
1998 &changerule
($confignat);
2001 #check if we change a NAT to a INPUT (external access)
2002 elsif(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2003 &changerule
($confignat);
2006 #check if we change a NAT to a OUTGOING
2007 elsif(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2008 &changerule
($confignat);
2011 ################################################################
2012 #check if we change a DMZ to a NAT
2013 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2014 &changerule
($configdmz);
2017 #check if we change a DMZ to an OUTGOING
2018 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2019 &changerule
($configdmz);
2022 #check if we change a DMZ to an INPUT
2023 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2024 &changerule
($configdmz);
2027 #check if we change a DMZ to a FORWARD/DMZ
2028 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'FORWARDFW' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
2029 &changerule
($configdmz);
2032 ################################################################
2033 #check if we change an INPUT rule to a NAT
2034 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2035 &changerule
($configinput);
2038 #check if we change an INPUT rule to a OUTGOING
2039 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2040 &changerule
($configinput);
2043 #check if we change an INPUT rule to a FORWARD/DMZ
2044 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2045 &changerule
($configinput);
2048 ################################################################
2049 #check if we change an OUTGOING rule to an INPUT
2050 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2051 &changerule
($configoutgoing);
2054 #check if we change an OUTGOING rule to a FORWARD/DMZ
2055 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2056 &changerule
($configoutgoing);
2059 #check if we change an OUTGOING rule to a NAT
2060 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2061 &changerule
($configoutgoing);
2064 ################################################################
2065 #check if we change a FORWARD rule to an INPUT
2066 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2067 &changerule
($configfwdfw);
2070 #check if we change a FORWARD rule to an DMZ
2071 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on'){
2072 &changerule
($configfwdfw);
2075 #check if we change a FORWARD rule to an OUTGOING
2076 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2077 &changerule
($configfwdfw);
2080 #check if we change a FORWARD rule to an NAT
2081 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2082 &changerule
($configfwdfw);
2085 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2086 my $key = &General
::findhasharraykey
($hash);
2087 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2088 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2089 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2090 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2091 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2092 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2093 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2094 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2095 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2096 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2097 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2098 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2099 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2100 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2101 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2102 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2103 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2104 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2105 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2106 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2107 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2108 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2109 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2110 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2111 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2112 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2113 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2114 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2115 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
2116 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2117 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2118 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2119 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2121 &General
::writehasharray
("$config", $hash);
2123 foreach my $key (sort {$a <=> $b} keys %$hash){
2124 if($key eq $fwdfwsettings{'key'}){
2125 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2126 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2127 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2128 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2129 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2130 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2131 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2132 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2133 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2134 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2135 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2136 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2137 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2138 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2139 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2140 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2141 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2142 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2143 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2144 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2145 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2146 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2147 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2148 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2149 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2150 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2151 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2152 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2153 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
2154 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2155 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2156 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2157 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2163 &General
::writehasharray
("$config", $hash);
2164 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2166 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2167 for (my $z=0;$z<$val;$z++){
2168 foreach my $key (sort {$a <=> $b} keys %$hash){
2169 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2171 if (exists $$hash{$last}){
2173 foreach my $y (0 .. $#{$$hash{$last}}) {
2174 $tmp{0}[$y] = $$hash{$last}[$y];
2176 #copy active rule to last
2177 foreach my $i (0 .. $#{$$hash{$last}}) {
2178 $$hash{$last}[$i] = $$hash{$key}[$i];
2180 #copy saved rule to actual position
2181 foreach my $x (0 .. $#{$tmp{0}}) {
2182 $$hash{$key}[$x] = $tmp{0}[$x];
2187 $fwdfwsettings{'oldrulenumber'}--;
2189 &General
::writehasharray
("$config", $hash);
2191 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2193 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2194 for (my $z=0;$z<$val;$z++){
2195 foreach my $key (sort {$a <=> $b} keys %$hash){
2196 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2197 my $next = $key + 1;
2198 if (exists $$hash{$next}){
2200 foreach my $y (0 .. $#{$$hash{$next}}) {
2201 $tmp{0}[$y] = $$hash{$next}[$y];
2203 #copy active rule to next
2204 foreach my $i (0 .. $#{$$hash{$next}}) {
2205 $$hash{$next}[$i] = $$hash{$key}[$i];
2207 #copy saved rule to actual position
2208 foreach my $x (0 .. $#{$tmp{0}}) {
2209 $$hash{$key}[$x] = $tmp{0}[$x];
2214 $fwdfwsettings{'oldrulenumber'}++;
2216 &General
::writehasharray
("$config", $hash);
2223 # Checks a hostname against RFC1035
2226 # Each part should be at least two characters in length
2227 # but no more than 63 characters
2228 if (length ($remark) < 1 || length ($remark) > 255) {
2230 # Only valid characters are a-z, A-Z, 0-9 and -
2231 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2233 # First character can only be a letter or a digit
2234 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2236 # Last character can only be a letter or a digit
2237 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2243 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2244 &viewtablenew
(\
%configdmzfw,$configdmz,$Lang::tr
{'fwdfw rules'},"DMZ" );
2245 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
2246 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
2247 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
2248 &viewtablenew
(\
%confignatfw,$confignat,"","NAT" );
2257 &General
::get_aliases
(\
%aliases);
2258 &General
::readhasharray
("$confighost", \
%customhost);
2259 &General
::readhasharray
("$config", $hash);
2261 &Header
::openbox
('100%', 'left',$title);
2269 print"<b>$title1</b><br>";
2270 print"<table width='100%' cellspacing='0' cellpadding='0'>";
2271 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>";
2272 foreach my $key (sort {$a <=> $b} keys %$hash){
2275 #check if vpn hosts/nets have been deleted
2276 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2277 push (@tmpsrc,$$hash{$key}[4]);
2279 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2280 push (@tmpsrc,$$hash{$key}[6]);
2282 foreach my $host (@tmpsrc){
2283 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2284 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2286 &disable_rule
($key);
2289 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2290 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2292 &disable_rule
($key);
2295 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2296 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2298 &disable_rule
($key);
2301 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2302 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2304 &disable_rule
($key);
2309 $$hash{'ACTIVE'}=$$hash{$key}[2];
2311 if($coloryellow eq 'on'){
2312 print"<tr bgcolor='$color{'color14'}' >";
2314 }elsif($coloryellow eq ''){
2316 $color="$color{'color22'}";
2319 $color="$color{'color20'}";
2322 print"<tr bgcolor='$color' >";
2324 <td align='right' width='15'><b>$key</b></td>
2326 if ($$hash{$key}[0] eq 'ACCEPT'){
2329 $rulecolor=$color{'color17'};
2330 }elsif($$hash{$key}[0] eq 'DROP'){
2333 $rulecolor=$color{'color25'};
2334 }elsif($$hash{$key}[0] eq 'REJECT'){
2337 $rulecolor=$color{'color16'};
2339 print"<td bgcolor='$rulecolor' align='center' width='20'><span title='$tooltip'><b>$ruletype</b></span></td>";
2340 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2341 print"<td align='center' width='160' $tdcolor>";
2342 if ($$hash{$key}[3] eq 'std_net_src'){
2343 print &get_name
($$hash{$key}[4]);
2345 print $$hash{$key}[4];
2348 &getsrcport
(\
%$hash,$key);
2349 #Is this a SNAT rule?
2350 if ($$hash{$key}[31] eq 'snat'){
2351 print"<br>SNAT -> $$hash{$key}[29]";
2352 if ($$hash{$key}[30] ne ''){
2353 print": $$hash{$key}[30]";
2356 if ($$hash{$key}[17] eq 'ON'){
2357 $log="/images/on.gif";
2359 $log="/images/off.gif";
2363 <form method='post'>
2364 <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 ;'/>
2365 <input type='hidden' name='key' value='$key' />
2366 <input type='hidden' name='config' value='$config' />
2367 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2370 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2372 <td align='center' width='160' $tdcolor>
2374 #Is this a DNAT rule?
2375 if ($$hash{$key}[31] eq 'dnat'){
2376 print "IPFire ($$hash{$key}[29])";
2377 if($$hash{$key}[30] ne ''){
2378 print": $$hash{$key}[30]";
2382 if ($$hash{$key}[5] eq 'std_net_tgt'){
2383 print &get_name
($$hash{$key}[6]);
2385 print $$hash{$key}[6];
2388 &gettgtport
(\
%$hash,$key);
2392 if ($$hash{$key}[12]){ #target prot if manual
2393 push (@protocols,$$hash{$key}[12]);
2394 }elsif($$hash{$key}[8]){ #source prot if manual
2395 push (@protocols,$$hash{$key}[8]);
2396 }elsif($$hash{$key}[14] eq 'cust_srv'){
2397 &get_serviceports
("service",$$hash{$key}[15]);
2398 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2399 &get_serviceports
("group",$$hash{$key}[15]);
2401 push (@protocols,$Lang::tr
{'all'});
2403 my $protz=join(",",@protocols);
2404 print"<td align='center'>$protz</td>";
2406 if ($$hash{$key}[18] eq 'ON'){
2408 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2409 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2410 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2411 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2412 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2413 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2414 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2415 my $weekdays=join(",",@days);
2417 print"<td align='center' width='100'>$weekdays   $$hash{$key}[26] - $$hash{$key}[27] </td>";
2420 print"<td align='center'>24/7</td>";
2422 if($$hash{$key}[2] eq 'ON'){
2423 $gif="/images/on.gif"
2426 $gif="/images/off.gif"
2429 <form method='post'>
2430 <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;' />
2431 <input type='hidden' name='key' value='$key' />
2432 <input type='hidden' name='config' value='$config' />
2433 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2435 <form method='post'>
2436 <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;' />
2437 <input type='hidden' name='key' value='$key' />
2438 <input type='hidden' name='config' value='$config' />
2439 <input type='hidden' name='ACTION' value='editrule' />
2441 <form method='post'>
2442 <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;' />
2443 <input type='hidden' name='key' value='$key' />
2444 <input type='hidden' name='config' value='$config' />
2445 <input type='hidden' name='ACTION' value='copyrule' />
2447 <form method='post'>
2448 <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;' />
2449 <input type='hidden' name='key' value='$key' />
2450 <input type='hidden' name='config' value='$config' />
2451 <input type='hidden' name='ACTION' value='deleterule' />
2454 if (exists $$hash{$key-1}){
2456 <form method='post'>
2457 <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;' />
2458 <input type='hidden' name='key' value='$key' />
2459 <input type='hidden' name='config' value='$config' />
2460 <input type='hidden' name='ACTION' value='moveup' />
2464 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2466 if (exists $$hash{$key+1}){
2468 <form method='post'>
2469 <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;' />
2470 <input type='hidden' name='key' value='$key' />
2471 <input type='hidden' name='config' value='$config' />
2472 <input type='hidden' name='ACTION' value='movedown' />
2473 </td></form></td></tr>
2476 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2479 if ($optionsfw{'SHOWREMARK'} eq 'on'){
2480 print"<tr bgcolor='$color'>";
2481 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='11'>  $$hash{$key}[16]</td></tr>";
2483 print"<tr bgcolor='$color'><td height='1'></td><td bgcolor='$rulecolor'></td><td colspan='11'></td></tr>";
2486 &Header
::closebox
();
2490 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2491 print "<b>$title1</b><br>";
2492 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>";
2498 &Header
::closebigbox
();
2499 &Header
::closepage
();