]>
git.ipfire.org Git - people/ms/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'})){
147 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
148 $fwdfwsettings{'nosave'} = 'on';
153 #check if we just close a rule
154 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'} ) {
155 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
157 $fwdfwsettings{'nosave2'} = 'on';
160 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
161 if ($fwdfwsettings{'nobase'} ne 'on'){
162 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
164 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
165 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
166 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
167 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
168 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
169 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
171 if($fwdfwsettings{'nosave2'} ne 'on'){
172 &saverule
(\
%configinputfw,$configinput);
174 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
175 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
176 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
177 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
178 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
179 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
180 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
181 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
182 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
183 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
184 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
185 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
186 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
187 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
188 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
189 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
191 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
192 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
193 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
194 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
197 $fwdfwsettings{'chain'} = 'FORWARDFW';
198 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
199 #check if we have an identical rule already
200 foreach my $key (sort keys %configfwdfw){
201 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'}"
202 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]"){
203 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
204 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
207 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
208 $fwdfwsettings{'nosave'} = 'on';
213 #check if we just close a rule
214 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'} ) {
215 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
216 $fwdfwsettings{'nosave2'} = 'on';
222 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
223 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
224 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
225 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
226 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
227 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
228 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
229 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
231 if ($fwdfwsettings{'nobase'} eq 'on'){
232 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
234 if ($fwdfwsettings{'nosave2'} ne 'on'){
235 &saverule
(\
%configfwdfw,$configfwdfw);
237 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
238 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
239 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
240 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
241 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
242 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
243 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
244 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
245 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
246 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
247 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
248 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
249 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
250 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
251 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
252 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
254 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
255 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
256 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
257 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
262 if($fwdfwsettings{'nosave2'} ne 'on'){
268 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
270 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
271 foreach my $key (sort keys %configfwdfw){
272 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
273 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
274 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
276 &General
::readhasharray
("$configinput", \
%configinputfw);
277 foreach my $key (sort keys %configinputfw){
278 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
279 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
280 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
282 $fwdfwsettings{'POLICY'}='MODE0';
283 system("rm ${General::swroot}/forward/config");
284 system("rm ${General::swroot}/forward/input");
285 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
286 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
287 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
292 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
296 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
299 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
300 foreach my $key (sort keys %togglehash){
301 if ($key eq $fwdfwsettings{'key'}){
302 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
305 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
309 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
312 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
313 foreach my $key (sort keys %togglehash){
314 if ($key eq $fwdfwsettings{'key'}){
315 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
318 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
322 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
327 if ($fwdfwsettings{'ACTION'} eq 'editrule')
329 $fwdfwsettings{'updatefwrule'}='on';
332 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
336 if ($fwdfwsettings{'ACTION'} eq 'moveup')
341 if ($fwdfwsettings{'ACTION'} eq 'movedown')
346 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
348 $fwdfwsettings{'copyfwrule'}='on';
349 #$fwdfwsettings{'updatefwrule'}='on';
352 if ($fwdfwsettings{'ACTION'} eq 'togglep2p')
354 #$errormessage="Toggle $fwdfwsettings{'P2PROT'}<br>";
355 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
358 open( FILE
, "> $p2pfile" ) or die "Unable to write $p2pfile";
359 foreach my $p2pentry (sort @p2ps)
361 my @p2pline = split( /\;/, $p2pentry );
362 if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) {
363 if($p2pline[2] eq 'on'){
369 print FILE
"$p2pline[0];$p2pline[1];$p2pline[2];\n";
375 if ($fwdfwsettings{'ACTION'} eq '')
384 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
385 foreach my $key (sort keys %uphash){
386 if ($key eq $fwdfwsettings{'key'}) {
388 if (exists $uphash{$last}){
390 foreach my $y (0 .. $#{$uphash{$last}}) {
391 $tmp{0}[$y] = $uphash{$last}[$y];
393 #copy active rule to last
394 foreach my $i (0 .. $#{$uphash{$last}}) {
395 $uphash{$last}[$i] = $uphash{$key}[$i];
397 #copy saved rule to actual position
398 foreach my $x (0 .. $#{$tmp{0}}) {
399 $uphash{$key}[$x] = $tmp{0}[$x];
404 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
411 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
412 foreach my $key (sort keys %downhash){
413 if ($key eq $fwdfwsettings{'key'}) {
415 if (exists $downhash{$next}){
417 foreach my $y (0 .. $#{$downhash{$next}}) {
418 $tmp{0}[$y] = $downhash{$next}[$y];
420 #copy active rule to next
421 foreach my $i (0 .. $#{$downhash{$next}}) {
422 $downhash{$next}[$i] = $downhash{$key}[$i];
424 #copy saved rule to actual position
425 foreach my $x (0 .. $#{$tmp{0}}) {
426 $downhash{$key}[$x] = $tmp{0}[$x];
431 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
436 my ($base1,$val1,$base2,$val2) = @_;
438 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
439 &dec_counter
($confignet,\
%customnetwork,$val1);
440 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
441 &dec_counter
($confighost,\
%customhost,$val1);
442 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
443 &dec_counter
($configgrp,\
%customgrp,$val1);
444 }elsif($base1 eq 'cust_srv'){
445 &dec_counter
($configsrv,\
%customservice,$val1);
446 }elsif($base1 eq 'cust_srvgrp'){
447 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
450 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
451 &inc_counter
($confignet,\
%customnetwork,$val2);
452 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
453 &inc_counter
($confighost,\
%customhost,$val2);
454 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
455 &inc_counter
($configgrp,\
%customgrp,$val2);
456 }elsif($base2 eq 'cust_srv'){
457 &inc_counter
($configsrv,\
%customservice,$val2);
458 }elsif($base2 eq 'cust_srvgrp'){
459 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
469 &General
::readhasharray
($config, \
%hash);
470 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
471 if($hash{$key}[0] eq $val){
472 $pos=$#{$hash{$key}};
473 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
476 &General
::writehasharray
($config, \
%hash);
484 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
485 &General
::readhasharray
($config, \
%hash);
486 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
487 if($hash{$key}[0] eq $val){
488 $pos=$#{$hash{$key}};
489 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
492 &General
::writehasharray
($config, \
%hash);
496 if ($fwdfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
497 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
498 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
501 if ($fwdfwsettings{'POLICY'} ne 'MODE0' && $fwdfwsettings{'POLICY'} ne '') {
505 #print"<table width='100' border='1'><tr>";
508 #print"<td bgcolor='$color{$i}'>$_</td>";
510 #print"</tr></table>";
511 if ($fwdfwsettings{'POLICY'} eq 'MODE1' || $fwdfwsettings{'POLICY'} eq 'MODE2' ) {
514 &Header
::openbox
('100%', 'center', 'Policy');
516 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
518 <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>
519 <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>
520 <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>
521 <tr><td colspan='3'><hr /></td></tr>
522 <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>
523 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
524 <td width='45%' align='left'>
526 if ($fwdfwsettings{'POLICY'} ne 'MODE0'&& $fwdfwsettings{'POLICY'} ne '' ) {
527 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
529 print "</table></form>";
535 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
537 print "<form method='post'>";
538 print "<table border='0'>";
539 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
540 if (-f
"${General::swroot}/forward/reread"){
541 print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'></td>";
543 print"</tr></table></form><hr>";
551 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
552 foreach my $key (sort {$a <=> $b} keys %delhash){
553 if ($key == $fwdfwsettings{'key'}){
554 #check hosts/net and groups
555 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
556 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
557 #check services and groups
558 if ($delhash{$key}[11] eq 'ON'){
559 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
562 if ($key >= $fwdfwsettings{'key'}) {
564 if (exists $delhash{$next}) {
565 foreach my $i (0 .. $#{$delhash{$next}}) {
566 $delhash{$key}[$i] = $delhash{$next}[$i];
571 # Remove the very last entry.
572 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
573 delete $delhash{$last_key};
575 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
578 if($fwdfwsettings{'nobase'} ne 'on'){
585 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
586 foreach my $key (sort keys %configfwdfw){
588 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
591 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
598 #check ip-address if manual
599 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
600 #check if ip with subnet
601 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
602 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
603 $subnet = &General
::iporsubtocidr
($subnet);
604 $fwdfwsettings{'isip'}='on';
607 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
608 $ip=$fwdfwsettings{'src_addr'};
610 $fwdfwsettings{'isip'}='on';
613 if ($fwdfwsettings{'isip'} ne 'on'){
614 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
616 if ($fwdfwsettings{'isip'} eq 'on'){
617 #check and form valid IP
618 $ip=&General
::ip2dec
($ip);
619 $ip=&General
::dec2ip
($ip);
620 #check if net or broadcast
621 my @tmp= split (/\./,$ip);
622 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
624 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
626 $fwdfwsettings{'src_addr'}="$ip/$subnet";
628 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
629 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
632 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
633 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
635 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
636 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
637 return $errormessage;
641 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
643 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
644 $fwdfwsettings{'SRC_PORT'}='';
645 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
646 foreach my $key (keys %icmptypes){
647 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
648 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
651 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
652 $fwdfwsettings{'SRC_PORT'}='';
653 $fwdfwsettings{'ICMP_TYPES'}='';
654 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
655 $fwdfwsettings{'SRC_PORT'}='';
656 $fwdfwsettings{'ICMP_TYPES'}='';
657 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
658 $fwdfwsettings{'SRC_PORT'}='';
659 $fwdfwsettings{'ICMP_TYPES'}='';
660 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
661 $fwdfwsettings{'ICMP_TYPES'}='';
663 $fwdfwsettings{'ICMP_TYPES'}='';
664 $fwdfwsettings{'SRC_PORT'}='';
665 $fwdfwsettings{'PROT'}='';
668 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
669 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
673 if ($_ =~ /^(\d+)\:(\d+)$/) {
675 #change dashes with :
678 push(@values,"1:65535");
681 if ($_ =~ /^(\D)\:(\d+)$/) {
682 push(@values,"1:$2");
685 if ($_ =~ /^(\d+)\:(\D)$/) {
686 push(@values,"$1:65535");
689 $errormessage .= &General
::validportrange
($_, 'destination');
694 if (&General
::validport
($_)){
701 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
702 return $errormessage;
709 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
710 #check if ip with subnet
711 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
712 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
713 $subnet = &General
::iporsubtocidr
($subnet);
716 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
717 $ip=$fwdfwsettings{'tgt_addr'};
720 #check and form valid IP
721 $ip=&General
::ip2dec
($ip);
722 $ip=&General
::dec2ip
($ip);
724 #check if net or broadcast
725 my @tmp= split (/\./,$ip);
726 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
728 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
730 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
732 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
733 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
736 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
737 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
738 return $errormessage;
742 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
745 if ($fwdfwsettings{'USESRV'} eq 'ON'){
746 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
747 $fwdfwsettings{'TGT_PROT'}='';
748 $fwdfwsettings{'ICMP_TGT'}='';
750 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
751 $fwdfwsettings{'TGT_PROT'}='';
752 $fwdfwsettings{'ICMP_TGT'}='';
753 #check target service
754 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
755 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
758 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
759 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
760 if ($fwdfwsettings{'TGT_PORT'} ne ''){
761 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
765 if ($_ =~ /^(\d+)\:(\d+)$/) {
767 #change dashes with :
770 push(@values,"1:65535");
773 if ($_ =~ /^(\D)\:(\d+)$/) {
774 push(@values,"1:$2");
777 if ($_ =~ /^(\d+)\:(\D)$/) {
778 push(@values,"$1:65535");
781 $errormessage .= &General
::validportrange
($_, 'destination');
786 if (&General
::validport
($_)){
793 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
795 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
796 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
797 $fwdfwsettings{'TGT_PORT'} = '';
798 $fwdfwsettings{'ICMP_TGT'} = '';
799 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
800 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
801 $fwdfwsettings{'TGT_PORT'} = '';
802 $fwdfwsettings{'ICMP_TGT'}='';
803 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
804 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
805 $fwdfwsettings{'TGT_PORT'} = '';
806 $fwdfwsettings{'ICMP_TGT'}='';
807 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
808 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
809 $fwdfwsettings{'TGT_PORT'} = '';
810 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
811 foreach my $key (keys %icmptypes){
813 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
814 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
822 if ($fwdfwsettings{'USESRV'} ne 'ON'){
823 $fwdfwsettings{'grp3'}='';
824 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
825 $fwdfwsettings{'TGT_PROT'}='';
826 $fwdfwsettings{'ICMP_TGT'}='';
829 if($fwdfwsettings{'TIME'} eq 'ON'){
830 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 ''){
831 $errormessage=$Lang::tr
{'fwdfw err time'};
834 return $errormessage;
839 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
840 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
842 #check if source and target identical
843 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
844 $errormessage.=$Lang::tr
{'fwdfw err same'};
845 return $errormessage;
848 #get source and targetip address if possible
849 my ($sip,$scidr,$tip,$tcidr);
850 ($sip,$scidr)=&get_ip
("src","grp1");
851 ($tip,$tcidr)=&get_ip
("tgt","grp2");
853 #check same iprange in source and target
854 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
855 my $networkip1=&General
::getnetworkip
($sip,$scidr);
856 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
857 if ($scidr gt $tcidr){
858 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr)) ){
859 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
861 }elsif($scidr eq $tcidr && $scidr eq '32'){
862 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
863 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
864 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
865 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
866 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
869 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
870 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
875 #check source and destination protocol if manual
876 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
879 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
880 $errormessage.=$Lang::tr
{'fwdfw err prot'};
882 #check source and destination protocol if source manual and dest servicegrp
883 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
884 &General
::readhasharray
("$configsrv", \
%customservice);
885 foreach my $key (sort keys %customservice){
886 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
887 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
888 $errormessage.=$Lang::tr
{'fwdfw err prot'};
902 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
903 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
904 if ($fwdfwsettings{$grp} eq $val.'_addr'){
905 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
906 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
907 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
908 $a=$netsettings{'GREEN_NETADDRESS'};
909 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
910 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
911 $a=$netsettings{'ORANGE_NETADDRESS'};
912 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
913 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
914 $a=$netsettings{'BLUE_NETADDRESS'};
915 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
916 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
917 &General
::readhash
("$configovpn",\
%ovpnsettings);
918 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
919 $b=&General
::iporsubtocidr
($b);
921 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
922 &General
::readhasharray
("$confignet", \
%customnetwork);
923 foreach my $key (keys %customnetwork){
924 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
925 $a=$customnetwork{$key}[1];
926 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
929 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
930 &General
::readhasharray
("$confighost", \
%customhost);
931 foreach my $key (keys %customhost){
932 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
933 if ($customhost{$key}[1] eq 'ip'){
934 ($a,$b)=split (/\//,$customhost{$key}[2]);
935 $b=&General
::iporsubtocidr
($b);
938 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
950 &General
::setup_default_networks
(\
%defaultNetworks);
951 #read all configfiles
952 &General
::readhasharray
("$configccdnet", \
%ccdnet);
953 &General
::readhasharray
("$confignet", \
%customnetwork);
954 &General
::readhasharray
("$configccdhost", \
%ccdhost);
955 &General
::readhasharray
("$confighost", \
%customhost);
956 &General
::readhasharray
("$configccdhost", \
%ccdhost);
957 &General
::readhasharray
("$configgrp", \
%customgrp);
958 &General
::readhasharray
("$configipsec", \
%ipsecconf);
959 &General
::get_aliases
(\
%aliases);
963 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
964 my $config=$fwdfwsettings{'config'};
966 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
967 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
968 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
969 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
970 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
971 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
972 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
973 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
974 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
975 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
976 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
977 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
978 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
979 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
980 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
981 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
982 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
983 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
984 #check if update and get values
985 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
986 &General
::readhasharray
("$config", \
%hash);
987 foreach my $key (sort keys %hash){
989 if ($key eq $fwdfwsettings{'key'}){
990 $fwdfwsettings{'oldrulenumber'} = $key;
991 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
992 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
993 $fwdfwsettings{'grp1'} = $hash{$key}[3];
994 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
995 $fwdfwsettings{'grp2'} = $hash{$key}[5];
996 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
997 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
998 $fwdfwsettings{'PROT'} = $hash{$key}[8];
999 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1000 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1001 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1002 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1003 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1004 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1005 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1006 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1007 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1008 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1009 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1010 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1011 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1012 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1013 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1014 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1015 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1016 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1017 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1018 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1019 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1020 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1021 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1022 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1023 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1024 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1025 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1026 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1027 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1028 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1029 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1030 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1031 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1032 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1033 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1034 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1035 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1038 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1039 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1040 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1041 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1042 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1043 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1044 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1045 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1047 $fwdfwsettings{'ACTIVE'}='ON';
1048 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1051 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1054 <form method="post">
1056 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1058 foreach ("ACCEPT","DROP","REJECT")
1060 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1062 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1063 print">$_</option>";
1065 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1066 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1069 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1071 print"<option selected>$_</option>";
1073 print"<option>$_</option>";
1077 print"</select></td></tr></table><hr>";
1079 &Header
::closebox
();
1080 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1082 #------SOURCE-------------------------------------------------------
1084 <table width='100%' border='0'>
1085 <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>
1086 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1087 <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;'>
1089 foreach my $network (sort keys %defaultNetworks)
1091 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1092 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1093 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1094 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1095 print ">$network</option>";
1098 </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;'>
1100 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1103 <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;'>
1105 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1107 </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;'>
1109 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1111 if ($ccdhost{$key}[33] ne ''){
1113 print "<option value='$ccdhost{$key}[1]'";
1114 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1115 print ">$ccdhost{$key}[1]</option>";
1120 <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;'>
1122 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1124 </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;'>
1126 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1127 if($ccdhost{$key}[3] eq 'net'){
1129 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1130 print ">$ccdhost{$key}[1]</option>";
1136 <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;'>
1138 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1139 if($helper ne $customgrp{$key}[0]){
1141 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1142 print ">$customgrp{$key}[0]</option>";
1144 $helper=$customgrp{$key}[0];
1148 <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;'>
1150 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1151 if ($ipsecconf{$key}[3] eq 'net'){
1153 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1154 print ">$ipsecconf{$key}[1]</option>";
1162 # <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;'>
1164 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1165 # if ($ipsecconf{$key}[3] eq 'host'){
1167 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1168 # print ">$ipsecconf{$key}[1]</option>";
1172 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1173 <table width='100%' border='0'>
1174 <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>
1175 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1177 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1179 if ($_ eq $fwdfwsettings{'PROT'})
1181 print"<option selected>$_</option>";
1183 print"<option>$_</option>";
1186 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1188 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1189 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1191 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1192 print"<option>All ICMP-Types</option>";
1193 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1194 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1195 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1197 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1201 </select></td></tr></table><hr>
1203 &Header
::closebox
();
1205 #---TARGET------------------------------------------------------
1206 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1208 <table width='100%' border='0'>
1209 <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;'>
1211 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1213 foreach my $alias (sort keys %aliases)
1215 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1220 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1221 <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;'>
1223 foreach my $network (sort keys %defaultNetworks)
1225 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1226 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1227 print ">$network</option>";
1230 </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;'>
1232 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1235 <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;'>
1237 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1239 </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;'>
1241 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1243 if ($ccdhost{$key}[33] ne ''){
1244 print "<option value='$ccdhost{$key}[1]' ";
1245 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1246 print ">$ccdhost{$key}[1]</option>";
1251 <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;'>
1253 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1255 </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;'>
1257 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1258 if($ccdhost{$key}[3] eq 'net'){
1260 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1261 print ">$ccdhost{$key}[1]</option>";
1266 <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;'>
1269 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1270 if($helper ne $customgrp{$key}[0]){
1272 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1273 print">$customgrp{$key}[0]</option>";
1275 $helper=$customgrp{$key}[0];
1279 <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;'>
1281 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1282 if ($ipsecconf{$key}[3] eq 'net'){
1284 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1285 print">$ipsecconf{$key}[1]</option>";
1291 # <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;'>
1293 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1294 # if ($ipsecconf{$key}[3] eq 'host'){
1296 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1297 # print">$ipsecconf{$key}[1]</option>";
1302 <b>$Lang::tr{'fwhost attention'}:</b><br>
1303 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1305 <table width='100%' border='0'>
1306 <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;' >
1308 &General
::readhasharray
("$configsrv", \
%customservice);
1309 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1311 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1312 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1316 <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;' >
1318 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1320 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1321 if ($helper ne $customservicegrp{$key}[0]){
1323 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1324 print">$customservicegrp{$key}[0]</option>";
1326 $helper=$customservicegrp{$key}[0];
1330 <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'>
1332 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1334 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1336 print"<option selected>$_</option>";
1338 print"<option>$_</option>";
1341 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1343 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1344 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1346 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1347 print"<option>All ICMP-Types</option>";
1348 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1349 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1350 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1352 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1357 </table><hr><br><br>
1360 #---Activate/logging/remark-------------------------------------
1361 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1363 <table width='100%' border='0'>
1364 <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>
1366 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1367 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1368 for (my $count =1; $count <= $sum; $count++){
1369 print"<option value='$count' ";
1370 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1371 print">$count</option>";
1373 print"</select></td></tr>";
1377 </table><table width='100%'>
1378 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1379 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1382 &Header
::closebox
();
1383 #---ADD TIMEFRAME-----------------------------------------------
1384 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1386 <table width='70%' border='0'>
1387 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1388 <tr><td colspan='7'> </td></tr>
1390 <td align='left'>$Lang::tr{'time'}:</td>
1391 <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>
1392 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1393 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1396 <td align='right'></td>
1397 <td width='30%' align='left'>
1398 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1399 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1400 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1401 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1402 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1403 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1404 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1406 <td><select name='TIME_FROM'>
1408 for (my $i=0;$i<=23;$i++) {
1409 $i = sprintf("%02s",$i);
1410 for (my $j=0;$j<=45;$j+=15) {
1411 $j = sprintf("%02s",$j);
1412 my $time = $i.":".$j;
1413 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1418 <td><select name='TIME_TO'>
1420 for (my $i=0;$i<=23;$i++) {
1421 $i = sprintf("%02s",$i);
1422 for (my $j=0;$j<=45;$j+=15) {
1423 $j = sprintf("%02s",$j);
1424 my $time = $i.":".$j;
1425 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1432 &Header
::closebox
();
1433 #---ACTION------------------------------------------------------
1434 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1436 <table border='0' width='100%'>
1437 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1438 <input type='hidden' name='config' value='$config' >
1439 <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>
1444 <table border='0' width='100%'>
1445 <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'}'>
1446 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1447 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1448 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1449 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1450 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1451 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1452 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1453 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1454 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1455 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1456 <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>
1460 &Header
::closebox
();
1466 &General
::readhasharray
("$config", $hash);
1467 if (!$errormessage){
1468 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1469 my $key = &General
::findhasharraykey
($hash);
1470 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1471 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1472 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1473 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1474 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1475 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1476 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1477 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1478 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1479 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1480 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1481 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1482 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1483 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1484 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1485 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1486 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1487 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1488 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1489 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1490 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1491 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1492 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1493 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1494 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1495 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1496 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1497 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1498 &General
::writehasharray
("$config", $hash);
1500 foreach my $key (sort {$a <=> $b} keys %$hash){
1501 if($key eq $fwdfwsettings{'key'}){
1502 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1503 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1504 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1505 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1506 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1507 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1508 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1509 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1510 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1511 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1512 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1513 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1514 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1515 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1516 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1517 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1518 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1519 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1520 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1521 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1522 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1523 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1524 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1525 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1526 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1527 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1528 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1529 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1534 &General
::writehasharray
("$config", $hash);
1535 if($fwdfwsettings{'oldrulenumber'} gt $fwdfwsettings{'rulepos'}){
1537 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1538 for (my $z=0;$z<$val;$z++){
1539 foreach my $key (sort {$a <=> $b} keys %$hash){
1540 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1542 if (exists $$hash{$last}){
1544 foreach my $y (0 .. $#{$$hash{$last}}) {
1545 $tmp{0}[$y] = $$hash{$last}[$y];
1547 #copy active rule to last
1548 foreach my $i (0 .. $#{$$hash{$last}}) {
1549 $$hash{$last}[$i] = $$hash{$key}[$i];
1551 #copy saved rule to actual position
1552 foreach my $x (0 .. $#{$tmp{0}}) {
1553 $$hash{$key}[$x] = $tmp{0}[$x];
1558 $fwdfwsettings{'oldrulenumber'}--;
1560 &General
::writehasharray
("$config", $hash);
1562 }elsif($fwdfwsettings{'rulepos'} gt $fwdfwsettings{'oldrulenumber'}){
1564 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1565 for (my $z=0;$z<$val;$z++){
1566 foreach my $key (sort {$a <=> $b} keys %$hash){
1567 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1568 my $next = $key + 1;
1569 if (exists $$hash{$next}){
1571 foreach my $y (0 .. $#{$$hash{$next}}) {
1572 $tmp{0}[$y] = $$hash{$next}[$y];
1574 #copy active rule to next
1575 foreach my $i (0 .. $#{$$hash{$next}}) {
1576 $$hash{$next}[$i] = $$hash{$key}[$i];
1578 #copy saved rule to actual position
1579 foreach my $x (0 .. $#{$tmp{0}}) {
1580 $$hash{$key}[$x] = $tmp{0}[$x];
1585 $fwdfwsettings{'oldrulenumber'}++;
1587 &General
::writehasharray
("$config", $hash);
1594 if ($errormessage) {
1595 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1596 print "<class name='base'>$errormessage\n";
1597 print " </class>\n";
1598 &Header
::closebox
();
1605 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1606 print "<class name='base'>$hint\n";
1607 print " </class>\n";
1608 &Header
::closebox
();
1615 &General
::setup_default_networks
(\
%defaultNetworks);
1616 foreach my $network (sort keys %defaultNetworks)
1618 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1623 # Checks a hostname against RFC1035
1626 # Each part should be at least two characters in length
1627 # but no more than 63 characters
1628 if (length ($remark) < 1 || length ($remark) > 255) {
1630 # Only valid characters are a-z, A-Z, 0-9 and -
1631 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:_\/\s
]*$/) {
1633 # First character can only be a letter or a digit
1634 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1636 # Last character can only be a letter or a digit
1637 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
1643 my %hash=%{(shift)};
1645 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1646 $hash{$key}[10]=~ s/\|/,/g;
1647 print": $hash{$key}[10]";
1648 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1649 print": <br>$hash{$key}[9] ";
1654 my %hash=%{(shift)};
1658 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1659 if($hash{$key}[14] eq 'cust_srv'){
1660 &General
::readhasharray
("$configsrv", \
%customservice);
1661 foreach my $i (sort keys %customservice){
1662 if($customservice{$i}[0] eq $hash{$key}[15]){
1663 $service = $customservice{$i}[0];
1666 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1667 $service=$hash{$key}[15];
1668 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1669 $hash{$key}[15]=~ s/\|/,/g;
1670 $service=$hash{$key}[15];
1675 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1676 print":<br>$hash{$key}[13]";
1679 sub get_serviceports
1683 &General
::readhasharray
("$configsrv", \
%customservice);
1684 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1688 if($type eq 'service'){
1689 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1690 if ($customservice{$key}[0] eq $name){
1691 $protocols=$customservice{$key}[2];
1695 }elsif($type eq 'group'){
1696 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1697 if ($customservicegrp{$key}[0] eq $name){
1698 if($customservicegrp{$key}[4] eq 'TCP'){$tcp='TCP';}else{$udp='UDP';}
1702 if($tcp){$protocols.="TCP";}
1703 if($udp){$protocols.=",UDP";}
1708 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1709 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1718 if ( ! -z
"$config"){
1719 &Header
::openbox
('100%', 'left',$title);
1727 &General
::readhasharray
("$config", $hash);
1728 print"<b>$title1</b><br>";
1729 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1730 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>";
1731 foreach my $key (sort {$a <=> $b} keys %$hash){
1733 #check if vpn hosts/nets have been deleted
1734 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1735 push (@tmpsrc,$$hash{$key}[4]);
1737 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1738 push (@tmpsrc,$$hash{$key}[6]);
1740 foreach my $host (@tmpsrc){
1741 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1742 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1744 &disable_rule
($key);
1747 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1748 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1750 &disable_rule
($key);
1753 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1754 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1756 &disable_rule
($key);
1759 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1760 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1762 &disable_rule
($key);
1769 $$hash{'ACTIVE'}=$$hash{$key}[2];
1771 if($coloryellow eq 'on'){
1772 print"<tr bgcolor='$color{'color14'}' >";
1774 }elsif($coloryellow eq ''){
1776 print"<tr bgcolor='$color{'color22'}' >";
1779 print"<tr bgcolor='$color{'color20'}' >";
1783 <td align='right'>$key</td>
1785 if ($$hash{$key}[0] eq 'ACCEPT'){
1788 $rulecolor=$color{'color17'};
1789 }elsif($$hash{$key}[0] eq 'DROP'){
1792 $rulecolor=$color{'color25'};
1793 }elsif($$hash{$key}[0] eq 'REJECT'){
1796 $rulecolor=$color{'color16'};
1798 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1799 print"<td align='center' nowrap='nowrap'>";
1800 if ($$hash{$key}[3] eq 'std_net_src'){
1801 print &get_name
($$hash{$key}[4]);
1803 print $$hash{$key}[4];
1805 &getsrcport
(\
%$hash,$key);
1806 if ($$hash{$key}[17] eq 'ON'){
1807 $log="/images/on.gif";
1809 $log="/images/off.gif";
1813 <form method='post'>
1814 <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 ;'/>
1815 <input type='hidden' name='key' value='$key' />
1816 <input type='hidden' name='config' value='$config' />
1817 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1822 <td align='center' nowrap='nowrap'>
1824 if ($$hash{$key}[5] eq 'std_net_tgt'){
1825 print &get_name
($$hash{$key}[6]);
1827 print $$hash{$key}[6];
1829 &gettgtport
(\
%$hash,$key);
1830 ################################################################################
1834 if ($$hash{$key}[12]){ #target prot if manual
1835 $prot=$$hash{$key}[12];
1836 }elsif($$hash{$key}[8]){ #source prot if manual
1837 $prot=$$hash{$key}[8];
1838 }elsif($$hash{$key}[14] eq 'cust_srv'){
1839 $prot=&get_serviceports
("service",$$hash{$key}[15]);
1840 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
1841 $prot=&get_serviceports
("group",$$hash{$key}[15]);
1843 $prot=$Lang::tr
{'all'};
1845 print"<td align='center'>$prot</td>";
1847 print"<td width='20%'>$$hash{$key}[16]</td>";
1849 if($$hash{$key}[2] eq 'ON'){
1850 $gif="/images/on.gif"
1853 $gif="/images/off.gif"
1856 <form method='post'>
1857 <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;' />
1858 <input type='hidden' name='key' value='$key' />
1859 <input type='hidden' name='config' value='$config' />
1860 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1862 <form method='post'>
1863 <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;' />
1864 <input type='hidden' name='key' value='$key' />
1865 <input type='hidden' name='config' value='$config' />
1866 <input type='hidden' name='ACTION' value='editrule' />
1868 <form method='post'>
1869 <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;' />
1870 <input type='hidden' name='key' value='$key' />
1871 <input type='hidden' name='config' value='$config' />
1872 <input type='hidden' name='ACTION' value='copyrule' />
1874 <form method='post'>
1875 <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;' />
1876 <input type='hidden' name='key' value='$key' />
1877 <input type='hidden' name='config' value='$config' />
1878 <input type='hidden' name='ACTION' value='deleterule' />
1881 if (exists $$hash{$key-1}){
1883 <form method='post'>
1884 <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;' />
1885 <input type='hidden' name='key' value='$key' />
1886 <input type='hidden' name='config' value='$config' />
1887 <input type='hidden' name='ACTION' value='moveup' />
1893 if (exists $$hash{$key+1}){
1895 <form method='post'>
1896 <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;' />
1897 <input type='hidden' name='key' value='$key' />
1898 <input type='hidden' name='config' value='$config' />
1899 <input type='hidden' name='ACTION' value='movedown' />
1900 </td></form></td></tr>
1903 print"<td></td></tr>";
1905 #if timeframe set, print new line in table
1906 if ($$hash{$key}[18] eq 'ON'){
1908 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1909 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1910 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1911 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1912 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1913 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1914 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1915 my $weekdays=join(",",@days);
1917 print"<tr bgcolor='#FFE4B5'><td colspan='6'>$Lang::tr{'fwdfw time'} ";
1919 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1924 &Header
::closebox
();
1930 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
1933 &Header
::openbox
('100%', 'center', 'P2P-Block');
1935 <table width='40%' border='0'>
1936 <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>
1938 foreach my $p2pentry (sort @p2ps)
1940 my @p2pline = split( /\;/, $p2pentry );
1941 if($p2pline[2] eq 'on'){
1942 $gif="/images/on.gif"
1944 $gif="/images/off.gif"
1947 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1948 <tr bgcolor='$color{'color20'}'>
1949 <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>
1952 print"<tr><td width='10%'><input type='image' img src='/images/on.gif'></td><td>$Lang::tr{'outgoing firewall p2p deny'}</td><td></td></tr>";
1953 print"<tr><td width='10%'><input type='image' img src='/images/off.gif'></td><td>$Lang::tr{'outgoing firewall p2p allow'}</td><td></td></tr></table>";
1954 &Header
::closebox
();
1958 my %hash=%{(shift)};
1961 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1962 if($hash{$key}[0] eq $val){
1963 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1965 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1971 if (!-f
"${General::swroot}/forward/reread"){
1972 system("touch ${General::swroot}/forward/reread");
1977 system("/usr/local/bin/forwardfwctrl");
1978 system("rm ${General::swroot}/forward/reread");
1980 &Header
::closebigbox
();
1981 &Header
::closepage
();