]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/forwardfw.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 # Hi folks! I hope this code is useful for all. I needed something to handle #
23 # my VPN Connections in a comfortable way. As a prerequisite i needed #
24 # something that makes sure the vpn roadwarrior are able to have a fixed #
25 # ip-address. So i developed the ccd extension for the vpn server. #
27 # Now that the ccd extension is ready i am able to develop the main request. #
28 # Any feedback is appreciated. #
31 ###############################################################################
34 no warnings
'uninitialized';
35 # enable only the following on debugging purpose
37 #use CGI::Carp 'fatalsToBrowser';
39 require '/var/ipfire/general-functions.pl';
40 require "${General::swroot}/lang.pl";
41 require "${General::swroot}/header.pl";
42 require "${General::swroot}/forward/bin/firewall-lib.pl";
44 unless (-d
"${General::swroot}/forward") { system("mkdir ${General::swroot}/forward"); }
45 unless (-e
"${General::swroot}/forward/settings") { system("touch ${General::swroot}/forward/settings"); }
46 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
47 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
48 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
49 unless (-e
"${General::swroot}/forward/dmz") { system("touch ${General::swroot}/forward/dmz"); }
53 my %defaultNetworks=();
57 my %customnetworks=();
59 my %customservicegrp=();
65 my %configoutgoingfw=();
78 my $confignet = "${General::swroot}/fwhosts/customnetworks";
79 my $confighost = "${General::swroot}/fwhosts/customhosts";
80 my $configgrp = "${General::swroot}/fwhosts/customgroups";
81 my $configsrv = "${General::swroot}/fwhosts/customservices";
82 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
83 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
84 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
85 my $configipsec = "${General::swroot}/vpn/config";
86 my $configipsecrw = "${General::swroot}/vpn/settings";
87 my $configfwdfw = "${General::swroot}/forward/config";
88 my $configinput = "${General::swroot}/forward/input";
89 my $configoutgoing = "${General::swroot}/forward/outgoing";
90 my $configdmz = "${General::swroot}/forward/dmz";
91 my $configovpn = "${General::swroot}/ovpn/settings";
92 my $fwoptions = "${General::swroot}/optionsfw/settings";
95 my $ipgrp="${General::swroot}/outgoing/groups";
99 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
100 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
101 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
102 &General
::readhash
($fwoptions, \
%optionsfw);
104 &Header
::showhttpheaders
();
105 &Header
::getcgihash
(\
%fwdfwsettings);
106 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
107 &Header
::openbigbox
('100%', 'center',$errormessage);
110 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
112 my $MODE = $fwdfwsettings{'POLICY'};
113 my $MODE1 = $fwdfwsettings{'POLICY1'};
115 $fwdfwsettings{'POLICY'} = "$MODE";
116 $fwdfwsettings{'POLICY1'} = "$MODE1";
117 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
120 if ($fwdfwsettings{'ACTION'} eq 'saverule')
122 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
123 &General
::readhasharray
("$configinput", \
%configinputfw);
124 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
126 $errormessage=&checksource
;
127 if(!$errormessage){&checktarget
;}
128 if(!$errormessage){&checkrule
;}
129 #check if manual ip (source) is orange network
130 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
131 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
132 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
137 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
138 $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{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on'){
147 $fwdfwsettings{'config'}=$configdmz;
148 $fwdfwsettings{'chain'} = 'FORWARDFW';
149 my $maxkey=&General
::findhasharraykey
(\
%configdmzfw);
150 #check if we have an identical rule already
151 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
152 foreach my $key (sort keys %configdmzfw){
153 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'}"
154 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]"){
155 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
156 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
158 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
159 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
161 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
162 $fwdfwsettings{'nosave'} = 'on';
167 #check Rulepos on new Rule
168 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
169 $fwdfwsettings{'oldrulenumber'}=$maxkey;
170 foreach my $key (sort keys %configdmzfw){
171 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'}"
172 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]"){
173 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
177 #check if we just close a rule
178 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'} ) {
179 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
181 $fwdfwsettings{'nosave2'} = 'on';
184 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
185 if ($fwdfwsettings{'nobase'} ne 'on'){
186 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
188 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
189 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
190 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
191 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
192 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
193 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
195 if($fwdfwsettings{'nosave2'} ne 'on'){
196 &saverule
(\
%configdmzfw,$configdmz);
199 }elsif($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
200 $fwdfwsettings{'config'}=$configinput;
201 $fwdfwsettings{'chain'} = 'INPUTFW';
202 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
203 #check if we have an identical rule already
204 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
205 foreach my $key (sort keys %configinputfw){
206 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'}"
207 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]"){
208 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
209 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
211 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
212 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
214 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
215 $fwdfwsettings{'nosave'} = 'on';
220 #check Rulepos on new Rule
221 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
222 $fwdfwsettings{'oldrulenumber'}=$maxkey;
223 foreach my $key (sort keys %configinputfw){
224 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'}"
225 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]"){
226 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
230 #check if we just close a rule
231 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'} ) {
232 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
234 $fwdfwsettings{'nosave2'} = 'on';
237 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
238 if ($fwdfwsettings{'nobase'} ne 'on'){
239 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
241 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
242 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
243 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
244 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
245 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
246 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
248 if($fwdfwsettings{'nosave2'} ne 'on'){
249 &saverule
(\
%configinputfw,$configinput);
251 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
252 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
253 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
254 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
255 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
256 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
257 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
258 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
259 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
260 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
261 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
262 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
263 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
264 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
265 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
266 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
268 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
269 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
270 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
271 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
272 }elsif($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' ){
274 $fwdfwsettings{'config'}=$configoutgoing;
275 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
276 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
277 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
278 foreach my $key (sort keys %configoutgoingfw){
279 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'}"
280 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]"){
281 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
282 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
284 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
285 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
287 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
288 $fwdfwsettings{'nosave'} = 'on';
293 #check Rulepos on new Rule
294 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
295 print"CHECK OUTGOING DOPPELTE REGEL<br>";
296 $fwdfwsettings{'oldrulenumber'}=$maxkey;
297 foreach my $key (sort keys %configoutgoingfw){
298 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'}"
299 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]"){
300 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
304 #check if we just close a rule
305 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'} ) {
306 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
307 $fwdfwsettings{'nosave2'} = 'on';
312 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
313 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
314 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
315 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
316 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
317 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
318 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
319 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
321 if ($fwdfwsettings{'nobase'} eq 'on'){
322 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
324 if ($fwdfwsettings{'nosave2'} ne 'on'){
325 &saverule
(\
%configoutgoingfw,$configoutgoing);
329 $fwdfwsettings{'config'}=$configfwdfw;
330 $fwdfwsettings{'chain'} = 'FORWARDFW';
331 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
332 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
333 #check if we have an identical rule already
334 foreach my $key (sort keys %configfwdfw){
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 "$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}[18],$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]"){
337 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
338 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
340 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
341 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
343 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
344 $fwdfwsettings{'nosave'} = 'on';
349 #check Rulepos on new Rule
350 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
351 $fwdfwsettings{'oldrulenumber'}=$maxkey;
352 foreach my $key (sort keys %configfwdfw){
353 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'}"
354 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}[18],$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]"){
355 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
359 #check if we just close a rule
360 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'} ) {
361 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
362 $fwdfwsettings{'nosave2'} = 'on';
367 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
368 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
369 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
370 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
371 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
372 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
373 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
374 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
376 if ($fwdfwsettings{'nobase'} eq 'on'){
377 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
379 if ($fwdfwsettings{'nosave2'} ne 'on'){
380 &saverule
(\
%configfwdfw,$configfwdfw);
382 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
383 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
384 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
385 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
386 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
387 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
388 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
389 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
390 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
391 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
392 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
393 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
394 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
395 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
396 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
397 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
399 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
400 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
401 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
402 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
407 if($fwdfwsettings{'nosave2'} ne 'on'){
413 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
415 if($fwdfwsettings{'poltype'} eq 'forward'){
416 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
417 foreach my $key (sort keys %configfwdfw){
418 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
419 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
420 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
422 &General
::readhasharray
("$configinput", \
%configinputfw);
423 foreach my $key (sort keys %configinputfw){
424 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
425 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
426 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
429 system("rm ${General::swroot}/forward/config");
430 system("rm ${General::swroot}/forward/input");
431 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
432 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
433 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
434 my $MODE1=$fwdfwsettings{'POLICY1'};
436 $fwdfwsettings{'POLICY'}='MODE2';
437 $fwdfwsettings{'POLICY1'}=$MODE1;
438 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
441 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
442 foreach my $key (sort keys %configoutgoingfw){
443 &checkcounter
($configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],,);
444 &checkcounter
($configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],,);
445 &checkcounter
($configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],,);
447 system("rm ${General::swroot}/forward/outgoing");
448 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
449 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
450 my $MODE=$fwdfwsettings{'POLICY'};
452 $fwdfwsettings{'POLICY'}=$MODE;
453 $fwdfwsettings{'POLICY1'}='MODE2';
454 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
458 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
462 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
465 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
466 foreach my $key (sort keys %togglehash){
467 if ($key eq $fwdfwsettings{'key'}){
468 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
471 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
475 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
478 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
479 foreach my $key (sort keys %togglehash){
480 if ($key eq $fwdfwsettings{'key'}){
481 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
484 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
488 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
493 if ($fwdfwsettings{'ACTION'} eq 'editrule')
495 $fwdfwsettings{'updatefwrule'}='on';
498 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
502 if ($fwdfwsettings{'ACTION'} eq 'moveup')
507 if ($fwdfwsettings{'ACTION'} eq 'movedown')
512 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
514 $fwdfwsettings{'copyfwrule'}='on';
515 #$fwdfwsettings{'updatefwrule'}='on';
518 if ($fwdfwsettings{'ACTION'} eq '')
526 if (-f
"${General::swroot}/forward/reread"){
527 print "<table border='0'><form method='post'><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: red; font-weight: bold;'>$Lang::tr{'fwhost reread'}</td></tr></table></form><hr><br>";
529 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
530 print "<form method='post'>";
531 print "<table border='0'>";
532 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
533 print"</tr></table></form><hr>";
539 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
540 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
541 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){ $selected{'POLICY1'}{'MODE1'} = 'selected'; } else { $selected{'POLICY1'}{'MODE1'} = ''; }
542 if ($fwdfwsettings{'POLICY1'} eq 'MODE2'){ $selected{'POLICY1'}{'MODE2'} = 'selected'; } else { $selected{'POLICY1'}{'MODE2'} = ''; }
546 &Header
::openbox
('100%', 'center', $Lang::tr
{'fwdfw pol title'});
548 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
549 <table width='100%' border='0'>
550 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>FORWARD </td></tr>
551 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text'}</td></tr>
552 <tr><td colspan='3'><hr /></td></tr>
553 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
554 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
555 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
556 <input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td><td width='45%' align='right'>
559 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='forward' /></td></tr>";
560 print "</table></form>";
563 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
564 <table width='100%' border='0'>
565 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>OUTGOING </td></tr>
566 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text1'}</td></tr>
567 <tr><td colspan='3'><hr /></td></tr>
568 <tr><td width='15%' align='left'> <select name='POLICY1' style="width: 100px">
569 <option value='MODE1' $selected{'POLICY1'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
570 <option value='MODE2' $selected{'POLICY1'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
571 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td><td width='45%' align='right'>
574 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='outgoing' /></tr>";
575 print "</table></form>";
581 $fwdfwsettings{'updatefwrule'}='';
582 $fwdfwsettings{'config'}=$oldchain;
583 $fwdfwsettings{'nobase'}='on';
585 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
586 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
592 #check ip-address if manual
593 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
594 #check if ip with subnet
595 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
596 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
597 $subnet = &General
::iporsubtocidr
($subnet);
598 $fwdfwsettings{'isip'}='on';
601 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
602 $ip=$fwdfwsettings{'src_addr'};
604 $fwdfwsettings{'isip'}='on';
607 if ($fwdfwsettings{'isip'} ne 'on'){
608 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
610 if ($fwdfwsettings{'isip'} eq 'on'){
611 #check and form valid IP
612 $ip=&General
::ip2dec
($ip);
613 $ip=&General
::dec2ip
($ip);
614 #check if net or broadcast
615 my @tmp= split (/\./,$ip);
616 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
618 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
620 $fwdfwsettings{'src_addr'}="$ip/$subnet";
622 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
623 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
626 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
627 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
629 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
630 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
631 return $errormessage;
635 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
637 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
638 $fwdfwsettings{'SRC_PORT'}='';
639 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
640 foreach my $key (keys %icmptypes){
641 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
642 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
645 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
646 $fwdfwsettings{'SRC_PORT'}='';
647 $fwdfwsettings{'ICMP_TYPES'}='';
648 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
649 $fwdfwsettings{'SRC_PORT'}='';
650 $fwdfwsettings{'ICMP_TYPES'}='';
651 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
652 $fwdfwsettings{'SRC_PORT'}='';
653 $fwdfwsettings{'ICMP_TYPES'}='';
654 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
655 $fwdfwsettings{'ICMP_TYPES'}='';
657 $fwdfwsettings{'ICMP_TYPES'}='';
658 $fwdfwsettings{'SRC_PORT'}='';
659 $fwdfwsettings{'PROT'}='';
662 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
663 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
667 if ($_ =~ /^(\d+)\:(\d+)$/) {
669 #change dashes with :
672 push(@values,"1:65535");
675 if ($_ =~ /^(\D)\:(\d+)$/) {
676 push(@values,"1:$2");
679 if ($_ =~ /^(\d+)\:(\D)$/) {
680 push(@values,"$1:65535");
683 $errormessage .= &General
::validportrange
($_, 'destination');
688 if (&General
::validport
($_)){
695 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
696 return $errormessage;
703 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
704 #check if ip with subnet
705 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
706 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
707 $subnet = &General
::iporsubtocidr
($subnet);
710 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
711 $ip=$fwdfwsettings{'tgt_addr'};
714 #check and form valid IP
715 $ip=&General
::ip2dec
($ip);
716 $ip=&General
::dec2ip
($ip);
718 ##check if net or broadcast
719 #my @tmp= split (/\./,$ip);
720 #if ($tmp[3] eq "0" || ($tmp[3] eq "255"))
722 #$errormessage=$Lang::tr{'fwhost err hostip'}."<br>";
724 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
726 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
727 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
730 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
731 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
732 return $errormessage;
736 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
739 if ($fwdfwsettings{'USESRV'} eq 'ON'){
740 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
741 $fwdfwsettings{'TGT_PROT'}='';
742 $fwdfwsettings{'ICMP_TGT'}='';
744 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
745 $fwdfwsettings{'TGT_PROT'}='';
746 $fwdfwsettings{'ICMP_TGT'}='';
747 #check target service
748 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
749 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
752 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
753 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
754 if ($fwdfwsettings{'TGT_PORT'} ne ''){
755 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
759 if ($_ =~ /^(\d+)\:(\d+)$/) {
761 #change dashes with :
764 push(@values,"1:65535");
767 if ($_ =~ /^(\D)\:(\d+)$/) {
768 push(@values,"1:$2");
771 if ($_ =~ /^(\d+)\:(\D)$/) {
772 push(@values,"$1:65535");
775 $errormessage .= &General
::validportrange
($_, 'destination');
780 if (&General
::validport
($_)){
787 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
789 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
790 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
791 $fwdfwsettings{'TGT_PORT'} = '';
792 $fwdfwsettings{'ICMP_TGT'} = '';
793 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
794 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
795 $fwdfwsettings{'TGT_PORT'} = '';
796 $fwdfwsettings{'ICMP_TGT'}='';
797 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
798 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
799 $fwdfwsettings{'TGT_PORT'} = '';
800 $fwdfwsettings{'ICMP_TGT'}='';
801 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
802 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
803 $fwdfwsettings{'TGT_PORT'} = '';
804 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
805 foreach my $key (keys %icmptypes){
807 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
808 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
816 if ($fwdfwsettings{'USESRV'} ne 'ON'){
817 $fwdfwsettings{'grp3'}='';
818 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
819 $fwdfwsettings{'TGT_PROT'}='';
820 $fwdfwsettings{'ICMP_TGT'}='';
823 if($fwdfwsettings{'TIME'} eq 'ON'){
824 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 ''){
825 $errormessage=$Lang::tr
{'fwdfw err time'};
828 return $errormessage;
833 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
834 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
836 #check if source and target identical
837 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
838 $errormessage.=$Lang::tr
{'fwdfw err same'};
839 return $errormessage;
842 #get source and targetip address if possible
843 my ($sip,$scidr,$tip,$tcidr);
844 ($sip,$scidr)=&get_ip
("src","grp1");
845 ($tip,$tcidr)=&get_ip
("tgt","grp2");
847 #check same iprange in source and target
848 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
849 my $networkip1=&General
::getnetworkip
($sip,$scidr);
850 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
851 if ($scidr gt $tcidr){
852 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
853 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
855 }elsif($scidr eq $tcidr && $scidr eq '32'){
856 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
857 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
858 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
859 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
860 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
863 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
864 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
869 #check source and destination protocol if manual
870 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
871 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
872 $errormessage.=$Lang::tr
{'fwdfw err prot'};
874 #check source and destination protocol if source manual and dest servicegrp
875 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
876 &General
::readhasharray
("$configsrv", \
%customservice);
877 foreach my $key (sort keys %customservice){
878 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
879 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
880 $errormessage.=$Lang::tr
{'fwdfw err prot'};
890 my ($base1,$val1,$base2,$val2) = @_;
892 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
893 &dec_counter
($confignet,\
%customnetwork,$val1);
894 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
895 &dec_counter
($confighost,\
%customhost,$val1);
896 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
897 &dec_counter
($configgrp,\
%customgrp,$val1);
898 }elsif($base1 eq 'cust_srv'){
899 &dec_counter
($configsrv,\
%customservice,$val1);
900 }elsif($base1 eq 'cust_srvgrp'){
901 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
904 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
905 &inc_counter
($confignet,\
%customnetwork,$val2);
906 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
907 &inc_counter
($confighost,\
%customhost,$val2);
908 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
909 &inc_counter
($configgrp,\
%customgrp,$val2);
910 }elsif($base2 eq 'cust_srv'){
911 &inc_counter
($configsrv,\
%customservice,$val2);
912 }elsif($base2 eq 'cust_srvgrp'){
913 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
919 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
920 foreach my $key (sort {$a <=> $b} keys %delhash){
921 if ($key == $fwdfwsettings{'key'}){
922 #check hosts/net and groups
923 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
924 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
925 #check services and groups
926 if ($delhash{$key}[11] eq 'ON'){
927 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
930 if ($key >= $fwdfwsettings{'key'}) {
932 if (exists $delhash{$next}) {
933 foreach my $i (0 .. $#{$delhash{$next}}) {
934 $delhash{$key}[$i] = $delhash{$next}[$i];
939 # Remove the very last entry.
940 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
941 delete $delhash{$last_key};
943 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
946 if($fwdfwsettings{'nobase'} ne 'on'){
953 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
954 foreach my $key (sort keys %configfwdfw){
956 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
959 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
968 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
969 &General
::readhasharray
($config, \
%hash);
970 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
971 if($hash{$key}[0] eq $val){
972 $pos=$#{$hash{$key}};
973 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
976 &General
::writehasharray
($config, \
%hash);
981 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
982 print "<class name='base'>$errormessage\n";
983 print " </class>\n";
993 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
994 if($hash{$key}[0] eq $val){
995 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
997 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1007 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1008 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1009 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1010 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1011 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1012 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1013 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1014 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1015 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1016 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1017 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1018 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1019 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1020 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1021 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1022 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1023 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1024 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1026 <table width='100%' border='0'>
1027 <tr><td width='50%' valign='top'>
1028 <table width='100%' border='0'>
1029 <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><select name='std_net_$srctgt' style='min-width:185px;'>
1031 foreach my $network (sort keys %defaultNetworks)
1033 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1034 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1035 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1036 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1037 print ">$network</option>";
1039 print"</select></td></tr>";
1041 if (! -z
$confignet){
1042 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><select name='cust_net_$srctgt' style='min-width:185px;'>";
1043 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1044 print"</select></td>";
1047 if (! -z
$confighost){
1048 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><select name='cust_host_$srctgt' style='min-width:185px;'>";
1049 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1050 print"</select></td>";
1053 if (! -z
$configgrp){
1054 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><select name='cust_grp_$srctgt' style='min-width:185px;'>";
1055 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1056 if($helper ne $customgrp{$key}[0]){
1058 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1059 print ">$customgrp{$key}[0]</option>";
1061 $helper=$customgrp{$key}[0];
1063 print"</select></td>";
1065 #End left table. start right table (vpn)
1066 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1068 if( ! -z
$configccdnet){
1069 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%'><select name='ovpn_net_$srctgt' style='min-width:185px;'>";
1070 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1071 print"</select></td></tr>";
1074 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1075 if ($ccdhost{$key}[33] ne ''){
1076 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%'><select name='ovpn_host_$srctgt' style='min-width:185px;'>" if ($show eq '');
1078 print "<option value='$ccdhost{$key}[1]'";
1079 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1080 print ">$ccdhost{$key}[1]</option>";
1083 if ($show eq '1'){$show='';print"</select></td></tr>";}
1085 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1086 if ($ccdhost{$key}[3] eq 'net'){
1087 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 ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_n2n_$srctgt' style='min-width:185px;'>" if ($show eq '');
1089 print "<option value='$ccdhost{$key}[1]'";
1090 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1091 print ">$ccdhost{$key}[1]</option>";
1094 if ($show eq '1'){$show='';print"</select></td></tr>";}
1096 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1097 if ($ipsecconf{$key}[3] eq 'net'){
1098 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><select name='ipsec_net_$srctgt' style='min-width:185px;'>" if ($show eq '');
1101 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1102 print ">$ipsecconf{$key}[1]</option>";
1105 if ($show eq '1'){$show='';print"</select></td></tr>";}
1107 print"</tr></table>";
1108 print"</td></tr></table><br>";
1116 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1117 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1118 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1119 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1120 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1121 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1122 $a=$netsettings{'GREEN_NETADDRESS'};
1123 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1124 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1125 $a=$netsettings{'ORANGE_NETADDRESS'};
1126 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1127 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1128 $a=$netsettings{'BLUE_NETADDRESS'};
1129 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1130 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1131 &General
::readhash
("$configovpn",\
%ovpnsettings);
1132 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1133 $b=&General
::iporsubtocidr
($b);
1135 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1136 &General
::readhasharray
("$confignet", \
%customnetwork);
1137 foreach my $key (keys %customnetwork){
1138 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1139 $a=$customnetwork{$key}[1];
1140 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1143 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1144 &General
::readhasharray
("$confighost", \
%customhost);
1145 foreach my $key (keys %customhost){
1146 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1147 if ($customhost{$key}[1] eq 'ip'){
1148 ($a,$b)=split (/\//,$customhost{$key}[2]);
1149 $b=&General
::iporsubtocidr
($b);
1151 if ($grp eq 'grp2'){
1152 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1164 &General
::setup_default_networks
(\
%defaultNetworks);
1165 foreach my $network (sort keys %defaultNetworks)
1167 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1172 my %hash=%{(shift)};
1174 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1175 $hash{$key}[10]=~ s/\|/,/g;
1176 print": $hash{$key}[10]";
1177 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1178 print": <br>$hash{$key}[9] ";
1183 my %hash=%{(shift)};
1187 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1188 if($hash{$key}[14] eq 'cust_srv'){
1189 &General
::readhasharray
("$configsrv", \
%customservice);
1190 foreach my $i (sort keys %customservice){
1191 if($customservice{$i}[0] eq $hash{$key}[15]){
1192 $service = $customservice{$i}[0];
1195 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1196 $service=$hash{$key}[15];
1197 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1198 $hash{$key}[15]=~ s/\|/,/g;
1199 $service=$hash{$key}[15];
1204 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1205 print":<br>$hash{$key}[13]";
1208 sub get_serviceports
1212 &General
::readhasharray
("$configsrv", \
%customservice);
1213 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1217 if($type eq 'service'){
1218 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1219 if ($customservice{$key}[0] eq $name){
1220 $protocols=$customservice{$key}[2];
1223 }elsif($type eq 'group'){
1224 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1225 if ($customservicegrp{$key}[0] eq $name){
1226 foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1227 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1228 if($customservice{$key1}[2] eq 'TCP'){$tcp='TCP';}else{$udp='UDP';}
1234 if($tcp && $udp){$protocols="TCP,UDP";
1235 }elsif($tcp){$protocols.="TCP";
1236 }elsif($udp){$protocols.="UDP";}
1244 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1246 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'){
1247 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1250 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1251 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1255 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1256 foreach my $key (sort keys %$hash){
1257 if ($$hash{$key}[0] eq $val){
1258 $val=$$hash{$key}[2];
1263 foreach my $alias (sort keys %aliases)
1265 if ($val eq $alias){
1266 $tdcolor="style='border: 2px solid red;'";
1271 if ($val eq 'GREEN'){
1272 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1273 }elsif ($val eq 'ORANGE'){
1274 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1275 }elsif ($val eq 'BLUE'){
1276 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1277 }elsif ($val eq 'RED'){
1278 $tdcolor="style='border: 1px solid $Header::colourred;'";
1279 }elsif ($val eq 'IPFire' ){
1280 $tdcolor="style='border: 1px solid $Header::colourred;'";
1281 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1282 my ($sip,$scidr) = split ("/",$val);
1283 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1284 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1286 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1287 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1289 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1290 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1292 }elsif ($val eq 'Default IP'){
1293 $tdcolor="style='border: 1px solid red;'";
1302 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1303 print "<class name='base'>$hint\n";
1304 print " </class>\n";
1305 &Header
::closebox
();
1312 my %hash=%{(shift)};
1316 &General
::readhasharray
($config, \
%hash);
1317 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1318 if($hash{$key}[0] eq $val){
1319 $pos=$#{$hash{$key}};
1320 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1323 &General
::writehasharray
($config, \
%hash);
1328 &General
::setup_default_networks
(\
%defaultNetworks);
1329 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1330 #read all configfiles
1331 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1332 &General
::readhasharray
("$confignet", \
%customnetwork);
1333 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1334 &General
::readhasharray
("$confighost", \
%customhost);
1335 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1336 &General
::readhasharray
("$configgrp", \
%customgrp);
1337 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1338 &General
::get_aliases
(\
%aliases);
1342 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1343 my $config=$fwdfwsettings{'config'};
1345 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1346 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1347 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1348 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1349 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1350 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1351 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1352 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1353 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1354 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1355 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1356 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1357 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1358 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1359 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1360 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1361 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1362 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1363 #check if update and get values
1364 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1365 &General
::readhasharray
("$config", \
%hash);
1366 foreach my $key (sort keys %hash){
1368 if ($key eq $fwdfwsettings{'key'}){
1369 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1370 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1371 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1372 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1373 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1374 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1375 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1376 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1377 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1378 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1379 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1380 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1381 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1382 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1383 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1384 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1385 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1386 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1387 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1388 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1389 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1390 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1391 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1392 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1393 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1394 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1395 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1396 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1397 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1398 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1399 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1400 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1401 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1402 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1403 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1404 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1405 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1406 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1407 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1408 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1409 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1410 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1411 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1412 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1413 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1414 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1417 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1418 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1419 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1420 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1421 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1422 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1423 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1424 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1425 #check if manual ip (source) is orange network
1426 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1427 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1428 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1429 $fwdfwsettings{'oldorange'} ='on';
1433 $fwdfwsettings{'ACTIVE'}='ON';
1434 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1435 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1436 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1437 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1438 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1439 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1440 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1441 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1442 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1443 #check if manual ip (source) is orange network
1444 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1445 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1446 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1447 $fwdfwsettings{'oldorange'} ='on';
1451 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1454 <form method="post">
1456 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1458 foreach ("ACCEPT","DROP","REJECT")
1460 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1462 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1463 print">$_</option>";
1465 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1466 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1469 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1471 print"<option selected>$_</option>";
1473 print"<option>$_</option>";
1477 print"</select></td></tr></table><hr>";
1479 &Header
::closebox
();
1480 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1481 #------SOURCE-------------------------------------------------------
1483 <table width='100%' border='0'>
1484 <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'}' ></td></tr>
1485 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1488 &gen_dd_block
('src','grp1');
1491 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1492 <table width='100%' border='0'>
1493 <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>
1494 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1496 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1498 if ($_ eq $fwdfwsettings{'PROT'})
1500 print"<option selected>$_</option>";
1502 print"<option>$_</option>";
1505 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1507 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1508 <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;'>
1510 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1511 print"<option>All ICMP-Types</option>";
1512 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1513 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1514 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1516 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1520 </select></td></tr></table><br><hr>
1522 &Header
::closebox
();
1524 #---TARGET------------------------------------------------------
1525 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1527 <table width='100%' border='0'>
1528 <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td colspan='2'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16'><td><input type='radio' name='grp2' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>IPFire ($Lang::tr{'external access'})</b></td><td align='right'><select name='ipfire' style='min-width:185px;'>
1530 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1532 foreach my $alias (sort keys %aliases)
1534 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1538 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1540 &gen_dd_block
('tgt','grp2');
1542 <b>$Lang::tr{'fwhost attention'}:</b><br>
1543 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1544 <table width='100%' border='0'>
1545 <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;' >
1547 &General
::readhasharray
("$configsrv", \
%customservice);
1548 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1550 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1551 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1555 <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;' >
1557 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1559 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1560 if ($helper ne $customservicegrp{$key}[0]){
1562 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1563 print">$customservicegrp{$key}[0]</option>";
1565 $helper=$customservicegrp{$key}[0];
1569 <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'>
1571 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1573 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1575 print"<option selected>$_</option>";
1577 print"<option>$_</option>";
1580 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1582 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1583 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT' style='min-width:230px;'>
1585 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1586 print"<option>All ICMP-Types</option>";
1587 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1588 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1589 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1591 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1600 #---Activate/logging/remark-------------------------------------
1601 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1603 <table width='100%' border='0'>
1604 <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>
1606 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1607 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1608 for (my $count =1; $count <= $sum; $count++){
1609 print"<option value='$count' ";
1610 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1611 print">$count</option>";
1613 print"</select></td></tr>";
1615 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1619 </table><table width='100%'>
1620 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1621 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1624 &Header
::closebox
();
1625 #---ADD TIMEFRAME-----------------------------------------------
1626 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1628 <table width='70%' border='0'>
1629 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1630 <tr><td colspan='7'> </td></tr>
1632 <td align='left'>$Lang::tr{'time'}:</td>
1633 <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>
1634 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1635 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1638 <td align='right'></td>
1639 <td width='30%' align='left'>
1640 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1641 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1642 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1643 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1644 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1645 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1646 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1648 <td><select name='TIME_FROM'>
1650 for (my $i=0;$i<=23;$i++) {
1651 $i = sprintf("%02s",$i);
1652 for (my $j=0;$j<=45;$j+=15) {
1653 $j = sprintf("%02s",$j);
1654 my $time = $i.":".$j;
1655 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1660 <td><select name='TIME_TO'>
1662 for (my $i=0;$i<=23;$i++) {
1663 $i = sprintf("%02s",$i);
1664 for (my $j=0;$j<=45;$j+=15) {
1665 $j = sprintf("%02s",$j);
1666 my $time = $i.":".$j;
1667 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1674 #---ACTION------------------------------------------------------
1675 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1677 <table border='0' width='100%'>
1678 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1679 <input type='hidden' name='config' value='$config' >
1680 <input type='hidden' name='ACTION' value='saverule' >
1681 </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>
1686 <table border='0' width='100%'>
1687 <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'}'>
1688 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1689 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1690 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1691 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1692 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1693 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1694 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1695 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1696 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1697 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1698 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1699 <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>
1703 &Header
::closebox
();
1709 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1710 foreach my $key (sort keys %uphash){
1711 if ($key eq $fwdfwsettings{'key'}) {
1713 if (exists $uphash{$last}){
1715 foreach my $y (0 .. $#{$uphash{$last}}) {
1716 $tmp{0}[$y] = $uphash{$last}[$y];
1718 #copy active rule to last
1719 foreach my $i (0 .. $#{$uphash{$last}}) {
1720 $uphash{$last}[$i] = $uphash{$key}[$i];
1722 #copy saved rule to actual position
1723 foreach my $x (0 .. $#{$tmp{0}}) {
1724 $uphash{$key}[$x] = $tmp{0}[$x];
1729 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1736 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1737 foreach my $key (sort keys %downhash){
1738 if ($key eq $fwdfwsettings{'key'}) {
1739 my $next = $key + 1;
1740 if (exists $downhash{$next}){
1742 foreach my $y (0 .. $#{$downhash{$next}}) {
1743 $tmp{0}[$y] = $downhash{$next}[$y];
1745 #copy active rule to next
1746 foreach my $i (0 .. $#{$downhash{$next}}) {
1747 $downhash{$next}[$i] = $downhash{$key}[$i];
1749 #copy saved rule to actual position
1750 foreach my $x (0 .. $#{$tmp{0}}) {
1751 $downhash{$key}[$x] = $tmp{0}[$x];
1756 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1761 if (!-f
"${General::swroot}/forward/reread"){
1762 system("touch ${General::swroot}/forward/reread");
1763 system("touch ${General::swroot}/fwhosts/reread");
1768 system("/usr/local/bin/forwardfwctrl");
1769 if ( -f
"${General::swroot}/forward/reread"){
1770 system("rm ${General::swroot}/forward/reread");
1771 system("rm ${General::swroot}/fwhosts/reread");
1778 &General
::readhasharray
("$config", $hash);
1779 if (!$errormessage){
1780 #check if we change a DMZ to an outgoing
1781 if( ($fwdfwsettings{'oldgrp1b'} eq 'ORANGE' || $fwdfwsettings{'oldorange'} eq 'on') && $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1782 &changerule
($configdmz);
1785 #check if we change a DMZ to an external access
1786 elsif( $fwdfwsettings{'oldgrp1b'} eq 'ORANGE' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE' && $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1787 &changerule
($configdmz);
1790 #check if we change an external access rule to a outgoing
1791 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'oldgrp1b'} ne 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1792 &changerule
($configinput);
1795 #check if we change an external access rule to a DMZ
1796 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1797 &changerule
($configinput);
1800 #check if we change an outgoing rule to a external access
1801 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1802 &changerule
($configoutgoing);
1805 #check if we change an outgoing rule to a DMZ
1806 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1807 &changerule
($configoutgoing);
1810 #check if we change an forward rule to an external access
1811 elsif( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1812 &changerule
($configfwdfw);
1815 #check if we change an forward rule to an DMZ
1816 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && ($fwdfwsettings{'oldgrp1b'} ne 'ORANGE' && $fwdfwsettings{'oldorange'} ne 'on') && $fwdfwsettings{'updatefwrule'} eq 'on'){
1817 &changerule
($configfwdfw);
1820 #check if we change an forward rule to an outgoing
1821 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'oldgrp1b'} ne 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1822 &changerule
($configfwdfw);
1825 #check if we change a DMZ to a forward
1826 elsif( ($fwdfwsettings{'oldgrp1b'} eq 'ORANGE' || $fwdfwsettings{'oldorange'} eq 'on') && ($fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE' && $checkorange ne 'on') && $fwdfwsettings{'updatefwrule'} eq 'on'){
1827 &changerule
($configdmz);
1830 #check if we change an external access rule to a forward
1831 elsif( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1832 &changerule
($configinput);
1835 #check if we change an outgoing rule to a forward
1836 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1837 &changerule
($configoutgoing);
1840 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1841 my $key = &General
::findhasharraykey
($hash);
1842 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1843 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1844 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1845 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1846 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1847 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1848 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1849 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1850 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1851 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1852 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1853 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1854 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1855 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1856 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1857 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1858 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1859 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1860 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1861 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1862 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1863 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1864 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1865 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1866 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1867 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1868 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1869 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1870 &General
::writehasharray
("$config", $hash);
1872 foreach my $key (sort {$a <=> $b} keys %$hash){
1873 if($key eq $fwdfwsettings{'key'}){
1874 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1875 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1876 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1877 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1878 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1879 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1880 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1881 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1882 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1883 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1884 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1885 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1886 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1887 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1888 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1889 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1890 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1891 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1892 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1893 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1894 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1895 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1896 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1897 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1898 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1899 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1900 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1901 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1906 &General
::writehasharray
("$config", $hash);
1907 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
1909 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1910 for (my $z=0;$z<$val;$z++){
1911 foreach my $key (sort {$a <=> $b} keys %$hash){
1912 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1914 if (exists $$hash{$last}){
1916 foreach my $y (0 .. $#{$$hash{$last}}) {
1917 $tmp{0}[$y] = $$hash{$last}[$y];
1919 #copy active rule to last
1920 foreach my $i (0 .. $#{$$hash{$last}}) {
1921 $$hash{$last}[$i] = $$hash{$key}[$i];
1923 #copy saved rule to actual position
1924 foreach my $x (0 .. $#{$tmp{0}}) {
1925 $$hash{$key}[$x] = $tmp{0}[$x];
1930 $fwdfwsettings{'oldrulenumber'}--;
1932 &General
::writehasharray
("$config", $hash);
1934 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
1936 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1937 for (my $z=0;$z<$val;$z++){
1938 foreach my $key (sort {$a <=> $b} keys %$hash){
1939 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1940 my $next = $key + 1;
1941 if (exists $$hash{$next}){
1943 foreach my $y (0 .. $#{$$hash{$next}}) {
1944 $tmp{0}[$y] = $$hash{$next}[$y];
1946 #copy active rule to next
1947 foreach my $i (0 .. $#{$$hash{$next}}) {
1948 $$hash{$next}[$i] = $$hash{$key}[$i];
1950 #copy saved rule to actual position
1951 foreach my $x (0 .. $#{$tmp{0}}) {
1952 $$hash{$key}[$x] = $tmp{0}[$x];
1957 $fwdfwsettings{'oldrulenumber'}++;
1959 &General
::writehasharray
("$config", $hash);
1966 # Checks a hostname against RFC1035
1969 # Each part should be at least two characters in length
1970 # but no more than 63 characters
1971 if (length ($remark) < 1 || length ($remark) > 255) {
1973 # Only valid characters are a-z, A-Z, 0-9 and -
1974 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
1976 # First character can only be a letter or a digit
1977 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1979 # Last character can only be a letter or a digit
1980 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
1986 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1987 &viewtablenew
(\
%configdmzfw,$configdmz,$Lang::tr
{'fwdfw rules'},"DMZ" );
1988 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
1989 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1990 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
1999 &General
::get_aliases
(\
%aliases);
2000 &General
::readhasharray
("$confighost", \
%customhost);
2001 &General
::readhasharray
("$config", $hash);
2003 &Header
::openbox
('100%', 'left',$title);
2011 print"<b>$title1</b><br>";
2012 print"<table width='100%' cellspacing='0' cellpadding='0'>";
2013 print"<tr><td align='center'><b>#</td><td ></td><td align='center'><b>$Lang::tr{'fwdfw source'}</td><td><b>Log</td><td align='center'><b>$Lang::tr{'fwdfw target'}</td><td align='center'><b>$Lang::tr{'protocol'}</b></td><td align='center'><b>$Lang::tr{'fwdfw time'}</td><td align='center' colspan='6'><b>$Lang::tr{'fwdfw action'}</td></tr>";
2014 foreach my $key (sort {$a <=> $b} keys %$hash){
2017 #check if vpn hosts/nets have been deleted
2018 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2019 push (@tmpsrc,$$hash{$key}[4]);
2021 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2022 push (@tmpsrc,$$hash{$key}[6]);
2024 foreach my $host (@tmpsrc){
2025 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2026 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2028 &disable_rule
($key);
2031 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2032 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2034 &disable_rule
($key);
2037 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2038 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2040 &disable_rule
($key);
2043 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2044 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2046 &disable_rule
($key);
2050 #$$hash{$key}[3]='';
2051 #$$hash{$key}[5]='';
2053 $$hash{'ACTIVE'}=$$hash{$key}[2];
2055 if($coloryellow eq 'on'){
2056 print"<tr bgcolor='$color{'color14'}' >";
2058 }elsif($coloryellow eq ''){
2060 $color="$color{'color22'}";
2063 $color="$color{'color20'}";
2066 print"<tr bgcolor='$color' >";
2068 <td align='right' width='15'><b>$key</b></td>
2070 if ($$hash{$key}[0] eq 'ACCEPT'){
2073 $rulecolor=$color{'color17'};
2074 }elsif($$hash{$key}[0] eq 'DROP'){
2077 $rulecolor=$color{'color25'};
2078 }elsif($$hash{$key}[0] eq 'REJECT'){
2081 $rulecolor=$color{'color16'};
2083 print"<td bgcolor='$rulecolor' align='center' width='20'><span title='$tooltip'><b>$ruletype</b></span></td>";
2084 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2085 print"<td align='center' width='160' $tdcolor>";
2086 if ($$hash{$key}[3] eq 'std_net_src'){
2087 print &get_name
($$hash{$key}[4]);
2089 print $$hash{$key}[4];
2092 &getsrcport
(\
%$hash,$key);
2093 if ($$hash{$key}[17] eq 'ON'){
2094 $log="/images/on.gif";
2096 $log="/images/off.gif";
2100 <form method='post'>
2101 <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 ;'/>
2102 <input type='hidden' name='key' value='$key' />
2103 <input type='hidden' name='config' value='$config' />
2104 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2107 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2109 <td align='center' width='160' $tdcolor>
2111 if ($$hash{$key}[5] eq 'std_net_tgt'){
2112 print &get_name
($$hash{$key}[6]);
2114 print $$hash{$key}[6];
2117 &gettgtport
(\
%$hash,$key);
2121 if ($$hash{$key}[12]){ #target prot if manual
2122 $prot=$$hash{$key}[12];
2123 }elsif($$hash{$key}[8]){ #source prot if manual
2124 $prot=$$hash{$key}[8];
2125 }elsif($$hash{$key}[14] eq 'cust_srv'){
2126 $prot=&get_serviceports
("service",$$hash{$key}[15]);
2127 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2128 $prot=&get_serviceports
("group",$$hash{$key}[15]);
2130 $prot=$Lang::tr
{'all'};
2132 print"<td align='center'>$prot</td>";
2133 if ($$hash{$key}[18] eq 'ON'){
2135 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2136 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2137 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2138 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2139 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2140 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2141 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2142 my $weekdays=join(",",@days);
2144 print"<td align='center' width='100'>$weekdays   $$hash{$key}[26] - $$hash{$key}[27]</td>";
2147 print"<td align='center'>24/7</td>";
2149 if($$hash{$key}[2] eq 'ON'){
2150 $gif="/images/on.gif"
2153 $gif="/images/off.gif"
2156 <form method='post'>
2157 <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;' />
2158 <input type='hidden' name='key' value='$key' />
2159 <input type='hidden' name='config' value='$config' />
2160 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2162 <form method='post'>
2163 <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;' />
2164 <input type='hidden' name='key' value='$key' />
2165 <input type='hidden' name='config' value='$config' />
2166 <input type='hidden' name='ACTION' value='editrule' />
2168 <form method='post'>
2169 <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;' />
2170 <input type='hidden' name='key' value='$key' />
2171 <input type='hidden' name='config' value='$config' />
2172 <input type='hidden' name='ACTION' value='copyrule' />
2174 <form method='post'>
2175 <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;' />
2176 <input type='hidden' name='key' value='$key' />
2177 <input type='hidden' name='config' value='$config' />
2178 <input type='hidden' name='ACTION' value='deleterule' />
2181 if (exists $$hash{$key-1}){
2183 <form method='post'>
2184 <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;' />
2185 <input type='hidden' name='key' value='$key' />
2186 <input type='hidden' name='config' value='$config' />
2187 <input type='hidden' name='ACTION' value='moveup' />
2191 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2193 if (exists $$hash{$key+1}){
2195 <form method='post'>
2196 <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;' />
2197 <input type='hidden' name='key' value='$key' />
2198 <input type='hidden' name='config' value='$config' />
2199 <input type='hidden' name='ACTION' value='movedown' />
2200 </td></form></td></tr>
2203 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2206 if ($optionsfw{'SHOWREMARK'} eq 'on'){
2207 print"<tr bgcolor='$color'>";
2208 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='11'>  $$hash{$key}[16]</td></tr>";
2210 print"<tr bgcolor='$color'><td height='1'></td><td bgcolor='$rulecolor'></td><td colspan='11'></td></tr>";
2213 &Header
::closebox
();
2217 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2218 print "<b>$title1</b><br>";
2219 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>";
2225 &Header
::closebigbox
();
2226 &Header
::closepage
();