]>
git.ipfire.org Git - people/teissler/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.0';
82 my $confignet = "${General::swroot}/fwhosts/customnetworks";
83 my $confighost = "${General::swroot}/fwhosts/customhosts";
84 my $configgrp = "${General::swroot}/fwhosts/customgroups";
85 my $configsrv = "${General::swroot}/fwhosts/customservices";
86 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
87 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
88 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
89 my $configipsec = "${General::swroot}/vpn/config";
90 my $configipsecrw = "${General::swroot}/vpn/settings";
91 my $configfwdfw = "${General::swroot}/forward/config";
92 my $configinput = "${General::swroot}/forward/input";
93 my $configoutgoing = "${General::swroot}/forward/outgoing";
94 my $configdmz = "${General::swroot}/forward/dmz";
95 my $confignat = "${General::swroot}/forward/nat";
96 my $configovpn = "${General::swroot}/ovpn/settings";
97 my $fwoptions = "${General::swroot}/optionsfw/settings";
98 my $ifacesettings = "${General::swroot}/ethernet/settings";
101 my $ipgrp="${General::swroot}/outgoing/groups";
105 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
106 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
107 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
108 &General
::readhash
($fwoptions, \
%optionsfw);
109 &General
::readhash
($ifacesettings, \
%ifaces);
111 &Header
::showhttpheaders
();
112 &Header
::getcgihash
(\
%fwdfwsettings);
113 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
114 &Header
::openbigbox
('100%', 'center',$errormessage);
117 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
119 my $MODE = $fwdfwsettings{'POLICY'};
120 my $MODE1 = $fwdfwsettings{'POLICY1'};
122 $fwdfwsettings{'POLICY'} = "$MODE";
123 $fwdfwsettings{'POLICY1'} = "$MODE1";
124 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
127 if ($fwdfwsettings{'ACTION'} eq 'saverule')
129 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
130 &General
::readhasharray
("$configinput", \
%configinputfw);
131 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
132 &General
::readhasharray
("$confignat", \
%confignatfw);
133 $errormessage=&checksource
;
134 if(!$errormessage){&checktarget
;}
135 if(!$errormessage){&checkrule
;}
136 #check if manual ip (source) is orange network
137 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
138 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
139 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
144 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
145 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
147 #check if we try to break rules
148 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire'){
149 $errormessage.=$Lang::tr
{'fwdfw err same'};
152 if ($fwdfwsettings{'USE_NAT'} eq 'ON'){
153 $fwdfwsettings{'config'}=$confignat;
154 if ($fwdfwsettings{'nat'} eq 'dnat'){
155 $fwdfwsettings{'chain'} = 'NAT_DESTINATION';
157 $fwdfwsettings{'chain'} = 'NAT_SOURCE';
159 my $maxkey=&General
::findhasharraykey
(\
%confignatfw);
160 #check if we have an identical rule already
161 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
162 foreach my $key (sort keys %confignatfw){
163 if ("$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'snatport'},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"
164 eq "$confignatfw{$key}[0],$confignatfw{$key}[2],$confignatfw{$key}[3],$confignatfw{$key}[4],$confignatfw{$key}[5],$confignatfw{$key}[6],$confignatfw{$key}[7],$confignatfw{$key}[8],$confignatfw{$key}[9],$confignatfw{$key}[10],$confignatfw{$key}[11],$confignatfw{$key}[12],$confignatfw{$key}[13],$confignatfw{$key}[14],$confignatfw{$key}[15],$confignatfw{$key}[17],$confignatfw{$key}[19],$confignatfw{$key}[20],$confignatfw{$key}[21],$confignatfw{$key}[22],$confignatfw{$key}[23],$confignatfw{$key}[24],$confignatfw{$key}[25],$confignatfw{$key}[26],$confignatfw{$key}[27],$confignatfw{$key}[28],$confignatfw{$key}[29],$confignatfw{$key}[30],$confignatfw{$key}[31],$confignatfw{$key}[32]"){
165 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
166 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
168 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
169 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
171 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
172 $fwdfwsettings{'nosave'} = 'on';
178 #check Rulepos on new Rule
179 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
180 $fwdfwsettings{'oldrulenumber'}=$maxkey;
181 foreach my $key (sort keys %confignatfw){
182 #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>";
183 #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>";
184 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'}"
185 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]"){
186 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
190 #check if we just close a rule
191 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'}) {
192 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
194 $fwdfwsettings{'nosave2'} = 'on';
197 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
198 if ($fwdfwsettings{'nobase'} ne 'on'){
199 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
201 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
202 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
203 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
204 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
205 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
206 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
208 if($fwdfwsettings{'nosave2'} ne 'on'){
209 &saverule
(\
%confignatfw,$confignat);
212 }elsif ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on'){
213 $fwdfwsettings{'config'}=$configdmz;
214 $fwdfwsettings{'chain'} = 'FORWARDFW';
215 my $maxkey=&General
::findhasharraykey
(\
%configdmzfw);
216 #check if we have an identical rule already
217 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
218 foreach my $key (sort keys %configdmzfw){
219 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'}"
220 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]"){
221 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
222 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
224 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
225 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
227 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
228 $fwdfwsettings{'nosave'} = 'on';
233 #check Rulepos on new Rule
234 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
235 $fwdfwsettings{'oldrulenumber'}=$maxkey;
236 foreach my $key (sort keys %configdmzfw){
237 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'}"
238 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]"){
239 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
243 #check if we just close a rule
244 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'}) {
245 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
247 $fwdfwsettings{'nosave2'} = 'on';
250 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
251 if ($fwdfwsettings{'nobase'} ne 'on'){
252 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
254 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
255 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
256 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
257 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
258 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
259 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
261 if($fwdfwsettings{'nosave2'} ne 'on'){
262 &saverule
(\
%configdmzfw,$configdmz);
265 }elsif($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
266 $fwdfwsettings{'config'}=$configinput;
267 $fwdfwsettings{'chain'} = 'INPUTFW';
268 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
269 #check if we have an identical rule already
270 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
271 foreach my $key (sort keys %configinputfw){
272 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'}"
273 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]"){
274 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
275 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
277 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
278 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
280 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
281 $fwdfwsettings{'nosave'} = 'on';
286 #check Rulepos on new Rule
287 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
288 $fwdfwsettings{'oldrulenumber'}=$maxkey;
289 foreach my $key (sort keys %configinputfw){
290 if ("$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'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'}"
291 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]"){
292 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
296 #check if we just close a rule
297 if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'}) {
298 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
300 $fwdfwsettings{'nosave2'} = 'on';
303 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
304 if ($fwdfwsettings{'nobase'} ne 'on'){
305 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
307 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
308 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
309 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
310 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
311 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
312 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
314 if($fwdfwsettings{'nosave2'} ne 'on'){
315 &saverule
(\
%configinputfw,$configinput);
317 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
318 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
319 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
320 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
321 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
322 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
323 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
324 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
325 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
326 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
327 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
328 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
329 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
330 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
331 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
332 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
334 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
335 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
336 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
337 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
338 }elsif($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' ){
340 $fwdfwsettings{'config'}=$configoutgoing;
341 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
342 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
343 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
344 foreach my $key (sort keys %configoutgoingfw){
345 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'}"
346 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]"){
347 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
348 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
350 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
351 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
353 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
354 $fwdfwsettings{'nosave'} = 'on';
359 #check Rulepos on new Rule
360 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
361 print"CHECK OUTGOING DOPPELTE REGEL<br>";
362 $fwdfwsettings{'oldrulenumber'}=$maxkey;
363 foreach my $key (sort keys %configoutgoingfw){
364 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'}"
365 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]"){
366 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
370 #check if we just close a rule
371 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'}) {
372 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
373 $fwdfwsettings{'nosave2'} = 'on';
378 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
379 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
380 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
381 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
382 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
383 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
384 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
385 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
387 if ($fwdfwsettings{'nobase'} eq 'on'){
388 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
390 if ($fwdfwsettings{'nosave2'} ne 'on'){
391 &saverule
(\
%configoutgoingfw,$configoutgoing);
395 $fwdfwsettings{'config'}=$configfwdfw;
396 $fwdfwsettings{'chain'} = 'FORWARDFW';
397 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
398 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
399 #check if we have an identical rule already
400 foreach my $key (sort keys %configfwdfw){
401 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'}"
402 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]"){
403 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
404 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
406 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
407 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
409 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
410 $fwdfwsettings{'nosave'} = 'on';
415 #check Rulepos on new Rule
416 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
417 $fwdfwsettings{'oldrulenumber'}=$maxkey;
418 foreach my $key (sort keys %configfwdfw){
419 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'}"
420 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]"){
421 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
425 #check if we just close a rule
426 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'} ) {
427 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
428 $fwdfwsettings{'nosave2'} = 'on';
433 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
434 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
435 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
436 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
437 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
438 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
439 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
440 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
442 if ($fwdfwsettings{'nobase'} eq 'on'){
443 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
445 if ($fwdfwsettings{'nosave2'} ne 'on'){
446 &saverule
(\
%configfwdfw,$configfwdfw);
448 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
449 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
450 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
451 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
452 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
453 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
454 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
455 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
456 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
457 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
458 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
459 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
460 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
461 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
462 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
463 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
465 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
466 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
467 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
468 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
473 if($fwdfwsettings{'nosave2'} ne 'on'){
479 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
481 if($fwdfwsettings{'poltype'} eq 'forward'){
482 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
483 foreach my $key (sort keys %configfwdfw){
484 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
485 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
486 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
488 #&General::readhasharray("$configinput", \%configinputfw);
489 #foreach my $key (sort keys %configinputfw){
490 # &checkcounter($configinputfw{$key}[3],$configinputfw{$key}[4],,);
491 # &checkcounter($configinputfw{$key}[5],$configinputfw{$key}[6],,);
492 # &checkcounter($configinputfw{$key}[14],$configinputfw{$key}[15],,);
495 system("rm ${General::swroot}/forward/config");
496 #system("rm ${General::swroot}/forward/input");
497 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
498 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
499 #unless (-e "${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
500 my $MODE1=$fwdfwsettings{'POLICY1'};
502 $fwdfwsettings{'POLICY'}='MODE2';
503 $fwdfwsettings{'POLICY1'}=$MODE1;
504 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
507 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
508 foreach my $key (sort keys %configoutgoingfw){
509 &checkcounter
($configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],,);
510 &checkcounter
($configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],,);
511 &checkcounter
($configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],,);
513 system("rm ${General::swroot}/forward/outgoing");
514 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
515 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
516 my $MODE=$fwdfwsettings{'POLICY'};
518 $fwdfwsettings{'POLICY'}=$MODE;
519 $fwdfwsettings{'POLICY1'}='MODE2';
520 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
524 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
528 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
531 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
532 foreach my $key (sort keys %togglehash){
533 if ($key eq $fwdfwsettings{'key'}){
534 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
537 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
541 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
544 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
545 foreach my $key (sort keys %togglehash){
546 if ($key eq $fwdfwsettings{'key'}){
547 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
550 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
554 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
559 if ($fwdfwsettings{'ACTION'} eq 'editrule')
561 $fwdfwsettings{'updatefwrule'}='on';
564 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
568 if ($fwdfwsettings{'ACTION'} eq 'moveup')
573 if ($fwdfwsettings{'ACTION'} eq 'movedown')
578 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
580 $fwdfwsettings{'copyfwrule'}='on';
581 #$fwdfwsettings{'updatefwrule'}='on';
584 if ($fwdfwsettings{'ACTION'} eq '')
592 if (-f
"${General::swroot}/forward/reread"){
593 print "<table border='0'><form method='post'><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: red; font-weight: bold;'>$Lang::tr{'fwhost reread'}</td></tr></table></form><hr><br>";
595 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
596 print "<form method='post'>";
597 print "<table border='0'>";
598 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
599 print"</tr></table></form><hr>";
605 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
606 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
607 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){ $selected{'POLICY1'}{'MODE1'} = 'selected'; } else { $selected{'POLICY1'}{'MODE1'} = ''; }
608 if ($fwdfwsettings{'POLICY1'} eq 'MODE2'){ $selected{'POLICY1'}{'MODE2'} = 'selected'; } else { $selected{'POLICY1'}{'MODE2'} = ''; }
612 &Header
::openbox
('100%', 'center', $Lang::tr
{'fwdfw pol title'});
614 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
615 <table width='100%' border='0'>
616 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>FORWARD </td></tr>
617 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text'}</td></tr>
618 <tr><td colspan='3'><hr /></td></tr>
619 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
620 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
621 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
622 <input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td><td width='45%' align='right'>
625 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='forward' /></td></tr>";
626 print "</table></form>";
629 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
630 <table width='100%' border='0'>
631 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>OUTGOING </td></tr>
632 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text1'}</td></tr>
633 <tr><td colspan='3'><hr /></td></tr>
634 <tr><td width='15%' align='left'> <select name='POLICY1' style="width: 100px">
635 <option value='MODE1' $selected{'POLICY1'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
636 <option value='MODE2' $selected{'POLICY1'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
637 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td><td width='45%' align='right'>
640 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='outgoing' /></tr>";
641 print "</table></form>";
643 print "<br><br><div align='right'><font size='1' color='grey'>Version: $VERSION</font></div>";
648 $fwdfwsettings{'updatefwrule'}='';
649 $fwdfwsettings{'config'}=$oldchain;
650 $fwdfwsettings{'nobase'}='on';
652 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
653 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
659 #check ip-address if manual
660 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
661 #check if ip with subnet
662 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
663 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
664 $subnet = &General
::iporsubtocidr
($subnet);
665 $fwdfwsettings{'isip'}='on';
668 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
669 $ip=$fwdfwsettings{'src_addr'};
671 $fwdfwsettings{'isip'}='on';
674 if ($fwdfwsettings{'isip'} ne 'on'){
675 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
677 if ($fwdfwsettings{'isip'} eq 'on'){
678 #check and form valid IP
679 $ip=&General
::ip2dec
($ip);
680 $ip=&General
::dec2ip
($ip);
681 #check if net or broadcast
682 my @tmp= split (/\./,$ip);
683 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
685 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
687 $fwdfwsettings{'src_addr'}="$ip/$subnet";
689 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
690 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
693 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
694 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
696 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
697 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
698 return $errormessage;
702 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
704 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
705 $fwdfwsettings{'SRC_PORT'}='';
706 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
707 foreach my $key (keys %icmptypes){
708 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
709 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
712 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
713 $fwdfwsettings{'SRC_PORT'}='';
714 $fwdfwsettings{'ICMP_TYPES'}='';
715 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
716 $fwdfwsettings{'SRC_PORT'}='';
717 $fwdfwsettings{'ICMP_TYPES'}='';
718 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
719 $fwdfwsettings{'SRC_PORT'}='';
720 $fwdfwsettings{'ICMP_TYPES'}='';
721 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
722 $fwdfwsettings{'ICMP_TYPES'}='';
724 $fwdfwsettings{'ICMP_TYPES'}='';
725 $fwdfwsettings{'SRC_PORT'}='';
726 $fwdfwsettings{'PROT'}='';
729 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
730 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
734 if ($_ =~ /^(\d+)\:(\d+)$/) {
736 #change dashes with :
739 push(@values,"1:65535");
742 if ($_ =~ /^(\D)\:(\d+)$/) {
743 push(@values,"1:$2");
746 if ($_ =~ /^(\d+)\:(\D)$/) {
747 push(@values,"$1:65535");
750 $errormessage .= &General
::validportrange
($_, 'destination');
755 if (&General
::validport
($_)){
762 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
763 return $errormessage;
769 &General
::readhasharray
("$configsrv", \
%customservice);
770 #check DNAT settings (has to be single Host and single Port)
771 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
772 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
773 if ($fwdfwsettings{'USESRV'} eq ''){
774 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
776 #check if manual ip is a single Host (if set)
777 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
778 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
779 my @tmp1= split ("/",$tmp[3]);
780 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
782 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
785 #check if Port is a single Port
786 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
787 if(($fwdfwsettings{'TGT_PROT'} ne 'TCP'|| $fwdfwsettings{'TGT_PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
788 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
790 if (($fwdfwsettings{'TGT_PROT'} eq 'TCP'|| $fwdfwsettings{'TGT_PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
791 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
795 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
798 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
799 #check if ip with subnet
800 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
801 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
802 $subnet = &General
::iporsubtocidr
($subnet);
805 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
806 $ip=$fwdfwsettings{'tgt_addr'};
809 #check and form valid IP
810 $ip=&General
::ip2dec
($ip);
811 $ip=&General
::dec2ip
($ip);
813 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
814 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
815 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
817 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
818 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
819 return $errormessage;
822 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
824 if ($fwdfwsettings{'USESRV'} eq 'ON'){
825 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
826 $fwdfwsettings{'TGT_PROT'}='';
827 $fwdfwsettings{'ICMP_TGT'}='';
829 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
830 $fwdfwsettings{'TGT_PROT'}='';
831 $fwdfwsettings{'ICMP_TGT'}='';
832 #check target service
833 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
834 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
837 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
838 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
839 if ($fwdfwsettings{'TGT_PORT'} ne ''){
840 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
844 if ($_ =~ /^(\d+)\:(\d+)$/) {
846 #change dashes with :
849 push(@values,"1:65535");
852 if ($_ =~ /^(\D)\:(\d+)$/) {
853 push(@values,"1:$2");
856 if ($_ =~ /^(\d+)\:(\D)$/) {
857 push(@values,"$1:65535");
860 $errormessage .= &General
::validportrange
($_, 'destination');
865 if (&General
::validport
($_)){
872 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
874 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
875 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
876 $fwdfwsettings{'TGT_PORT'} = '';
877 $fwdfwsettings{'ICMP_TGT'} = '';
878 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
879 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
880 $fwdfwsettings{'TGT_PORT'} = '';
881 $fwdfwsettings{'ICMP_TGT'}='';
882 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
883 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
884 $fwdfwsettings{'TGT_PORT'} = '';
885 $fwdfwsettings{'ICMP_TGT'}='';
886 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
887 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
888 $fwdfwsettings{'TGT_PORT'} = '';
889 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
890 foreach my $key (keys %icmptypes){
892 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
893 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
901 if ($fwdfwsettings{'USESRV'} ne 'ON'){
902 $fwdfwsettings{'grp3'}='';
903 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
904 $fwdfwsettings{'TGT_PROT'}='';
905 $fwdfwsettings{'ICMP_TGT'}='';
908 if($fwdfwsettings{'TIME'} eq 'ON'){
909 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 ''){
910 $errormessage=$Lang::tr
{'fwdfw err time'};
913 return $errormessage;
918 if ($val =~ "," || $val =~ ":" || $val>65536 || $val<0){
925 #check valid port for NAT
926 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
927 #if no port is given in nat area, take target host port
928 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
930 #check if given nat port is already used by another dnatrule
931 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'updatefwrule'} ne 'on'){
932 foreach my $id (sort keys %confignatfw){
933 if ($fwdfwsettings{'dnatport'} eq $confignatfw{$id}[30]){
934 $errormessage=$Lang::tr
{'fwdfw natport used'}."<br>";
939 #check if port given in nat area is a single valid port
940 if($fwdfwsettings{'nat'} eq 'dnat' && !&check_natport
($fwdfwsettings{'dnatport'})){
941 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
943 elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
945 #get servcie Protocol and Port
946 foreach my $key (sort keys %customservice){
947 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
948 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
949 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
951 $custsrvport= $customservice{$key}[1];
954 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
958 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
959 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
961 #check if source and target identical
962 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
963 $errormessage.=$Lang::tr
{'fwdfw err same'};
964 return $errormessage;
966 #get source and targetip address if possible
967 my ($sip,$scidr,$tip,$tcidr);
968 ($sip,$scidr)=&get_ip
("src","grp1");
969 ($tip,$tcidr)=&get_ip
("tgt","grp2");
970 #check same iprange in source and target
971 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
972 my $networkip1=&General
::getnetworkip
($sip,$scidr);
973 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
974 if ($scidr gt $tcidr){
975 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
976 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
978 }elsif($scidr eq $tcidr && $scidr eq '32'){
979 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
980 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
981 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
982 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
983 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
986 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
987 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
991 #check source and destination protocol if manual
992 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
993 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
994 $errormessage.=$Lang::tr
{'fwdfw err prot'};
996 #check source and destination protocol if source manual and dest servicegrp
997 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
998 foreach my $key (sort keys %customservice){
999 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
1000 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
1001 $errormessage.=$Lang::tr
{'fwdfw err prot'};
1011 my ($base1,$val1,$base2,$val2) = @_;
1013 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
1014 &dec_counter
($confignet,\
%customnetwork,$val1);
1015 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
1016 &dec_counter
($confighost,\
%customhost,$val1);
1017 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
1018 &dec_counter
($configgrp,\
%customgrp,$val1);
1019 }elsif($base1 eq 'cust_srv'){
1020 &dec_counter
($configsrv,\
%customservice,$val1);
1021 }elsif($base1 eq 'cust_srvgrp'){
1022 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
1025 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
1026 &inc_counter
($confignet,\
%customnetwork,$val2);
1027 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
1028 &inc_counter
($confighost,\
%customhost,$val2);
1029 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
1030 &inc_counter
($configgrp,\
%customgrp,$val2);
1031 }elsif($base2 eq 'cust_srv'){
1032 &inc_counter
($configsrv,\
%customservice,$val2);
1033 }elsif($base2 eq 'cust_srvgrp'){
1034 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
1040 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
1041 foreach my $key (sort {$a <=> $b} keys %delhash){
1042 if ($key == $fwdfwsettings{'key'}){
1043 #check hosts/net and groups
1044 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
1045 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
1046 #check services and groups
1047 if ($delhash{$key}[11] eq 'ON'){
1048 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
1051 if ($key >= $fwdfwsettings{'key'}) {
1052 my $next = $key + 1;
1053 if (exists $delhash{$next}) {
1054 foreach my $i (0 .. $#{$delhash{$next}}) {
1055 $delhash{$key}[$i] = $delhash{$next}[$i];
1060 # Remove the very last entry.
1061 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
1062 delete $delhash{$last_key};
1064 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
1067 if($fwdfwsettings{'nobase'} ne 'on'){
1074 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
1075 foreach my $key (sort keys %configfwdfw){
1076 if ($key eq $key1 ){
1077 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
1080 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
1086 my %hash=%{(shift)};
1089 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
1090 &General
::readhasharray
($config, \
%hash);
1091 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1092 if($hash{$key}[0] eq $val){
1093 $pos=$#{$hash{$key}};
1094 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
1097 &General
::writehasharray
($config, \
%hash);
1101 if ($errormessage) {
1102 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1103 print "<class name='base'>$errormessage\n";
1104 print " </class>\n";
1105 &Header
::closebox
();
1111 my %hash=%{(shift)};
1114 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1115 if($hash{$key}[0] eq $val){
1116 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1118 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1128 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1129 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1130 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1131 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1132 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1133 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1134 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1135 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1136 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1137 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1138 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1139 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1140 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1141 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1142 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1143 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1144 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1145 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1147 <table width='100%' border='0'>
1148 <tr><td width='50%' valign='top'>
1149 <table width='100%' border='0'>
1150 <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;'>
1152 foreach my $network (sort keys %defaultNetworks)
1154 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1155 next if($defaultNetworks{$network}{'NAME'} eq "IPFire" && $srctgt eq 'tgt');
1156 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1157 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1158 print ">$network</option>";
1160 print"</select></td></tr>";
1162 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1163 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;'>";
1164 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1165 print"</select></td>";
1168 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1169 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;'>";
1170 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1171 print"</select></td>";
1174 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1175 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;'>";
1176 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1177 if($helper ne $customgrp{$key}[0]){
1179 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1180 print ">$customgrp{$key}[0]</option>";
1182 $helper=$customgrp{$key}[0];
1184 print"</select></td>";
1186 #End left table. start right table (vpn)
1187 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1189 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1190 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;'>";
1191 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1192 print"</select></td></tr>";
1195 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1196 if ($ccdhost{$key}[33] ne '' ){
1197 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 '');
1199 print "<option value='$ccdhost{$key}[1]'";
1200 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1201 print ">$ccdhost{$key}[1]</option>";
1204 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1205 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>" ;
1207 if ($show eq '1'){$show='';print"</select></td></tr>";}
1209 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1210 if ($ccdhost{$key}[3] eq 'net'){
1211 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 '');
1213 print "<option value='$ccdhost{$key}[1]'";
1214 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1215 print ">$ccdhost{$key}[1]</option>";
1218 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1219 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>" ;
1221 if ($show eq '1'){$show='';print"</select></td></tr>";}
1223 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1224 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1225 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 '');
1228 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1229 print ">$ipsecconf{$key}[1]</option>";
1232 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1233 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>";
1235 if ($show eq '1'){$show='';print"</select></td></tr>";}
1237 print"</tr></table>";
1238 print"</td></tr></table><br>";
1246 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1247 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1248 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1249 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1250 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1251 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1252 $a=$netsettings{'GREEN_NETADDRESS'};
1253 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1254 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1255 $a=$netsettings{'ORANGE_NETADDRESS'};
1256 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1257 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1258 $a=$netsettings{'BLUE_NETADDRESS'};
1259 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1260 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1261 &General
::readhash
("$configovpn",\
%ovpnsettings);
1262 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1263 $b=&General
::iporsubtocidr
($b);
1265 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1266 &General
::readhasharray
("$confignet", \
%customnetwork);
1267 foreach my $key (keys %customnetwork){
1268 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1269 $a=$customnetwork{$key}[1];
1270 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1273 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1274 &General
::readhasharray
("$confighost", \
%customhost);
1275 foreach my $key (keys %customhost){
1276 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1277 if ($customhost{$key}[1] eq 'ip'){
1278 ($a,$b)=split (/\//,$customhost{$key}[2]);
1279 $b=&General
::iporsubtocidr
($b);
1281 if ($grp eq 'grp2'){
1282 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1294 &General
::setup_default_networks
(\
%defaultNetworks);
1295 foreach my $network (sort keys %defaultNetworks)
1297 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1302 my %hash=%{(shift)};
1304 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1305 $hash{$key}[10]=~ s/\|/,/g;
1306 print": $hash{$key}[10]";
1307 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1308 print": <br>$hash{$key}[9] ";
1313 my %hash=%{(shift)};
1317 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1318 if($hash{$key}[14] eq 'cust_srv'){
1319 &General
::readhasharray
("$configsrv", \
%customservice);
1320 foreach my $i (sort keys %customservice){
1321 if($customservice{$i}[0] eq $hash{$key}[15]){
1322 $service = $customservice{$i}[0];
1325 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1326 $service=$hash{$key}[15];
1327 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1328 $hash{$key}[15]=~ s/\|/,/g;
1329 $service=$hash{$key}[15];
1334 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1335 print":<br>$hash{$key}[13]";
1338 sub get_serviceports
1342 &General
::readhasharray
("$configsrv", \
%customservice);
1343 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1348 if($type eq 'service'){
1349 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1350 if ($customservice{$key}[0] eq $name){
1351 push (@protocols,$customservice{$key}[2]);
1354 }elsif($type eq 'group'){
1355 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1356 if ($customservicegrp{$key}[0] eq $name){
1357 foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1358 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1359 if($customservice{$key1}[2] eq 'TCP'){
1361 }elsif($customservice{$key1}[2] eq 'ICMP'){
1363 }elsif($customservice{$key1}[2] eq 'UDP'){
1371 if($tcp && $udp && $icmp){
1372 push (@protocols,"All");
1376 push (@protocols,"TCP");
1379 push (@protocols,"UDP");
1382 push (@protocols,"ICMP");
1391 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1393 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'){
1394 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1397 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1398 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1402 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1403 foreach my $key (sort keys %$hash){
1404 if ($$hash{$key}[0] eq $val){
1405 $val=$$hash{$key}[2];
1410 foreach my $alias (sort keys %aliases)
1412 if ($val eq $alias){
1413 $tdcolor="style='border: 1px solid $Header::colourred;'";
1418 if ($val eq 'GREEN'){
1419 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1420 }elsif ($val eq 'ORANGE'){
1421 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1422 }elsif ($val eq 'BLUE'){
1423 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1424 }elsif ($val eq 'RED'){
1425 $tdcolor="style='border: 1px solid $Header::colourred;'";
1426 }elsif ($val eq 'IPFire' ){
1427 $tdcolor="style='border: 1px solid $Header::colourred;'";
1428 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1429 my ($sip,$scidr) = split ("/",$val);
1430 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1431 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1433 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1434 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1436 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1437 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1439 }elsif ($val eq 'Default IP'){
1440 $tdcolor="style='border: 1px solid $Header::colourred;'";
1449 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1450 print "<class name='base'>$hint\n";
1451 print " </class>\n";
1452 &Header
::closebox
();
1459 my %hash=%{(shift)};
1463 &General
::readhasharray
($config, \
%hash);
1464 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1465 if($hash{$key}[0] eq $val){
1466 $pos=$#{$hash{$key}};
1467 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1470 &General
::writehasharray
($config, \
%hash);
1475 &General
::setup_default_networks
(\
%defaultNetworks);
1476 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1477 #read all configfiles
1478 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1479 &General
::readhasharray
("$confignet", \
%customnetwork);
1480 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1481 &General
::readhasharray
("$confighost", \
%customhost);
1482 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1483 &General
::readhasharray
("$configgrp", \
%customgrp);
1484 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1485 &General
::get_aliases
(\
%aliases);
1489 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1490 my $config=$fwdfwsettings{'config'};
1492 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1493 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1494 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1495 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1496 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1497 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1498 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1499 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1500 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1501 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1502 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1503 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1504 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1505 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1506 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1507 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1508 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1509 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1510 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1511 #check if update and get values
1512 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1513 &General
::readhasharray
("$config", \
%hash);
1514 foreach my $key (sort keys %hash){
1516 if ($key eq $fwdfwsettings{'key'}){
1517 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1518 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1519 $fwdfwsettings{'chain'} = $hash{$key}[1];
1520 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1521 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1522 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1523 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1524 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1525 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1526 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1527 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1528 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1529 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1530 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1531 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1532 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1533 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1534 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1535 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1536 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1537 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1538 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1539 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1540 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1541 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1542 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1543 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1544 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1545 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1546 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1547 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1548 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1549 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1550 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1551 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1552 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1553 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1554 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1555 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1556 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1557 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1558 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1559 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1560 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1561 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1562 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1563 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1564 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1565 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1566 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1567 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1568 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1569 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1570 $selected{'dnat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1571 $selected{'snat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1574 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1575 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1576 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1577 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1578 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1579 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1580 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1581 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1582 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1583 if ($fwdfwsettings{'config'} eq "${General::swroot}/forward/dmz"){
1584 $fwdfwsettings{'oldruletype'}='DMZ';
1586 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1588 #check if manual ip (source) is orange network
1589 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1590 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1591 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1592 $fwdfwsettings{'oldorange'} ='on';
1596 $fwdfwsettings{'ACTIVE'}='ON';
1597 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1598 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1599 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1600 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1601 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1602 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1603 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1604 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1605 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1606 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1607 #check if manual ip (source) is orange network
1608 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1609 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1610 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1611 $fwdfwsettings{'oldorange'} ='on';
1615 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1616 if ($fwdfwsettings{'TIME'} eq 'ON'){
1617 $fwdfwsettings{'TIME_FROM'} = &timeconvert
($fwdfwsettings{'TIME_FROM'},'');
1618 $fwdfwsettings{'TIME_TO'} = &timeconvert
($fwdfwsettings{'TIME_TO'},'');
1620 print "<form method='post'>";
1621 &Header
::closebox
();
1622 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1623 #------SOURCE-------------------------------------------------------
1625 <table width='100%' border='0'>
1626 <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>
1627 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1630 &gen_dd_block
('src','grp1');
1632 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1633 <table width='100%' border='0'>
1634 <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>
1635 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1637 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1639 if ($_ eq $fwdfwsettings{'PROT'})
1641 print"<option selected>$_</option>";
1643 print"<option>$_</option>";
1646 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1648 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1649 <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;'>
1651 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1652 print"<option>All ICMP-Types</option>";
1653 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1654 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1655 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1657 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1661 </select></td></tr></table><br><hr>
1663 &Header
::closebox
();
1665 #---TARGET------------------------------------------------------
1666 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1668 <table width='100%' border='0'>
1669 <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>
1671 if (! -z
"${General::swroot}/ethernet/aliases"){
1672 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1673 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1675 foreach my $alias (sort keys %aliases)
1677 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1681 print"<td style='width:200px;'><input type='hidden' name ='ipfire' value='Default IP'>";
1685 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1687 &gen_dd_block
('tgt','grp2');
1689 <b>$Lang::tr{'fwhost attention'}:</b><br>
1690 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1691 <table width='100%' border='0'>
1692 <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;' >
1694 &General
::readhasharray
("$configsrv", \
%customservice);
1695 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1697 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1698 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1702 <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;' >
1704 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1706 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1707 if ($helper ne $customservicegrp{$key}[0]){
1709 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1710 print">$customservicegrp{$key}[0]</option>";
1712 $helper=$customservicegrp{$key}[0];
1716 <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'>
1718 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1720 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1722 print"<option selected>$_</option>";
1724 print"<option>$_</option>";
1727 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1729 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1730 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT' style='min-width:230px;'>
1732 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1733 print"<option>All ICMP-Types</option>";
1734 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1735 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1736 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1738 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1747 #---SNAT / DNAT ------------------------------------------------
1748 &Header
::openbox
('100%', 'left', 'NAT');
1750 <table width='100%' border='0'>
1751 <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>
1752 <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>
1754 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
1755 print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
1756 print "<option value='Default IP' $selected{'dnat'}{'Default IP'}>Default IP</option>";
1757 foreach my $alias (sort keys %aliases)
1759 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
1762 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>";
1763 print"<tr><td colspan='8'><br></td></tr>";
1765 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>";
1766 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
1767 print "<option value='Default IP' $selected{'snat'}{'Default IP'}>Default IP</option>";
1768 foreach my $alias (sort keys %aliases)
1770 print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
1772 foreach my $network (sort keys %defaultNetworks)
1774 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1775 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1776 next if($defaultNetworks{$network}{'NAME'} eq "ALL");
1777 next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
1778 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1779 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
1780 print ">$network</option>";
1784 &Header
::closebox
();
1785 #---Activate/logging/remark-------------------------------------
1786 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1788 <table width='100%' border='0'>
1789 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1791 foreach ("ACCEPT","DROP","REJECT")
1793 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1794 print"<option value='$_'";
1795 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1796 print">$Lang::tr{'fwdfw '.$_}</option>";
1798 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1799 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1801 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1803 print"<option value='$_' selected>$Lang::tr{'fwdfw '.$_}</option>";
1805 print"<option value='$_'>$Lang::tr{'fwdfw '.$_}</option>";
1809 print"</select></td></tr>";
1810 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>";
1811 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1812 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1813 for (my $count =1; $count <= $sum; $count++){
1814 print"<option value='$count' ";
1815 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1816 print">$count</option>";
1818 print"</select></td></tr>";
1820 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1824 </table><table width='100%'>
1825 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1826 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1829 &Header
::closebox
();
1830 #---ADD TIMEFRAME-----------------------------------------------
1831 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1833 <table width='70%' border='0'>
1834 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1835 <tr><td colspan='7'> </td></tr>
1837 <td align='left'>$Lang::tr{'time'}:</td>
1838 <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>
1839 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1840 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1843 <td align='right'></td>
1844 <td width='30%' align='left'>
1845 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1846 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1847 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1848 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1849 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1850 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1851 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1853 <td><select name='TIME_FROM'>
1855 for (my $i=0;$i<=23;$i++) {
1856 $i = sprintf("%02s",$i);
1857 for (my $j=0;$j<=45;$j+=15) {
1858 $j = sprintf("%02s",$j);
1859 my $time = $i.":".$j;
1860 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1865 <td><select name='TIME_TO'>
1867 for (my $i=0;$i<=23;$i++) {
1868 $i = sprintf("%02s",$i);
1869 for (my $j=0;$j<=45;$j+=15) {
1870 $j = sprintf("%02s",$j);
1871 my $time = $i.":".$j;
1872 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1879 #---ACTION------------------------------------------------------
1880 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1882 <table border='0' width='100%'>
1883 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1884 <input type='hidden' name='config' value='$config' >
1885 <input type='hidden' name='ACTION' value='saverule' >
1886 </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>
1891 <table border='0' width='100%'>
1892 <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'}'>
1893 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1894 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1895 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1896 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1897 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1898 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1899 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1900 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1901 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1902 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1903 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1904 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
1905 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
1906 <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>
1910 &Header
::closebox
();
1916 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1917 foreach my $key (sort keys %uphash){
1918 if ($key eq $fwdfwsettings{'key'}) {
1920 if (exists $uphash{$last}){
1922 foreach my $y (0 .. $#{$uphash{$last}}) {
1923 $tmp{0}[$y] = $uphash{$last}[$y];
1925 #copy active rule to last
1926 foreach my $i (0 .. $#{$uphash{$last}}) {
1927 $uphash{$last}[$i] = $uphash{$key}[$i];
1929 #copy saved rule to actual position
1930 foreach my $x (0 .. $#{$tmp{0}}) {
1931 $uphash{$key}[$x] = $tmp{0}[$x];
1936 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1943 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1944 foreach my $key (sort keys %downhash){
1945 if ($key eq $fwdfwsettings{'key'}) {
1946 my $next = $key + 1;
1947 if (exists $downhash{$next}){
1949 foreach my $y (0 .. $#{$downhash{$next}}) {
1950 $tmp{0}[$y] = $downhash{$next}[$y];
1952 #copy active rule to next
1953 foreach my $i (0 .. $#{$downhash{$next}}) {
1954 $downhash{$next}[$i] = $downhash{$key}[$i];
1956 #copy saved rule to actual position
1957 foreach my $x (0 .. $#{$tmp{0}}) {
1958 $downhash{$key}[$x] = $tmp{0}[$x];
1963 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1968 if (!-f
"${General::swroot}/forward/reread"){
1969 system("touch ${General::swroot}/forward/reread");
1970 system("touch ${General::swroot}/fwhosts/reread");
1975 system("/usr/local/bin/forwardfwctrl");
1976 if ( -f
"${General::swroot}/forward/reread"){
1977 system("rm ${General::swroot}/forward/reread");
1978 system("rm ${General::swroot}/fwhosts/reread");
1985 &General
::readhasharray
("$config", $hash);
1986 if (!$errormessage){
1987 #check if we change a NAT to a FORWARD/DMZ
1988 if(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'FORWARDFW'){
1989 &changerule
($confignat);
1992 #check if we change a NAT to a INPUT (external access)
1993 elsif(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'INPUTFW'){
1994 &changerule
($confignat);
1997 #check if we change a NAT to a OUTGOING
1998 elsif(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
1999 &changerule
($confignat);
2002 ################################################################
2003 #check if we change a DMZ to a NAT
2004 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2005 &changerule
($configdmz);
2008 #check if we change a DMZ to an OUTGOING
2009 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2010 &changerule
($configdmz);
2013 #check if we change a DMZ to an INPUT
2014 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2015 &changerule
($configdmz);
2018 #check if we change a DMZ to a FORWARD/DMZ
2019 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2020 &changerule
($configdmz);
2023 ################################################################
2024 #check if we change an INPUT rule to a NAT
2025 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2026 &changerule
($configinput);
2029 #check if we change an INPUT rule to a OUTGOING
2030 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2031 &changerule
($configinput);
2034 #check if we change an INPUT rule to a FORWARD/DMZ
2035 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2036 &changerule
($configinput);
2039 ################################################################
2040 #check if we change an OUTGOING rule to an INPUT
2041 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2042 &changerule
($configoutgoing);
2045 #check if we change an OUTGOING rule to a FORWARD/DMZ
2046 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2047 &changerule
($configoutgoing);
2050 #check if we change an OUTGOING rule to a NAT
2051 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2052 &changerule
($configoutgoing);
2055 ################################################################
2056 #check if we change a FORWARD rule to an INPUT
2057 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2058 &changerule
($configfwdfw);
2061 #check if we change a FORWARD rule to an DMZ
2062 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on'){
2063 &changerule
($configfwdfw);
2066 #check if we change a FORWARD rule to an OUTGOING
2067 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2068 &changerule
($configfwdfw);
2071 #check if we change a FORWARD rule to an NAT
2072 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2073 &changerule
($configfwdfw);
2076 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2077 my $key = &General
::findhasharraykey
($hash);
2078 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2079 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2080 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2081 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2082 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2083 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2084 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2085 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2086 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2087 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2088 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2089 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2090 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2091 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2092 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2093 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2094 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2095 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2096 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2097 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2098 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2099 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2100 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2101 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2102 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2103 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2104 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2105 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2106 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
2107 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2108 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2109 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2110 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2112 &General
::writehasharray
("$config", $hash);
2114 foreach my $key (sort {$a <=> $b} keys %$hash){
2115 if($key eq $fwdfwsettings{'key'}){
2116 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2117 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2118 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2119 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2120 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2121 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2122 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2123 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2124 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2125 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2126 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2127 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2128 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2129 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2130 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2131 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2132 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2133 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2134 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2135 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2136 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2137 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2138 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2139 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2140 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2141 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2142 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2143 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2144 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
2145 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2146 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2147 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2148 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2154 &General
::writehasharray
("$config", $hash);
2155 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2157 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2158 for (my $z=0;$z<$val;$z++){
2159 foreach my $key (sort {$a <=> $b} keys %$hash){
2160 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2162 if (exists $$hash{$last}){
2164 foreach my $y (0 .. $#{$$hash{$last}}) {
2165 $tmp{0}[$y] = $$hash{$last}[$y];
2167 #copy active rule to last
2168 foreach my $i (0 .. $#{$$hash{$last}}) {
2169 $$hash{$last}[$i] = $$hash{$key}[$i];
2171 #copy saved rule to actual position
2172 foreach my $x (0 .. $#{$tmp{0}}) {
2173 $$hash{$key}[$x] = $tmp{0}[$x];
2178 $fwdfwsettings{'oldrulenumber'}--;
2180 &General
::writehasharray
("$config", $hash);
2182 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2184 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2185 for (my $z=0;$z<$val;$z++){
2186 foreach my $key (sort {$a <=> $b} keys %$hash){
2187 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2188 my $next = $key + 1;
2189 if (exists $$hash{$next}){
2191 foreach my $y (0 .. $#{$$hash{$next}}) {
2192 $tmp{0}[$y] = $$hash{$next}[$y];
2194 #copy active rule to next
2195 foreach my $i (0 .. $#{$$hash{$next}}) {
2196 $$hash{$next}[$i] = $$hash{$key}[$i];
2198 #copy saved rule to actual position
2199 foreach my $x (0 .. $#{$tmp{0}}) {
2200 $$hash{$key}[$x] = $tmp{0}[$x];
2205 $fwdfwsettings{'oldrulenumber'}++;
2207 &General
::writehasharray
("$config", $hash);
2214 # Checks a hostname against RFC1035
2217 # Each part should be at least two characters in length
2218 # but no more than 63 characters
2219 if (length ($remark) < 1 || length ($remark) > 255) {
2221 # Only valid characters are a-z, A-Z, 0-9 and -
2222 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2224 # First character can only be a letter or a digit
2225 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2227 # Last character can only be a letter or a digit
2228 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2234 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2235 &viewtablenew
(\
%configdmzfw,$configdmz,$Lang::tr
{'fwdfw rules'},"DMZ" );
2236 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
2237 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
2238 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
2239 &viewtablenew
(\
%confignatfw,$confignat,"","NAT" );
2248 &General
::get_aliases
(\
%aliases);
2249 &General
::readhasharray
("$confighost", \
%customhost);
2250 &General
::readhasharray
("$config", $hash);
2252 &Header
::openbox
('100%', 'left',$title);
2260 print"<b>$title1</b><br>";
2261 print"<table width='100%' cellspacing='0' cellpadding='0'>";
2262 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>";
2263 foreach my $key (sort {$a <=> $b} keys %$hash){
2266 #check if vpn hosts/nets have been deleted
2267 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2268 push (@tmpsrc,$$hash{$key}[4]);
2270 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2271 push (@tmpsrc,$$hash{$key}[6]);
2273 foreach my $host (@tmpsrc){
2274 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2275 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2277 &disable_rule
($key);
2280 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2281 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2283 &disable_rule
($key);
2286 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2287 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2289 &disable_rule
($key);
2292 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2293 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2295 &disable_rule
($key);
2300 $$hash{'ACTIVE'}=$$hash{$key}[2];
2302 if($coloryellow eq 'on'){
2303 print"<tr bgcolor='$color{'color14'}' >";
2305 }elsif($coloryellow eq ''){
2307 $color="$color{'color22'}";
2310 $color="$color{'color20'}";
2313 print"<tr bgcolor='$color' >";
2315 <td align='right' width='15'><b>$key</b></td>
2317 if ($$hash{$key}[0] eq 'ACCEPT'){
2320 $rulecolor=$color{'color17'};
2321 }elsif($$hash{$key}[0] eq 'DROP'){
2324 $rulecolor=$color{'color25'};
2325 }elsif($$hash{$key}[0] eq 'REJECT'){
2328 $rulecolor=$color{'color16'};
2330 if($$hash{$key}[28] eq 'ON'){
2331 print"<td bgcolor='$color' align='center' width='20'></td>";
2334 print"<td bgcolor='$rulecolor' align='center' width='20'><span title='$tooltip'><b>$ruletype</b></span></td>";
2336 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2337 print"<td align='center' width='160' $tdcolor>";
2338 if ($$hash{$key}[3] eq 'std_net_src'){
2339 print &get_name
($$hash{$key}[4]);
2341 print $$hash{$key}[4];
2344 &getsrcport
(\
%$hash,$key);
2345 #Is this a SNAT rule?
2346 if ($$hash{$key}[31] eq 'snat'){
2347 print"<br>SNAT -> $$hash{$key}[29]";
2348 if ($$hash{$key}[30] ne ''){
2349 print": $$hash{$key}[30]";
2352 if ($$hash{$key}[17] eq 'ON'){
2353 $log="/images/on.gif";
2355 $log="/images/off.gif";
2359 <form method='post'>
2360 <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 ;'/>
2361 <input type='hidden' name='key' value='$key' />
2362 <input type='hidden' name='config' value='$config' />
2363 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2366 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2368 <td align='center' width='160' $tdcolor>
2370 #Is this a DNAT rule?
2371 if ($$hash{$key}[31] eq 'dnat'){
2372 print "IPFire ($$hash{$key}[29])";
2373 if($$hash{$key}[30] ne ''){
2374 print": $$hash{$key}[30]";
2378 if ($$hash{$key}[5] eq 'std_net_tgt'){
2379 print &get_name
($$hash{$key}[6]);
2381 print $$hash{$key}[6];
2384 &gettgtport
(\
%$hash,$key);
2388 if ($$hash{$key}[12]){ #target prot if manual
2389 push (@protocols,$$hash{$key}[12]);
2390 }elsif($$hash{$key}[8]){ #source prot if manual
2391 push (@protocols,$$hash{$key}[8]);
2392 }elsif($$hash{$key}[14] eq 'cust_srv'){
2393 &get_serviceports
("service",$$hash{$key}[15]);
2394 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2395 &get_serviceports
("group",$$hash{$key}[15]);
2397 push (@protocols,$Lang::tr
{'all'});
2399 my $protz=join(",",@protocols);
2400 print"<td align='center'>$protz</td>";
2402 if ($$hash{$key}[18] eq 'ON'){
2404 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2405 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2406 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2407 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2408 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2409 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2410 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2411 my $weekdays=join(",",@days);
2413 print"<td align='center' width='100'>$weekdays   $$hash{$key}[26] - $$hash{$key}[27] </td>";
2416 print"<td align='center'>24/7</td>";
2418 if($$hash{$key}[2] eq 'ON'){
2419 $gif="/images/on.gif"
2422 $gif="/images/off.gif"
2425 <form method='post'>
2426 <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;' />
2427 <input type='hidden' name='key' value='$key' />
2428 <input type='hidden' name='config' value='$config' />
2429 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2431 <form method='post'>
2432 <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;' />
2433 <input type='hidden' name='key' value='$key' />
2434 <input type='hidden' name='config' value='$config' />
2435 <input type='hidden' name='ACTION' value='editrule' />
2437 <form method='post'>
2438 <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;' />
2439 <input type='hidden' name='key' value='$key' />
2440 <input type='hidden' name='config' value='$config' />
2441 <input type='hidden' name='ACTION' value='copyrule' />
2443 <form method='post'>
2444 <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;' />
2445 <input type='hidden' name='key' value='$key' />
2446 <input type='hidden' name='config' value='$config' />
2447 <input type='hidden' name='ACTION' value='deleterule' />
2450 if (exists $$hash{$key-1}){
2452 <form method='post'>
2453 <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;' />
2454 <input type='hidden' name='key' value='$key' />
2455 <input type='hidden' name='config' value='$config' />
2456 <input type='hidden' name='ACTION' value='moveup' />
2460 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2462 if (exists $$hash{$key+1}){
2464 <form method='post'>
2465 <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;' />
2466 <input type='hidden' name='key' value='$key' />
2467 <input type='hidden' name='config' value='$config' />
2468 <input type='hidden' name='ACTION' value='movedown' />
2469 </td></form></td></tr>
2472 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2475 if ($optionsfw{'SHOWREMARK'} eq 'on'){
2476 print"<tr bgcolor='$color'>";
2477 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='11'>  $$hash{$key}[16]</td></tr>";
2479 print"<tr bgcolor='$color'><td height='1'></td><td bgcolor='$rulecolor'></td><td colspan='11'></td></tr>";
2482 &Header
::closebox
();
2486 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2487 print "<b>$title1</b><br>";
2488 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>";
2494 &Header
::closebigbox
();
2495 &Header
::closepage
();