]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/forwardfw.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 # Hi folks! I hope this code is useful for all. I needed something to handle #
23 # my VPN Connections in a comfortable way. As a prerequisite i needed #
24 # something that makes sure the vpn roadwarrior are able to have a fixed #
25 # ip-address. So i developed the ccd extension for the vpn server. #
27 # Now that the ccd extension is ready i am able to develop the main request. #
28 # Any feedback is appreciated. #
31 ###############################################################################
35 no warnings
'uninitialized';
36 # enable only the following on debugging purpose
38 #use CGI::Carp 'fatalsToBrowser';
40 require '/var/ipfire/general-functions.pl';
41 require "${General::swroot}/lang.pl";
42 require "${General::swroot}/header.pl";
43 require "${General::swroot}/forward/bin/firewall-lib.pl";
45 unless (-d
"${General::swroot}/forward") { system("mkdir ${General::swroot}/forward"); }
46 unless (-e
"${General::swroot}/forward/settings") { system("touch ${General::swroot}/forward/settings"); }
47 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
48 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
49 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
50 unless (-e
"${General::swroot}/forward/dmz") { system("touch ${General::swroot}/forward/dmz"); }
51 unless (-e
"${General::swroot}/forward/nat") { system("touch ${General::swroot}/forward/nat"); }
55 my %defaultNetworks=();
59 my %customnetworks=();
61 my %customservicegrp=();
67 my %configoutgoingfw=();
81 my $VERSION='0.9.9.8';
83 my $confignet = "${General::swroot}/fwhosts/customnetworks";
84 my $confighost = "${General::swroot}/fwhosts/customhosts";
85 my $configgrp = "${General::swroot}/fwhosts/customgroups";
86 my $configsrv = "${General::swroot}/fwhosts/customservices";
87 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
88 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
89 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
90 my $configipsec = "${General::swroot}/vpn/config";
91 my $configipsecrw = "${General::swroot}/vpn/settings";
92 my $configfwdfw = "${General::swroot}/forward/config";
93 my $configinput = "${General::swroot}/forward/input";
94 my $configoutgoing = "${General::swroot}/forward/outgoing";
95 my $configdmz = "${General::swroot}/forward/dmz";
96 my $confignat = "${General::swroot}/forward/nat";
97 my $configovpn = "${General::swroot}/ovpn/settings";
98 my $fwoptions = "${General::swroot}/optionsfw/settings";
99 my $ifacesettings = "${General::swroot}/ethernet/settings";
102 my $ipgrp="${General::swroot}/outgoing/groups";
106 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
107 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
108 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
109 &General
::readhash
($fwoptions, \
%optionsfw);
110 &General
::readhash
($ifacesettings, \
%ifaces);
111 &General
::readhash
("$configovpn", \
%ovpnsettings);
112 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
113 &General
::readhasharray
("$configipsec", \
%ipsecconf);
114 &Header
::showhttpheaders
();
115 &Header
::getcgihash
(\
%fwdfwsettings);
116 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
117 &Header
::openbigbox
('100%', 'center',$errormessage);
120 if ($fwdfwsettings{'ACTION'} eq 'saverule')
122 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
123 &General
::readhasharray
("$configinput", \
%configinputfw);
124 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
125 &General
::readhasharray
("$confignat", \
%confignatfw);
126 $errormessage=&checksource
;
127 if(!$errormessage){&checktarget
;}
128 if(!$errormessage){&checkrule
;}
130 #check if manual ip (source) is orange network
131 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
132 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
133 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
138 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
139 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
141 #check if we try to break rules
142 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire'){
143 $errormessage.=$Lang::tr
{'fwdfw err same'};
146 if ($fwdfwsettings{'USE_NAT'} eq 'ON'){
147 $fwdfwsettings{'config'}=$confignat;
148 if ($fwdfwsettings{'nat'} eq 'dnat'){
149 $fwdfwsettings{'chain'} = 'NAT_DESTINATION';
151 $fwdfwsettings{'chain'} = 'NAT_SOURCE';
153 my $maxkey=&General
::findhasharraykey
(\
%confignatfw);
154 #check if we have an identical rule already
155 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
156 foreach my $key (sort keys %confignatfw){
157 if ("$confignatfw{$key}[0],$confignatfw{$key}[1],$confignatfw{$key}[2],$confignatfw{$key}[3],$confignatfw{$key}[4],$confignatfw{$key}[5],$confignatfw{$key}[6],$confignatfw{$key}[11],$confignatfw{$key}[12],$confignatfw{$key}[14],$confignatfw{$key}[15],$confignatfw{$key}[28],$confignatfw{$key}[29],$confignatfw{$key}[30],$confignatfw{$key}[31]"
158 eq "$fwdfwsettings{'RULE_ACTION'},NAT_DESTINATION,$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"){
159 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
160 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
162 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
163 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
165 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
166 $fwdfwsettings{'nosave'} = 'on';
172 #check Rulepos on new Rule
173 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
174 $fwdfwsettings{'oldrulenumber'}=$maxkey;
175 foreach my $key (sort keys %confignatfw){
176 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'}"
177 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]"){
178 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
182 #check if we just close a rule
183 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'}) {
184 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
186 $fwdfwsettings{'nosave2'} = 'on';
189 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
190 if ($fwdfwsettings{'nobase'} ne 'on'){
191 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
193 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
194 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
195 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
196 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
197 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
198 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
200 if($fwdfwsettings{'nosave2'} ne 'on'){
201 &saverule
(\
%confignatfw,$confignat);
204 }elsif ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on'){
205 $fwdfwsettings{'config'}=$configdmz;
206 $fwdfwsettings{'chain'} = 'FORWARDFW';
207 my $maxkey=&General
::findhasharraykey
(\
%configdmzfw);
208 #check if we have an identical rule already
209 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
210 foreach my $key (sort keys %configdmzfw){
211 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'}"
212 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]"){
213 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
214 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
216 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
217 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
219 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
220 $fwdfwsettings{'nosave'} = 'on';
225 #check Rulepos on new Rule
226 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
227 $fwdfwsettings{'oldrulenumber'}=$maxkey;
228 foreach my $key (sort keys %configdmzfw){
229 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'}"
230 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]"){
231 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
235 #check if we just close a rule
236 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'}) {
237 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
239 $fwdfwsettings{'nosave2'} = 'on';
242 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
243 if ($fwdfwsettings{'nobase'} ne 'on'){
244 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
246 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
247 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
248 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
249 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
250 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
251 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
253 if($fwdfwsettings{'nosave2'} ne 'on'){
254 &saverule
(\
%configdmzfw,$configdmz);
257 }elsif($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
258 $fwdfwsettings{'config'}=$configinput;
259 $fwdfwsettings{'chain'} = 'INPUTFW';
260 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
261 #check if we have an identical rule already
262 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
263 foreach my $key (sort keys %configinputfw){
264 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'}"
265 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]"){
266 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
267 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
269 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
270 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
272 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
273 $fwdfwsettings{'nosave'} = 'on';
278 #check Rulepos on new Rule
279 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
280 $fwdfwsettings{'oldrulenumber'}=$maxkey;
281 foreach my $key (sort keys %configinputfw){
282 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'}"
283 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]"){
284 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
288 #check if we just close a rule
289 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'}) {
290 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
292 $fwdfwsettings{'nosave2'} = 'on';
295 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
296 if ($fwdfwsettings{'nobase'} ne 'on'){
297 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
299 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
300 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
301 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
302 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
303 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
304 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
306 if($fwdfwsettings{'nosave2'} ne 'on'){
307 &saverule
(\
%configinputfw,$configinput);
309 }elsif($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' ){
311 $fwdfwsettings{'config'}=$configoutgoing;
312 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
313 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
314 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
315 foreach my $key (sort keys %configoutgoingfw){
316 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'}"
317 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]"){
318 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
319 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
321 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
322 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
324 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
325 $fwdfwsettings{'nosave'} = 'on';
330 #check Rulepos on new Rule
331 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
332 print"CHECK OUTGOING DOPPELTE REGEL<br>";
333 $fwdfwsettings{'oldrulenumber'}=$maxkey;
334 foreach my $key (sort keys %configoutgoingfw){
335 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'}"
336 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]"){
337 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
341 #check if we just close a rule
342 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'}) {
343 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
344 $fwdfwsettings{'nosave2'} = 'on';
349 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
350 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
351 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
352 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
353 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
354 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
355 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
356 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
358 if ($fwdfwsettings{'nobase'} eq 'on'){
359 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
361 if ($fwdfwsettings{'nosave2'} ne 'on'){
362 &saverule
(\
%configoutgoingfw,$configoutgoing);
366 $fwdfwsettings{'config'}=$configfwdfw;
367 $fwdfwsettings{'chain'} = 'FORWARDFW';
368 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
369 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
370 #check if we have an identical rule already
371 foreach my $key (sort keys %configfwdfw){
372 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'}"
373 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]"){
374 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
375 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
377 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
378 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
380 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
381 $fwdfwsettings{'nosave'} = 'on';
386 #check Rulepos on new Rule
387 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
388 $fwdfwsettings{'oldrulenumber'}=$maxkey;
389 foreach my $key (sort keys %configfwdfw){
390 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'}"
391 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]"){
392 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
396 #check if we just close a rule
397 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'}) {
398 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
399 $fwdfwsettings{'nosave2'} = 'on';
404 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
405 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
406 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
407 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
408 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
409 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
410 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
411 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
413 if ($fwdfwsettings{'nobase'} eq 'on'){
414 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
416 if ($fwdfwsettings{'nosave2'} ne 'on'){
417 &saverule
(\
%configfwdfw,$configfwdfw);
423 if($fwdfwsettings{'nosave2'} ne 'on'){
429 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
433 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
436 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
437 foreach my $key (sort keys %togglehash){
438 if ($key eq $fwdfwsettings{'key'}){
439 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
442 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
446 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
449 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
450 foreach my $key (sort keys %togglehash){
451 if ($key eq $fwdfwsettings{'key'}){
452 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
455 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
459 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
464 if ($fwdfwsettings{'ACTION'} eq 'editrule')
466 $fwdfwsettings{'updatefwrule'}='on';
469 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
473 if ($fwdfwsettings{'ACTION'} eq 'moveup')
478 if ($fwdfwsettings{'ACTION'} eq 'movedown')
483 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
485 $fwdfwsettings{'copyfwrule'}='on';
488 if ($fwdfwsettings{'ACTION'} eq '')
496 if (-f
"${General::swroot}/forward/reread"){
497 print "<table border='0'><form method='post'><td><div style='font-size:11pt; font-weight: bold;vertical-align: middle; '><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: red; font-weight: bold; font-size: 14pt;'>    $Lang::tr{'fwhost reread'}</div</td></tr></table></form><hr><br>";
499 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw menu'});
500 print "<form method='post'>";
501 print "<table border='0'>";
502 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
503 print"</tr></table></form><hr>";
512 print "<br><br><div align='right'><font size='1' color='grey'>Version: $VERSION</font></div>";
517 $fwdfwsettings{'updatefwrule'}='';
518 $fwdfwsettings{'config'}=$oldchain;
519 $fwdfwsettings{'nobase'}='on';
521 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
522 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
527 #check ip-address if manual
528 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
529 #check if ip with subnet
530 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
531 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
532 $subnet = &General
::iporsubtocidr
($subnet);
533 $fwdfwsettings{'isip'}='on';
536 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
537 $ip=$fwdfwsettings{'src_addr'};
539 $fwdfwsettings{'isip'}='on';
542 if ($fwdfwsettings{'isip'} ne 'on'){
543 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
545 if ($fwdfwsettings{'isip'} eq 'on'){
546 ##check if ip is valid
547 if (! &General
::validip
($ip)){
548 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
549 return $errormessage;
551 #check and form valid IP
552 $ip=&General
::ip2dec
($ip);
553 $ip=&General
::dec2ip
($ip);
554 #check if net or broadcast
555 my @tmp= split (/\./,$ip);
556 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
558 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
559 return $errormessage;
561 $fwdfwsettings{'src_addr'}="$ip/$subnet";
562 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
563 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
564 return $errormessage;
567 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
568 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
569 return $errormessage;
571 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
572 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
573 return $errormessage;
577 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
579 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
580 $fwdfwsettings{'SRC_PORT'}='';
581 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
582 foreach my $key (keys %icmptypes){
583 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
584 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
587 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
588 $fwdfwsettings{'SRC_PORT'}='';
589 $fwdfwsettings{'ICMP_TYPES'}='';
590 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
591 $fwdfwsettings{'SRC_PORT'}='';
592 $fwdfwsettings{'ICMP_TYPES'}='';
593 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
594 $fwdfwsettings{'SRC_PORT'}='';
595 $fwdfwsettings{'ICMP_TYPES'}='';
596 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
597 $fwdfwsettings{'ICMP_TYPES'}='';
599 $fwdfwsettings{'ICMP_TYPES'}='';
600 $fwdfwsettings{'SRC_PORT'}='';
601 $fwdfwsettings{'PROT'}='';
604 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
605 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
609 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
611 #change dashes with :
614 push(@values,"1:65535");
617 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
618 push(@values,"1:$2");
621 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
622 push(@values,"$1:65535");
625 $errormessage .= &General
::validportrange
($_, 'destination');
630 if (&General
::validport
($_)){
637 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
639 return $errormessage;
644 &General
::readhasharray
("$configsrv", \
%customservice);
645 #check DNAT settings (has to be single Host and single Port or portrange)
646 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
647 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
648 if ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'dnatport'} eq ''){
649 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
650 return $errormessage;
652 #check if manual ip is a single Host (if set)
653 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
654 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
655 my @tmp1= split ("/",$tmp[3]);
656 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
658 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
659 return $errormessage;
662 #check if Port is a single Port or portrange
663 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
664 if(($fwdfwsettings{'TGT_PROT'} ne 'TCP'|| $fwdfwsettings{'TGT_PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
665 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
666 return $errormessage;
668 if (($fwdfwsettings{'TGT_PROT'} eq 'TCP'|| $fwdfwsettings{'TGT_PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
669 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
670 return $errormessage;
674 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
675 return $errormessage;
678 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
679 #check if ip with subnet
680 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
681 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
682 $subnet = &General
::iporsubtocidr
($subnet);
685 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
686 $ip=$fwdfwsettings{'tgt_addr'};
689 #check if ip is valid
690 if (! &General
::validip
($ip)){
691 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
692 return $errormessage;
694 #check and form valid IP
695 $ip=&General
::ip2dec
($ip);
696 $ip=&General
::dec2ip
($ip);
697 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
698 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
699 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
700 return $errormessage;
702 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
703 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
704 return $errormessage;
707 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
709 if ($fwdfwsettings{'USESRV'} eq 'ON'){
710 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
711 $fwdfwsettings{'TGT_PROT'}='';
712 $fwdfwsettings{'ICMP_TGT'}='';
714 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
715 $fwdfwsettings{'TGT_PROT'}='';
716 $fwdfwsettings{'ICMP_TGT'}='';
717 #check target service
718 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
719 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
722 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
723 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
724 if ($fwdfwsettings{'TGT_PORT'} ne ''){
725 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
726 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
727 return $errormessage;
729 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
733 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
735 #change dashes with :
738 push(@values,"1:65535");
741 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
742 push(@values,"1:$2");
745 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
746 push(@values,"$1:65535");
749 $errormessage .= &General
::validportrange
($_, 'destination');
754 if (&General
::validport
($_)){
761 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
763 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
764 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
765 $fwdfwsettings{'TGT_PORT'} = '';
766 $fwdfwsettings{'ICMP_TGT'} = '';
767 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
768 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
769 $fwdfwsettings{'TGT_PORT'} = '';
770 $fwdfwsettings{'ICMP_TGT'}='';
771 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
772 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
773 $fwdfwsettings{'TGT_PORT'} = '';
774 $fwdfwsettings{'ICMP_TGT'}='';
775 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
776 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
777 $fwdfwsettings{'TGT_PORT'} = '';
778 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
779 foreach my $key (keys %icmptypes){
781 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
782 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
789 if ($fwdfwsettings{'USESRV'} ne 'ON'){
790 $fwdfwsettings{'grp3'}='';
791 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
792 $fwdfwsettings{'ICMP_TGT'}='';
795 if($fwdfwsettings{'TIME'} eq 'ON'){
796 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 ''){
797 $errormessage=$Lang::tr
{'fwdfw err time'};
798 return $errormessage;
801 return $errormessage;
806 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
807 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
808 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
809 if ($fwdfwsettings{'dnatport'} eq "*") {
810 $fwdfwsettings{'dnatport'}="1:65535";
812 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
813 $fwdfwsettings{'dnatport'} = "1:$2";
815 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
816 $fwdfwsettings{'dnatport'} ="$1:65535";
821 if ($val =~ "," || $val>65536 || $val<0){
828 #check valid port for NAT
829 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
830 #if no port is given in nat area, take target host port
831 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
832 #check if port given in nat area is a single valid port or portrange
833 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
834 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
835 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
837 #get servcie Protocol and Port
838 foreach my $key (sort keys %customservice){
839 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
840 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
841 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
843 $custsrvport= $customservice{$key}[1];
846 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
848 #check if DNAT port is multiple
849 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
850 my @parts=split(",",$fwdfwsettings{'dnatport'});
854 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
856 #change dashes with :
859 push(@values,"1:65535");
862 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
863 push(@values,"1:$2");
866 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
867 push(@values,"$1:65535");
870 $errormessage .= &General
::validportrange
($_, 'destination');
875 if (&General
::validport
($_)){
882 $fwdfwsettings{'dnatport'}=join("|",@values);
886 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
887 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
889 #check if source and target identical
890 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
891 $errormessage.=$Lang::tr
{'fwdfw err same'};
892 return $errormessage;
894 #get source and targetip address if possible
895 my ($sip,$scidr,$tip,$tcidr);
896 ($sip,$scidr)=&get_ip
("src","grp1");
897 ($tip,$tcidr)=&get_ip
("tgt","grp2");
898 #check same iprange in source and target
899 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
900 my $networkip1=&General
::getnetworkip
($sip,$scidr);
901 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
902 if ($scidr gt $tcidr){
903 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
904 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
906 }elsif($scidr eq $tcidr && $scidr eq '32'){
907 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
908 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
909 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
910 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
911 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
914 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
915 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
919 #check source and destination protocol if manual
920 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
921 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
922 $errormessage.=$Lang::tr
{'fwdfw err prot'};
924 #check source and destination protocol if source manual and dest servicegrp
925 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
926 foreach my $key (sort keys %customservice){
927 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
928 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
929 $errormessage.=$Lang::tr
{'fwdfw err prot'};
939 my ($base1,$val1,$base2,$val2) = @_;
941 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
942 &dec_counter
($confignet,\
%customnetwork,$val1);
943 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
944 &dec_counter
($confighost,\
%customhost,$val1);
945 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
946 &dec_counter
($configgrp,\
%customgrp,$val1);
947 }elsif($base1 eq 'cust_srv'){
948 &dec_counter
($configsrv,\
%customservice,$val1);
949 }elsif($base1 eq 'cust_srvgrp'){
950 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
953 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
954 &inc_counter
($confignet,\
%customnetwork,$val2);
955 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
956 &inc_counter
($confighost,\
%customhost,$val2);
957 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
958 &inc_counter
($configgrp,\
%customgrp,$val2);
959 }elsif($base2 eq 'cust_srv'){
960 &inc_counter
($configsrv,\
%customservice,$val2);
961 }elsif($base2 eq 'cust_srvgrp'){
962 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
968 #Test if manual IP is part of static OpenVPN networks
969 &General
::readhasharray
("$configccdnet", \
%ccdnet);
970 foreach my $key (sort keys %ccdnet){
971 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
972 my $sub=&General
::iporsubtodec
($vpnsubnet);
973 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
977 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
978 # because if one creates a custom host with the ip, we need to check the color there!
979 # It does not make sense to check this here
981 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
982 # Is also checked in getcolor
984 # Test if manual ip is part of an IPsec Network is also checked in getcolor
994 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
995 foreach my $key (sort {$a <=> $b} keys %delhash){
996 if ($key == $fwdfwsettings{'key'}){
997 #check hosts/net and groups
998 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
999 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
1000 #check services and groups
1001 if ($delhash{$key}[11] eq 'ON'){
1002 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
1005 if ($key >= $fwdfwsettings{'key'}) {
1006 my $next = $key + 1;
1007 if (exists $delhash{$next}) {
1008 foreach my $i (0 .. $#{$delhash{$next}}) {
1009 $delhash{$key}[$i] = $delhash{$next}[$i];
1014 # Remove the very last entry.
1015 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
1016 delete $delhash{$last_key};
1018 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
1021 if($fwdfwsettings{'nobase'} ne 'on'){
1028 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
1029 foreach my $key (sort keys %configfwdfw){
1030 if ($key eq $key1 ){
1031 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
1034 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
1040 my %hash=%{(shift)};
1043 &General
::readhasharray
($config, \
%hash);
1044 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1045 if($hash{$key}[0] eq $val){
1046 $pos=$#{$hash{$key}};
1047 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
1050 &General
::writehasharray
($config, \
%hash);
1054 if ($errormessage) {
1055 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1056 print "<class name='base'>$errormessage\n";
1057 print " </class>\n";
1058 &Header
::closebox
();
1064 my %hash=%{(shift)};
1067 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
1068 if($hash{$key}[0] eq $val){
1069 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1071 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1081 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1082 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1083 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1084 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1085 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1086 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1087 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1088 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1089 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1090 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1091 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1092 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1093 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1094 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1095 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1096 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1097 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1098 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1100 <table width='100%' border='0'>
1101 <tr><td width='50%' valign='top'>
1102 <table width='100%' border='0'>
1103 <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;'>
1105 foreach my $network (sort keys %defaultNetworks)
1107 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1108 next if($defaultNetworks{$network}{'NAME'} eq "IPFire" && $srctgt eq 'tgt');
1109 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1110 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1111 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1112 $ifaces{$defnet} = '0.0.0.0' if ($defaultNetworks{$network}{'NAME'} eq 'ALL');
1113 $defnet = "RED_ADDRESS" if ($defaultNetworks{$network}{'NAME'} eq 'IPFire');
1114 print ">$network $ifaces{$defnet} </option>";
1116 print"</select></td></tr>";
1118 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1119 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;'>";
1120 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1121 print"</select></td>";
1124 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1125 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;'>";
1126 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1127 print"</select></td>";
1130 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1131 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;'>";
1132 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1133 if($helper ne $customgrp{$key}[0]){
1135 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1136 print ">$customgrp{$key}[0]</option>";
1138 $helper=$customgrp{$key}[0];
1140 print"</select></td>";
1142 #End left table. start right table (vpn)
1143 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1145 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1146 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;'>";
1147 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1148 print"</select></td></tr>";
1151 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1152 if ($ccdhost{$key}[33] ne '' ){
1153 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 '');
1155 print "<option value='$ccdhost{$key}[1]'";
1156 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1157 print ">$ccdhost{$key}[1]</option>";
1160 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1161 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>" ;
1163 if ($show eq '1'){$show='';print"</select></td></tr>";}
1165 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1166 if ($ccdhost{$key}[3] eq 'net'){
1167 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 '');
1169 print "<option value='$ccdhost{$key}[1]'";
1170 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1171 print ">$ccdhost{$key}[1]</option>";
1174 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1175 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>" ;
1177 if ($show eq '1'){$show='';print"</select></td></tr>";}
1179 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1180 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1181 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 '');
1184 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1185 print ">$ipsecconf{$key}[1]</option>";
1188 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1189 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>";
1191 if ($show eq '1'){$show='';print"</select></td></tr>";}
1193 print"</tr></table>";
1194 print"</td></tr></table><br>";
1202 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1203 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1204 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1205 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1206 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1207 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1208 $a=$netsettings{'GREEN_NETADDRESS'};
1209 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1210 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1211 $a=$netsettings{'ORANGE_NETADDRESS'};
1212 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1213 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1214 $a=$netsettings{'BLUE_NETADDRESS'};
1215 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1216 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1217 &General
::readhash
("$configovpn",\
%ovpnsettings);
1218 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1219 $b=&General
::iporsubtocidr
($b);
1221 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1222 &General
::readhasharray
("$confignet", \
%customnetwork);
1223 foreach my $key (keys %customnetwork){
1224 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1225 $a=$customnetwork{$key}[1];
1226 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1229 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1230 &General
::readhasharray
("$confighost", \
%customhost);
1231 foreach my $key (keys %customhost){
1232 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1233 if ($customhost{$key}[1] eq 'ip'){
1234 ($a,$b)=split (/\//,$customhost{$key}[2]);
1235 $b=&General
::iporsubtocidr
($b);
1237 if ($grp eq 'grp2'){
1238 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1250 &General
::setup_default_networks
(\
%defaultNetworks);
1251 foreach my $network (sort keys %defaultNetworks)
1253 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1258 my %hash=%{(shift)};
1260 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1261 $hash{$key}[10]=~ s/\|/,/g;
1262 print": $hash{$key}[10]";
1263 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1264 print": <br>$hash{$key}[9] ";
1269 my %hash=%{(shift)};
1273 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1274 if($hash{$key}[14] eq 'cust_srv'){
1275 &General
::readhasharray
("$configsrv", \
%customservice);
1276 foreach my $i (sort keys %customservice){
1277 if($customservice{$i}[0] eq $hash{$key}[15]){
1278 $service = $customservice{$i}[0];
1281 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1282 $service=$hash{$key}[15];
1283 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1284 $hash{$key}[15]=~ s/\|/,/g;
1285 $service=$hash{$key}[15];
1290 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1291 print":<br>$hash{$key}[13]";
1294 sub get_serviceports
1298 &General
::readhasharray
("$configsrv", \
%customservice);
1299 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1304 if($type eq 'service'){
1305 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1306 if ($customservice{$key}[0] eq $name){
1307 push (@protocols,$customservice{$key}[2]);
1310 }elsif($type eq 'group'){
1311 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1312 if ($customservicegrp{$key}[0] eq $name){
1313 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1314 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1315 if($customservice{$key1}[2] eq 'TCP'){
1317 }elsif($customservice{$key1}[2] eq 'ICMP'){
1319 }elsif($customservice{$key1}[2] eq 'UDP'){
1327 if($tcp && $udp && $icmp){
1328 push (@protocols,"All");
1332 push (@protocols,"TCP");
1335 push (@protocols,"UDP");
1338 push (@protocols,"ICMP");
1347 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1349 if ($val eq 'GREEN'){
1350 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1352 }elsif ($val eq 'ORANGE'){
1353 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1355 }elsif ($val eq 'BLUE'){
1356 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1358 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1359 $tdcolor="style='border: 1px solid $Header::colourred;'";
1361 }elsif ($val eq 'IPFire' ){
1362 $tdcolor="style='border: 1px solid $Header::colourred;'";
1364 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1365 my ($sip,$scidr) = split ("/",$val);
1366 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1367 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1370 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1371 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1374 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1375 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1378 }elsif ($val eq 'Default IP'){
1379 $tdcolor="style='border: 1px solid $Header::colourred;'";
1382 #Check if a manual IP is part of a VPN
1383 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr'){
1384 #Check if IP is part of OpenVPN dynamic subnet
1385 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1386 my ($c,$d) = split("/",$val);
1387 if (&General
::IpInSubnet
($c,$a,$b)){
1388 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1391 #Check if IP is part of OpenVPN static subnet
1392 foreach my $key (sort keys %ccdnet){
1393 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1394 $b =&General
::iporsubtodec
($b);
1395 if (&General
::IpInSubnet
($c,$a,$b)){
1396 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1400 #Check if IP is part of OpenVPN N2N subnet
1401 foreach my $key (sort keys %ccdhost){
1402 if ($ccdhost{$key}[3] eq 'net'){
1403 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1404 if (&General
::IpInSubnet
($c,$a,$b)){
1405 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1410 #Check if IP is part of IPsec RW network
1411 if ($ipsecsettings{'RW_NET'} ne ''){
1412 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1413 $b=&General
::iporsubtodec
($b);
1414 if (&General
::IpInSubnet
($c,$a,$b)){
1415 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1419 #Check if IP is part of a IPsec N2N network
1420 foreach my $key (sort keys %ipsecconf){
1421 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1422 if (&General
::IpInSubnet
($c,$a,$b)){
1423 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1429 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'){
1430 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1433 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1434 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1438 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1439 foreach my $key (sort keys %$hash){
1440 if ($$hash{$key}[0] eq $val){
1441 $val=$$hash{$key}[2];
1446 foreach my $alias (sort keys %aliases)
1448 if ($val eq $alias){
1449 $tdcolor="style='border: 1px solid $Header::colourred;'";
1460 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1461 print "<class name='base'>$hint\n";
1462 print " </class>\n";
1463 &Header
::closebox
();
1470 my %hash=%{(shift)};
1474 &General
::readhasharray
($config, \
%hash);
1475 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1476 if($hash{$key}[0] eq $val){
1477 $pos=$#{$hash{$key}};
1478 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1481 &General
::writehasharray
($config, \
%hash);
1486 &General
::setup_default_networks
(\
%defaultNetworks);
1487 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1488 #read all configfiles
1489 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1490 &General
::readhasharray
("$confignet", \
%customnetwork);
1491 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1492 &General
::readhasharray
("$confighost", \
%customhost);
1493 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1494 &General
::readhasharray
("$configgrp", \
%customgrp);
1495 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1496 &General
::get_aliases
(\
%aliases);
1500 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1501 my $config=$fwdfwsettings{'config'};
1503 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1504 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1505 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1506 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1507 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1508 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1509 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1510 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1511 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1512 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1513 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1514 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1515 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1516 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1517 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1518 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1519 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1520 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1521 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1522 #check if update and get values
1523 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1524 &General
::readhasharray
("$config", \
%hash);
1525 foreach my $key (sort keys %hash){
1527 if ($key eq $fwdfwsettings{'key'}){
1528 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1529 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1530 $fwdfwsettings{'chain'} = $hash{$key}[1];
1531 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1532 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1533 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1534 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1535 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1536 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1537 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1538 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1539 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1540 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1541 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1542 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1543 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1544 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1545 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1546 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1547 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1548 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1549 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1550 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1551 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1552 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1553 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1554 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1555 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1556 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1557 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1558 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1559 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1560 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1561 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1562 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1563 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1564 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1565 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1566 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1567 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1568 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1569 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1570 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1571 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1572 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1573 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1574 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1575 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1576 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1577 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1578 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1579 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1580 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1581 $selected{'dnat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1582 $selected{'snat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1585 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1586 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1587 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1588 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1589 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1590 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1591 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1592 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1593 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1594 if ($fwdfwsettings{'config'} eq "${General::swroot}/forward/dmz"){
1595 $fwdfwsettings{'oldruletype'}='DMZ';
1597 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1599 #check if manual ip (source) is orange network
1600 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1601 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1602 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1603 $fwdfwsettings{'oldorange'} ='on';
1607 $fwdfwsettings{'ACTIVE'}='ON';
1608 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1609 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1610 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1611 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1612 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1613 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1614 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1615 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1616 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1617 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1618 #check if manual ip (source) is orange network
1619 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1620 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1621 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1622 $fwdfwsettings{'oldorange'} ='on';
1626 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1627 print "<form method='post'>";
1628 &Header
::closebox
();
1629 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1630 #------SOURCE-------------------------------------------------------
1632 <table width='100%' border='0'>
1633 <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>
1634 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1637 &gen_dd_block
('src','grp1');
1639 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1640 <table width='100%' border='0'>
1641 <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>
1642 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1644 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1646 if ($_ eq $fwdfwsettings{'PROT'})
1648 print"<option selected>$_</option>";
1650 print"<option>$_</option>";
1653 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1655 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1656 <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;'>
1658 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1659 print"<option>All ICMP-Types</option>";
1660 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) } keys %icmptypes){
1661 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1662 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1664 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1668 </select></td></tr></table><br><hr>
1670 &Header
::closebox
();
1672 #---TARGET------------------------------------------------------
1673 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1675 <table width='100%' border='0'>
1676 <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>Firewall</b></td>
1678 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1679 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'} 0.0.0.0</option>";
1680 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} $ifaces{'GREEN_ADDRESS'}</option>" if $ifaces{'GREEN_ADDRESS'};
1681 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} $ifaces{'ORANGE_ADDRESS'}</option>" if $ifaces{'ORANGE_ADDRESS'};
1682 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} $ifaces{'BLUE_ADDRESS'}</option>" if $ifaces{'BLUE_ADDRESS'};
1683 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} $ifaces{'RED_ADDRESS'}</option>" if $ifaces{'RED_ADDRESS'};
1685 if (! -z
"${General::swroot}/ethernet/aliases"){
1686 foreach my $alias (sort keys %aliases)
1688 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1693 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1695 &gen_dd_block
('tgt','grp2');
1697 <b>$Lang::tr{'fwhost attention'}:</b><br>
1698 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1699 <table width='100%' border='0'>
1700 <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;' >
1702 &General
::readhasharray
("$configsrv", \
%customservice);
1703 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1705 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1706 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1710 <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;' >
1712 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1714 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1715 if ($helper ne $customservicegrp{$key}[0]){
1717 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1718 print">$customservicegrp{$key}[0]</option>";
1720 $helper=$customservicegrp{$key}[0];
1724 <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'>
1726 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1728 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1730 print"<option selected>$_</option>";
1732 print"<option>$_</option>";
1735 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1737 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1738 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT' style='min-width:230px;'>
1740 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1741 print"<option>All ICMP-Types</option>";
1742 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1743 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1744 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1746 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1755 #---SNAT / DNAT ------------------------------------------------
1756 &Header
::openbox
('100%', 'left', 'NAT');
1758 <table width='100%' border='0'>
1759 <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>
1760 <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>
1762 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
1763 print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
1764 print "<option value='Default IP' $selected{'dnat'}{'Default IP'}>Default IP</option>";
1765 foreach my $alias (sort keys %aliases)
1767 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
1770 $fwdfwsettings{'dnatport'}=~ tr/|/,/;
1771 print"<tr><td colspan='4'></td><td>Port: </td><td align='right'><input type='text' name='dnatport' style='width:130px;' value=$fwdfwsettings{'dnatport'}> </td></tr>";
1772 print"<tr><td colspan='8'><br></td></tr>";
1774 print"<tr><td colspan='2'></td><td width='1%'><input type='radio' name='nat' value='snat' $checked{'nat'}{'snat'}></td><td width='20%'>$Lang::tr{'fwdfw snat'}</td>";
1775 print"<td width='8%'>IPFire: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
1776 print "<option value='Default IP' $selected{'snat'}{'Default IP'}>Default IP</option>";
1777 foreach my $alias (sort keys %aliases)
1779 print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
1781 foreach my $network (sort keys %defaultNetworks)
1783 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1784 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1785 next if($defaultNetworks{$network}{'NAME'} eq "ALL");
1786 next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
1787 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1788 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
1789 print ">$network</option>";
1793 &Header
::closebox
();
1794 #---Activate/logging/remark-------------------------------------
1795 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1797 <table width='100%' border='0'>
1798 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1800 foreach ("ACCEPT","DROP","REJECT")
1802 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1803 print"<option value='$_'";
1804 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1805 print">$Lang::tr{'fwdfw '.$_}</option>";
1807 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1808 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1810 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1812 print"<option value='$_' selected>$Lang::tr{'fwdfw '.$_}</option>";
1814 print"<option value='$_'>$Lang::tr{'fwdfw '.$_}</option>";
1818 print"</select></td></tr>";
1819 print"<tr><td width='12%'>$Lang::tr{'remark'}:</td><td align='left'><input type='text' name='ruleremark' size='40' maxlength='255' value='$fwdfwsettings{'ruleremark'}'></td></tr>";
1820 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1821 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1822 for (my $count =1; $count <= $sum; $count++){
1823 print"<option value='$count' ";
1824 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1825 print">$count</option>";
1827 print"</select></td></tr>";
1829 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1833 </table><table width='100%'>
1834 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1835 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1838 &Header
::closebox
();
1839 #---ADD TIMEFRAME-----------------------------------------------
1840 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1842 <table width='70%' border='0'>
1843 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1844 <tr><td colspan='7'> </td></tr>
1846 <td align='left'>$Lang::tr{'time'}:</td>
1847 <td width='30%' align='left'>$Lang::tr{'advproxy monday'} $Lang::tr{'advproxy tuesday'} $Lang::tr{'advproxy wednesday'} $Lang::tr{'advproxy thursday'} $Lang::tr{'advproxy friday'} $Lang::tr{'advproxy saturday'} $Lang::tr{'advproxy sunday'}</td>
1848 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1849 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1852 <td align='right'></td>
1853 <td width='30%' align='left'>
1854 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1855 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1856 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1857 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1858 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1859 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1860 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1862 <td><select name='TIME_FROM'>
1864 for (my $i=0;$i<=23;$i++) {
1865 $i = sprintf("%02s",$i);
1866 for (my $j=0;$j<=45;$j+=15) {
1867 $j = sprintf("%02s",$j);
1868 my $time = $i.":".$j;
1869 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1874 <td><select name='TIME_TO'>
1876 for (my $i=0;$i<=23;$i++) {
1877 $i = sprintf("%02s",$i);
1878 for (my $j=0;$j<=45;$j+=15) {
1879 $j = sprintf("%02s",$j);
1880 my $time = $i.":".$j;
1881 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1888 #---ACTION------------------------------------------------------
1889 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1891 <table border='0' width='100%'>
1892 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1893 <input type='hidden' name='config' value='$config' >
1894 <input type='hidden' name='ACTION' value='saverule' >
1895 </form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value'reset'></td></td>
1900 <table border='0' width='100%'>
1901 <tr><td align='right'><input type='submit' value='$Lang::tr{'fwdfw change'}' style='min-width:100px;' /><input type='hidden' name='updatefwrule' value='$fwdfwsettings{'updatefwrule'}'><input type='hidden' name='key' value='$fwdfwsettings{'key'}'>
1902 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1903 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1904 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1905 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1906 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1907 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1908 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1909 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1910 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1911 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1912 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1913 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
1914 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
1915 <input type='hidden' name='ACTION' value='saverule' ></form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value'reset'></td></td>
1919 &Header
::closebox
();
1925 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1926 foreach my $key (sort keys %uphash){
1927 if ($key eq $fwdfwsettings{'key'}) {
1929 if (exists $uphash{$last}){
1931 foreach my $y (0 .. $#{$uphash{$last}}) {
1932 $tmp{0}[$y] = $uphash{$last}[$y];
1934 #copy active rule to last
1935 foreach my $i (0 .. $#{$uphash{$last}}) {
1936 $uphash{$last}[$i] = $uphash{$key}[$i];
1938 #copy saved rule to actual position
1939 foreach my $x (0 .. $#{$tmp{0}}) {
1940 $uphash{$key}[$x] = $tmp{0}[$x];
1945 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1952 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1953 foreach my $key (sort keys %downhash){
1954 if ($key eq $fwdfwsettings{'key'}) {
1955 my $next = $key + 1;
1956 if (exists $downhash{$next}){
1958 foreach my $y (0 .. $#{$downhash{$next}}) {
1959 $tmp{0}[$y] = $downhash{$next}[$y];
1961 #copy active rule to next
1962 foreach my $i (0 .. $#{$downhash{$next}}) {
1963 $downhash{$next}[$i] = $downhash{$key}[$i];
1965 #copy saved rule to actual position
1966 foreach my $x (0 .. $#{$tmp{0}}) {
1967 $downhash{$key}[$x] = $tmp{0}[$x];
1972 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1977 if (!-f
"${General::swroot}/forward/reread"){
1978 system("touch ${General::swroot}/forward/reread");
1979 system("touch ${General::swroot}/fwhosts/reread");
1984 system("/usr/local/bin/forwardfwctrl");
1985 if ( -f
"${General::swroot}/forward/reread"){
1986 system("rm ${General::swroot}/forward/reread");
1987 system("rm ${General::swroot}/fwhosts/reread");
1994 &General
::readhasharray
("$config", $hash);
1995 if (!$errormessage){
1996 #check if we change a NAT to a FORWARD/DMZ
1997 if(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'FORWARDFW'){
1998 &changerule
($confignat);
2001 #check if we change a NAT to a INPUT (external access)
2002 elsif(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2003 &changerule
($confignat);
2006 #check if we change a NAT to a OUTGOING
2007 elsif(($fwdfwsettings{'oldruletype'} eq 'NAT_SOURCE' || $fwdfwsettings{'oldruletype'} eq 'NAT_DESTINATION') && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2008 &changerule
($confignat);
2011 ################################################################
2012 #check if we change a DMZ to a NAT
2013 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2014 &changerule
($configdmz);
2017 #check if we change a DMZ to an OUTGOING
2018 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2019 &changerule
($configdmz);
2022 #check if we change a DMZ to an INPUT
2023 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2024 &changerule
($configdmz);
2027 #check if we change a DMZ to a FORWARD/DMZ
2028 elsif($fwdfwsettings{'oldruletype'} eq 'DMZ' && $fwdfwsettings{'chain'} eq 'FORWARDFW' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE' && $checkorange ne 'on'){
2029 &changerule
($configdmz);
2032 ################################################################
2033 #check if we change an INPUT rule to a NAT
2034 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2035 &changerule
($configinput);
2038 #check if we change an INPUT rule to a OUTGOING
2039 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2040 &changerule
($configinput);
2043 #check if we change an INPUT rule to a FORWARD/DMZ
2044 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2045 &changerule
($configinput);
2048 ################################################################
2049 #check if we change an OUTGOING rule to an INPUT
2050 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2051 &changerule
($configoutgoing);
2054 #check if we change an OUTGOING rule to a FORWARD/DMZ
2055 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2056 &changerule
($configoutgoing);
2059 #check if we change an OUTGOING rule to a NAT
2060 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2061 &changerule
($configoutgoing);
2064 ################################################################
2065 #check if we change a FORWARD rule to an INPUT
2066 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2067 &changerule
($configfwdfw);
2070 #check if we change a FORWARD rule to an DMZ
2071 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on')){
2072 &changerule
($configfwdfw);
2075 #check if we change a FORWARD rule to an OUTGOING
2076 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2077 &changerule
($configfwdfw);
2080 #check if we change a FORWARD rule to an NAT
2081 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && ($fwdfwsettings{'chain'} eq 'NAT_SOURCE' || $fwdfwsettings{'chain'} eq 'NAT_DESTINATION')){
2082 &changerule
($configfwdfw);
2085 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2086 my $key = &General
::findhasharraykey
($hash);
2087 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2088 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2089 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2090 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2091 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2092 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2093 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2094 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2095 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2096 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2097 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2098 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2099 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2100 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2101 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2102 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2103 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2104 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2105 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2106 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2107 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2108 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2109 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2110 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2111 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2112 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2113 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2114 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2115 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
2116 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2117 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2118 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2119 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2121 &General
::writehasharray
("$config", $hash);
2123 foreach my $key (sort {$a <=> $b} keys %$hash){
2124 if($key eq $fwdfwsettings{'key'}){
2125 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2126 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2127 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2128 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2129 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2130 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2131 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2132 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2133 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2134 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2135 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2136 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2137 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2138 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2139 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2140 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2141 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2142 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2143 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2144 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2145 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2146 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2147 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2148 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2149 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2150 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2151 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2152 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2153 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
2154 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2155 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2156 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2157 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2163 &General
::writehasharray
("$config", $hash);
2164 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2166 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2167 for (my $z=0;$z<$val;$z++){
2168 foreach my $key (sort {$a <=> $b} keys %$hash){
2169 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2171 if (exists $$hash{$last}){
2173 foreach my $y (0 .. $#{$$hash{$last}}) {
2174 $tmp{0}[$y] = $$hash{$last}[$y];
2176 #copy active rule to last
2177 foreach my $i (0 .. $#{$$hash{$last}}) {
2178 $$hash{$last}[$i] = $$hash{$key}[$i];
2180 #copy saved rule to actual position
2181 foreach my $x (0 .. $#{$tmp{0}}) {
2182 $$hash{$key}[$x] = $tmp{0}[$x];
2187 $fwdfwsettings{'oldrulenumber'}--;
2189 &General
::writehasharray
("$config", $hash);
2191 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2193 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2194 for (my $z=0;$z<$val;$z++){
2195 foreach my $key (sort {$a <=> $b} keys %$hash){
2196 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2197 my $next = $key + 1;
2198 if (exists $$hash{$next}){
2200 foreach my $y (0 .. $#{$$hash{$next}}) {
2201 $tmp{0}[$y] = $$hash{$next}[$y];
2203 #copy active rule to next
2204 foreach my $i (0 .. $#{$$hash{$next}}) {
2205 $$hash{$next}[$i] = $$hash{$key}[$i];
2207 #copy saved rule to actual position
2208 foreach my $x (0 .. $#{$tmp{0}}) {
2209 $$hash{$key}[$x] = $tmp{0}[$x];
2214 $fwdfwsettings{'oldrulenumber'}++;
2216 &General
::writehasharray
("$config", $hash);
2223 # Checks a hostname against RFC1035
2226 # Each part should be at least two characters in length
2227 # but no more than 63 characters
2228 if (length ($remark) < 1 || length ($remark) > 255) {
2230 # Only valid characters are a-z, A-Z, 0-9 and -
2231 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2233 # First character can only be a letter or a digit
2234 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2236 # Last character can only be a letter or a digit
2237 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2243 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2244 &viewtablenew
(\
%confignatfw,$confignat,"$Lang::tr{'fwdfw rules'}","Portforward / SNAT" );
2245 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
2246 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
2247 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'fwdfw xt access'} );
2248 &viewtablenew
(\
%configdmzfw,$configdmz,"","DMZ" );
2257 &General
::get_aliases
(\
%aliases);
2258 &General
::readhasharray
("$confighost", \
%customhost);
2259 &General
::readhasharray
("$config", $hash);
2260 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2261 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2263 &Header
::openbox
('100%', 'left',$title);
2271 print"<b>$title1</b><br>";
2272 print"<table width='100%' cellspacing='0' cellpadding='0' border='0'>";
2273 print"<tr><td align='center'><b>#</td><td ></td><td align='center'><b>$Lang::tr{'fwdfw source'}</td><td width='1%'><b>Log</td><td align='center'><b>$Lang::tr{'fwdfw target'}</td><td align='center' width='25'></td><td align='center' colspan='6' width='1%'><b>$Lang::tr{'fwdfw action'}</td></tr>";#<td align='center'><b>$Lang::tr{'fwdfw time'}</td><b>$Lang::tr{'protocol'}</b>
2274 foreach my $key (sort {$a <=> $b} keys %$hash){
2277 #check if vpn hosts/nets have been deleted
2278 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2279 push (@tmpsrc,$$hash{$key}[4]);
2281 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2282 push (@tmpsrc,$$hash{$key}[6]);
2284 foreach my $host (@tmpsrc){
2285 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2286 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2288 &disable_rule
($key);
2291 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2292 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2294 &disable_rule
($key);
2297 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2298 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2300 &disable_rule
($key);
2303 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2304 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2306 &disable_rule
($key);
2311 $$hash{'ACTIVE'}=$$hash{$key}[2];
2313 if($coloryellow eq 'on'){
2314 print"<tr bgcolor='$color{'color14'}' >";
2316 }elsif($coloryellow eq ''){
2318 $color="$color{'color22'}";
2321 $color="$color{'color20'}";
2324 print"<tr bgcolor='$color' >";
2326 <td align='right' width='18'><b>$key  </b></td>
2328 if ($$hash{$key}[0] eq 'ACCEPT'){
2331 $rulecolor=$color{'color17'};
2332 }elsif($$hash{$key}[0] eq 'DROP'){
2335 $rulecolor=$color{'color25'};
2336 }elsif($$hash{$key}[0] eq 'REJECT'){
2339 $rulecolor=$color{'color16'};
2341 print"<td bgcolor='$rulecolor' align='center' width='10'><span title='$tooltip'><b>$ruletype</b></span></td>";
2342 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2343 print"<td align='center' width='160' $tdcolor>";
2344 if ($$hash{$key}[3] eq 'std_net_src'){
2345 print &get_name
($$hash{$key}[4]);
2347 print $$hash{$key}[4];
2350 &getsrcport
(\
%$hash,$key);
2351 #Is this a SNAT rule?
2352 if ($$hash{$key}[31] eq 'snat'){
2353 print"<br>-> $$hash{$key}[29]";
2354 if ($$hash{$key}[30] ne ''){
2355 print": $$hash{$key}[30]";
2358 if ($$hash{$key}[17] eq 'ON'){
2359 $log="/images/on.gif";
2361 $log="/images/off.gif";
2365 <form method='post'>
2366 <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 ;'/>
2367 <input type='hidden' name='key' value='$key' />
2368 <input type='hidden' name='config' value='$config' />
2369 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2372 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2374 <td align='center' width='160' $tdcolor>
2376 #Is this a DNAT rule?
2377 if ($$hash{$key}[31] eq 'dnat'){
2378 print "IPFire ($$hash{$key}[29])";
2379 if($$hash{$key}[30] ne ''){
2380 $$hash{$key}[30]=~ tr/|/,/;
2381 print": $$hash{$key}[30]";
2385 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire' && $$hash{$key}[6] eq 'RED' || $$hash{$key}[6] eq 'RED1' || $$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE' ){
2386 if ($$hash{$key}[6] eq 'RED1')
2388 print $Lang::tr
{'red1'};
2390 print &get_name
($$hash{$key}[6]);
2393 print $$hash{$key}[6];
2396 &gettgtport
(\
%$hash,$key);
2400 if ($$hash{$key}[8] && $$hash{$key}[7] eq 'ON'){#source prot if manual
2401 push (@protocols,$$hash{$key}[8]);
2402 }elsif ($$hash{$key}[12]){ #target prot if manual
2403 push (@protocols,$$hash{$key}[12]);
2404 }elsif($$hash{$key}[14] eq 'cust_srv'){
2405 &get_serviceports
("service",$$hash{$key}[15]);
2406 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2407 &get_serviceports
("group",$$hash{$key}[15]);
2409 push (@protocols,$Lang::tr
{'all'});
2411 my $protz=join(",",@protocols);
2412 print"<td align='center'>$protz</td>";
2415 if($$hash{$key}[2] eq 'ON'){
2416 $gif="/images/on.gif"
2419 $gif="/images/off.gif"
2422 <form method='post'>
2423 <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;' />
2424 <input type='hidden' name='key' value='$key' />
2425 <input type='hidden' name='config' value='$config' />
2426 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2428 <form method='post'>
2429 <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;' />
2430 <input type='hidden' name='key' value='$key' />
2431 <input type='hidden' name='config' value='$config' />
2432 <input type='hidden' name='ACTION' value='editrule' />
2434 <form method='post'>
2435 <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;' />
2436 <input type='hidden' name='key' value='$key' />
2437 <input type='hidden' name='config' value='$config' />
2438 <input type='hidden' name='ACTION' value='copyrule' />
2440 <form method='post'>
2441 <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;' />
2442 <input type='hidden' name='key' value='$key' />
2443 <input type='hidden' name='config' value='$config' />
2444 <input type='hidden' name='ACTION' value='deleterule' />
2447 if (exists $$hash{$key-1}){
2449 <form method='post'>
2450 <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;' />
2451 <input type='hidden' name='key' value='$key' />
2452 <input type='hidden' name='config' value='$config' />
2453 <input type='hidden' name='ACTION' value='moveup' />
2457 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2459 if (exists $$hash{$key+1}){
2461 <form method='post'>
2462 <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;' />
2463 <input type='hidden' name='key' value='$key' />
2464 <input type='hidden' name='config' value='$config' />
2465 <input type='hidden' name='ACTION' value='movedown' />
2466 </td></form></td></tr>
2469 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2472 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2473 print"<tr bgcolor='$color'>";
2474 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='10'>  $$hash{$key}[16]</td></tr>";
2476 if ($$hash{$key}[18] eq 'ON'){
2478 if ($$hash{$key}[18] eq 'ON'){
2480 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2481 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2482 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2483 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2484 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2485 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2486 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2487 my $weekdays=join(",",@days);
2489 print"<tr bgcolor='$color'>";
2490 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'>$weekdays   $$hash{$key}[26] - $$hash{$key}[27] </td></tr>";
2494 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2497 &Header
::closebox
();
2501 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2502 print "<b>$title1</b><br>";
2503 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>";
2507 &Header
::closebigbox
();
2508 &Header
::closepage
();