]>
git.ipfire.org Git - 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+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
736 #change dashes with :
739 push(@values,"1:65535");
742 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
743 push(@values,"1:$2");
746 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\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 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'}) {
841 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
843 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
847 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
849 #change dashes with :
852 push(@values,"1:65535");
855 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
856 push(@values,"1:$2");
859 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
860 push(@values,"$1:65535");
863 $errormessage .= &General
::validportrange
($_, 'destination');
868 if (&General
::validport
($_)){
875 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
877 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
878 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
879 $fwdfwsettings{'TGT_PORT'} = '';
880 $fwdfwsettings{'ICMP_TGT'} = '';
881 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
882 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
883 $fwdfwsettings{'TGT_PORT'} = '';
884 $fwdfwsettings{'ICMP_TGT'}='';
885 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
886 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
887 $fwdfwsettings{'TGT_PORT'} = '';
888 $fwdfwsettings{'ICMP_TGT'}='';
889 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
890 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
891 $fwdfwsettings{'TGT_PORT'} = '';
892 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
893 foreach my $key (keys %icmptypes){
895 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
896 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
904 if ($fwdfwsettings{'USESRV'} ne 'ON'){
905 $fwdfwsettings{'grp3'}='';
906 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
907 $fwdfwsettings{'TGT_PROT'}='';
908 $fwdfwsettings{'ICMP_TGT'}='';
911 if($fwdfwsettings{'TIME'} eq 'ON'){
912 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 ''){
913 $errormessage=$Lang::tr
{'fwdfw err time'};
916 return $errormessage;
921 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
922 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
923 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
924 if ($fwdfwsettings{'dnatport'} eq "*") {
925 $fwdfwsettings{'dnatport'}="1:65535";
927 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
928 $fwdfwsettings{'dnatport'} = "1:$2";
930 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
931 $fwdfwsettings{'dnatport'} ="$1:65535";
936 if ($val =~ "," || $val>65536 || $val<0){
943 #check valid port for NAT
944 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
945 #if no port is given in nat area, take target host port
946 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
948 #check if given nat port is already used by another dnatrule
949 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'updatefwrule'} ne 'on'){
950 foreach my $id (sort keys %confignatfw){
951 if ($fwdfwsettings{'dnatport'} eq $confignatfw{$id}[30]){
952 $errormessage=$Lang::tr
{'fwdfw natport used'}."<br>";
957 #check if port given in nat area is a single valid port
958 if($fwdfwsettings{'nat'} eq 'dnat' && !&check_natport
($fwdfwsettings{'dnatport'})){
959 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
961 elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
963 #get servcie Protocol and Port
964 foreach my $key (sort keys %customservice){
965 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
966 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
967 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
969 $custsrvport= $customservice{$key}[1];
972 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
976 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
977 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
979 #check if source and target identical
980 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
981 $errormessage.=$Lang::tr
{'fwdfw err same'};
982 return $errormessage;
984 #get source and targetip address if possible
985 my ($sip,$scidr,$tip,$tcidr);
986 ($sip,$scidr)=&get_ip
("src","grp1");
987 ($tip,$tcidr)=&get_ip
("tgt","grp2");
988 #check same iprange in source and target
989 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
990 my $networkip1=&General
::getnetworkip
($sip,$scidr);
991 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
992 if ($scidr gt $tcidr){
993 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
994 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
996 }elsif($scidr eq $tcidr && $scidr eq '32'){
997 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
998 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
999 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
1000 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
1001 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
1004 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
1005 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
1009 #check source and destination protocol if manual
1010 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
1011 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
1012 $errormessage.=$Lang::tr
{'fwdfw err prot'};
1014 #check source and destination protocol if source manual and dest servicegrp
1015 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
1016 foreach my $key (sort keys %customservice){
1017 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
1018 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
1019 $errormessage.=$Lang::tr
{'fwdfw err prot'};
1029 my ($base1,$val1,$base2,$val2) = @_;
1031 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
1032 &dec_counter
($confignet,\
%customnetwork,$val1);
1033 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
1034 &dec_counter
($confighost,\
%customhost,$val1);
1035 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
1036 &dec_counter
($configgrp,\
%customgrp,$val1);
1037 }elsif($base1 eq 'cust_srv'){
1038 &dec_counter
($configsrv,\
%customservice,$val1);
1039 }elsif($base1 eq 'cust_srvgrp'){
1040 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
1043 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
1044 &inc_counter
($confignet,\
%customnetwork,$val2);
1045 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
1046 &inc_counter
($confighost,\
%customhost,$val2);
1047 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
1048 &inc_counter
($configgrp,\
%customgrp,$val2);
1049 }elsif($base2 eq 'cust_srv'){
1050 &inc_counter
($configsrv,\
%customservice,$val2);
1051 }elsif($base2 eq 'cust_srvgrp'){
1052 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
1058 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
1059 foreach my $key (sort {$a <=> $b} keys %delhash){
1060 if ($key == $fwdfwsettings{'key'}){
1061 #check hosts/net and groups
1062 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
1063 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
1064 #check services and groups
1065 if ($delhash{$key}[11] eq 'ON'){
1066 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
1069 if ($key >= $fwdfwsettings{'key'}) {
1070 my $next = $key + 1;
1071 if (exists $delhash{$next}) {
1072 foreach my $i (0 .. $#{$delhash{$next}}) {
1073 $delhash{$key}[$i] = $delhash{$next}[$i];
1078 # Remove the very last entry.
1079 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
1080 delete $delhash{$last_key};
1082 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
1085 if($fwdfwsettings{'nobase'} ne 'on'){
1092 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
1093 foreach my $key (sort keys %configfwdfw){
1094 if ($key eq $key1 ){
1095 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
1098 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
1104 my %hash=%{(shift)};
1107 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
1108 &General
::readhasharray
($config, \
%hash);
1109 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1110 if($hash{$key}[0] eq $val){
1111 $pos=$#{$hash{$key}};
1112 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
1115 &General
::writehasharray
($config, \
%hash);
1119 if ($errormessage) {
1120 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1121 print "<class name='base'>$errormessage\n";
1122 print " </class>\n";
1123 &Header
::closebox
();
1129 my %hash=%{(shift)};
1132 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1133 if($hash{$key}[0] eq $val){
1134 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1136 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1146 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1147 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1148 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1149 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1150 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1151 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1152 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1153 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1154 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1155 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1156 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1157 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1158 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1159 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1160 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1161 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1162 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1163 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1165 <table width='100%' border='0'>
1166 <tr><td width='50%' valign='top'>
1167 <table width='100%' border='0'>
1168 <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;'>
1170 foreach my $network (sort keys %defaultNetworks)
1172 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1173 next if($defaultNetworks{$network}{'NAME'} eq "IPFire" && $srctgt eq 'tgt');
1174 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1175 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1176 print ">$network</option>";
1178 print"</select></td></tr>";
1180 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1181 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;'>";
1182 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1183 print"</select></td>";
1186 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1187 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;'>";
1188 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1189 print"</select></td>";
1192 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1193 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;'>";
1194 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1195 if($helper ne $customgrp{$key}[0]){
1197 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1198 print ">$customgrp{$key}[0]</option>";
1200 $helper=$customgrp{$key}[0];
1202 print"</select></td>";
1204 #End left table. start right table (vpn)
1205 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1207 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1208 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;'>";
1209 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1210 print"</select></td></tr>";
1213 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1214 if ($ccdhost{$key}[33] ne '' ){
1215 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 '');
1217 print "<option value='$ccdhost{$key}[1]'";
1218 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1219 print ">$ccdhost{$key}[1]</option>";
1222 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1223 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>" ;
1225 if ($show eq '1'){$show='';print"</select></td></tr>";}
1227 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1228 if ($ccdhost{$key}[3] eq 'net'){
1229 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 '');
1231 print "<option value='$ccdhost{$key}[1]'";
1232 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1233 print ">$ccdhost{$key}[1]</option>";
1236 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1237 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>" ;
1239 if ($show eq '1'){$show='';print"</select></td></tr>";}
1241 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1242 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1243 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 '');
1246 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1247 print ">$ipsecconf{$key}[1]</option>";
1250 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1251 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>";
1253 if ($show eq '1'){$show='';print"</select></td></tr>";}
1255 print"</tr></table>";
1256 print"</td></tr></table><br>";
1264 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1265 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1266 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1267 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1268 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1269 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1270 $a=$netsettings{'GREEN_NETADDRESS'};
1271 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1272 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1273 $a=$netsettings{'ORANGE_NETADDRESS'};
1274 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1275 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1276 $a=$netsettings{'BLUE_NETADDRESS'};
1277 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1278 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1279 &General
::readhash
("$configovpn",\
%ovpnsettings);
1280 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1281 $b=&General
::iporsubtocidr
($b);
1283 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1284 &General
::readhasharray
("$confignet", \
%customnetwork);
1285 foreach my $key (keys %customnetwork){
1286 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1287 $a=$customnetwork{$key}[1];
1288 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1291 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1292 &General
::readhasharray
("$confighost", \
%customhost);
1293 foreach my $key (keys %customhost){
1294 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1295 if ($customhost{$key}[1] eq 'ip'){
1296 ($a,$b)=split (/\//,$customhost{$key}[2]);
1297 $b=&General
::iporsubtocidr
($b);
1299 if ($grp eq 'grp2'){
1300 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1312 &General
::setup_default_networks
(\
%defaultNetworks);
1313 foreach my $network (sort keys %defaultNetworks)
1315 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1320 my %hash=%{(shift)};
1322 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1323 $hash{$key}[10]=~ s/\|/,/g;
1324 print": $hash{$key}[10]";
1325 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1326 print": <br>$hash{$key}[9] ";
1331 my %hash=%{(shift)};
1335 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1336 if($hash{$key}[14] eq 'cust_srv'){
1337 &General
::readhasharray
("$configsrv", \
%customservice);
1338 foreach my $i (sort keys %customservice){
1339 if($customservice{$i}[0] eq $hash{$key}[15]){
1340 $service = $customservice{$i}[0];
1343 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1344 $service=$hash{$key}[15];
1345 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1346 $hash{$key}[15]=~ s/\|/,/g;
1347 $service=$hash{$key}[15];
1352 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1353 print":<br>$hash{$key}[13]";
1356 sub get_serviceports
1360 &General
::readhasharray
("$configsrv", \
%customservice);
1361 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1366 if($type eq 'service'){
1367 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1368 if ($customservice{$key}[0] eq $name){
1369 push (@protocols,$customservice{$key}[2]);
1372 }elsif($type eq 'group'){
1373 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1374 if ($customservicegrp{$key}[0] eq $name){
1375 foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1376 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1377 if($customservice{$key1}[2] eq 'TCP'){
1379 }elsif($customservice{$key1}[2] eq 'ICMP'){
1381 }elsif($customservice{$key1}[2] eq 'UDP'){
1389 if($tcp && $udp && $icmp){
1390 push (@protocols,"All");
1394 push (@protocols,"TCP");
1397 push (@protocols,"UDP");
1400 push (@protocols,"ICMP");
1409 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1411 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'){
1412 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1415 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1416 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1420 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1421 foreach my $key (sort keys %$hash){
1422 if ($$hash{$key}[0] eq $val){
1423 $val=$$hash{$key}[2];
1428 foreach my $alias (sort keys %aliases)
1430 if ($val eq $alias){
1431 $tdcolor="style='border: 1px solid $Header::colourred;'";
1436 if ($val eq 'GREEN'){
1437 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1438 }elsif ($val eq 'ORANGE'){
1439 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1440 }elsif ($val eq 'BLUE'){
1441 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1442 }elsif ($val eq 'RED'){
1443 $tdcolor="style='border: 1px solid $Header::colourred;'";
1444 }elsif ($val eq 'IPFire' ){
1445 $tdcolor="style='border: 1px solid $Header::colourred;'";
1446 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1447 my ($sip,$scidr) = split ("/",$val);
1448 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1449 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1451 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1452 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1454 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1455 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1457 }elsif ($val eq 'Default IP'){
1458 $tdcolor="style='border: 1px solid $Header::colourred;'";
1467 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1468 print "<class name='base'>$hint\n";
1469 print " </class>\n";
1470 &Header
::closebox
();
1477 my %hash=%{(shift)};
1481 &General
::readhasharray
($config, \
%hash);
1482 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1483 if($hash{$key}[0] eq $val){
1484 $pos=$#{$hash{$key}};
1485 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1488 &General
::writehasharray
($config, \
%hash);
1493 &General
::setup_default_networks
(\
%defaultNetworks);
1494 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1495 #read all configfiles
1496 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1497 &General
::readhasharray
("$confignet", \
%customnetwork);
1498 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1499 &General
::readhasharray
("$confighost", \
%customhost);
1500 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1501 &General
::readhasharray
("$configgrp", \
%customgrp);
1502 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1503 &General
::get_aliases
(\
%aliases);
1507 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1508 my $config=$fwdfwsettings{'config'};
1510 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1511 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1512 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1513 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1514 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1515 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1516 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1517 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1518 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1519 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1520 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1521 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1522 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1523 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1524 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1525 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1526 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1527 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1528 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1529 #check if update and get values
1530 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1531 &General
::readhasharray
("$config", \
%hash);
1532 foreach my $key (sort keys %hash){
1534 if ($key eq $fwdfwsettings{'key'}){
1535 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1536 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1537 $fwdfwsettings{'chain'} = $hash{$key}[1];
1538 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1539 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1540 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1541 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1542 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1543 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1544 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1545 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1546 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1547 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1548 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1549 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1550 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1551 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1552 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1553 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1554 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1555 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1556 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1557 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1558 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1559 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1560 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1561 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1562 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1563 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1564 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1565 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1566 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1567 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1568 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1569 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1570 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1571 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1572 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1573 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1574 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1575 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1576 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1577 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1578 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1579 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1580 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1581 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1582 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1583 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1584 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1585 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1586 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1587 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1588 $selected{'dnat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1589 $selected{'snat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1592 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1593 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1594 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1595 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1596 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1597 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1598 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1599 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1600 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1601 if ($fwdfwsettings{'config'} eq "${General::swroot}/forward/dmz"){
1602 $fwdfwsettings{'oldruletype'}='DMZ';
1604 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1606 #check if manual ip (source) is orange network
1607 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1608 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1609 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1610 $fwdfwsettings{'oldorange'} ='on';
1614 $fwdfwsettings{'ACTIVE'}='ON';
1615 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1616 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1617 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1618 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1619 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1620 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1621 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1622 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1623 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1624 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1625 #check if manual ip (source) is orange network
1626 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1627 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1628 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1629 $fwdfwsettings{'oldorange'} ='on';
1633 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1634 if ($fwdfwsettings{'TIME'} eq 'ON'){
1635 $fwdfwsettings{'TIME_FROM'} = &timeconvert
($fwdfwsettings{'TIME_FROM'},'');
1636 $fwdfwsettings{'TIME_TO'} = &timeconvert
($fwdfwsettings{'TIME_TO'},'');
1638 print "<form method='post'>";
1639 &Header
::closebox
();
1640 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1641 #------SOURCE-------------------------------------------------------
1643 <table width='100%' border='0'>
1644 <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>
1645 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1648 &gen_dd_block
('src','grp1');
1650 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1651 <table width='100%' border='0'>
1652 <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>
1653 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1655 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1657 if ($_ eq $fwdfwsettings{'PROT'})
1659 print"<option selected>$_</option>";
1661 print"<option>$_</option>";
1664 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1666 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1667 <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;'>
1669 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1670 print"<option>All ICMP-Types</option>";
1671 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1672 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1673 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1675 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1679 </select></td></tr></table><br><hr>
1681 &Header
::closebox
();
1683 #---TARGET------------------------------------------------------
1684 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1686 <table width='100%' border='0'>
1687 <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>
1689 if (! -z
"${General::swroot}/ethernet/aliases"){
1690 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1691 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1693 foreach my $alias (sort keys %aliases)
1695 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1699 print"<td style='width:200px;'><input type='hidden' name ='ipfire' value='Default IP'>";
1703 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1705 &gen_dd_block
('tgt','grp2');
1707 <b>$Lang::tr{'fwhost attention'}:</b><br>
1708 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1709 <table width='100%' border='0'>
1710 <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;' >
1712 &General
::readhasharray
("$configsrv", \
%customservice);
1713 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1715 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1716 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1720 <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;' >
1722 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1724 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1725 if ($helper ne $customservicegrp{$key}[0]){
1727 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1728 print">$customservicegrp{$key}[0]</option>";
1730 $helper=$customservicegrp{$key}[0];
1734 <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'>
1736 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1738 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1740 print"<option selected>$_</option>";
1742 print"<option>$_</option>";
1745 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1747 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1748 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT' style='min-width:230px;'>
1750 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1751 print"<option>All ICMP-Types</option>";
1752 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1753 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1754 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1756 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1765 #---SNAT / DNAT ------------------------------------------------
1766 &Header
::openbox
('100%', 'left', 'NAT');
1768 <table width='100%' border='0'>
1769 <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>
1770 <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>
1772 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
1773 print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
1774 print "<option value='Default IP' $selected{'dnat'}{'Default IP'}>Default IP</option>";
1775 foreach my $alias (sort keys %aliases)
1777 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
1780 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>";
1781 print"<tr><td colspan='8'><br></td></tr>";
1783 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>";
1784 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
1785 print "<option value='Default IP' $selected{'snat'}{'Default IP'}>Default IP</option>";
1786 foreach my $alias (sort keys %aliases)
1788 print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
1790 foreach my $network (sort keys %defaultNetworks)
1792 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1793 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1794 next if($defaultNetworks{$network}{'NAME'} eq "ALL");
1795 next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
1796 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1797 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
1798 print ">$network</option>";
1802 &Header
::closebox
();
1803 #---Activate/logging/remark-------------------------------------
1804 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1806 <table width='100%' border='0'>
1807 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1809 foreach ("ACCEPT","DROP","REJECT")
1811 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1812 print"<option value='$_'";
1813 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1814 print">$Lang::tr{'fwdfw '.$_}</option>";
1816 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1817 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1819 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1821 print"<option value='$_' selected>$Lang::tr{'fwdfw '.$_}</option>";
1823 print"<option value='$_'>$Lang::tr{'fwdfw '.$_}</option>";
1827 print"</select></td></tr>";
1828 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>";
1829 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1830 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1831 for (my $count =1; $count <= $sum; $count++){
1832 print"<option value='$count' ";
1833 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1834 print">$count</option>";
1836 print"</select></td></tr>";
1838 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1842 </table><table width='100%'>
1843 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1844 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1847 &Header
::closebox
();
1848 #---ADD TIMEFRAME-----------------------------------------------
1849 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1851 <table width='70%' border='0'>
1852 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1853 <tr><td colspan='7'> </td></tr>
1855 <td align='left'>$Lang::tr{'time'}:</td>
1856 <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>
1857 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1858 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1861 <td align='right'></td>
1862 <td width='30%' align='left'>
1863 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1864 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1865 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1866 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1867 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1868 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1869 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1871 <td><select name='TIME_FROM'>
1873 for (my $i=0;$i<=23;$i++) {
1874 $i = sprintf("%02s",$i);
1875 for (my $j=0;$j<=45;$j+=15) {
1876 $j = sprintf("%02s",$j);
1877 my $time = $i.":".$j;
1878 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1883 <td><select name='TIME_TO'>
1885 for (my $i=0;$i<=23;$i++) {
1886 $i = sprintf("%02s",$i);
1887 for (my $j=0;$j<=45;$j+=15) {
1888 $j = sprintf("%02s",$j);
1889 my $time = $i.":".$j;
1890 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1897 #---ACTION------------------------------------------------------
1898 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1900 <table border='0' width='100%'>
1901 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1902 <input type='hidden' name='config' value='$config' >
1903 <input type='hidden' name='ACTION' value='saverule' >
1904 </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>
1909 <table border='0' width='100%'>
1910 <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'}'>
1911 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1912 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1913 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1914 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1915 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1916 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1917 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1918 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1919 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1920 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1921 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1922 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
1923 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
1924 <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>
1928 &Header
::closebox
();
1934 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1935 foreach my $key (sort keys %uphash){
1936 if ($key eq $fwdfwsettings{'key'}) {
1938 if (exists $uphash{$last}){
1940 foreach my $y (0 .. $#{$uphash{$last}}) {
1941 $tmp{0}[$y] = $uphash{$last}[$y];
1943 #copy active rule to last
1944 foreach my $i (0 .. $#{$uphash{$last}}) {
1945 $uphash{$last}[$i] = $uphash{$key}[$i];
1947 #copy saved rule to actual position
1948 foreach my $x (0 .. $#{$tmp{0}}) {
1949 $uphash{$key}[$x] = $tmp{0}[$x];
1954 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1961 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1962 foreach my $key (sort keys %downhash){
1963 if ($key eq $fwdfwsettings{'key'}) {
1964 my $next = $key + 1;
1965 if (exists $downhash{$next}){
1967 foreach my $y (0 .. $#{$downhash{$next}}) {
1968 $tmp{0}[$y] = $downhash{$next}[$y];
1970 #copy active rule to next
1971 foreach my $i (0 .. $#{$downhash{$next}}) {
1972 $downhash{$next}[$i] = $downhash{$key}[$i];
1974 #copy saved rule to actual position
1975 foreach my $x (0 .. $#{$tmp{0}}) {
1976 $downhash{$key}[$x] = $tmp{0}[$x];
1981 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1986 if (!-f
"${General::swroot}/forward/reread"){
1987 system("touch ${General::swroot}/forward/reread");
1988 system("touch ${General::swroot}/fwhosts/reread");
1993 system("/usr/local/bin/forwardfwctrl");
1994 if ( -f
"${General::swroot}/forward/reread"){
1995 system("rm ${General::swroot}/forward/reread");
1996 system("rm ${General::swroot}/fwhosts/reread");
2003 &General
::readhasharray
("$config", $hash);
2004 if (!$errormessage){
2005 #check if we change a NAT to a FORWARD/DMZ
2006 if(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'FORWARDFW'){
2007 &changerule
($confignat);
2010 #check if we change a NAT to a INPUT (external access)
2011 elsif(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2012 &changerule
($confignat);
2015 #check if we change a NAT to a OUTGOING
2016 elsif(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2017 &changerule
($confignat);
2020 ################################################################
2021 #check if we change a DMZ to a NAT
2022 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2023 &changerule
($configdmz);
2026 #check if we change a DMZ to an OUTGOING
2027 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2028 &changerule
($configdmz);
2031 #check if we change a DMZ to an INPUT
2032 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2033 &changerule
($configdmz);
2036 #check if we change a DMZ to a FORWARD/DMZ
2037 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2038 &changerule
($configdmz);
2041 ################################################################
2042 #check if we change an INPUT rule to a NAT
2043 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2044 &changerule
($configinput);
2047 #check if we change an INPUT rule to a OUTGOING
2048 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2049 &changerule
($configinput);
2052 #check if we change an INPUT rule to a FORWARD/DMZ
2053 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2054 &changerule
($configinput);
2057 ################################################################
2058 #check if we change an OUTGOING rule to an INPUT
2059 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2060 &changerule
($configoutgoing);
2063 #check if we change an OUTGOING rule to a FORWARD/DMZ
2064 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2065 &changerule
($configoutgoing);
2068 #check if we change an OUTGOING rule to a NAT
2069 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2070 &changerule
($configoutgoing);
2073 ################################################################
2074 #check if we change a FORWARD rule to an INPUT
2075 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2076 &changerule
($configfwdfw);
2079 #check if we change a FORWARD rule to an DMZ
2080 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on'){
2081 &changerule
($configfwdfw);
2084 #check if we change a FORWARD rule to an OUTGOING
2085 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2086 &changerule
($configfwdfw);
2089 #check if we change a FORWARD rule to an NAT
2090 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2091 &changerule
($configfwdfw);
2094 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2095 my $key = &General
::findhasharraykey
($hash);
2096 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2097 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2098 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2099 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2100 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2101 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2102 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2103 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2104 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2105 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2106 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2107 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2108 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2109 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2110 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2111 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2112 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2113 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2114 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2115 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2116 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2117 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2118 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2119 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2120 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2121 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2122 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2123 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2124 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
2125 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2126 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2127 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2128 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2130 &General
::writehasharray
("$config", $hash);
2132 foreach my $key (sort {$a <=> $b} keys %$hash){
2133 if($key eq $fwdfwsettings{'key'}){
2134 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2135 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2136 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2137 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2138 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2139 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2140 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2141 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2142 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2143 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2144 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2145 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2146 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2147 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2148 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2149 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2150 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2151 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2152 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2153 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2154 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2155 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2156 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2157 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2158 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2159 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2160 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2161 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2162 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
2163 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2164 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2165 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2166 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2172 &General
::writehasharray
("$config", $hash);
2173 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2175 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2176 for (my $z=0;$z<$val;$z++){
2177 foreach my $key (sort {$a <=> $b} keys %$hash){
2178 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2180 if (exists $$hash{$last}){
2182 foreach my $y (0 .. $#{$$hash{$last}}) {
2183 $tmp{0}[$y] = $$hash{$last}[$y];
2185 #copy active rule to last
2186 foreach my $i (0 .. $#{$$hash{$last}}) {
2187 $$hash{$last}[$i] = $$hash{$key}[$i];
2189 #copy saved rule to actual position
2190 foreach my $x (0 .. $#{$tmp{0}}) {
2191 $$hash{$key}[$x] = $tmp{0}[$x];
2196 $fwdfwsettings{'oldrulenumber'}--;
2198 &General
::writehasharray
("$config", $hash);
2200 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2202 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2203 for (my $z=0;$z<$val;$z++){
2204 foreach my $key (sort {$a <=> $b} keys %$hash){
2205 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2206 my $next = $key + 1;
2207 if (exists $$hash{$next}){
2209 foreach my $y (0 .. $#{$$hash{$next}}) {
2210 $tmp{0}[$y] = $$hash{$next}[$y];
2212 #copy active rule to next
2213 foreach my $i (0 .. $#{$$hash{$next}}) {
2214 $$hash{$next}[$i] = $$hash{$key}[$i];
2216 #copy saved rule to actual position
2217 foreach my $x (0 .. $#{$tmp{0}}) {
2218 $$hash{$key}[$x] = $tmp{0}[$x];
2223 $fwdfwsettings{'oldrulenumber'}++;
2225 &General
::writehasharray
("$config", $hash);
2232 # Checks a hostname against RFC1035
2235 # Each part should be at least two characters in length
2236 # but no more than 63 characters
2237 if (length ($remark) < 1 || length ($remark) > 255) {
2239 # Only valid characters are a-z, A-Z, 0-9 and -
2240 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2242 # First character can only be a letter or a digit
2243 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2245 # Last character can only be a letter or a digit
2246 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2252 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2253 &viewtablenew
(\
%configdmzfw,$configdmz,$Lang::tr
{'fwdfw rules'},"DMZ" );
2254 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
2255 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
2256 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
2257 &viewtablenew
(\
%confignatfw,$confignat,"","NAT" );
2266 &General
::get_aliases
(\
%aliases);
2267 &General
::readhasharray
("$confighost", \
%customhost);
2268 &General
::readhasharray
("$config", $hash);
2270 &Header
::openbox
('100%', 'left',$title);
2278 print"<b>$title1</b><br>";
2279 print"<table width='100%' cellspacing='0' cellpadding='0'>";
2280 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>";
2281 foreach my $key (sort {$a <=> $b} keys %$hash){
2284 #check if vpn hosts/nets have been deleted
2285 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2286 push (@tmpsrc,$$hash{$key}[4]);
2288 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2289 push (@tmpsrc,$$hash{$key}[6]);
2291 foreach my $host (@tmpsrc){
2292 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2293 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2295 &disable_rule
($key);
2298 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2299 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2301 &disable_rule
($key);
2304 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2305 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2307 &disable_rule
($key);
2310 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2311 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2313 &disable_rule
($key);
2318 $$hash{'ACTIVE'}=$$hash{$key}[2];
2320 if($coloryellow eq 'on'){
2321 print"<tr bgcolor='$color{'color14'}' >";
2323 }elsif($coloryellow eq ''){
2325 $color="$color{'color22'}";
2328 $color="$color{'color20'}";
2331 print"<tr bgcolor='$color' >";
2333 <td align='right' width='15'><b>$key</b></td>
2335 if ($$hash{$key}[0] eq 'ACCEPT'){
2338 $rulecolor=$color{'color17'};
2339 }elsif($$hash{$key}[0] eq 'DROP'){
2342 $rulecolor=$color{'color25'};
2343 }elsif($$hash{$key}[0] eq 'REJECT'){
2346 $rulecolor=$color{'color16'};
2348 if($$hash{$key}[28] eq 'ON'){
2349 print"<td bgcolor='$color' align='center' width='20'></td>";
2352 print"<td bgcolor='$rulecolor' align='center' width='20'><span title='$tooltip'><b>$ruletype</b></span></td>";
2354 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2355 print"<td align='center' width='160' $tdcolor>";
2356 if ($$hash{$key}[3] eq 'std_net_src'){
2357 print &get_name
($$hash{$key}[4]);
2359 print $$hash{$key}[4];
2362 &getsrcport
(\
%$hash,$key);
2363 #Is this a SNAT rule?
2364 if ($$hash{$key}[31] eq 'snat'){
2365 print"<br>SNAT -> $$hash{$key}[29]";
2366 if ($$hash{$key}[30] ne ''){
2367 print": $$hash{$key}[30]";
2370 if ($$hash{$key}[17] eq 'ON'){
2371 $log="/images/on.gif";
2373 $log="/images/off.gif";
2377 <form method='post'>
2378 <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 ;'/>
2379 <input type='hidden' name='key' value='$key' />
2380 <input type='hidden' name='config' value='$config' />
2381 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2384 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2386 <td align='center' width='160' $tdcolor>
2388 #Is this a DNAT rule?
2389 if ($$hash{$key}[31] eq 'dnat'){
2390 print "IPFire ($$hash{$key}[29])";
2391 if($$hash{$key}[30] ne ''){
2392 print": $$hash{$key}[30]";
2396 if ($$hash{$key}[5] eq 'std_net_tgt'){
2397 print &get_name
($$hash{$key}[6]);
2399 print $$hash{$key}[6];
2402 &gettgtport
(\
%$hash,$key);
2406 if ($$hash{$key}[12]){ #target prot if manual
2407 push (@protocols,$$hash{$key}[12]);
2408 }elsif($$hash{$key}[8]){ #source prot if manual
2409 push (@protocols,$$hash{$key}[8]);
2410 }elsif($$hash{$key}[14] eq 'cust_srv'){
2411 &get_serviceports
("service",$$hash{$key}[15]);
2412 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2413 &get_serviceports
("group",$$hash{$key}[15]);
2415 push (@protocols,$Lang::tr
{'all'});
2417 my $protz=join(",",@protocols);
2418 print"<td align='center'>$protz</td>";
2420 if ($$hash{$key}[18] eq 'ON'){
2422 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2423 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2424 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2425 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2426 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2427 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2428 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2429 my $weekdays=join(",",@days);
2431 print"<td align='center' width='100'>$weekdays   $$hash{$key}[26] - $$hash{$key}[27] </td>";
2434 print"<td align='center'>24/7</td>";
2436 if($$hash{$key}[2] eq 'ON'){
2437 $gif="/images/on.gif"
2440 $gif="/images/off.gif"
2443 <form method='post'>
2444 <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;' />
2445 <input type='hidden' name='key' value='$key' />
2446 <input type='hidden' name='config' value='$config' />
2447 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2449 <form method='post'>
2450 <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;' />
2451 <input type='hidden' name='key' value='$key' />
2452 <input type='hidden' name='config' value='$config' />
2453 <input type='hidden' name='ACTION' value='editrule' />
2455 <form method='post'>
2456 <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;' />
2457 <input type='hidden' name='key' value='$key' />
2458 <input type='hidden' name='config' value='$config' />
2459 <input type='hidden' name='ACTION' value='copyrule' />
2461 <form method='post'>
2462 <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;' />
2463 <input type='hidden' name='key' value='$key' />
2464 <input type='hidden' name='config' value='$config' />
2465 <input type='hidden' name='ACTION' value='deleterule' />
2468 if (exists $$hash{$key-1}){
2470 <form method='post'>
2471 <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;' />
2472 <input type='hidden' name='key' value='$key' />
2473 <input type='hidden' name='config' value='$config' />
2474 <input type='hidden' name='ACTION' value='moveup' />
2478 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2480 if (exists $$hash{$key+1}){
2482 <form method='post'>
2483 <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;' />
2484 <input type='hidden' name='key' value='$key' />
2485 <input type='hidden' name='config' value='$config' />
2486 <input type='hidden' name='ACTION' value='movedown' />
2487 </td></form></td></tr>
2490 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2493 if ($optionsfw{'SHOWREMARK'} eq 'on'){
2494 print"<tr bgcolor='$color'>";
2495 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='11'>  $$hash{$key}[16]</td></tr>";
2497 print"<tr bgcolor='$color'><td height='1'></td><td bgcolor='$rulecolor'></td><td colspan='11'></td></tr>";
2500 &Header
::closebox
();
2504 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2505 print "<b>$title1</b><br>";
2506 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>";
2512 &Header
::closebigbox
();
2513 &Header
::closepage
();