]>
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"); }
51 my %defaultNetworks=();
55 my %customnetworks=();
57 my %customservicegrp=();
73 my $confignet = "${General::swroot}/fwhosts/customnetworks";
74 my $confighost = "${General::swroot}/fwhosts/customhosts";
75 my $configgrp = "${General::swroot}/fwhosts/customgroups";
76 my $configsrv = "${General::swroot}/fwhosts/customservices";
77 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
78 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
79 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
80 my $configipsec = "${General::swroot}/vpn/config";
81 my $configipsecrw = "${General::swroot}/vpn/settings";
82 my $configfwdfw = "${General::swroot}/forward/config";
83 my $configinput = "${General::swroot}/forward/input";
84 my $configovpn = "${General::swroot}/ovpn/settings";
85 my $p2pfile = "${General::swroot}/forward/p2protocols";
88 my $ipgrp="${General::swroot}/outgoing/groups";
91 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
92 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
93 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
95 &Header
::showhttpheaders
();
96 &Header
::getcgihash
(\
%fwdfwsettings);
97 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
98 &Header
::openbigbox
('100%', 'center',$errormessage);
101 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
103 my $MODE = $fwdfwsettings{'POLICY'};
105 $fwdfwsettings{'POLICY'} = "$MODE";
106 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
109 if ($fwdfwsettings{'ACTION'} eq 'saverule')
111 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
112 &General
::readhasharray
("$configinput", \
%configinputfw);
113 $errormessage=&checksource
;
114 if(!$errormessage){&checktarget
;}
115 if(!$errormessage){&checkrule
;}
116 #check if we change an forward rule to an external access
117 if( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
118 $fwdfwsettings{'updatefwrule'}='';
119 $fwdfwsettings{'config'}=$configfwdfw;
120 $fwdfwsettings{'nobase'}='on';
122 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
123 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
125 #check if we change an external access rule to an forward
126 if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
127 $fwdfwsettings{'updatefwrule'}='';
128 $fwdfwsettings{'config'}=$configinput;
129 $fwdfwsettings{'nobase'}='on';
131 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
132 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
135 if($fwdfwsettings{'grp2'} eq 'ipfire'){
136 $fwdfwsettings{'chain'} = 'INPUTFW';
137 #check if we have an identical rule already
138 if($fwdfwsettings{'oldrulenumer'} eq $fwdfwsettings{'rulepos'}){
139 foreach my $key (sort keys %configinputfw){
140 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'}"
141 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]"){
142 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
143 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && &validremark
($fwdfwsettings{'ruleremark'})){
145 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && !&validremark
($fwdfwsettings{'ruleremark'})){
146 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
148 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
149 $fwdfwsettings{'nosave'} = 'on';
154 #check if we just close a rule
155 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'} ) {
156 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
158 $fwdfwsettings{'nosave2'} = 'on';
161 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
162 if ($fwdfwsettings{'nobase'} ne 'on'){
163 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
165 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
166 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
167 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
168 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
169 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
170 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
172 if($fwdfwsettings{'nosave2'} ne 'on'){
173 &saverule
(\
%configinputfw,$configinput);
175 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
176 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
177 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
178 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
179 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
180 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
181 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
182 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
183 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
184 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
185 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
186 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
187 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
188 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
189 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
190 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
192 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
193 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
194 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
195 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
198 $fwdfwsettings{'chain'} = 'FORWARDFW';
199 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
200 #check if we have an identical rule already
201 foreach my $key (sort keys %configfwdfw){
202 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'}"
203 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]"){
204 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
205 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && &validremark
($fwdfwsettings{'ruleremark'})){
207 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && !&validremark
($fwdfwsettings{'ruleremark'})){
208 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
210 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
211 $fwdfwsettings{'nosave'} = 'on';
216 #check if we just close a rule
217 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'} ) {
218 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
219 $fwdfwsettings{'nosave2'} = 'on';
224 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
225 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
226 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
227 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
228 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
229 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
230 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
231 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
233 if ($fwdfwsettings{'nobase'} eq 'on'){
234 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
236 if ($fwdfwsettings{'nosave2'} ne 'on'){
237 &saverule
(\
%configfwdfw,$configfwdfw);
239 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
240 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
241 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
242 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
243 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
244 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
245 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
246 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
247 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
248 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
249 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
250 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
251 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
252 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
253 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
254 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
256 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
257 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
258 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
259 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
264 if($fwdfwsettings{'nosave2'} ne 'on'){
270 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
272 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
273 foreach my $key (sort keys %configfwdfw){
274 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
275 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
276 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
278 &General
::readhasharray
("$configinput", \
%configinputfw);
279 foreach my $key (sort keys %configinputfw){
280 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
281 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
282 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
284 $fwdfwsettings{'POLICY'}='MODE0';
285 system("rm ${General::swroot}/forward/config");
286 system("rm ${General::swroot}/forward/input");
287 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
288 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
289 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
294 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
298 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
301 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
302 foreach my $key (sort keys %togglehash){
303 if ($key eq $fwdfwsettings{'key'}){
304 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
307 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
311 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
314 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
315 foreach my $key (sort keys %togglehash){
316 if ($key eq $fwdfwsettings{'key'}){
317 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
320 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
324 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
329 if ($fwdfwsettings{'ACTION'} eq 'editrule')
331 $fwdfwsettings{'updatefwrule'}='on';
334 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
338 if ($fwdfwsettings{'ACTION'} eq 'moveup')
343 if ($fwdfwsettings{'ACTION'} eq 'movedown')
348 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
350 $fwdfwsettings{'copyfwrule'}='on';
351 #$fwdfwsettings{'updatefwrule'}='on';
354 if ($fwdfwsettings{'ACTION'} eq 'togglep2p')
356 #$errormessage="Toggle $fwdfwsettings{'P2PROT'}<br>";
357 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
360 open( FILE
, "> $p2pfile" ) or die "Unable to write $p2pfile";
361 foreach my $p2pentry (sort @p2ps)
363 my @p2pline = split( /\;/, $p2pentry );
364 if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) {
365 if($p2pline[2] eq 'on'){
371 print FILE
"$p2pline[0];$p2pline[1];$p2pline[2];\n";
377 if ($fwdfwsettings{'ACTION'} eq '')
386 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
387 foreach my $key (sort keys %uphash){
388 if ($key eq $fwdfwsettings{'key'}) {
390 if (exists $uphash{$last}){
392 foreach my $y (0 .. $#{$uphash{$last}}) {
393 $tmp{0}[$y] = $uphash{$last}[$y];
395 #copy active rule to last
396 foreach my $i (0 .. $#{$uphash{$last}}) {
397 $uphash{$last}[$i] = $uphash{$key}[$i];
399 #copy saved rule to actual position
400 foreach my $x (0 .. $#{$tmp{0}}) {
401 $uphash{$key}[$x] = $tmp{0}[$x];
406 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
413 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
414 foreach my $key (sort keys %downhash){
415 if ($key eq $fwdfwsettings{'key'}) {
417 if (exists $downhash{$next}){
419 foreach my $y (0 .. $#{$downhash{$next}}) {
420 $tmp{0}[$y] = $downhash{$next}[$y];
422 #copy active rule to next
423 foreach my $i (0 .. $#{$downhash{$next}}) {
424 $downhash{$next}[$i] = $downhash{$key}[$i];
426 #copy saved rule to actual position
427 foreach my $x (0 .. $#{$tmp{0}}) {
428 $downhash{$key}[$x] = $tmp{0}[$x];
433 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
438 my ($base1,$val1,$base2,$val2) = @_;
440 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
441 &dec_counter
($confignet,\
%customnetwork,$val1);
442 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
443 &dec_counter
($confighost,\
%customhost,$val1);
444 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
445 &dec_counter
($configgrp,\
%customgrp,$val1);
446 }elsif($base1 eq 'cust_srv'){
447 &dec_counter
($configsrv,\
%customservice,$val1);
448 }elsif($base1 eq 'cust_srvgrp'){
449 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
452 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
453 &inc_counter
($confignet,\
%customnetwork,$val2);
454 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
455 &inc_counter
($confighost,\
%customhost,$val2);
456 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
457 &inc_counter
($configgrp,\
%customgrp,$val2);
458 }elsif($base2 eq 'cust_srv'){
459 &inc_counter
($configsrv,\
%customservice,$val2);
460 }elsif($base2 eq 'cust_srvgrp'){
461 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
471 &General
::readhasharray
($config, \
%hash);
472 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
473 if($hash{$key}[0] eq $val){
474 $pos=$#{$hash{$key}};
475 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
478 &General
::writehasharray
($config, \
%hash);
486 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
487 &General
::readhasharray
($config, \
%hash);
488 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
489 if($hash{$key}[0] eq $val){
490 $pos=$#{$hash{$key}};
491 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
494 &General
::writehasharray
($config, \
%hash);
498 if ($fwdfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
499 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
500 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
503 if ($fwdfwsettings{'POLICY'} ne 'MODE0' && $fwdfwsettings{'POLICY'} ne '') {
507 #print"<table width='100' border='1'><tr>";
510 #print"<td bgcolor='$color{$i}'>$_</td>";
512 #print"</tr></table>";
513 if ($fwdfwsettings{'POLICY'} eq 'MODE1' || $fwdfwsettings{'POLICY'} eq 'MODE2' ) {
516 &Header
::openbox
('100%', 'center', 'Policy');
518 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
520 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 0:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode0'}</td></tr>
521 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 1:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode1'}</td></tr>
522 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 2:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode2'}</td></tr>
523 <tr><td colspan='3'><hr /></td></tr>
524 <tr><td width='10%' align='left'> <select name='POLICY' style="width: 85px"><option value='MODE0' $selected{'POLICY'}{'MODE0'}>$Lang::tr{'mode'} 0</option><option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'mode'} 1</option><option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'mode'} 2</option></select>
525 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
526 <td width='45%' align='left'>
528 if ($fwdfwsettings{'POLICY'} ne 'MODE0'&& $fwdfwsettings{'POLICY'} ne '' ) {
529 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
531 print "</table></form>";
537 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
539 print "<form method='post'>";
540 print "<table border='0'>";
541 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
542 if (-f
"${General::swroot}/forward/reread"){
543 print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'></td>";
545 print"</tr></table></form><hr>";
553 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
554 foreach my $key (sort {$a <=> $b} keys %delhash){
555 if ($key == $fwdfwsettings{'key'}){
556 #check hosts/net and groups
557 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
558 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
559 #check services and groups
560 if ($delhash{$key}[11] eq 'ON'){
561 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
564 if ($key >= $fwdfwsettings{'key'}) {
566 if (exists $delhash{$next}) {
567 foreach my $i (0 .. $#{$delhash{$next}}) {
568 $delhash{$key}[$i] = $delhash{$next}[$i];
573 # Remove the very last entry.
574 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
575 delete $delhash{$last_key};
577 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
580 if($fwdfwsettings{'nobase'} ne 'on'){
587 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
588 foreach my $key (sort keys %configfwdfw){
590 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
593 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
600 #check ip-address if manual
601 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
602 #check if ip with subnet
603 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
604 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
605 $subnet = &General
::iporsubtocidr
($subnet);
606 $fwdfwsettings{'isip'}='on';
609 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
610 $ip=$fwdfwsettings{'src_addr'};
612 $fwdfwsettings{'isip'}='on';
615 if ($fwdfwsettings{'isip'} ne 'on'){
616 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
618 if ($fwdfwsettings{'isip'} eq 'on'){
619 #check and form valid IP
620 $ip=&General
::ip2dec
($ip);
621 $ip=&General
::dec2ip
($ip);
622 #check if net or broadcast
623 my @tmp= split (/\./,$ip);
624 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
626 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
628 $fwdfwsettings{'src_addr'}="$ip/$subnet";
630 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
631 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
634 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
635 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
637 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
638 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
639 return $errormessage;
643 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
645 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
646 $fwdfwsettings{'SRC_PORT'}='';
647 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
648 foreach my $key (keys %icmptypes){
649 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
650 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
653 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
654 $fwdfwsettings{'SRC_PORT'}='';
655 $fwdfwsettings{'ICMP_TYPES'}='';
656 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
657 $fwdfwsettings{'SRC_PORT'}='';
658 $fwdfwsettings{'ICMP_TYPES'}='';
659 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
660 $fwdfwsettings{'SRC_PORT'}='';
661 $fwdfwsettings{'ICMP_TYPES'}='';
662 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
663 $fwdfwsettings{'ICMP_TYPES'}='';
665 $fwdfwsettings{'ICMP_TYPES'}='';
666 $fwdfwsettings{'SRC_PORT'}='';
667 $fwdfwsettings{'PROT'}='';
670 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
671 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
675 if ($_ =~ /^(\d+)\:(\d+)$/) {
677 #change dashes with :
680 push(@values,"1:65535");
683 if ($_ =~ /^(\D)\:(\d+)$/) {
684 push(@values,"1:$2");
687 if ($_ =~ /^(\d+)\:(\D)$/) {
688 push(@values,"$1:65535");
691 $errormessage .= &General
::validportrange
($_, 'destination');
696 if (&General
::validport
($_)){
703 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
704 return $errormessage;
711 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
712 #check if ip with subnet
713 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
714 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
715 $subnet = &General
::iporsubtocidr
($subnet);
718 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
719 $ip=$fwdfwsettings{'tgt_addr'};
722 #check and form valid IP
723 $ip=&General
::ip2dec
($ip);
724 $ip=&General
::dec2ip
($ip);
726 #check if net or broadcast
727 my @tmp= split (/\./,$ip);
728 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
730 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
732 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
734 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
735 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
738 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
739 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
740 return $errormessage;
744 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
747 if ($fwdfwsettings{'USESRV'} eq 'ON'){
748 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
749 $fwdfwsettings{'TGT_PROT'}='';
750 $fwdfwsettings{'ICMP_TGT'}='';
752 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
753 $fwdfwsettings{'TGT_PROT'}='';
754 $fwdfwsettings{'ICMP_TGT'}='';
755 #check target service
756 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
757 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
760 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
761 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
762 if ($fwdfwsettings{'TGT_PORT'} ne ''){
763 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
767 if ($_ =~ /^(\d+)\:(\d+)$/) {
769 #change dashes with :
772 push(@values,"1:65535");
775 if ($_ =~ /^(\D)\:(\d+)$/) {
776 push(@values,"1:$2");
779 if ($_ =~ /^(\d+)\:(\D)$/) {
780 push(@values,"$1:65535");
783 $errormessage .= &General
::validportrange
($_, 'destination');
788 if (&General
::validport
($_)){
795 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
797 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
798 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
799 $fwdfwsettings{'TGT_PORT'} = '';
800 $fwdfwsettings{'ICMP_TGT'} = '';
801 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
802 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
803 $fwdfwsettings{'TGT_PORT'} = '';
804 $fwdfwsettings{'ICMP_TGT'}='';
805 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
806 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
807 $fwdfwsettings{'TGT_PORT'} = '';
808 $fwdfwsettings{'ICMP_TGT'}='';
809 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
810 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
811 $fwdfwsettings{'TGT_PORT'} = '';
812 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
813 foreach my $key (keys %icmptypes){
815 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
816 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
824 if ($fwdfwsettings{'USESRV'} ne 'ON'){
825 $fwdfwsettings{'grp3'}='';
826 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
827 $fwdfwsettings{'TGT_PROT'}='';
828 $fwdfwsettings{'ICMP_TGT'}='';
831 if($fwdfwsettings{'TIME'} eq 'ON'){
832 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 ''){
833 $errormessage=$Lang::tr
{'fwdfw err time'};
836 return $errormessage;
841 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
842 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
844 #check if source and target identical
845 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
846 $errormessage.=$Lang::tr
{'fwdfw err same'};
847 return $errormessage;
850 #get source and targetip address if possible
851 my ($sip,$scidr,$tip,$tcidr);
852 ($sip,$scidr)=&get_ip
("src","grp1");
853 ($tip,$tcidr)=&get_ip
("tgt","grp2");
855 #check same iprange in source and target
856 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
857 my $networkip1=&General
::getnetworkip
($sip,$scidr);
858 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
859 if ($scidr gt $tcidr){
860 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr)) ){
861 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
863 }elsif($scidr eq $tcidr && $scidr eq '32'){
864 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
865 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
866 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
867 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
868 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
871 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
872 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
877 #check source and destination protocol if manual
878 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
881 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
882 $errormessage.=$Lang::tr
{'fwdfw err prot'};
884 #check source and destination protocol if source manual and dest servicegrp
885 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
886 &General
::readhasharray
("$configsrv", \
%customservice);
887 foreach my $key (sort keys %customservice){
888 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
889 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
890 $errormessage.=$Lang::tr
{'fwdfw err prot'};
904 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
905 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
906 if ($fwdfwsettings{$grp} eq $val.'_addr'){
907 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
908 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
909 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
910 $a=$netsettings{'GREEN_NETADDRESS'};
911 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
912 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
913 $a=$netsettings{'ORANGE_NETADDRESS'};
914 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
915 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
916 $a=$netsettings{'BLUE_NETADDRESS'};
917 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
918 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
919 &General
::readhash
("$configovpn",\
%ovpnsettings);
920 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
921 $b=&General
::iporsubtocidr
($b);
923 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
924 &General
::readhasharray
("$confignet", \
%customnetwork);
925 foreach my $key (keys %customnetwork){
926 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
927 $a=$customnetwork{$key}[1];
928 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
931 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
932 &General
::readhasharray
("$confighost", \
%customhost);
933 foreach my $key (keys %customhost){
934 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
935 if ($customhost{$key}[1] eq 'ip'){
936 ($a,$b)=split (/\//,$customhost{$key}[2]);
937 $b=&General
::iporsubtocidr
($b);
940 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
952 &General
::setup_default_networks
(\
%defaultNetworks);
953 #read all configfiles
954 &General
::readhasharray
("$configccdnet", \
%ccdnet);
955 &General
::readhasharray
("$confignet", \
%customnetwork);
956 &General
::readhasharray
("$configccdhost", \
%ccdhost);
957 &General
::readhasharray
("$confighost", \
%customhost);
958 &General
::readhasharray
("$configccdhost", \
%ccdhost);
959 &General
::readhasharray
("$configgrp", \
%customgrp);
960 &General
::readhasharray
("$configipsec", \
%ipsecconf);
961 &General
::get_aliases
(\
%aliases);
965 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
966 my $config=$fwdfwsettings{'config'};
968 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
969 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
970 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
971 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
972 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
973 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
974 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
975 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
976 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
977 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
978 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
979 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
980 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
981 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
982 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
983 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
984 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
985 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
986 #check if update and get values
987 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
988 &General
::readhasharray
("$config", \
%hash);
989 foreach my $key (sort keys %hash){
991 if ($key eq $fwdfwsettings{'key'}){
992 $fwdfwsettings{'oldrulenumber'} = $key;
993 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
994 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
995 $fwdfwsettings{'grp1'} = $hash{$key}[3];
996 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
997 $fwdfwsettings{'grp2'} = $hash{$key}[5];
998 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
999 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1000 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1001 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1002 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1003 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1004 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1005 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1006 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1007 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1008 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1009 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1010 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1011 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1012 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1013 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1014 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1015 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1016 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1017 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1018 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1019 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1020 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1021 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1022 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1023 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1024 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1025 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1026 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1027 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1028 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1029 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1030 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1031 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1032 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1033 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1034 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1035 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1036 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1037 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1040 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1041 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1042 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1043 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1044 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1045 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1046 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1047 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1049 $fwdfwsettings{'ACTIVE'}='ON';
1050 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1053 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1056 <form method="post">
1058 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1060 foreach ("ACCEPT","DROP","REJECT")
1062 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1064 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1065 print">$_</option>";
1067 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1068 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1071 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1073 print"<option selected>$_</option>";
1075 print"<option>$_</option>";
1079 print"</select></td></tr></table><hr>";
1081 &Header
::closebox
();
1082 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1084 #------SOURCE-------------------------------------------------------
1086 <table width='100%' border='0'>
1087 <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>
1088 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1089 <tr><td width='1%'><input type='radio' name='grp1' value='std_net_src' $checked{'grp1'}{'std_net_src'}></td><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost stdnet'}</td><td width='13%'><select name='std_net_src' style='min-width:185px;'>
1091 foreach my $network (sort keys %defaultNetworks)
1093 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1094 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1095 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1096 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1097 print ">$network</option>";
1100 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_net_src' $checked{'grp1'}{'ovpn_net_src'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_src' style='min-width:185px;'>
1102 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1105 <tr><td><input type='radio' name='grp1' value='cust_net_src' $checked{'grp1'}{'cust_net_src'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_src' style='min-width:185px;'>
1107 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1109 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_host_src' $checked{'grp1'}{'ovpn_host_src'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_src' style='min-width:185px;'>
1111 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1113 if ($ccdhost{$key}[33] ne ''){
1115 print "<option value='$ccdhost{$key}[1]'";
1116 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1117 print ">$ccdhost{$key}[1]</option>";
1122 <tr><td valign='top'><input type='radio' name='grp1' value='cust_host_src' $checked{'grp1'}{'cust_host_src'}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_src' style='min-width:185px;'>
1124 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1126 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_n2n_src' $checked{'grp1'}{'ovpn_n2n_src'}></td><td >$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='ovpn_n2n_src' style='min-width:185px;'>
1128 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1129 if($ccdhost{$key}[3] eq 'net'){
1131 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1132 print ">$ccdhost{$key}[1]</option>";
1138 <tr><td valign='top'><input type='radio' name='grp1' value='cust_grp_src' $checked{'grp1'}{'cust_grp_src'}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_src' style='min-width:185px;'>
1140 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1141 if($helper ne $customgrp{$key}[0]){
1143 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1144 print ">$customgrp{$key}[0]</option>";
1146 $helper=$customgrp{$key}[0];
1150 <td valign='top'><input type='radio' name='grp1' value='ipsec_net_src' $checked{'grp1'}{'ipsec_net_src'}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_src' style='min-width:185px;'>
1152 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1153 if ($ipsecconf{$key}[3] eq 'net'){
1155 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1156 print ">$ipsecconf{$key}[1]</option>";
1164 # <td valign='top'><input type='radio' name='grp1' value='ipsec_host_src' $checked{'grp1'}{'ipsec_host_src'}></td><td >$Lang::tr{'fwhost ipsec host'}</td><td><select name='ipsec_host_src' style='min-width:185px;'>
1166 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1167 # if ($ipsecconf{$key}[3] eq 'host'){
1169 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1170 # print ">$ipsecconf{$key}[1]</option>";
1174 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1175 <table width='100%' border='0'>
1176 <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>
1177 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1179 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1181 if ($_ eq $fwdfwsettings{'PROT'})
1183 print"<option selected>$_</option>";
1185 print"<option>$_</option>";
1188 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1190 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1191 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1193 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1194 print"<option>All ICMP-Types</option>";
1195 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1196 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1197 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1199 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1203 </select></td></tr></table><hr>
1205 &Header
::closebox
();
1207 #---TARGET------------------------------------------------------
1208 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1210 <table width='100%' border='0'>
1211 <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td colspan='2'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16'><td><input type='radio' name='grp2' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>IPFire ($Lang::tr{'external access'})</b></td><td><select name='ipfire' style='min-width:185px;'>
1213 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1215 foreach my $alias (sort keys %aliases)
1217 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1222 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1223 <tr><td width='1%'><input type='radio' name='grp2' value='std_net_tgt' $checked{'grp2'}{'std_net_tgt'}></td><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost stdnet'}</td><td width='13%'><select name='std_net_tgt' style='min-width:185px;'>
1225 foreach my $network (sort keys %defaultNetworks)
1227 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1228 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1229 print ">$network</option>";
1232 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_net_tgt' $checked{'grp2'}{'ovpn_net_tgt'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_tgt' style='min-width:185px;'>
1234 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1237 <tr><td><input type='radio' name='grp2' value='cust_net_tgt' $checked{'grp2'}{'cust_net_tgt'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_tgt' style='min-width:185px;'>
1239 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1241 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_host_tgt' $checked{'grp2'}{'ovpn_host_tgt'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_tgt' style='min-width:185px;'>
1243 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1245 if ($ccdhost{$key}[33] ne ''){
1246 print "<option value='$ccdhost{$key}[1]' ";
1247 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1248 print ">$ccdhost{$key}[1]</option>";
1253 <tr><td valign='top'><input type='radio' name='grp2' value='cust_host_tgt' $checked{'grp2'}{'cust_host_tgt'}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_tgt' style='min-width:185px;'>
1255 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1257 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_n2n_tgt' $checked{'grp2'}{'ovpn_n2n_tgt'}></td><td >$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='ovpn_n2n_tgt' style='min-width:185px;'>
1259 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1260 if($ccdhost{$key}[3] eq 'net'){
1262 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1263 print ">$ccdhost{$key}[1]</option>";
1268 <tr><td valign='top'><input type='radio' name='grp2' value='cust_grp_tgt' $checked{'grp2'}{'cust_grp_tgt'}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_tgt' style='min-width:185px;'>
1271 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1272 if($helper ne $customgrp{$key}[0]){
1274 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1275 print">$customgrp{$key}[0]</option>";
1277 $helper=$customgrp{$key}[0];
1281 <td valign='top'><input type='radio' name='grp2' value='ipsec_net_tgt' $checked{'grp2'}{'ipsec_net_tgt'}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_tgt' style='min-width:185px;'>
1283 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1284 if ($ipsecconf{$key}[3] eq 'net'){
1286 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1287 print">$ipsecconf{$key}[1]</option>";
1293 # <td valign='top'><input type='radio' name='grp2' value='ipsec_host_tgt' $checked{'grp2'}{'ipsec_host_tgt'}></td><td >$Lang::tr{'fwhost ipsec host'}</td><td><select name='ipsec_host_tgt' style='min-width:185px;'>
1295 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1296 # if ($ipsecconf{$key}[3] eq 'host'){
1298 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1299 # print">$ipsecconf{$key}[1]</option>";
1304 <b>$Lang::tr{'fwhost attention'}:</b><br>
1305 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1307 <table width='100%' border='0'>
1308 <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;' >
1310 &General
::readhasharray
("$configsrv", \
%customservice);
1311 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1313 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1314 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1318 <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;' >
1320 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1322 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1323 if ($helper ne $customservicegrp{$key}[0]){
1325 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1326 print">$customservicegrp{$key}[0]</option>";
1328 $helper=$customservicegrp{$key}[0];
1332 <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'>
1334 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1336 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1338 print"<option selected>$_</option>";
1340 print"<option>$_</option>";
1343 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1345 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1346 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1348 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1349 print"<option>All ICMP-Types</option>";
1350 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1351 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1352 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1354 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1359 </table><hr><br><br>
1362 #---Activate/logging/remark-------------------------------------
1363 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1365 <table width='100%' border='0'>
1366 <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>
1368 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1369 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1370 for (my $count =1; $count <= $sum; $count++){
1371 print"<option value='$count' ";
1372 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1373 print">$count</option>";
1375 print"</select></td></tr>";
1379 </table><table width='100%'>
1380 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1381 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1384 &Header
::closebox
();
1385 #---ADD TIMEFRAME-----------------------------------------------
1386 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1388 <table width='70%' border='0'>
1389 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1390 <tr><td colspan='7'> </td></tr>
1392 <td align='left'>$Lang::tr{'time'}:</td>
1393 <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>
1394 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1395 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1398 <td align='right'></td>
1399 <td width='30%' align='left'>
1400 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1401 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1402 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1403 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1404 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1405 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1406 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1408 <td><select name='TIME_FROM'>
1410 for (my $i=0;$i<=23;$i++) {
1411 $i = sprintf("%02s",$i);
1412 for (my $j=0;$j<=45;$j+=15) {
1413 $j = sprintf("%02s",$j);
1414 my $time = $i.":".$j;
1415 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1420 <td><select name='TIME_TO'>
1422 for (my $i=0;$i<=23;$i++) {
1423 $i = sprintf("%02s",$i);
1424 for (my $j=0;$j<=45;$j+=15) {
1425 $j = sprintf("%02s",$j);
1426 my $time = $i.":".$j;
1427 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1434 &Header
::closebox
();
1435 #---ACTION------------------------------------------------------
1436 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1438 <table border='0' width='100%'>
1439 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1440 <input type='hidden' name='config' value='$config' >
1441 <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>
1446 <table border='0' width='100%'>
1447 <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'}'>
1448 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1449 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1450 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1451 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1452 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1453 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1454 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1455 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1456 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1457 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1458 <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>
1462 &Header
::closebox
();
1468 &General
::readhasharray
("$config", $hash);
1469 if (!$errormessage){
1470 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1471 my $key = &General
::findhasharraykey
($hash);
1472 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1473 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1474 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1475 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1476 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1477 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1478 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1479 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1480 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1481 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1482 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1483 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1484 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1485 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1486 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1487 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1488 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1489 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1490 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1491 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1492 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1493 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1494 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1495 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1496 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1497 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1498 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1499 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1500 &General
::writehasharray
("$config", $hash);
1502 foreach my $key (sort {$a <=> $b} keys %$hash){
1503 if($key eq $fwdfwsettings{'key'}){
1504 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1505 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1506 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1507 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1508 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1509 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1510 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1511 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1512 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1513 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1514 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1515 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1516 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1517 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1518 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1519 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1520 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1521 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1522 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1523 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1524 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1525 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1526 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1527 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1528 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1529 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1530 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1531 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1536 &General
::writehasharray
("$config", $hash);
1537 if($fwdfwsettings{'oldrulenumber'} gt $fwdfwsettings{'rulepos'}){
1539 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1540 for (my $z=0;$z<$val;$z++){
1541 foreach my $key (sort {$a <=> $b} keys %$hash){
1542 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1544 if (exists $$hash{$last}){
1546 foreach my $y (0 .. $#{$$hash{$last}}) {
1547 $tmp{0}[$y] = $$hash{$last}[$y];
1549 #copy active rule to last
1550 foreach my $i (0 .. $#{$$hash{$last}}) {
1551 $$hash{$last}[$i] = $$hash{$key}[$i];
1553 #copy saved rule to actual position
1554 foreach my $x (0 .. $#{$tmp{0}}) {
1555 $$hash{$key}[$x] = $tmp{0}[$x];
1560 $fwdfwsettings{'oldrulenumber'}--;
1562 &General
::writehasharray
("$config", $hash);
1564 }elsif($fwdfwsettings{'rulepos'} gt $fwdfwsettings{'oldrulenumber'}){
1566 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1567 for (my $z=0;$z<$val;$z++){
1568 foreach my $key (sort {$a <=> $b} keys %$hash){
1569 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1570 my $next = $key + 1;
1571 if (exists $$hash{$next}){
1573 foreach my $y (0 .. $#{$$hash{$next}}) {
1574 $tmp{0}[$y] = $$hash{$next}[$y];
1576 #copy active rule to next
1577 foreach my $i (0 .. $#{$$hash{$next}}) {
1578 $$hash{$next}[$i] = $$hash{$key}[$i];
1580 #copy saved rule to actual position
1581 foreach my $x (0 .. $#{$tmp{0}}) {
1582 $$hash{$key}[$x] = $tmp{0}[$x];
1587 $fwdfwsettings{'oldrulenumber'}++;
1589 &General
::writehasharray
("$config", $hash);
1596 if ($errormessage) {
1597 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1598 print "<class name='base'>$errormessage\n";
1599 print " </class>\n";
1600 &Header
::closebox
();
1607 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1608 print "<class name='base'>$hint\n";
1609 print " </class>\n";
1610 &Header
::closebox
();
1617 &General
::setup_default_networks
(\
%defaultNetworks);
1618 foreach my $network (sort keys %defaultNetworks)
1620 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1625 # Checks a hostname against RFC1035
1628 # Each part should be at least two characters in length
1629 # but no more than 63 characters
1630 if (length ($remark) < 1 || length ($remark) > 255) {
1632 # Only valid characters are a-z, A-Z, 0-9 and -
1633 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:_\/\s
]*$/) {
1635 # First character can only be a letter or a digit
1636 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1638 # Last character can only be a letter or a digit
1639 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
1645 my %hash=%{(shift)};
1647 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1648 $hash{$key}[10]=~ s/\|/,/g;
1649 print": $hash{$key}[10]";
1650 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1651 print": <br>$hash{$key}[9] ";
1656 my %hash=%{(shift)};
1660 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1661 if($hash{$key}[14] eq 'cust_srv'){
1662 &General
::readhasharray
("$configsrv", \
%customservice);
1663 foreach my $i (sort keys %customservice){
1664 if($customservice{$i}[0] eq $hash{$key}[15]){
1665 $service = $customservice{$i}[0];
1668 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1669 $service=$hash{$key}[15];
1670 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1671 $hash{$key}[15]=~ s/\|/,/g;
1672 $service=$hash{$key}[15];
1677 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1678 print":<br>$hash{$key}[13]";
1681 sub get_serviceports
1685 &General
::readhasharray
("$configsrv", \
%customservice);
1686 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1690 if($type eq 'service'){
1691 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1692 if ($customservice{$key}[0] eq $name){
1693 $protocols=$customservice{$key}[2];
1697 }elsif($type eq 'group'){
1698 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1699 if ($customservicegrp{$key}[0] eq $name){
1700 if($customservicegrp{$key}[4] eq 'TCP'){$tcp='TCP';}else{$udp='UDP';}
1704 if($tcp){$protocols.="TCP";}
1705 if($udp){$protocols.=",UDP";}
1710 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1711 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1720 if ( ! -z
"$config"){
1721 &Header
::openbox
('100%', 'left',$title);
1729 &General
::readhasharray
("$config", $hash);
1730 print"<b>$title1</b><br>";
1731 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1732 print"<tr><td align='center' width='1%'><b>#</td><td width='1%'></td><td align='center' ><b>$Lang::tr{'fwdfw source'}</td><td width='1%'><b>Log</td><td align='center' width='20%'><b>$Lang::tr{'fwdfw target'}</td><td align='center'><b>$Lang::tr{'protocol'}</b></td><td align='center' width='70%'><b>$Lang::tr{'remark'}</td><td align='center' colspan='3' width='1%'><b>$Lang::tr{'fwdfw action'}</td></tr>";
1733 foreach my $key (sort {$a <=> $b} keys %$hash){
1735 #check if vpn hosts/nets have been deleted
1736 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1737 push (@tmpsrc,$$hash{$key}[4]);
1739 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1740 push (@tmpsrc,$$hash{$key}[6]);
1742 foreach my $host (@tmpsrc){
1743 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1744 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1746 &disable_rule
($key);
1749 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1750 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1752 &disable_rule
($key);
1755 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1756 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1758 &disable_rule
($key);
1761 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1762 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1764 &disable_rule
($key);
1771 $$hash{'ACTIVE'}=$$hash{$key}[2];
1773 if($coloryellow eq 'on'){
1774 print"<tr bgcolor='$color{'color14'}' >";
1776 }elsif($coloryellow eq ''){
1778 print"<tr bgcolor='$color{'color22'}' >";
1781 print"<tr bgcolor='$color{'color20'}' >";
1785 <td align='right'>$key</td>
1787 if ($$hash{$key}[0] eq 'ACCEPT'){
1790 $rulecolor=$color{'color17'};
1791 }elsif($$hash{$key}[0] eq 'DROP'){
1794 $rulecolor=$color{'color25'};
1795 }elsif($$hash{$key}[0] eq 'REJECT'){
1798 $rulecolor=$color{'color16'};
1800 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1801 print"<td align='center' nowrap='nowrap'>";
1802 if ($$hash{$key}[3] eq 'std_net_src'){
1803 print &get_name
($$hash{$key}[4]);
1805 print $$hash{$key}[4];
1807 &getsrcport
(\
%$hash,$key);
1808 if ($$hash{$key}[17] eq 'ON'){
1809 $log="/images/on.gif";
1811 $log="/images/off.gif";
1815 <form method='post'>
1816 <td width='1%' align='left'><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 ;'/>
1817 <input type='hidden' name='key' value='$key' />
1818 <input type='hidden' name='config' value='$config' />
1819 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1824 <td align='center' nowrap='nowrap'>
1826 if ($$hash{$key}[5] eq 'std_net_tgt'){
1827 print &get_name
($$hash{$key}[6]);
1829 print $$hash{$key}[6];
1831 &gettgtport
(\
%$hash,$key);
1832 ################################################################################
1836 if ($$hash{$key}[12]){ #target prot if manual
1837 $prot=$$hash{$key}[12];
1838 }elsif($$hash{$key}[8]){ #source prot if manual
1839 $prot=$$hash{$key}[8];
1840 }elsif($$hash{$key}[14] eq 'cust_srv'){
1841 $prot=&get_serviceports
("service",$$hash{$key}[15]);
1842 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
1843 $prot=&get_serviceports
("group",$$hash{$key}[15]);
1845 $prot=$Lang::tr
{'all'};
1847 print"<td align='center'>$prot</td>";
1849 print"<td width='20%'>$$hash{$key}[16]</td>";
1851 if($$hash{$key}[2] eq 'ON'){
1852 $gif="/images/on.gif"
1855 $gif="/images/off.gif"
1858 <form method='post'>
1859 <td width='1%'><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;' />
1860 <input type='hidden' name='key' value='$key' />
1861 <input type='hidden' name='config' value='$config' />
1862 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1864 <form method='post'>
1865 <td width='1%' ><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;' />
1866 <input type='hidden' name='key' value='$key' />
1867 <input type='hidden' name='config' value='$config' />
1868 <input type='hidden' name='ACTION' value='editrule' />
1870 <form method='post'>
1871 <td width='1%'><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;' />
1872 <input type='hidden' name='key' value='$key' />
1873 <input type='hidden' name='config' value='$config' />
1874 <input type='hidden' name='ACTION' value='copyrule' />
1876 <form method='post'>
1877 <td width='1%' ><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;' />
1878 <input type='hidden' name='key' value='$key' />
1879 <input type='hidden' name='config' value='$config' />
1880 <input type='hidden' name='ACTION' value='deleterule' />
1883 if (exists $$hash{$key-1}){
1885 <form method='post'>
1886 <td width='1%'><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;' />
1887 <input type='hidden' name='key' value='$key' />
1888 <input type='hidden' name='config' value='$config' />
1889 <input type='hidden' name='ACTION' value='moveup' />
1895 if (exists $$hash{$key+1}){
1897 <form method='post'>
1898 <td width='1%' ><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;' />
1899 <input type='hidden' name='key' value='$key' />
1900 <input type='hidden' name='config' value='$config' />
1901 <input type='hidden' name='ACTION' value='movedown' />
1902 </td></form></td></tr>
1905 print"<td></td></tr>";
1907 #if timeframe set, print new line in table
1908 if ($$hash{$key}[18] eq 'ON'){
1910 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1911 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1912 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1913 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1914 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1915 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1916 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1917 my $weekdays=join(",",@days);
1919 print"<tr bgcolor='#FFE4B5'><td colspan='6'>$Lang::tr{'fwdfw time'} ";
1921 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1926 &Header
::closebox
();
1932 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
1935 &Header
::openbox
('100%', 'center', 'P2P-Block');
1937 <table width='40%' border='0'>
1938 <tr bgcolor='$color{'color22'}'><td align=center colspan='2' width='30%'><b>$Lang::tr{'protocol'}</b><td width='10%' align=center><b>$Lang::tr{'status'}</b>
1940 foreach my $p2pentry (sort @p2ps)
1942 my @p2pline = split( /\;/, $p2pentry );
1943 if($p2pline[2] eq 'on'){
1944 $gif="/images/on.gif"
1946 $gif="/images/off.gif"
1949 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1950 <tr bgcolor='$color{'color20'}'>
1951 <td width='66%' align='center' colspan='2'>$p2pline[0]:</td><td width='33%' align='center'><input type='hidden' name='P2PROT' value='$p2pline[1]' /><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;' ><input type='hidden' name='ACTION' value='togglep2p'></td></tr></form>
1954 print"<tr><td width='10%'><input type='image' img src='/images/on.gif'></td><td>$Lang::tr{'outgoing firewall p2p allow'}</td><td></td></tr>";
1955 print"<tr><td width='10%'><input type='image' img src='/images/off.gif'></td><td>$Lang::tr{'outgoing firewall p2p deny'}</td><td></td></tr></table>";
1956 &Header
::closebox
();
1960 my %hash=%{(shift)};
1963 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1964 if($hash{$key}[0] eq $val){
1965 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1967 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1973 if (!-f
"${General::swroot}/forward/reread"){
1974 system("touch ${General::swroot}/forward/reread");
1979 system("/usr/local/bin/forwardfwctrl");
1980 system("rm ${General::swroot}/forward/reread");
1982 &Header
::closebigbox
();
1983 &Header
::closepage
();