]>
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=();
77 my $VERSION='0.9.7.9';
79 my $confignet = "${General::swroot}/fwhosts/customnetworks";
80 my $confighost = "${General::swroot}/fwhosts/customhosts";
81 my $configgrp = "${General::swroot}/fwhosts/customgroups";
82 my $configsrv = "${General::swroot}/fwhosts/customservices";
83 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
84 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
85 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
86 my $configipsec = "${General::swroot}/vpn/config";
87 my $configipsecrw = "${General::swroot}/vpn/settings";
88 my $configfwdfw = "${General::swroot}/forward/config";
89 my $configinput = "${General::swroot}/forward/input";
90 my $configoutgoing = "${General::swroot}/forward/outgoing";
91 my $configdmz = "${General::swroot}/forward/dmz";
92 my $configovpn = "${General::swroot}/ovpn/settings";
93 my $fwoptions = "${General::swroot}/optionsfw/settings";
96 my $ipgrp="${General::swroot}/outgoing/groups";
100 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
101 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
102 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
103 &General
::readhash
($fwoptions, \
%optionsfw);
105 &Header
::showhttpheaders
();
106 &Header
::getcgihash
(\
%fwdfwsettings);
107 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
108 &Header
::openbigbox
('100%', 'center',$errormessage);
111 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
113 my $MODE = $fwdfwsettings{'POLICY'};
114 my $MODE1 = $fwdfwsettings{'POLICY1'};
116 $fwdfwsettings{'POLICY'} = "$MODE";
117 $fwdfwsettings{'POLICY1'} = "$MODE1";
118 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
121 if ($fwdfwsettings{'ACTION'} eq 'saverule')
123 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
124 &General
::readhasharray
("$configinput", \
%configinputfw);
125 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
127 $errormessage=&checksource
;
128 if(!$errormessage){&checktarget
;}
129 if(!$errormessage){&checkrule
;}
130 #check if manual ip (source) is orange network
131 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
132 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
133 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
138 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
139 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
142 #check if we try to break rules
143 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire'){
144 $errormessage.=$Lang::tr
{'fwdfw err same'};
147 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on'){
148 $fwdfwsettings{'config'}=$configdmz;
149 $fwdfwsettings{'chain'} = 'FORWARDFW';
150 my $maxkey=&General
::findhasharraykey
(\
%configdmzfw);
151 #check if we have an identical rule already
152 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
153 foreach my $key (sort keys %configdmzfw){
154 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'}"
155 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]"){
156 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
157 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
159 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
160 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
162 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
163 $fwdfwsettings{'nosave'} = 'on';
168 #check Rulepos on new Rule
169 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
170 $fwdfwsettings{'oldrulenumber'}=$maxkey;
171 foreach my $key (sort keys %configdmzfw){
172 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'}"
173 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]"){
174 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
178 #check if we just close a rule
179 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'} ) {
180 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
182 $fwdfwsettings{'nosave2'} = 'on';
185 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
186 if ($fwdfwsettings{'nobase'} ne 'on'){
187 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
189 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
190 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
191 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
192 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
193 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
194 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
196 if($fwdfwsettings{'nosave2'} ne 'on'){
197 &saverule
(\
%configdmzfw,$configdmz);
200 }elsif($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
201 $fwdfwsettings{'config'}=$configinput;
202 $fwdfwsettings{'chain'} = 'INPUTFW';
203 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
204 #check if we have an identical rule already
205 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
206 foreach my $key (sort keys %configinputfw){
207 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'}"
208 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]"){
209 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
210 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
212 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
213 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
215 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
216 $fwdfwsettings{'nosave'} = 'on';
221 #check Rulepos on new Rule
222 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
223 $fwdfwsettings{'oldrulenumber'}=$maxkey;
224 foreach my $key (sort keys %configinputfw){
225 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'}"
226 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]"){
227 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
231 #check if we just close a rule
232 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'} ) {
233 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
235 $fwdfwsettings{'nosave2'} = 'on';
238 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
239 if ($fwdfwsettings{'nobase'} ne 'on'){
240 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
242 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
243 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
244 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
245 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
246 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
247 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
249 if($fwdfwsettings{'nosave2'} ne 'on'){
250 &saverule
(\
%configinputfw,$configinput);
252 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
253 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
254 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
255 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
256 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
257 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
258 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
259 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
260 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
261 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
262 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
263 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
264 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
265 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
266 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
267 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
269 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
270 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
271 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
272 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
273 }elsif($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' ){
275 $fwdfwsettings{'config'}=$configoutgoing;
276 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
277 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
278 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
279 foreach my $key (sort keys %configoutgoingfw){
280 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'}"
281 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]"){
282 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
283 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
285 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
286 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
288 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
289 $fwdfwsettings{'nosave'} = 'on';
294 #check Rulepos on new Rule
295 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
296 print"CHECK OUTGOING DOPPELTE REGEL<br>";
297 $fwdfwsettings{'oldrulenumber'}=$maxkey;
298 foreach my $key (sort keys %configoutgoingfw){
299 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'}"
300 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]"){
301 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
305 #check if we just close a rule
306 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'} ) {
307 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
308 $fwdfwsettings{'nosave2'} = 'on';
313 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
314 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
315 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
316 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
317 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
318 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
319 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
320 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
322 if ($fwdfwsettings{'nobase'} eq 'on'){
323 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
325 if ($fwdfwsettings{'nosave2'} ne 'on'){
326 &saverule
(\
%configoutgoingfw,$configoutgoing);
330 $fwdfwsettings{'config'}=$configfwdfw;
331 $fwdfwsettings{'chain'} = 'FORWARDFW';
332 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
333 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
334 #check if we have an identical rule already
335 foreach my $key (sort keys %configfwdfw){
336 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'}"
337 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]"){
338 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
339 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
341 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
342 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
344 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
345 $fwdfwsettings{'nosave'} = 'on';
350 #check Rulepos on new Rule
351 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
352 $fwdfwsettings{'oldrulenumber'}=$maxkey;
353 foreach my $key (sort keys %configfwdfw){
354 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'}"
355 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]"){
356 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
360 #check if we just close a rule
361 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'} ) {
362 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
363 $fwdfwsettings{'nosave2'} = 'on';
368 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
369 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
370 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
371 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
372 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
373 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
374 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
375 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
377 if ($fwdfwsettings{'nobase'} eq 'on'){
378 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
380 if ($fwdfwsettings{'nosave2'} ne 'on'){
381 &saverule
(\
%configfwdfw,$configfwdfw);
383 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
384 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
385 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
386 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
387 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
388 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
389 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
390 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
391 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
392 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
393 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
394 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
395 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
396 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
397 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
398 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
400 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
401 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
402 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
403 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
408 if($fwdfwsettings{'nosave2'} ne 'on'){
414 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
416 if($fwdfwsettings{'poltype'} eq 'forward'){
417 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
418 foreach my $key (sort keys %configfwdfw){
419 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
420 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
421 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
423 &General
::readhasharray
("$configinput", \
%configinputfw);
424 foreach my $key (sort keys %configinputfw){
425 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
426 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
427 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
430 system("rm ${General::swroot}/forward/config");
431 system("rm ${General::swroot}/forward/input");
432 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
433 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
434 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
435 my $MODE1=$fwdfwsettings{'POLICY1'};
437 $fwdfwsettings{'POLICY'}='MODE2';
438 $fwdfwsettings{'POLICY1'}=$MODE1;
439 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
442 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
443 foreach my $key (sort keys %configoutgoingfw){
444 &checkcounter
($configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],,);
445 &checkcounter
($configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],,);
446 &checkcounter
($configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],,);
448 system("rm ${General::swroot}/forward/outgoing");
449 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
450 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
451 my $MODE=$fwdfwsettings{'POLICY'};
453 $fwdfwsettings{'POLICY'}=$MODE;
454 $fwdfwsettings{'POLICY1'}='MODE2';
455 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
459 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
463 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
466 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
467 foreach my $key (sort keys %togglehash){
468 if ($key eq $fwdfwsettings{'key'}){
469 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
472 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
476 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
479 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
480 foreach my $key (sort keys %togglehash){
481 if ($key eq $fwdfwsettings{'key'}){
482 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
485 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
489 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
494 if ($fwdfwsettings{'ACTION'} eq 'editrule')
496 $fwdfwsettings{'updatefwrule'}='on';
499 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
503 if ($fwdfwsettings{'ACTION'} eq 'moveup')
508 if ($fwdfwsettings{'ACTION'} eq 'movedown')
513 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
515 $fwdfwsettings{'copyfwrule'}='on';
516 #$fwdfwsettings{'updatefwrule'}='on';
519 if ($fwdfwsettings{'ACTION'} eq '')
527 if (-f
"${General::swroot}/forward/reread"){
528 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>";
530 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
531 print "<form method='post'>";
532 print "<table border='0'>";
533 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
534 print"</tr></table></form><hr>";
540 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
541 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
542 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){ $selected{'POLICY1'}{'MODE1'} = 'selected'; } else { $selected{'POLICY1'}{'MODE1'} = ''; }
543 if ($fwdfwsettings{'POLICY1'} eq 'MODE2'){ $selected{'POLICY1'}{'MODE2'} = 'selected'; } else { $selected{'POLICY1'}{'MODE2'} = ''; }
547 &Header
::openbox
('100%', 'center', $Lang::tr
{'fwdfw pol title'});
549 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
550 <table width='100%' border='0'>
551 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>FORWARD </td></tr>
552 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text'}</td></tr>
553 <tr><td colspan='3'><hr /></td></tr>
554 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
555 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
556 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
557 <input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td><td width='45%' align='right'>
560 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='forward' /></td></tr>";
561 print "</table></form>";
564 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
565 <table width='100%' border='0'>
566 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>OUTGOING </td></tr>
567 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text1'}</td></tr>
568 <tr><td colspan='3'><hr /></td></tr>
569 <tr><td width='15%' align='left'> <select name='POLICY1' style="width: 100px">
570 <option value='MODE1' $selected{'POLICY1'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
571 <option value='MODE2' $selected{'POLICY1'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
572 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td><td width='45%' align='right'>
575 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='outgoing' /></tr>";
576 print "</table></form>";
578 print "<br><br><div align='right'><font size='1' color='grey'>Version: $VERSION</div>";
584 $fwdfwsettings{'updatefwrule'}='';
585 $fwdfwsettings{'config'}=$oldchain;
586 $fwdfwsettings{'nobase'}='on';
588 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
589 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
595 #check ip-address if manual
596 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
597 #check if ip with subnet
598 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
599 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
600 $subnet = &General
::iporsubtocidr
($subnet);
601 $fwdfwsettings{'isip'}='on';
604 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
605 $ip=$fwdfwsettings{'src_addr'};
607 $fwdfwsettings{'isip'}='on';
610 if ($fwdfwsettings{'isip'} ne 'on'){
611 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
613 if ($fwdfwsettings{'isip'} eq 'on'){
614 #check and form valid IP
615 $ip=&General
::ip2dec
($ip);
616 $ip=&General
::dec2ip
($ip);
617 #check if net or broadcast
618 my @tmp= split (/\./,$ip);
619 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
621 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
623 $fwdfwsettings{'src_addr'}="$ip/$subnet";
625 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
626 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
629 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
630 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
632 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
633 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
634 return $errormessage;
638 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
640 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
641 $fwdfwsettings{'SRC_PORT'}='';
642 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
643 foreach my $key (keys %icmptypes){
644 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
645 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
648 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
649 $fwdfwsettings{'SRC_PORT'}='';
650 $fwdfwsettings{'ICMP_TYPES'}='';
651 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
652 $fwdfwsettings{'SRC_PORT'}='';
653 $fwdfwsettings{'ICMP_TYPES'}='';
654 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
655 $fwdfwsettings{'SRC_PORT'}='';
656 $fwdfwsettings{'ICMP_TYPES'}='';
657 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
658 $fwdfwsettings{'ICMP_TYPES'}='';
660 $fwdfwsettings{'ICMP_TYPES'}='';
661 $fwdfwsettings{'SRC_PORT'}='';
662 $fwdfwsettings{'PROT'}='';
665 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
666 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
670 if ($_ =~ /^(\d+)\:(\d+)$/) {
672 #change dashes with :
675 push(@values,"1:65535");
678 if ($_ =~ /^(\D)\:(\d+)$/) {
679 push(@values,"1:$2");
682 if ($_ =~ /^(\d+)\:(\D)$/) {
683 push(@values,"$1:65535");
686 $errormessage .= &General
::validportrange
($_, 'destination');
691 if (&General
::validport
($_)){
698 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
699 return $errormessage;
706 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
707 #check if ip with subnet
708 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
709 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
710 $subnet = &General
::iporsubtocidr
($subnet);
713 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
714 $ip=$fwdfwsettings{'tgt_addr'};
717 #check and form valid IP
718 $ip=&General
::ip2dec
($ip);
719 $ip=&General
::dec2ip
($ip);
721 ##check if net or broadcast
722 #my @tmp= split (/\./,$ip);
723 #if ($tmp[3] eq "0" || ($tmp[3] eq "255"))
725 #$errormessage=$Lang::tr{'fwhost err hostip'}."<br>";
727 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
729 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
730 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
733 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
734 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
735 return $errormessage;
739 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
742 if ($fwdfwsettings{'USESRV'} eq 'ON'){
743 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
744 $fwdfwsettings{'TGT_PROT'}='';
745 $fwdfwsettings{'ICMP_TGT'}='';
747 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
748 $fwdfwsettings{'TGT_PROT'}='';
749 $fwdfwsettings{'ICMP_TGT'}='';
750 #check target service
751 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
752 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
755 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
756 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
757 if ($fwdfwsettings{'TGT_PORT'} ne ''){
758 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
762 if ($_ =~ /^(\d+)\:(\d+)$/) {
764 #change dashes with :
767 push(@values,"1:65535");
770 if ($_ =~ /^(\D)\:(\d+)$/) {
771 push(@values,"1:$2");
774 if ($_ =~ /^(\d+)\:(\D)$/) {
775 push(@values,"$1:65535");
778 $errormessage .= &General
::validportrange
($_, 'destination');
783 if (&General
::validport
($_)){
790 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
792 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
793 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
794 $fwdfwsettings{'TGT_PORT'} = '';
795 $fwdfwsettings{'ICMP_TGT'} = '';
796 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
797 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
798 $fwdfwsettings{'TGT_PORT'} = '';
799 $fwdfwsettings{'ICMP_TGT'}='';
800 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
801 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
802 $fwdfwsettings{'TGT_PORT'} = '';
803 $fwdfwsettings{'ICMP_TGT'}='';
804 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
805 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
806 $fwdfwsettings{'TGT_PORT'} = '';
807 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
808 foreach my $key (keys %icmptypes){
810 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
811 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
819 if ($fwdfwsettings{'USESRV'} ne 'ON'){
820 $fwdfwsettings{'grp3'}='';
821 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
822 $fwdfwsettings{'TGT_PROT'}='';
823 $fwdfwsettings{'ICMP_TGT'}='';
826 if($fwdfwsettings{'TIME'} eq 'ON'){
827 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 ''){
828 $errormessage=$Lang::tr
{'fwdfw err time'};
831 return $errormessage;
836 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
837 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
839 #check if source and target identical
840 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
841 $errormessage.=$Lang::tr
{'fwdfw err same'};
842 return $errormessage;
845 #get source and targetip address if possible
846 my ($sip,$scidr,$tip,$tcidr);
847 ($sip,$scidr)=&get_ip
("src","grp1");
848 ($tip,$tcidr)=&get_ip
("tgt","grp2");
850 #check same iprange in source and target
851 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
852 my $networkip1=&General
::getnetworkip
($sip,$scidr);
853 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
854 if ($scidr gt $tcidr){
855 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
856 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
858 }elsif($scidr eq $tcidr && $scidr eq '32'){
859 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
860 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
861 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
862 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
863 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
866 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
867 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
872 #check source and destination protocol if manual
873 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
874 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
875 $errormessage.=$Lang::tr
{'fwdfw err prot'};
877 #check source and destination protocol if source manual and dest servicegrp
878 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
879 &General
::readhasharray
("$configsrv", \
%customservice);
880 foreach my $key (sort keys %customservice){
881 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
882 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
883 $errormessage.=$Lang::tr
{'fwdfw err prot'};
893 my ($base1,$val1,$base2,$val2) = @_;
895 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
896 &dec_counter
($confignet,\
%customnetwork,$val1);
897 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
898 &dec_counter
($confighost,\
%customhost,$val1);
899 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
900 &dec_counter
($configgrp,\
%customgrp,$val1);
901 }elsif($base1 eq 'cust_srv'){
902 &dec_counter
($configsrv,\
%customservice,$val1);
903 }elsif($base1 eq 'cust_srvgrp'){
904 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
907 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
908 &inc_counter
($confignet,\
%customnetwork,$val2);
909 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
910 &inc_counter
($confighost,\
%customhost,$val2);
911 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
912 &inc_counter
($configgrp,\
%customgrp,$val2);
913 }elsif($base2 eq 'cust_srv'){
914 &inc_counter
($configsrv,\
%customservice,$val2);
915 }elsif($base2 eq 'cust_srvgrp'){
916 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
922 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
923 foreach my $key (sort {$a <=> $b} keys %delhash){
924 if ($key == $fwdfwsettings{'key'}){
925 #check hosts/net and groups
926 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
927 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
928 #check services and groups
929 if ($delhash{$key}[11] eq 'ON'){
930 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
933 if ($key >= $fwdfwsettings{'key'}) {
935 if (exists $delhash{$next}) {
936 foreach my $i (0 .. $#{$delhash{$next}}) {
937 $delhash{$key}[$i] = $delhash{$next}[$i];
942 # Remove the very last entry.
943 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
944 delete $delhash{$last_key};
946 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
949 if($fwdfwsettings{'nobase'} ne 'on'){
956 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
957 foreach my $key (sort keys %configfwdfw){
959 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
962 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
971 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
972 &General
::readhasharray
($config, \
%hash);
973 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
974 if($hash{$key}[0] eq $val){
975 $pos=$#{$hash{$key}};
976 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
979 &General
::writehasharray
($config, \
%hash);
984 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
985 print "<class name='base'>$errormessage\n";
986 print " </class>\n";
996 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
997 if($hash{$key}[0] eq $val){
998 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1000 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1010 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1011 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1012 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1013 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1014 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1015 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1016 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1017 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1018 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1019 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1020 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1021 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1022 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1023 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1024 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1025 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1026 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1027 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1029 <table width='100%' border='0'>
1030 <tr><td width='50%' valign='top'>
1031 <table width='100%' border='0'>
1032 <tr><td width='1%'><input type='radio' name='$grp' value='std_net_$srctgt' $checked{$grp}{'std_net_'.$srctgt}></td><td>$Lang::tr{'fwhost stdnet'}</td><td align='right'><select name='std_net_$srctgt' style='width:200px;'>
1034 foreach my $network (sort keys %defaultNetworks)
1036 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1037 next if($defaultNetworks{$network}{'NAME'} eq "IPFire" && $srctgt eq 'tgt');
1038 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1039 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1040 print ">$network</option>";
1042 print"</select></td></tr>";
1044 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1045 print"<tr><td><input type='radio' name='$grp' value='cust_net_$srctgt' $checked{$grp}{'cust_net_'.$srctgt}></td><td>$Lang::tr{'fwhost cust net'}</td><td align='right'><select name='cust_net_$srctgt' style='width:200px;'>";
1046 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1047 print"</select></td>";
1050 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1051 print"<tr><td><input type='radio' name='$grp' value='cust_host_$srctgt' $checked{$grp}{'cust_host_'.$srctgt}></td><td>$Lang::tr{'fwhost cust addr'}</td><td align='right'><select name='cust_host_$srctgt' style='width:200px;'>";
1052 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1053 print"</select></td>";
1056 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1057 print"<tr><td valign='top'><input type='radio' name='$grp' value='cust_grp_$srctgt' $checked{$grp}{'cust_grp_'.$srctgt}></td><td >$Lang::tr{'fwhost cust grp'}</td><td align='right'><select name='cust_grp_$srctgt' style='width:200px;'>";
1058 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1059 if($helper ne $customgrp{$key}[0]){
1061 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1062 print ">$customgrp{$key}[0]</option>";
1064 $helper=$customgrp{$key}[0];
1066 print"</select></td>";
1068 #End left table. start right table (vpn)
1069 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1071 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1072 print"<td width='1%'><input type='radio' name='$grp' value='ovpn_net_$srctgt' $checked{$grp}{'ovpn_net_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_net_$srctgt' style='width:200px;'>";
1073 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1074 print"</select></td></tr>";
1077 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1078 if ($ccdhost{$key}[33] ne '' ){
1079 print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_host_$srctgt' $checked{$grp}{'ovpn_host_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_host_$srctgt' style='width:200px;'>" if ($show eq '');
1081 print "<option value='$ccdhost{$key}[1]'";
1082 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1083 print ">$ccdhost{$key}[1]</option>";
1086 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1087 print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_host_$srctgt' $checked{$grp}{'ovpn_host_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_host_$srctgt' style='width:200px;'></select></td></tr>" ;
1089 if ($show eq '1'){$show='';print"</select></td></tr>";}
1091 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost){
1092 if ($ccdhost{$key}[3] eq 'net'){
1093 print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_n2n_$srctgt' $checked{$grp}{'ovpn_n2n_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ovpn_n2n'}:</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_n2n_$srctgt' style='width:200px;'>" if ($show eq '');
1095 print "<option value='$ccdhost{$key}[1]'";
1096 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1097 print ">$ccdhost{$key}[1]</option>";
1100 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1101 print"<tr><td width='1%'><input type='radio' name='$grp' value='ovpn_n2n_$srctgt' $checked{$grp}{'ovpn_n2n_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ovpn_n2n'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_n2n_$srctgt' style='width:200px;'></select></td></tr>" ;
1103 if ($show eq '1'){$show='';print"</select></td></tr>";}
1105 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1106 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1107 print"<tr><td valign='top'><input type='radio' name='$grp' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'>" if ($show eq '');
1110 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1111 print ">$ipsecconf{$key}[1]</option>";
1114 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1115 print"<tr><td valign='top'><input type='radio' name='$grp' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'><select></td></tr>";
1117 if ($show eq '1'){$show='';print"</select></td></tr>";}
1119 print"</tr></table>";
1120 print"</td></tr></table><br>";
1128 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1129 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1130 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1131 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1132 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1133 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1134 $a=$netsettings{'GREEN_NETADDRESS'};
1135 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1136 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1137 $a=$netsettings{'ORANGE_NETADDRESS'};
1138 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1139 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1140 $a=$netsettings{'BLUE_NETADDRESS'};
1141 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1142 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1143 &General
::readhash
("$configovpn",\
%ovpnsettings);
1144 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1145 $b=&General
::iporsubtocidr
($b);
1147 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1148 &General
::readhasharray
("$confignet", \
%customnetwork);
1149 foreach my $key (keys %customnetwork){
1150 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1151 $a=$customnetwork{$key}[1];
1152 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1155 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1156 &General
::readhasharray
("$confighost", \
%customhost);
1157 foreach my $key (keys %customhost){
1158 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1159 if ($customhost{$key}[1] eq 'ip'){
1160 ($a,$b)=split (/\//,$customhost{$key}[2]);
1161 $b=&General
::iporsubtocidr
($b);
1163 if ($grp eq 'grp2'){
1164 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1176 &General
::setup_default_networks
(\
%defaultNetworks);
1177 foreach my $network (sort keys %defaultNetworks)
1179 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1184 my %hash=%{(shift)};
1186 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1187 $hash{$key}[10]=~ s/\|/,/g;
1188 print": $hash{$key}[10]";
1189 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1190 print": <br>$hash{$key}[9] ";
1195 my %hash=%{(shift)};
1199 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1200 if($hash{$key}[14] eq 'cust_srv'){
1201 &General
::readhasharray
("$configsrv", \
%customservice);
1202 foreach my $i (sort keys %customservice){
1203 if($customservice{$i}[0] eq $hash{$key}[15]){
1204 $service = $customservice{$i}[0];
1207 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1208 $service=$hash{$key}[15];
1209 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1210 $hash{$key}[15]=~ s/\|/,/g;
1211 $service=$hash{$key}[15];
1216 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1217 print":<br>$hash{$key}[13]";
1220 sub get_serviceports
1224 &General
::readhasharray
("$configsrv", \
%customservice);
1225 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1229 if($type eq 'service'){
1230 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1231 if ($customservice{$key}[0] eq $name){
1232 $protocols=$customservice{$key}[2];
1235 }elsif($type eq 'group'){
1236 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1237 if ($customservicegrp{$key}[0] eq $name){
1238 foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1239 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1240 if($customservice{$key1}[2] eq 'TCP'){$tcp='TCP';}else{$udp='UDP';}
1246 if($tcp && $udp){$protocols="TCP,UDP";
1247 }elsif($tcp){$protocols.="TCP";
1248 }elsif($udp){$protocols.="UDP";}
1256 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1258 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'){
1259 $tdcolor="style='border: 1px solid $Header::colourovpn;'";
1262 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1263 $tdcolor="style='border: 1px solid $Header::colourvpn;'";
1267 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1268 foreach my $key (sort keys %$hash){
1269 if ($$hash{$key}[0] eq $val){
1270 $val=$$hash{$key}[2];
1275 foreach my $alias (sort keys %aliases)
1277 if ($val eq $alias){
1278 $tdcolor="style='border: 2px solid red;'";
1283 if ($val eq 'GREEN'){
1284 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1285 }elsif ($val eq 'ORANGE'){
1286 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1287 }elsif ($val eq 'BLUE'){
1288 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1289 }elsif ($val eq 'RED'){
1290 $tdcolor="style='border: 1px solid $Header::colourred;'";
1291 }elsif ($val eq 'IPFire' ){
1292 $tdcolor="style='border: 1px solid $Header::colourred;'";
1293 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1294 my ($sip,$scidr) = split ("/",$val);
1295 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1296 $tdcolor="style='border: 1px solid $Header::colourorange;'";
1298 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1299 $tdcolor="style='border: 1px solid $Header::colourgreen;'";
1301 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1302 $tdcolor="style='border: 1px solid $Header::colourblue;'";
1304 }elsif ($val eq 'Default IP'){
1305 $tdcolor="style='border: 1px solid red;'";
1314 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1315 print "<class name='base'>$hint\n";
1316 print " </class>\n";
1317 &Header
::closebox
();
1324 my %hash=%{(shift)};
1328 &General
::readhasharray
($config, \
%hash);
1329 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1330 if($hash{$key}[0] eq $val){
1331 $pos=$#{$hash{$key}};
1332 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1335 &General
::writehasharray
($config, \
%hash);
1340 &General
::setup_default_networks
(\
%defaultNetworks);
1341 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1342 #read all configfiles
1343 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1344 &General
::readhasharray
("$confignet", \
%customnetwork);
1345 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1346 &General
::readhasharray
("$confighost", \
%customhost);
1347 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1348 &General
::readhasharray
("$configgrp", \
%customgrp);
1349 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1350 &General
::get_aliases
(\
%aliases);
1354 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1355 my $config=$fwdfwsettings{'config'};
1357 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1358 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1359 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1360 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1361 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1362 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1363 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1364 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1365 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1366 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1367 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1368 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1369 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1370 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1371 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1372 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1373 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1374 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1375 #check if update and get values
1376 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1377 &General
::readhasharray
("$config", \
%hash);
1378 foreach my $key (sort keys %hash){
1380 if ($key eq $fwdfwsettings{'key'}){
1381 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1382 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1383 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1384 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1385 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1386 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1387 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1388 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1389 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1390 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1391 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1392 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1393 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1394 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1395 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1396 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1397 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1398 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1399 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1400 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1401 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1402 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1403 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1404 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1405 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1406 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1407 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1408 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1409 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1410 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1411 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1412 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1413 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1414 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1415 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1416 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1417 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1418 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1419 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1420 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1421 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1422 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1423 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1424 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1425 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1426 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1429 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1430 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1431 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1432 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1433 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1434 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1435 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1436 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1437 #check if manual ip (source) is orange network
1438 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1439 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1440 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1441 $fwdfwsettings{'oldorange'} ='on';
1445 $fwdfwsettings{'ACTIVE'}='ON';
1446 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1447 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1448 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1449 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1450 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1451 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1452 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1453 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1454 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1455 #check if manual ip (source) is orange network
1456 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1457 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1458 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1459 $fwdfwsettings{'oldorange'} ='on';
1463 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1466 <form method="post">
1468 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1470 foreach ("ACCEPT","DROP","REJECT")
1472 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1474 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1475 print">$_</option>";
1477 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1478 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1481 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1483 print"<option selected>$_</option>";
1485 print"<option>$_</option>";
1489 print"</select></td></tr></table><hr>";
1491 &Header
::closebox
();
1492 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1493 #------SOURCE-------------------------------------------------------
1495 <table width='100%' border='0'>
1496 <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>
1497 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1500 &gen_dd_block
('src','grp1');
1503 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1504 <table width='100%' border='0'>
1505 <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>
1506 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1508 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1510 if ($_ eq $fwdfwsettings{'PROT'})
1512 print"<option selected>$_</option>";
1514 print"<option>$_</option>";
1517 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1519 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1520 <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;'>
1522 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1523 print"<option>All ICMP-Types</option>";
1524 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1525 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1526 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1528 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1532 </select></td></tr></table><br><hr>
1534 &Header
::closebox
();
1536 #---TARGET------------------------------------------------------
1537 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1539 <table width='100%' border='0'>
1540 <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td colspan='2'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16'><td><input type='radio' name='grp2' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>IPFire ($Lang::tr{'external access'})</b></td><td align='right'><select name='ipfire' style='width:200px;'>
1542 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1544 foreach my $alias (sort keys %aliases)
1546 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1550 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1552 &gen_dd_block
('tgt','grp2');
1554 <b>$Lang::tr{'fwhost attention'}:</b><br>
1555 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1556 <table width='100%' border='0'>
1557 <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;' >
1559 &General
::readhasharray
("$configsrv", \
%customservice);
1560 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1562 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1563 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1567 <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;' >
1569 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1571 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1572 if ($helper ne $customservicegrp{$key}[0]){
1574 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1575 print">$customservicegrp{$key}[0]</option>";
1577 $helper=$customservicegrp{$key}[0];
1581 <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'>
1583 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1585 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1587 print"<option selected>$_</option>";
1589 print"<option>$_</option>";
1592 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1594 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1595 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT' style='min-width:230px;'>
1597 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1598 print"<option>All ICMP-Types</option>";
1599 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1600 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1601 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1603 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1612 #---Activate/logging/remark-------------------------------------
1613 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1615 <table width='100%' border='0'>
1616 <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>
1618 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1619 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1620 for (my $count =1; $count <= $sum; $count++){
1621 print"<option value='$count' ";
1622 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1623 print">$count</option>";
1625 print"</select></td></tr>";
1627 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1631 </table><table width='100%'>
1632 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1633 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1636 &Header
::closebox
();
1637 #---ADD TIMEFRAME-----------------------------------------------
1638 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1640 <table width='70%' border='0'>
1641 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1642 <tr><td colspan='7'> </td></tr>
1644 <td align='left'>$Lang::tr{'time'}:</td>
1645 <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>
1646 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1647 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1650 <td align='right'></td>
1651 <td width='30%' align='left'>
1652 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1653 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1654 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1655 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1656 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1657 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1658 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1660 <td><select name='TIME_FROM'>
1662 for (my $i=0;$i<=23;$i++) {
1663 $i = sprintf("%02s",$i);
1664 for (my $j=0;$j<=45;$j+=15) {
1665 $j = sprintf("%02s",$j);
1666 my $time = $i.":".$j;
1667 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1672 <td><select name='TIME_TO'>
1674 for (my $i=0;$i<=23;$i++) {
1675 $i = sprintf("%02s",$i);
1676 for (my $j=0;$j<=45;$j+=15) {
1677 $j = sprintf("%02s",$j);
1678 my $time = $i.":".$j;
1679 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1686 #---ACTION------------------------------------------------------
1687 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1689 <table border='0' width='100%'>
1690 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1691 <input type='hidden' name='config' value='$config' >
1692 <input type='hidden' name='ACTION' value='saverule' >
1693 </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>
1698 <table border='0' width='100%'>
1699 <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'}'>
1700 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1701 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1702 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1703 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1704 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1705 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1706 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1707 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1708 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1709 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1710 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1711 <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>
1715 &Header
::closebox
();
1721 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1722 foreach my $key (sort keys %uphash){
1723 if ($key eq $fwdfwsettings{'key'}) {
1725 if (exists $uphash{$last}){
1727 foreach my $y (0 .. $#{$uphash{$last}}) {
1728 $tmp{0}[$y] = $uphash{$last}[$y];
1730 #copy active rule to last
1731 foreach my $i (0 .. $#{$uphash{$last}}) {
1732 $uphash{$last}[$i] = $uphash{$key}[$i];
1734 #copy saved rule to actual position
1735 foreach my $x (0 .. $#{$tmp{0}}) {
1736 $uphash{$key}[$x] = $tmp{0}[$x];
1741 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1748 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1749 foreach my $key (sort keys %downhash){
1750 if ($key eq $fwdfwsettings{'key'}) {
1751 my $next = $key + 1;
1752 if (exists $downhash{$next}){
1754 foreach my $y (0 .. $#{$downhash{$next}}) {
1755 $tmp{0}[$y] = $downhash{$next}[$y];
1757 #copy active rule to next
1758 foreach my $i (0 .. $#{$downhash{$next}}) {
1759 $downhash{$next}[$i] = $downhash{$key}[$i];
1761 #copy saved rule to actual position
1762 foreach my $x (0 .. $#{$tmp{0}}) {
1763 $downhash{$key}[$x] = $tmp{0}[$x];
1768 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1773 if (!-f
"${General::swroot}/forward/reread"){
1774 system("touch ${General::swroot}/forward/reread");
1775 system("touch ${General::swroot}/fwhosts/reread");
1780 system("/usr/local/bin/forwardfwctrl");
1781 if ( -f
"${General::swroot}/forward/reread"){
1782 system("rm ${General::swroot}/forward/reread");
1783 system("rm ${General::swroot}/fwhosts/reread");
1790 &General
::readhasharray
("$config", $hash);
1791 if (!$errormessage){
1792 #check if we change a DMZ to an outgoing
1793 if( ($fwdfwsettings{'oldgrp1b'} eq 'ORANGE' || $fwdfwsettings{'oldorange'} eq 'on') && $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1794 &changerule
($configdmz);
1797 #check if we change a DMZ to an external access
1798 elsif( $fwdfwsettings{'oldgrp1b'} eq 'ORANGE' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE' && $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1799 &changerule
($configdmz);
1802 #check if we change an external access rule to a outgoing
1803 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'oldgrp1b'} ne 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1804 &changerule
($configinput);
1807 #check if we change an external access rule to a DMZ
1808 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1809 &changerule
($configinput);
1812 #check if we change an outgoing rule to a external access
1813 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1814 &changerule
($configoutgoing);
1817 #check if we change an outgoing rule to a DMZ
1818 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1819 &changerule
($configoutgoing);
1822 #check if we change an forward rule to an external access
1823 elsif( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1824 &changerule
($configfwdfw);
1827 #check if we change an forward rule to an DMZ
1828 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && ($fwdfwsettings{'oldgrp1b'} ne 'ORANGE' && $fwdfwsettings{'oldorange'} ne 'on') && $fwdfwsettings{'updatefwrule'} eq 'on'){
1829 &changerule
($configfwdfw);
1832 #check if we change an forward rule to an outgoing
1833 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'oldgrp1b'} ne 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1834 &changerule
($configfwdfw);
1837 #check if we change a DMZ to a forward
1838 elsif( ($fwdfwsettings{'oldgrp1b'} eq 'ORANGE' || $fwdfwsettings{'oldorange'} eq 'on') && ($fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE' && $checkorange ne 'on') && $fwdfwsettings{'updatefwrule'} eq 'on'){
1839 &changerule
($configdmz);
1842 #check if we change an external access rule to a forward
1843 elsif( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1844 &changerule
($configinput);
1847 #check if we change an outgoing rule to a forward
1848 elsif( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1849 &changerule
($configoutgoing);
1852 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1853 my $key = &General
::findhasharraykey
($hash);
1854 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1855 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1856 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1857 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1858 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1859 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1860 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1861 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1862 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1863 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1864 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1865 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1866 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1867 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1868 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1869 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1870 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1871 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1872 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1873 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1874 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1875 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1876 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1877 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1878 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1879 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1880 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1881 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1882 &General
::writehasharray
("$config", $hash);
1884 foreach my $key (sort {$a <=> $b} keys %$hash){
1885 if($key eq $fwdfwsettings{'key'}){
1886 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1887 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1888 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1889 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1890 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1891 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1892 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1893 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1894 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1895 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1896 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1897 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1898 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1899 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1900 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1901 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1902 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1903 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1904 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1905 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1906 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1907 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1908 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1909 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1910 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1911 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1912 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1913 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1918 &General
::writehasharray
("$config", $hash);
1919 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
1921 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1922 for (my $z=0;$z<$val;$z++){
1923 foreach my $key (sort {$a <=> $b} keys %$hash){
1924 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1926 if (exists $$hash{$last}){
1928 foreach my $y (0 .. $#{$$hash{$last}}) {
1929 $tmp{0}[$y] = $$hash{$last}[$y];
1931 #copy active rule to last
1932 foreach my $i (0 .. $#{$$hash{$last}}) {
1933 $$hash{$last}[$i] = $$hash{$key}[$i];
1935 #copy saved rule to actual position
1936 foreach my $x (0 .. $#{$tmp{0}}) {
1937 $$hash{$key}[$x] = $tmp{0}[$x];
1942 $fwdfwsettings{'oldrulenumber'}--;
1944 &General
::writehasharray
("$config", $hash);
1946 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
1948 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1949 for (my $z=0;$z<$val;$z++){
1950 foreach my $key (sort {$a <=> $b} keys %$hash){
1951 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1952 my $next = $key + 1;
1953 if (exists $$hash{$next}){
1955 foreach my $y (0 .. $#{$$hash{$next}}) {
1956 $tmp{0}[$y] = $$hash{$next}[$y];
1958 #copy active rule to next
1959 foreach my $i (0 .. $#{$$hash{$next}}) {
1960 $$hash{$next}[$i] = $$hash{$key}[$i];
1962 #copy saved rule to actual position
1963 foreach my $x (0 .. $#{$tmp{0}}) {
1964 $$hash{$key}[$x] = $tmp{0}[$x];
1969 $fwdfwsettings{'oldrulenumber'}++;
1971 &General
::writehasharray
("$config", $hash);
1978 # Checks a hostname against RFC1035
1981 # Each part should be at least two characters in length
1982 # but no more than 63 characters
1983 if (length ($remark) < 1 || length ($remark) > 255) {
1985 # Only valid characters are a-z, A-Z, 0-9 and -
1986 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
1988 # First character can only be a letter or a digit
1989 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1991 # Last character can only be a letter or a digit
1992 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
1998 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1999 &viewtablenew
(\
%configdmzfw,$configdmz,$Lang::tr
{'fwdfw rules'},"DMZ" );
2000 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
2001 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
2002 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
2011 &General
::get_aliases
(\
%aliases);
2012 &General
::readhasharray
("$confighost", \
%customhost);
2013 &General
::readhasharray
("$config", $hash);
2015 &Header
::openbox
('100%', 'left',$title);
2023 print"<b>$title1</b><br>";
2024 print"<table width='100%' cellspacing='0' cellpadding='0'>";
2025 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>";
2026 foreach my $key (sort {$a <=> $b} keys %$hash){
2029 #check if vpn hosts/nets have been deleted
2030 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2031 push (@tmpsrc,$$hash{$key}[4]);
2033 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2034 push (@tmpsrc,$$hash{$key}[6]);
2036 foreach my $host (@tmpsrc){
2037 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2038 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2040 &disable_rule
($key);
2043 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2044 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2046 &disable_rule
($key);
2049 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2050 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2052 &disable_rule
($key);
2055 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2056 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2058 &disable_rule
($key);
2062 #$$hash{$key}[3]='';
2063 #$$hash{$key}[5]='';
2065 $$hash{'ACTIVE'}=$$hash{$key}[2];
2067 if($coloryellow eq 'on'){
2068 print"<tr bgcolor='$color{'color14'}' >";
2070 }elsif($coloryellow eq ''){
2072 $color="$color{'color22'}";
2075 $color="$color{'color20'}";
2078 print"<tr bgcolor='$color' >";
2080 <td align='right' width='15'><b>$key</b></td>
2082 if ($$hash{$key}[0] eq 'ACCEPT'){
2085 $rulecolor=$color{'color17'};
2086 }elsif($$hash{$key}[0] eq 'DROP'){
2089 $rulecolor=$color{'color25'};
2090 }elsif($$hash{$key}[0] eq 'REJECT'){
2093 $rulecolor=$color{'color16'};
2095 print"<td bgcolor='$rulecolor' align='center' width='20'><span title='$tooltip'><b>$ruletype</b></span></td>";
2096 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2097 print"<td align='center' width='160' $tdcolor>";
2098 if ($$hash{$key}[3] eq 'std_net_src'){
2099 print &get_name
($$hash{$key}[4]);
2101 print $$hash{$key}[4];
2104 &getsrcport
(\
%$hash,$key);
2105 if ($$hash{$key}[17] eq 'ON'){
2106 $log="/images/on.gif";
2108 $log="/images/off.gif";
2112 <form method='post'>
2113 <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 ;'/>
2114 <input type='hidden' name='key' value='$key' />
2115 <input type='hidden' name='config' value='$config' />
2116 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2119 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2121 <td align='center' width='160' $tdcolor>
2123 if ($$hash{$key}[5] eq 'std_net_tgt'){
2124 print &get_name
($$hash{$key}[6]);
2126 print $$hash{$key}[6];
2129 &gettgtport
(\
%$hash,$key);
2133 if ($$hash{$key}[12]){ #target prot if manual
2134 $prot=$$hash{$key}[12];
2135 }elsif($$hash{$key}[8]){ #source prot if manual
2136 $prot=$$hash{$key}[8];
2137 }elsif($$hash{$key}[14] eq 'cust_srv'){
2138 $prot=&get_serviceports
("service",$$hash{$key}[15]);
2139 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2140 $prot=&get_serviceports
("group",$$hash{$key}[15]);
2142 $prot=$Lang::tr
{'all'};
2144 print"<td align='center'>$prot</td>";
2145 if ($$hash{$key}[18] eq 'ON'){
2147 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2148 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2149 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2150 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2151 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2152 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2153 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2154 my $weekdays=join(",",@days);
2156 print"<td align='center' width='100'>$weekdays   $$hash{$key}[26] - $$hash{$key}[27]</td>";
2159 print"<td align='center'>24/7</td>";
2161 if($$hash{$key}[2] eq 'ON'){
2162 $gif="/images/on.gif"
2165 $gif="/images/off.gif"
2168 <form method='post'>
2169 <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;' />
2170 <input type='hidden' name='key' value='$key' />
2171 <input type='hidden' name='config' value='$config' />
2172 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2174 <form method='post'>
2175 <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;' />
2176 <input type='hidden' name='key' value='$key' />
2177 <input type='hidden' name='config' value='$config' />
2178 <input type='hidden' name='ACTION' value='editrule' />
2180 <form method='post'>
2181 <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;' />
2182 <input type='hidden' name='key' value='$key' />
2183 <input type='hidden' name='config' value='$config' />
2184 <input type='hidden' name='ACTION' value='copyrule' />
2186 <form method='post'>
2187 <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;' />
2188 <input type='hidden' name='key' value='$key' />
2189 <input type='hidden' name='config' value='$config' />
2190 <input type='hidden' name='ACTION' value='deleterule' />
2193 if (exists $$hash{$key-1}){
2195 <form method='post'>
2196 <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;' />
2197 <input type='hidden' name='key' value='$key' />
2198 <input type='hidden' name='config' value='$config' />
2199 <input type='hidden' name='ACTION' value='moveup' />
2203 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2205 if (exists $$hash{$key+1}){
2207 <form method='post'>
2208 <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;' />
2209 <input type='hidden' name='key' value='$key' />
2210 <input type='hidden' name='config' value='$config' />
2211 <input type='hidden' name='ACTION' value='movedown' />
2212 </td></form></td></tr>
2215 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2218 if ($optionsfw{'SHOWREMARK'} eq 'on'){
2219 print"<tr bgcolor='$color'>";
2220 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='11'>  $$hash{$key}[16]</td></tr>";
2222 print"<tr bgcolor='$color'><td height='1'></td><td bgcolor='$rulecolor'></td><td colspan='11'></td></tr>";
2225 &Header
::closebox
();
2229 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2230 print "<b>$title1</b><br>";
2231 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>";
2237 &Header
::closebigbox
();
2238 &Header
::closepage
();