]>
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 $fwdfwsettings{'updatefwrule'}='';
527 $fwdfwsettings{'config'}=$oldchain;
528 $fwdfwsettings{'nobase'}='on';
530 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
531 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
537 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
538 foreach my $key (sort keys %uphash){
539 if ($key eq $fwdfwsettings{'key'}) {
541 if (exists $uphash{$last}){
543 foreach my $y (0 .. $#{$uphash{$last}}) {
544 $tmp{0}[$y] = $uphash{$last}[$y];
546 #copy active rule to last
547 foreach my $i (0 .. $#{$uphash{$last}}) {
548 $uphash{$last}[$i] = $uphash{$key}[$i];
550 #copy saved rule to actual position
551 foreach my $x (0 .. $#{$tmp{0}}) {
552 $uphash{$key}[$x] = $tmp{0}[$x];
557 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
564 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
565 foreach my $key (sort keys %downhash){
566 if ($key eq $fwdfwsettings{'key'}) {
568 if (exists $downhash{$next}){
570 foreach my $y (0 .. $#{$downhash{$next}}) {
571 $tmp{0}[$y] = $downhash{$next}[$y];
573 #copy active rule to next
574 foreach my $i (0 .. $#{$downhash{$next}}) {
575 $downhash{$next}[$i] = $downhash{$key}[$i];
577 #copy saved rule to actual position
578 foreach my $x (0 .. $#{$tmp{0}}) {
579 $downhash{$key}[$x] = $tmp{0}[$x];
584 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
589 my ($base1,$val1,$base2,$val2) = @_;
591 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
592 &dec_counter
($confignet,\
%customnetwork,$val1);
593 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
594 &dec_counter
($confighost,\
%customhost,$val1);
595 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
596 &dec_counter
($configgrp,\
%customgrp,$val1);
597 }elsif($base1 eq 'cust_srv'){
598 &dec_counter
($configsrv,\
%customservice,$val1);
599 }elsif($base1 eq 'cust_srvgrp'){
600 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
603 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
604 &inc_counter
($confignet,\
%customnetwork,$val2);
605 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
606 &inc_counter
($confighost,\
%customhost,$val2);
607 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
608 &inc_counter
($configgrp,\
%customgrp,$val2);
609 }elsif($base2 eq 'cust_srv'){
610 &inc_counter
($configsrv,\
%customservice,$val2);
611 }elsif($base2 eq 'cust_srvgrp'){
612 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
622 &General
::readhasharray
($config, \
%hash);
623 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
624 if($hash{$key}[0] eq $val){
625 $pos=$#{$hash{$key}};
626 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
629 &General
::writehasharray
($config, \
%hash);
637 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
638 &General
::readhasharray
($config, \
%hash);
639 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
640 if($hash{$key}[0] eq $val){
641 $pos=$#{$hash{$key}};
642 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
645 &General
::writehasharray
($config, \
%hash);
649 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
650 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
651 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){ $selected{'POLICY1'}{'MODE1'} = 'selected'; } else { $selected{'POLICY1'}{'MODE1'} = ''; }
652 if ($fwdfwsettings{'POLICY1'} eq 'MODE2'){ $selected{'POLICY1'}{'MODE2'} = 'selected'; } else { $selected{'POLICY1'}{'MODE2'} = ''; }
656 &Header
::openbox
('100%', 'center', $Lang::tr
{'fwdfw pol title'});
658 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
659 <table width='100%' border='0'>
660 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>FORWARD </td></tr>
661 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text'}</td></tr>
662 <tr><td colspan='3'><hr /></td></tr>
663 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
664 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
665 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
666 <input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td><td width='45%' align='right'>
669 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='forward' /></td></tr>";
670 print "</table></form>";
673 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
674 <table width='100%' border='0'>
675 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>OUTGOING </td></tr>
676 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text1'}</td></tr>
677 <tr><td colspan='3'><hr /></td></tr>
678 <tr><td width='15%' align='left'> <select name='POLICY1' style="width: 100px">
679 <option value='MODE1' $selected{'POLICY1'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
680 <option value='MODE2' $selected{'POLICY1'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
681 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td><td width='45%' align='right'>
684 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='outgoing' /></tr>";
685 print "</table></form>";
691 if (-f
"${General::swroot}/forward/reread"){
692 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>";
694 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
695 print "<form method='post'>";
696 print "<table border='0'>";
697 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
698 print"</tr></table></form><hr>";
705 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
706 foreach my $key (sort {$a <=> $b} keys %delhash){
707 if ($key == $fwdfwsettings{'key'}){
708 #check hosts/net and groups
709 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
710 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
711 #check services and groups
712 if ($delhash{$key}[11] eq 'ON'){
713 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
716 if ($key >= $fwdfwsettings{'key'}) {
718 if (exists $delhash{$next}) {
719 foreach my $i (0 .. $#{$delhash{$next}}) {
720 $delhash{$key}[$i] = $delhash{$next}[$i];
725 # Remove the very last entry.
726 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
727 delete $delhash{$last_key};
729 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
732 if($fwdfwsettings{'nobase'} ne 'on'){
739 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
740 foreach my $key (sort keys %configfwdfw){
742 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
745 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
752 #check ip-address if manual
753 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
754 #check if ip with subnet
755 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
756 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
757 $subnet = &General
::iporsubtocidr
($subnet);
758 $fwdfwsettings{'isip'}='on';
761 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
762 $ip=$fwdfwsettings{'src_addr'};
764 $fwdfwsettings{'isip'}='on';
767 if ($fwdfwsettings{'isip'} ne 'on'){
768 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
770 if ($fwdfwsettings{'isip'} eq 'on'){
771 #check and form valid IP
772 $ip=&General
::ip2dec
($ip);
773 $ip=&General
::dec2ip
($ip);
774 #check if net or broadcast
775 my @tmp= split (/\./,$ip);
776 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
778 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
780 $fwdfwsettings{'src_addr'}="$ip/$subnet";
782 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
783 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
786 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
787 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
789 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
790 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
791 return $errormessage;
795 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
797 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
798 $fwdfwsettings{'SRC_PORT'}='';
799 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
800 foreach my $key (keys %icmptypes){
801 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
802 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
805 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
806 $fwdfwsettings{'SRC_PORT'}='';
807 $fwdfwsettings{'ICMP_TYPES'}='';
808 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
809 $fwdfwsettings{'SRC_PORT'}='';
810 $fwdfwsettings{'ICMP_TYPES'}='';
811 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
812 $fwdfwsettings{'SRC_PORT'}='';
813 $fwdfwsettings{'ICMP_TYPES'}='';
814 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
815 $fwdfwsettings{'ICMP_TYPES'}='';
817 $fwdfwsettings{'ICMP_TYPES'}='';
818 $fwdfwsettings{'SRC_PORT'}='';
819 $fwdfwsettings{'PROT'}='';
822 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
823 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
827 if ($_ =~ /^(\d+)\:(\d+)$/) {
829 #change dashes with :
832 push(@values,"1:65535");
835 if ($_ =~ /^(\D)\:(\d+)$/) {
836 push(@values,"1:$2");
839 if ($_ =~ /^(\d+)\:(\D)$/) {
840 push(@values,"$1:65535");
843 $errormessage .= &General
::validportrange
($_, 'destination');
848 if (&General
::validport
($_)){
855 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
856 return $errormessage;
863 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
864 #check if ip with subnet
865 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
866 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
867 $subnet = &General
::iporsubtocidr
($subnet);
870 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
871 $ip=$fwdfwsettings{'tgt_addr'};
874 #check and form valid IP
875 $ip=&General
::ip2dec
($ip);
876 $ip=&General
::dec2ip
($ip);
878 ##check if net or broadcast
879 #my @tmp= split (/\./,$ip);
880 #if ($tmp[3] eq "0" || ($tmp[3] eq "255"))
882 #$errormessage=$Lang::tr{'fwhost err hostip'}."<br>";
884 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
886 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
887 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
890 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
891 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
892 return $errormessage;
896 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
899 if ($fwdfwsettings{'USESRV'} eq 'ON'){
900 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
901 $fwdfwsettings{'TGT_PROT'}='';
902 $fwdfwsettings{'ICMP_TGT'}='';
904 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
905 $fwdfwsettings{'TGT_PROT'}='';
906 $fwdfwsettings{'ICMP_TGT'}='';
907 #check target service
908 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
909 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
912 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
913 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
914 if ($fwdfwsettings{'TGT_PORT'} ne ''){
915 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
919 if ($_ =~ /^(\d+)\:(\d+)$/) {
921 #change dashes with :
924 push(@values,"1:65535");
927 if ($_ =~ /^(\D)\:(\d+)$/) {
928 push(@values,"1:$2");
931 if ($_ =~ /^(\d+)\:(\D)$/) {
932 push(@values,"$1:65535");
935 $errormessage .= &General
::validportrange
($_, 'destination');
940 if (&General
::validport
($_)){
947 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
949 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
950 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
951 $fwdfwsettings{'TGT_PORT'} = '';
952 $fwdfwsettings{'ICMP_TGT'} = '';
953 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
954 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
955 $fwdfwsettings{'TGT_PORT'} = '';
956 $fwdfwsettings{'ICMP_TGT'}='';
957 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
958 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
959 $fwdfwsettings{'TGT_PORT'} = '';
960 $fwdfwsettings{'ICMP_TGT'}='';
961 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
962 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
963 $fwdfwsettings{'TGT_PORT'} = '';
964 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
965 foreach my $key (keys %icmptypes){
967 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
968 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
976 if ($fwdfwsettings{'USESRV'} ne 'ON'){
977 $fwdfwsettings{'grp3'}='';
978 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
979 $fwdfwsettings{'TGT_PROT'}='';
980 $fwdfwsettings{'ICMP_TGT'}='';
983 if($fwdfwsettings{'TIME'} eq 'ON'){
984 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 ''){
985 $errormessage=$Lang::tr
{'fwdfw err time'};
988 return $errormessage;
993 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
994 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
996 #check if source and target identical
997 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
998 $errormessage.=$Lang::tr
{'fwdfw err same'};
999 return $errormessage;
1002 #get source and targetip address if possible
1003 my ($sip,$scidr,$tip,$tcidr);
1004 ($sip,$scidr)=&get_ip
("src","grp1");
1005 ($tip,$tcidr)=&get_ip
("tgt","grp2");
1007 #check same iprange in source and target
1008 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
1009 my $networkip1=&General
::getnetworkip
($sip,$scidr);
1010 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
1011 if ($scidr gt $tcidr){
1012 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
1013 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
1015 }elsif($scidr eq $tcidr && $scidr eq '32'){
1016 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
1017 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
1018 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
1019 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
1020 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
1023 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
1024 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
1029 #check source and destination protocol if manual
1030 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
1031 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
1032 $errormessage.=$Lang::tr
{'fwdfw err prot'};
1034 #check source and destination protocol if source manual and dest servicegrp
1035 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
1036 &General
::readhasharray
("$configsrv", \
%customservice);
1037 foreach my $key (sort keys %customservice){
1038 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
1039 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
1040 $errormessage.=$Lang::tr
{'fwdfw err prot'};
1054 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1055 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1056 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1057 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1058 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1059 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1060 $a=$netsettings{'GREEN_NETADDRESS'};
1061 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1062 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1063 $a=$netsettings{'ORANGE_NETADDRESS'};
1064 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1065 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1066 $a=$netsettings{'BLUE_NETADDRESS'};
1067 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1068 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1069 &General
::readhash
("$configovpn",\
%ovpnsettings);
1070 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1071 $b=&General
::iporsubtocidr
($b);
1073 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1074 &General
::readhasharray
("$confignet", \
%customnetwork);
1075 foreach my $key (keys %customnetwork){
1076 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1077 $a=$customnetwork{$key}[1];
1078 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1081 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1082 &General
::readhasharray
("$confighost", \
%customhost);
1083 foreach my $key (keys %customhost){
1084 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1085 if ($customhost{$key}[1] eq 'ip'){
1086 ($a,$b)=split (/\//,$customhost{$key}[2]);
1087 $b=&General
::iporsubtocidr
($b);
1089 if ($grp eq 'grp2'){
1090 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1102 &General
::setup_default_networks
(\
%defaultNetworks);
1103 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1104 #read all configfiles
1105 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1106 &General
::readhasharray
("$confignet", \
%customnetwork);
1107 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1108 &General
::readhasharray
("$confighost", \
%customhost);
1109 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1110 &General
::readhasharray
("$configgrp", \
%customgrp);
1111 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1112 &General
::get_aliases
(\
%aliases);
1116 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1117 my $config=$fwdfwsettings{'config'};
1119 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1120 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1121 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1122 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1123 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1124 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1125 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1126 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1127 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1128 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1129 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1130 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1131 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1132 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1133 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1134 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1135 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1136 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1137 #check if update and get values
1138 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1139 &General
::readhasharray
("$config", \
%hash);
1140 foreach my $key (sort keys %hash){
1142 if ($key eq $fwdfwsettings{'key'}){
1143 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1144 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1145 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1146 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1147 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1148 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1149 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1150 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1151 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1152 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1153 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1154 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1155 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1156 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1157 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1158 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1159 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1160 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1161 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1162 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1163 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1164 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1165 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1166 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1167 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1168 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1169 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1170 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1171 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1172 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1173 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1174 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1175 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1176 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1177 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1178 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1179 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1180 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1181 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1182 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1183 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1184 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1185 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1186 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1187 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1188 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1191 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1192 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1193 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1194 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1195 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1196 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1197 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1198 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1199 #check if manual ip (source) is orange network
1200 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1201 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1202 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1203 $fwdfwsettings{'oldorange'} ='on';
1207 $fwdfwsettings{'ACTIVE'}='ON';
1208 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1209 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1210 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1211 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1212 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1213 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1214 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1215 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1216 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1217 #check if manual ip (source) is orange network
1218 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1219 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1220 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1221 $fwdfwsettings{'oldorange'} ='on';
1225 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1228 <form method="post">
1230 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1232 foreach ("ACCEPT","DROP","REJECT")
1234 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1236 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1237 print">$_</option>";
1239 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1240 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1243 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1245 print"<option selected>$_</option>";
1247 print"<option>$_</option>";
1251 print"</select></td></tr></table><hr>";
1253 &Header
::closebox
();
1254 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1255 #------SOURCE-------------------------------------------------------
1257 <table width='100%' border='0'>
1258 <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>
1259 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1260 <tr><td width='1%'><input type='radio' name='grp1' value='std_net_src' $checked{'grp1'}{'std_net_src'}></td><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost stdnet'}</td><td width='13%'><select name='std_net_src' style='min-width:185px;'>
1262 foreach my $network (sort keys %defaultNetworks)
1264 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1265 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1266 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1267 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1268 print ">$network</option>";
1271 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_net_src' $checked{'grp1'}{'ovpn_net_src'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_src' style='min-width:185px;'>
1273 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1276 <tr><td><input type='radio' name='grp1' value='cust_net_src' $checked{'grp1'}{'cust_net_src'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_src' style='min-width:185px;'>
1278 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1280 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_host_src' $checked{'grp1'}{'ovpn_host_src'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_src' style='min-width:185px;'>
1282 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1284 if ($ccdhost{$key}[33] ne ''){
1286 print "<option value='$ccdhost{$key}[1]'";
1287 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1288 print ">$ccdhost{$key}[1]</option>";
1293 <tr><td valign='top'><input type='radio' name='grp1' value='cust_host_src' $checked{'grp1'}{'cust_host_src'}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_src' style='min-width:185px;'>
1295 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1297 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_n2n_src' $checked{'grp1'}{'ovpn_n2n_src'}></td><td >$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='ovpn_n2n_src' style='min-width:185px;'>
1299 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1300 if($ccdhost{$key}[3] eq 'net'){
1302 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1303 print ">$ccdhost{$key}[1]</option>";
1309 <tr><td valign='top'><input type='radio' name='grp1' value='cust_grp_src' $checked{'grp1'}{'cust_grp_src'}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_src' style='min-width:185px;'>
1311 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1312 if($helper ne $customgrp{$key}[0]){
1314 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1315 print ">$customgrp{$key}[0]</option>";
1317 $helper=$customgrp{$key}[0];
1321 <td valign='top'><input type='radio' name='grp1' value='ipsec_net_src' $checked{'grp1'}{'ipsec_net_src'}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_src' style='min-width:185px;'>
1323 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1324 if ($ipsecconf{$key}[3] eq 'net'){
1326 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1327 print ">$ipsecconf{$key}[1]</option>";
1335 # <td valign='top'><input type='radio' name='grp1' value='ipsec_host_src' $checked{'grp1'}{'ipsec_host_src'}></td><td >$Lang::tr{'fwhost ipsec host'}</td><td><select name='ipsec_host_src' style='min-width:185px;'>
1337 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1338 # if ($ipsecconf{$key}[3] eq 'host'){
1340 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1341 # print ">$ipsecconf{$key}[1]</option>";
1345 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1346 <table width='100%' border='0'>
1347 <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>
1348 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1350 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1352 if ($_ eq $fwdfwsettings{'PROT'})
1354 print"<option selected>$_</option>";
1356 print"<option>$_</option>";
1359 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1361 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1362 <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;'>
1364 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1365 print"<option>All ICMP-Types</option>";
1366 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1367 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1368 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1370 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1374 </select></td></tr></table><br><hr>
1376 &Header
::closebox
();
1378 #---TARGET------------------------------------------------------
1379 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1381 <table width='100%' border='0'>
1382 <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><select name='ipfire' style='min-width:185px;'>
1384 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1386 foreach my $alias (sort keys %aliases)
1388 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1393 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1394 <tr><td width='1%'><input type='radio' name='grp2' value='std_net_tgt' $checked{'grp2'}{'std_net_tgt'}></td><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost stdnet'}</td><td width='13%'><select name='std_net_tgt' style='min-width:185px;'>
1396 foreach my $network (sort keys %defaultNetworks)
1398 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1399 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1400 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1401 print ">$network</option>";
1404 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_net_tgt' $checked{'grp2'}{'ovpn_net_tgt'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_tgt' style='min-width:185px;'>
1406 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1409 <tr><td><input type='radio' name='grp2' value='cust_net_tgt' $checked{'grp2'}{'cust_net_tgt'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_tgt' style='min-width:185px;'>
1411 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1413 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_host_tgt' $checked{'grp2'}{'ovpn_host_tgt'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_tgt' style='min-width:185px;'>
1415 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1417 if ($ccdhost{$key}[33] ne ''){
1418 print "<option value='$ccdhost{$key}[1]' ";
1419 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1420 print ">$ccdhost{$key}[1]</option>";
1425 <tr><td valign='top'><input type='radio' name='grp2' value='cust_host_tgt' $checked{'grp2'}{'cust_host_tgt'}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_tgt' style='min-width:185px;'>
1427 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1429 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_n2n_tgt' $checked{'grp2'}{'ovpn_n2n_tgt'}></td><td >$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='ovpn_n2n_tgt' style='min-width:185px;'>
1431 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1432 if($ccdhost{$key}[3] eq 'net'){
1434 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1435 print ">$ccdhost{$key}[1]</option>";
1440 <tr><td valign='top'><input type='radio' name='grp2' value='cust_grp_tgt' $checked{'grp2'}{'cust_grp_tgt'}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_tgt' style='min-width:185px;'>
1443 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1444 if($helper ne $customgrp{$key}[0]){
1446 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1447 print">$customgrp{$key}[0]</option>";
1449 $helper=$customgrp{$key}[0];
1453 <td valign='top'><input type='radio' name='grp2' value='ipsec_net_tgt' $checked{'grp2'}{'ipsec_net_tgt'}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_tgt' style='min-width:185px;'>
1455 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1456 if ($ipsecconf{$key}[3] eq 'net'){
1458 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1459 print">$ipsecconf{$key}[1]</option>";
1465 # <td valign='top'><input type='radio' name='grp2' value='ipsec_host_tgt' $checked{'grp2'}{'ipsec_host_tgt'}></td><td >$Lang::tr{'fwhost ipsec host'}</td><td><select name='ipsec_host_tgt' style='min-width:185px;'>
1467 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1468 # if ($ipsecconf{$key}[3] eq 'host'){
1470 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1471 # print">$ipsecconf{$key}[1]</option>";
1476 <b>$Lang::tr{'fwhost attention'}:</b><br>
1477 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1479 <table width='100%' border='0'>
1480 <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;' >
1482 &General
::readhasharray
("$configsrv", \
%customservice);
1483 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1485 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1486 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1490 <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;' >
1492 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1494 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1495 if ($helper ne $customservicegrp{$key}[0]){
1497 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1498 print">$customservicegrp{$key}[0]</option>";
1500 $helper=$customservicegrp{$key}[0];
1504 <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'>
1506 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1508 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1510 print"<option selected>$_</option>";
1512 print"<option>$_</option>";
1515 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1517 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1518 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT' style='min-width:230px;'>
1520 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1521 print"<option>All ICMP-Types</option>";
1522 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1523 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1524 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1526 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1535 #---Activate/logging/remark-------------------------------------
1536 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1538 <table width='100%' border='0'>
1539 <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>
1541 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1542 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1543 for (my $count =1; $count <= $sum; $count++){
1544 print"<option value='$count' ";
1545 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1546 print">$count</option>";
1548 print"</select></td></tr>";
1550 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1554 </table><table width='100%'>
1555 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1556 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1559 &Header
::closebox
();
1560 #---ADD TIMEFRAME-----------------------------------------------
1561 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1563 <table width='70%' border='0'>
1564 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1565 <tr><td colspan='7'> </td></tr>
1567 <td align='left'>$Lang::tr{'time'}:</td>
1568 <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>
1569 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1570 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1573 <td align='right'></td>
1574 <td width='30%' align='left'>
1575 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1576 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1577 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1578 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1579 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1580 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1581 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1583 <td><select name='TIME_FROM'>
1585 for (my $i=0;$i<=23;$i++) {
1586 $i = sprintf("%02s",$i);
1587 for (my $j=0;$j<=45;$j+=15) {
1588 $j = sprintf("%02s",$j);
1589 my $time = $i.":".$j;
1590 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1595 <td><select name='TIME_TO'>
1597 for (my $i=0;$i<=23;$i++) {
1598 $i = sprintf("%02s",$i);
1599 for (my $j=0;$j<=45;$j+=15) {
1600 $j = sprintf("%02s",$j);
1601 my $time = $i.":".$j;
1602 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1610 #---ACTION------------------------------------------------------
1611 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1613 <table border='0' width='100%'>
1614 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1615 <input type='hidden' name='config' value='$config' >
1616 <input type='hidden' name='ACTION' value='saverule' >
1617 </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>
1622 <table border='0' width='100%'>
1623 <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'}'>
1624 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1625 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1626 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1627 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1628 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1629 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1630 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1631 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1632 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1633 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1634 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1635 <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>
1639 &Header
::closebox
();
1645 &General
::readhasharray
("$config", $hash);
1646 if (!$errormessage){
1647 #check if we change a DMZ to an outgoing
1648 if( ($fwdfwsettings{'oldgrp1b'} eq 'ORANGE' || $fwdfwsettings{'oldorange'} eq 'on') && $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1649 &changerule
($configdmz);
1652 #check if we change a DMZ to an external access
1653 elsif( $fwdfwsettings{'oldgrp1b'} eq 'ORANGE' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE' && $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1654 &changerule
($configdmz);
1657 #check if we change an external access rule to a outgoing
1658 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'oldgrp1b'} ne 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1659 &changerule
($configinput);
1662 #check if we change an external access rule to a DMZ
1663 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1664 &changerule
($configinput);
1667 #check if we change an outgoing rule to a external access
1668 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1669 &changerule
($configoutgoing);
1672 #check if we change an outgoing rule to a DMZ
1673 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1674 &changerule
($configoutgoing);
1677 #check if we change an forward rule to an external access
1678 elsif( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1679 &changerule
($configfwdfw);
1682 #check if we change an forward rule to an DMZ
1683 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && ($fwdfwsettings{'oldgrp1b'} ne 'ORANGE' && $fwdfwsettings{'oldorange'} ne 'on') && $fwdfwsettings{'updatefwrule'} eq 'on'){
1684 &changerule
($configfwdfw);
1687 #check if we change an forward rule to an outgoing
1688 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'oldgrp1b'} ne 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1689 &changerule
($configfwdfw);
1692 #check if we change a DMZ to a forward
1693 elsif( ($fwdfwsettings{'oldgrp1b'} eq 'ORANGE' || $fwdfwsettings{'oldorange'} eq 'on') && ($fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE' && $checkorange ne 'on') && $fwdfwsettings{'updatefwrule'} eq 'on'){
1694 &changerule
($configdmz);
1697 #check if we change an external access rule to a forward
1698 elsif( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1699 &changerule
($configinput);
1702 #check if we change an outgoing rule to a forward
1703 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1704 &changerule
($configoutgoing);
1707 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1708 my $key = &General
::findhasharraykey
($hash);
1709 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1710 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1711 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1712 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1713 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1714 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1715 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1716 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1717 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1718 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1719 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1720 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1721 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1722 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1723 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1724 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1725 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1726 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1727 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1728 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1729 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1730 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1731 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1732 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1733 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1734 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1735 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1736 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1737 &General
::writehasharray
("$config", $hash);
1739 foreach my $key (sort {$a <=> $b} keys %$hash){
1740 if($key eq $fwdfwsettings{'key'}){
1741 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1742 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1743 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1744 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1745 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1746 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1747 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1748 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1749 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1750 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1751 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1752 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1753 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1754 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1755 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1756 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1757 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1758 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1759 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1760 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1761 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1762 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1763 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1764 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1765 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1766 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1767 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1768 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1773 &General
::writehasharray
("$config", $hash);
1774 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
1776 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1777 for (my $z=0;$z<$val;$z++){
1778 foreach my $key (sort {$a <=> $b} keys %$hash){
1779 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1781 if (exists $$hash{$last}){
1783 foreach my $y (0 .. $#{$$hash{$last}}) {
1784 $tmp{0}[$y] = $$hash{$last}[$y];
1786 #copy active rule to last
1787 foreach my $i (0 .. $#{$$hash{$last}}) {
1788 $$hash{$last}[$i] = $$hash{$key}[$i];
1790 #copy saved rule to actual position
1791 foreach my $x (0 .. $#{$tmp{0}}) {
1792 $$hash{$key}[$x] = $tmp{0}[$x];
1797 $fwdfwsettings{'oldrulenumber'}--;
1799 &General
::writehasharray
("$config", $hash);
1801 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
1803 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1804 for (my $z=0;$z<$val;$z++){
1805 foreach my $key (sort {$a <=> $b} keys %$hash){
1806 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1807 my $next = $key + 1;
1808 if (exists $$hash{$next}){
1810 foreach my $y (0 .. $#{$$hash{$next}}) {
1811 $tmp{0}[$y] = $$hash{$next}[$y];
1813 #copy active rule to next
1814 foreach my $i (0 .. $#{$$hash{$next}}) {
1815 $$hash{$next}[$i] = $$hash{$key}[$i];
1817 #copy saved rule to actual position
1818 foreach my $x (0 .. $#{$tmp{0}}) {
1819 $$hash{$key}[$x] = $tmp{0}[$x];
1824 $fwdfwsettings{'oldrulenumber'}++;
1826 &General
::writehasharray
("$config", $hash);
1833 if ($errormessage) {
1834 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1835 print "<class name='base'>$errormessage\n";
1836 print " </class>\n";
1837 &Header
::closebox
();
1844 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1845 print "<class name='base'>$hint\n";
1846 print " </class>\n";
1847 &Header
::closebox
();
1854 &General
::setup_default_networks
(\
%defaultNetworks);
1855 foreach my $network (sort keys %defaultNetworks)
1857 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1862 # Checks a hostname against RFC1035
1865 # Each part should be at least two characters in length
1866 # but no more than 63 characters
1867 if (length ($remark) < 1 || length ($remark) > 255) {
1869 # Only valid characters are a-z, A-Z, 0-9 and -
1870 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
1872 # First character can only be a letter or a digit
1873 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1875 # Last character can only be a letter or a digit
1876 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
1882 my %hash=%{(shift)};
1884 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1885 $hash{$key}[10]=~ s/\|/,/g;
1886 print": $hash{$key}[10]";
1887 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1888 print": <br>$hash{$key}[9] ";
1893 my %hash=%{(shift)};
1897 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1898 if($hash{$key}[14] eq 'cust_srv'){
1899 &General
::readhasharray
("$configsrv", \
%customservice);
1900 foreach my $i (sort keys %customservice){
1901 if($customservice{$i}[0] eq $hash{$key}[15]){
1902 $service = $customservice{$i}[0];
1905 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1906 $service=$hash{$key}[15];
1907 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1908 $hash{$key}[15]=~ s/\|/,/g;
1909 $service=$hash{$key}[15];
1914 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1915 print":<br>$hash{$key}[13]";
1918 sub get_serviceports
1922 &General
::readhasharray
("$configsrv", \
%customservice);
1923 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1927 if($type eq 'service'){
1928 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1929 if ($customservice{$key}[0] eq $name){
1930 $protocols=$customservice{$key}[2];
1933 }elsif($type eq 'group'){
1934 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1935 if ($customservicegrp{$key}[0] eq $name){
1936 foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1937 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1938 if($customservice{$key1}[2] eq 'TCP'){$tcp='TCP';}else{$udp='UDP';}
1944 if($tcp && $udp){$protocols="TCP,UDP";
1945 }elsif($tcp){$protocols.="TCP";
1946 }elsif($udp){$protocols.="UDP";}
1951 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1952 &viewtablenew
(\
%configdmzfw,$configdmz,$Lang::tr
{'fwdfw rules'},"DMZ" );
1953 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
1954 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1955 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
1964 &General
::get_aliases
(\
%aliases);
1965 &General
::readhasharray
("$confighost", \
%customhost);
1966 &General
::readhasharray
("$config", $hash);
1968 &Header
::openbox
('100%', 'left',$title);
1976 print"<b>$title1</b><br>";
1977 print"<table width='100%' cellspacing='0' style=' padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1978 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>";
1979 foreach my $key (sort {$a <=> $b} keys %$hash){
1982 #check if vpn hosts/nets have been deleted
1983 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1984 push (@tmpsrc,$$hash{$key}[4]);
1986 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1987 push (@tmpsrc,$$hash{$key}[6]);
1989 foreach my $host (@tmpsrc){
1990 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1991 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1993 &disable_rule
($key);
1996 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1997 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1999 &disable_rule
($key);
2002 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2003 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2005 &disable_rule
($key);
2008 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2009 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2011 &disable_rule
($key);
2015 #$$hash{$key}[3]='';
2016 #$$hash{$key}[5]='';
2018 $$hash{'ACTIVE'}=$$hash{$key}[2];
2020 if($coloryellow eq 'on'){
2021 print"<tr bgcolor='$color{'color14'}' >";
2023 }elsif($coloryellow eq ''){
2025 $color="$color{'color22'}";
2028 $color="$color{'color20'}";
2031 print"<tr bgcolor='$color' >";
2033 <td align='right' width='15'><b>$key</b></td>
2035 if ($$hash{$key}[0] eq 'ACCEPT'){
2038 $rulecolor=$color{'color17'};
2039 }elsif($$hash{$key}[0] eq 'DROP'){
2042 $rulecolor=$color{'color25'};
2043 }elsif($$hash{$key}[0] eq 'REJECT'){
2046 $rulecolor=$color{'color16'};
2048 print"<td bgcolor='$rulecolor' align='center' width='20'><span title='$tooltip'><b>$ruletype</b></span></td>";
2049 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2050 print"<td align='center' width='160' $tdcolor>";
2051 if ($$hash{$key}[3] eq 'std_net_src'){
2052 print &get_name
($$hash{$key}[4]);
2054 print $$hash{$key}[4];
2057 &getsrcport
(\
%$hash,$key);
2058 if ($$hash{$key}[17] eq 'ON'){
2059 $log="/images/on.gif";
2061 $log="/images/off.gif";
2065 <form method='post'>
2066 <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 ;'/>
2067 <input type='hidden' name='key' value='$key' />
2068 <input type='hidden' name='config' value='$config' />
2069 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2072 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2074 <td align='center' width='160' $tdcolor>
2076 if ($$hash{$key}[5] eq 'std_net_tgt'){
2077 print &get_name
($$hash{$key}[6]);
2079 print $$hash{$key}[6];
2082 &gettgtport
(\
%$hash,$key);
2086 if ($$hash{$key}[12]){ #target prot if manual
2087 $prot=$$hash{$key}[12];
2088 }elsif($$hash{$key}[8]){ #source prot if manual
2089 $prot=$$hash{$key}[8];
2090 }elsif($$hash{$key}[14] eq 'cust_srv'){
2091 $prot=&get_serviceports
("service",$$hash{$key}[15]);
2092 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2093 $prot=&get_serviceports
("group",$$hash{$key}[15]);
2095 $prot=$Lang::tr
{'all'};
2097 print"<td align='center'>$prot</td>";
2098 if ($$hash{$key}[18] eq 'ON'){
2100 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2101 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2102 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2103 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2104 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2105 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2106 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2107 my $weekdays=join(",",@days);
2109 print"<td align='center' width='100'>$weekdays   $$hash{$key}[26] - $$hash{$key}[27]</td>";
2112 print"<td align='center'>24/7</td>";
2114 if($$hash{$key}[2] eq 'ON'){
2115 $gif="/images/on.gif"
2118 $gif="/images/off.gif"
2121 <form method='post'>
2122 <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;' />
2123 <input type='hidden' name='key' value='$key' />
2124 <input type='hidden' name='config' value='$config' />
2125 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2127 <form method='post'>
2128 <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;' />
2129 <input type='hidden' name='key' value='$key' />
2130 <input type='hidden' name='config' value='$config' />
2131 <input type='hidden' name='ACTION' value='editrule' />
2133 <form method='post'>
2134 <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;' />
2135 <input type='hidden' name='key' value='$key' />
2136 <input type='hidden' name='config' value='$config' />
2137 <input type='hidden' name='ACTION' value='copyrule' />
2139 <form method='post'>
2140 <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;' />
2141 <input type='hidden' name='key' value='$key' />
2142 <input type='hidden' name='config' value='$config' />
2143 <input type='hidden' name='ACTION' value='deleterule' />
2146 if (exists $$hash{$key-1}){
2148 <form method='post'>
2149 <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;' />
2150 <input type='hidden' name='key' value='$key' />
2151 <input type='hidden' name='config' value='$config' />
2152 <input type='hidden' name='ACTION' value='moveup' />
2156 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2158 if (exists $$hash{$key+1}){
2160 <form method='post'>
2161 <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;' />
2162 <input type='hidden' name='key' value='$key' />
2163 <input type='hidden' name='config' value='$config' />
2164 <input type='hidden' name='ACTION' value='movedown' />
2165 </td></form></td></tr>
2168 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2171 if ($optionsfw{'SHOWREMARK'} eq 'on'){
2172 print"<tr bgcolor='$color'>";
2173 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='11'>  $$hash{$key}[16]</td></tr>";
2177 &Header
::closebox
();
2181 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2182 print "<b>$title1</b><br>";
2183 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>";
2192 if($optionsfw{'SHOWCOLORS'} eq 'on'){
2194 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'){
2195 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
2198 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
2199 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
2203 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
2204 foreach my $key (sort keys %$hash){
2205 if ($$hash{$key}[0] eq $val){
2206 $val=$$hash{$key}[2];
2211 foreach my $alias (sort keys %aliases)
2213 if ($val eq $alias){
2214 $tdcolor="style='border: 2px solid red;'";
2219 if ($val eq 'GREEN'){
2220 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
2221 }elsif ($val eq 'ORANGE'){
2222 $tdcolor="style='border: 1px solid $Header::colourorange;'";
2223 }elsif ($val eq 'BLUE'){
2224 $tdcolor="style='border: 1px solid $Header::colourblue;'";
2225 }elsif ($val eq 'RED'){
2226 $tdcolor="style='border: 1px solid $Header::colourred;'";
2227 }elsif ($val eq 'IPFire' ){
2228 $tdcolor="style='border: 1px solid $Header::colourred;'";
2229 }elsif($val =~ /^(.*?)\/(.*?
)$/){
2230 my ($sip,$scidr) = split ("/",$val);
2231 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
2232 $tdcolor="style='border: 1px solid $Header::colourorange;'";
2234 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
2235 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
2237 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
2238 $tdcolor="style='border: 1px solid $Header::colourblue;'";
2240 }elsif ($val eq 'Default IP'){
2241 $tdcolor="style='border: 1px solid red;'";
2249 my %hash=%{(shift)};
2252 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
2253 if($hash{$key}[0] eq $val){
2254 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
2256 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
2262 if (!-f
"${General::swroot}/forward/reread"){
2263 system("touch ${General::swroot}/forward/reread");
2264 system("touch ${General::swroot}/fwhosts/reread");
2269 system("/usr/local/bin/forwardfwctrl");
2270 if ( -f
"${General::swroot}/forward/reread"){
2271 system("rm ${General::swroot}/forward/reread");
2272 system("rm ${General::swroot}/fwhosts/reread");
2275 &Header
::closebigbox
();
2276 &Header
::closepage
();