]>
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'){
146 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
147 $fwdfwsettings{'nosave'} = 'on';
152 #check if we just close a rule
153 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'} ) {
154 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
156 $fwdfwsettings{'nosave2'} = 'on';
159 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
160 if ($fwdfwsettings{'nobase'} ne 'on'){
161 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
163 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
164 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
165 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
166 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
167 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
168 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
170 if($fwdfwsettings{'nosave2'} ne 'on'){
171 &saverule
(\
%configinputfw,$configinput);
173 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
174 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
175 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
176 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
177 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
178 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
179 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
180 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
181 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
182 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
183 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
184 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
185 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
186 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
187 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
188 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
190 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
191 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
192 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
193 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
196 $fwdfwsettings{'chain'} = 'FORWARDFW';
197 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
198 #check if we have an identical rule already
199 foreach my $key (sort keys %configfwdfw){
200 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'}"
201 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]"){
202 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
203 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
206 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
207 $fwdfwsettings{'nosave'} = 'on';
212 #check if we just close a rule
213 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'} ) {
214 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
215 $fwdfwsettings{'nosave2'} = 'on';
221 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
222 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
223 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
224 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
225 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
226 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
227 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
228 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
230 if ($fwdfwsettings{'nobase'} eq 'on'){
231 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
233 if ($fwdfwsettings{'nosave2'} ne 'on'){
234 &saverule
(\
%configfwdfw,$configfwdfw);
236 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
237 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
238 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
239 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
240 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
241 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
242 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
243 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
244 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
245 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
246 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
247 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
248 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
249 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
250 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
251 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
253 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
254 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
255 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
256 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
261 if($fwdfwsettings{'nosave2'} ne 'on'){
267 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
269 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
270 foreach my $key (sort keys %configfwdfw){
271 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
272 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
273 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
275 &General
::readhasharray
("$configinput", \
%configinputfw);
276 foreach my $key (sort keys %configinputfw){
277 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
278 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
279 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
281 $fwdfwsettings{'POLICY'}='MODE0';
282 system("rm ${General::swroot}/forward/config");
283 system("rm ${General::swroot}/forward/input");
284 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
285 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
286 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
291 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
295 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
298 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
299 foreach my $key (sort keys %togglehash){
300 if ($key eq $fwdfwsettings{'key'}){
301 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
304 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
308 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
311 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
312 foreach my $key (sort keys %togglehash){
313 if ($key eq $fwdfwsettings{'key'}){
314 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
317 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
321 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
326 if ($fwdfwsettings{'ACTION'} eq 'editrule')
328 $fwdfwsettings{'updatefwrule'}='on';
331 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
335 if ($fwdfwsettings{'ACTION'} eq 'moveup')
340 if ($fwdfwsettings{'ACTION'} eq 'movedown')
345 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
347 $fwdfwsettings{'copyfwrule'}='on';
348 #$fwdfwsettings{'updatefwrule'}='on';
351 if ($fwdfwsettings{'ACTION'} eq 'togglep2p')
353 #$errormessage="Toggle $fwdfwsettings{'P2PROT'}<br>";
354 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
357 open( FILE
, "> $p2pfile" ) or die "Unable to write $p2pfile";
358 foreach my $p2pentry (sort @p2ps)
360 my @p2pline = split( /\;/, $p2pentry );
361 if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) {
362 if($p2pline[2] eq 'on'){
368 print FILE
"$p2pline[0];$p2pline[1];$p2pline[2];\n";
374 if ($fwdfwsettings{'ACTION'} eq '')
383 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
384 foreach my $key (sort keys %uphash){
385 if ($key eq $fwdfwsettings{'key'}) {
387 if (exists $uphash{$last}){
389 foreach my $y (0 .. $#{$uphash{$last}}) {
390 $tmp{0}[$y] = $uphash{$last}[$y];
392 #copy active rule to last
393 foreach my $i (0 .. $#{$uphash{$last}}) {
394 $uphash{$last}[$i] = $uphash{$key}[$i];
396 #copy saved rule to actual position
397 foreach my $x (0 .. $#{$tmp{0}}) {
398 $uphash{$key}[$x] = $tmp{0}[$x];
403 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
410 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
411 foreach my $key (sort keys %downhash){
412 if ($key eq $fwdfwsettings{'key'}) {
414 if (exists $downhash{$next}){
416 foreach my $y (0 .. $#{$downhash{$next}}) {
417 $tmp{0}[$y] = $downhash{$next}[$y];
419 #copy active rule to next
420 foreach my $i (0 .. $#{$downhash{$next}}) {
421 $downhash{$next}[$i] = $downhash{$key}[$i];
423 #copy saved rule to actual position
424 foreach my $x (0 .. $#{$tmp{0}}) {
425 $downhash{$key}[$x] = $tmp{0}[$x];
430 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
435 my ($base1,$val1,$base2,$val2) = @_;
437 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
438 &dec_counter
($confignet,\
%customnetwork,$val1);
439 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
440 &dec_counter
($confighost,\
%customhost,$val1);
441 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
442 &dec_counter
($configgrp,\
%customgrp,$val1);
443 }elsif($base1 eq 'cust_srv'){
444 &dec_counter
($configsrv,\
%customservice,$val1);
445 }elsif($base1 eq 'cust_srvgrp'){
446 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
449 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
450 &inc_counter
($confignet,\
%customnetwork,$val2);
451 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
452 &inc_counter
($confighost,\
%customhost,$val2);
453 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
454 &inc_counter
($configgrp,\
%customgrp,$val2);
455 }elsif($base2 eq 'cust_srv'){
456 &inc_counter
($configsrv,\
%customservice,$val2);
457 }elsif($base2 eq 'cust_srvgrp'){
458 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
468 &General
::readhasharray
($config, \
%hash);
469 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
470 if($hash{$key}[0] eq $val){
471 $pos=$#{$hash{$key}};
472 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
475 &General
::writehasharray
($config, \
%hash);
483 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
484 &General
::readhasharray
($config, \
%hash);
485 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
486 if($hash{$key}[0] eq $val){
487 $pos=$#{$hash{$key}};
488 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
491 &General
::writehasharray
($config, \
%hash);
495 if ($fwdfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
496 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
497 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
500 if ($fwdfwsettings{'POLICY'} ne 'MODE0' && $fwdfwsettings{'POLICY'} ne '') {
504 #print"<table width='100' border='1'><tr>";
507 #print"<td bgcolor='$color{$i}'>$_</td>";
509 #print"</tr></table>";
510 if ($fwdfwsettings{'POLICY'} eq 'MODE1' || $fwdfwsettings{'POLICY'} eq 'MODE2' ) {
513 &Header
::openbox
('100%', 'center', 'Policy');
515 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
517 <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>
518 <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>
519 <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>
520 <tr><td colspan='3'><hr /></td></tr>
521 <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>
522 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
523 <td width='45%' align='left'>
525 if ($fwdfwsettings{'POLICY'} ne 'MODE0'&& $fwdfwsettings{'POLICY'} ne '' ) {
526 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
528 print "</table></form>";
534 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
536 print "<form method='post'>";
537 print "<table border='0'>";
538 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
539 if (-f
"${General::swroot}/forward/reread"){
540 print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'></td>";
542 print"</tr></table></form><hr>";
550 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
551 foreach my $key (sort {$a <=> $b} keys %delhash){
552 if ($key == $fwdfwsettings{'key'}){
553 #check hosts/net and groups
554 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
555 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
556 #check services and groups
557 if ($delhash{$key}[11] eq 'ON'){
558 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
561 if ($key >= $fwdfwsettings{'key'}) {
563 if (exists $delhash{$next}) {
564 foreach my $i (0 .. $#{$delhash{$next}}) {
565 $delhash{$key}[$i] = $delhash{$next}[$i];
570 # Remove the very last entry.
571 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
572 delete $delhash{$last_key};
574 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
577 if($fwdfwsettings{'nobase'} ne 'on'){
584 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
585 foreach my $key (sort keys %configfwdfw){
587 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
590 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
597 #check ip-address if manual
598 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
599 #check if ip with subnet
600 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
601 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
602 $subnet = &General
::iporsubtocidr
($subnet);
603 $fwdfwsettings{'isip'}='on';
606 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
607 $ip=$fwdfwsettings{'src_addr'};
609 $fwdfwsettings{'isip'}='on';
612 if ($fwdfwsettings{'isip'} ne 'on'){
613 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
615 if ($fwdfwsettings{'isip'} eq 'on'){
616 #check and form valid IP
617 $ip=&General
::ip2dec
($ip);
618 $ip=&General
::dec2ip
($ip);
619 #check if net or broadcast
620 my @tmp= split (/\./,$ip);
621 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
623 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
625 $fwdfwsettings{'src_addr'}="$ip/$subnet";
627 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
628 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
631 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
632 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
634 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
635 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
636 return $errormessage;
640 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
642 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
643 $fwdfwsettings{'SRC_PORT'}='';
644 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
645 foreach my $key (keys %icmptypes){
646 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
647 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
650 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
651 $fwdfwsettings{'SRC_PORT'}='';
652 $fwdfwsettings{'ICMP_TYPES'}='';
653 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
654 $fwdfwsettings{'SRC_PORT'}='';
655 $fwdfwsettings{'ICMP_TYPES'}='';
656 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
657 $fwdfwsettings{'SRC_PORT'}='';
658 $fwdfwsettings{'ICMP_TYPES'}='';
659 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
660 $fwdfwsettings{'ICMP_TYPES'}='';
662 $fwdfwsettings{'ICMP_TYPES'}='';
663 $fwdfwsettings{'SRC_PORT'}='';
664 $fwdfwsettings{'PROT'}='';
667 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
668 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
672 if ($_ =~ /^(\d+)\:(\d+)$/) {
674 #change dashes with :
677 push(@values,"1:65535");
680 if ($_ =~ /^(\D)\:(\d+)$/) {
681 push(@values,"1:$2");
684 if ($_ =~ /^(\d+)\:(\D)$/) {
685 push(@values,"$1:65535");
688 $errormessage .= &General
::validportrange
($_, 'destination');
693 if (&General
::validport
($_)){
700 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
701 return $errormessage;
708 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
709 #check if ip with subnet
710 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
711 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
712 $subnet = &General
::iporsubtocidr
($subnet);
715 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
716 $ip=$fwdfwsettings{'tgt_addr'};
719 #check and form valid IP
720 $ip=&General
::ip2dec
($ip);
721 $ip=&General
::dec2ip
($ip);
723 #check if net or broadcast
724 my @tmp= split (/\./,$ip);
725 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
727 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
729 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
731 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
732 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
735 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
736 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
737 return $errormessage;
741 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
744 if ($fwdfwsettings{'USESRV'} eq 'ON'){
745 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
746 $fwdfwsettings{'TGT_PROT'}='';
747 $fwdfwsettings{'ICMP_TGT'}='';
749 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
750 $fwdfwsettings{'TGT_PROT'}='';
751 $fwdfwsettings{'ICMP_TGT'}='';
752 #check target service
753 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
754 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
757 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
758 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
759 if ($fwdfwsettings{'TGT_PORT'} ne ''){
760 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
764 if ($_ =~ /^(\d+)\:(\d+)$/) {
766 #change dashes with :
769 push(@values,"1:65535");
772 if ($_ =~ /^(\D)\:(\d+)$/) {
773 push(@values,"1:$2");
776 if ($_ =~ /^(\d+)\:(\D)$/) {
777 push(@values,"$1:65535");
780 $errormessage .= &General
::validportrange
($_, 'destination');
785 if (&General
::validport
($_)){
792 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
794 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
795 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
796 $fwdfwsettings{'TGT_PORT'} = '';
797 $fwdfwsettings{'ICMP_TGT'} = '';
798 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
799 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
800 $fwdfwsettings{'TGT_PORT'} = '';
801 $fwdfwsettings{'ICMP_TGT'}='';
802 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
803 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
804 $fwdfwsettings{'TGT_PORT'} = '';
805 $fwdfwsettings{'ICMP_TGT'}='';
806 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
807 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
808 $fwdfwsettings{'TGT_PORT'} = '';
809 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
810 foreach my $key (keys %icmptypes){
812 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
813 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
821 if ($fwdfwsettings{'USESRV'} ne 'ON'){
822 $fwdfwsettings{'grp3'}='';
823 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
824 $fwdfwsettings{'TGT_PROT'}='';
825 $fwdfwsettings{'ICMP_TGT'}='';
828 if($fwdfwsettings{'TIME'} eq 'ON'){
829 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 ''){
830 $errormessage=$Lang::tr
{'fwdfw err time'};
833 return $errormessage;
838 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
839 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
841 #check if source and target identical
842 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
843 $errormessage.=$Lang::tr
{'fwdfw err same'};
844 return $errormessage;
847 #get source and targetip address if possible
848 my ($sip,$scidr,$tip,$tcidr);
849 ($sip,$scidr)=&get_ip
("src","grp1");
850 ($tip,$tcidr)=&get_ip
("tgt","grp2");
852 #check same iprange in source and target
853 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
854 my $networkip1=&General
::getnetworkip
($sip,$scidr);
855 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
856 if ($scidr gt $tcidr){
857 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr)) ){
858 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
860 }elsif($scidr eq $tcidr && $scidr eq '32'){
861 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
862 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
863 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
864 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
865 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
868 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
869 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
874 #check source and destination protocol if manual
875 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
878 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
879 $errormessage.=$Lang::tr
{'fwdfw err prot'};
881 #check source and destination protocol if source manual and dest servicegrp
882 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
883 &General
::readhasharray
("$configsrv", \
%customservice);
884 foreach my $key (sort keys %customservice){
885 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
886 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
887 $errormessage.=$Lang::tr
{'fwdfw err prot'};
901 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
902 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
903 if ($fwdfwsettings{$grp} eq $val.'_addr'){
904 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
905 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
906 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
907 $a=$netsettings{'GREEN_NETADDRESS'};
908 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
909 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
910 $a=$netsettings{'ORANGE_NETADDRESS'};
911 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
912 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
913 $a=$netsettings{'BLUE_NETADDRESS'};
914 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
915 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
916 &General
::readhash
("$configovpn",\
%ovpnsettings);
917 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
918 $b=&General
::iporsubtocidr
($b);
920 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
921 &General
::readhasharray
("$confignet", \
%customnetwork);
922 foreach my $key (keys %customnetwork){
923 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
924 $a=$customnetwork{$key}[1];
925 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
928 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
929 &General
::readhasharray
("$confighost", \
%customhost);
930 foreach my $key (keys %customhost){
931 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
932 if ($customhost{$key}[1] eq 'ip'){
933 ($a,$b)=split (/\//,$customhost{$key}[2]);
934 $b=&General
::iporsubtocidr
($b);
937 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
949 &General
::setup_default_networks
(\
%defaultNetworks);
950 #read all configfiles
951 &General
::readhasharray
("$configccdnet", \
%ccdnet);
952 &General
::readhasharray
("$confignet", \
%customnetwork);
953 &General
::readhasharray
("$configccdhost", \
%ccdhost);
954 &General
::readhasharray
("$confighost", \
%customhost);
955 &General
::readhasharray
("$configccdhost", \
%ccdhost);
956 &General
::readhasharray
("$configgrp", \
%customgrp);
957 &General
::readhasharray
("$configipsec", \
%ipsecconf);
958 &General
::get_aliases
(\
%aliases);
962 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
963 my $config=$fwdfwsettings{'config'};
965 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
966 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
967 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
968 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
969 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
970 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
971 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
972 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
973 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
974 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
975 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
976 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
977 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
978 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
979 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
980 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
981 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
982 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
983 #check if update and get values
984 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
985 &General
::readhasharray
("$config", \
%hash);
986 foreach my $key (sort keys %hash){
988 if ($key eq $fwdfwsettings{'key'}){
989 $fwdfwsettings{'oldrulenumber'} = $key;
990 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
991 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
992 $fwdfwsettings{'grp1'} = $hash{$key}[3];
993 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
994 $fwdfwsettings{'grp2'} = $hash{$key}[5];
995 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
996 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
997 $fwdfwsettings{'PROT'} = $hash{$key}[8];
998 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
999 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1000 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1001 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1002 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1003 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1004 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1005 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1006 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1007 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1008 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1009 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1010 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1011 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1012 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1013 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1014 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1015 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1016 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1017 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1018 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1019 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1020 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1021 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1022 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1023 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1024 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1025 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1026 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1027 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1028 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1029 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1030 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1031 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1032 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1033 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1034 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1037 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1038 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1039 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1040 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1041 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1042 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1043 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1044 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1046 $fwdfwsettings{'ACTIVE'}='ON';
1047 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1050 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1053 <form method="post">
1055 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1057 foreach ("ACCEPT","DROP","REJECT")
1059 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1061 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1062 print">$_</option>";
1064 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1065 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1068 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1070 print"<option selected>$_</option>";
1072 print"<option>$_</option>";
1076 print"</select></td></tr></table><hr>";
1078 &Header
::closebox
();
1079 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1081 #------SOURCE-------------------------------------------------------
1083 <table width='100%' border='0'>
1084 <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>
1085 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1086 <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;'>
1088 foreach my $network (sort keys %defaultNetworks)
1090 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1091 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1092 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1093 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1094 print ">$network</option>";
1097 </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;'>
1099 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1102 <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;'>
1104 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1106 </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;'>
1108 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1110 if ($ccdhost{$key}[33] ne ''){
1112 print "<option value='$ccdhost{$key}[1]'";
1113 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1114 print ">$ccdhost{$key}[1]</option>";
1119 <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;'>
1121 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1123 </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;'>
1125 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1126 if($ccdhost{$key}[3] eq 'net'){
1128 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1129 print ">$ccdhost{$key}[1]</option>";
1135 <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;'>
1137 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1138 if($helper ne $customgrp{$key}[0]){
1140 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1141 print ">$customgrp{$key}[0]</option>";
1143 $helper=$customgrp{$key}[0];
1147 <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;'>
1149 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1150 if ($ipsecconf{$key}[3] eq 'net'){
1152 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1153 print ">$ipsecconf{$key}[1]</option>";
1161 # <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;'>
1163 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1164 # if ($ipsecconf{$key}[3] eq 'host'){
1166 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1167 # print ">$ipsecconf{$key}[1]</option>";
1171 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1172 <table width='100%' border='0'>
1173 <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>
1174 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1176 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1178 if ($_ eq $fwdfwsettings{'PROT'})
1180 print"<option selected>$_</option>";
1182 print"<option>$_</option>";
1185 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1187 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1188 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1190 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1191 print"<option>All ICMP-Types</option>";
1192 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1193 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1194 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1196 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1200 </select></td></tr></table><hr>
1202 &Header
::closebox
();
1204 #---TARGET------------------------------------------------------
1205 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1207 <table width='100%' border='0'>
1208 <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;'>
1210 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1212 foreach my $alias (sort keys %aliases)
1214 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1219 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1220 <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;'>
1222 foreach my $network (sort keys %defaultNetworks)
1224 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1225 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1226 print ">$network</option>";
1229 </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;'>
1231 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1234 <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;'>
1236 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1238 </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;'>
1240 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1242 if ($ccdhost{$key}[33] ne ''){
1243 print "<option value='$ccdhost{$key}[1]' ";
1244 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1245 print ">$ccdhost{$key}[1]</option>";
1250 <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;'>
1252 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1254 </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;'>
1256 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1257 if($ccdhost{$key}[3] eq 'net'){
1259 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1260 print ">$ccdhost{$key}[1]</option>";
1265 <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;'>
1268 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1269 if($helper ne $customgrp{$key}[0]){
1271 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1272 print">$customgrp{$key}[0]</option>";
1274 $helper=$customgrp{$key}[0];
1278 <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;'>
1280 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1281 if ($ipsecconf{$key}[3] eq 'net'){
1283 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1284 print">$ipsecconf{$key}[1]</option>";
1290 # <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;'>
1292 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1293 # if ($ipsecconf{$key}[3] eq 'host'){
1295 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1296 # print">$ipsecconf{$key}[1]</option>";
1301 <b>$Lang::tr{'fwhost attention'}:</b><br>
1302 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1304 <table width='100%' border='0'>
1305 <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;' >
1307 &General
::readhasharray
("$configsrv", \
%customservice);
1308 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1310 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1311 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1315 <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;' >
1317 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1319 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1320 if ($helper ne $customservicegrp{$key}[0]){
1322 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1323 print">$customservicegrp{$key}[0]</option>";
1325 $helper=$customservicegrp{$key}[0];
1329 <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'>
1331 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1333 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1335 print"<option selected>$_</option>";
1337 print"<option>$_</option>";
1340 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1342 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1343 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1345 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1346 print"<option>All ICMP-Types</option>";
1347 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1348 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1349 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1351 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1356 </table><hr><br><br>
1359 #---Activate/logging/remark-------------------------------------
1360 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1362 <table width='100%' border='0'>
1363 <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>
1365 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1366 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1367 for (my $count =1; $count <= $sum; $count++){
1368 print"<option value='$count' ";
1369 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1370 print">$count</option>";
1372 print"</select></td></tr>";
1376 </table><table width='100%'>
1377 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1378 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1381 &Header
::closebox
();
1382 #---ADD TIMEFRAME-----------------------------------------------
1383 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1385 <table width='70%' border='0'>
1386 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1387 <tr><td colspan='7'> </td></tr>
1389 <td align='left'>$Lang::tr{'time'}:</td>
1390 <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>
1391 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1392 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1395 <td align='right'></td>
1396 <td width='30%' align='left'>
1397 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1398 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1399 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1400 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1401 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1402 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1403 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1405 <td><select name='TIME_FROM'>
1407 for (my $i=0;$i<=23;$i++) {
1408 $i = sprintf("%02s",$i);
1409 for (my $j=0;$j<=45;$j+=15) {
1410 $j = sprintf("%02s",$j);
1411 my $time = $i.":".$j;
1412 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1417 <td><select name='TIME_TO'>
1419 for (my $i=0;$i<=23;$i++) {
1420 $i = sprintf("%02s",$i);
1421 for (my $j=0;$j<=45;$j+=15) {
1422 $j = sprintf("%02s",$j);
1423 my $time = $i.":".$j;
1424 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1431 &Header
::closebox
();
1432 #---ACTION------------------------------------------------------
1433 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1435 <table border='0' width='100%'>
1436 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1437 <input type='hidden' name='config' value='$config' >
1438 <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>
1443 <table border='0' width='100%'>
1444 <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'}'>
1445 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1446 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1447 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1448 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1449 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1450 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1451 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1452 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1453 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1454 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1455 <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>
1459 &Header
::closebox
();
1465 &General
::readhasharray
("$config", $hash);
1466 if (!$errormessage){
1467 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1468 my $key = &General
::findhasharraykey
($hash);
1469 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1470 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1471 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1472 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1473 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1474 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1475 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1476 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1477 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1478 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1479 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1480 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1481 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1482 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1483 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1484 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1485 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1486 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1487 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1488 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1489 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1490 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1491 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1492 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1493 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1494 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1495 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1496 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1497 &General
::writehasharray
("$config", $hash);
1499 foreach my $key (sort {$a <=> $b} keys %$hash){
1500 if($key eq $fwdfwsettings{'key'}){
1501 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1502 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1503 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1504 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1505 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1506 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1507 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1508 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1509 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1510 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1511 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1512 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1513 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1514 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1515 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1516 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1517 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1518 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1519 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1520 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1521 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1522 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1523 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1524 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1525 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1526 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1527 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1528 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1533 &General
::writehasharray
("$config", $hash);
1534 if($fwdfwsettings{'oldrulenumber'} gt $fwdfwsettings{'rulepos'}){
1536 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1537 for (my $z=0;$z<$val;$z++){
1538 foreach my $key (sort {$a <=> $b} keys %$hash){
1539 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1541 if (exists $$hash{$last}){
1543 foreach my $y (0 .. $#{$$hash{$last}}) {
1544 $tmp{0}[$y] = $$hash{$last}[$y];
1546 #copy active rule to last
1547 foreach my $i (0 .. $#{$$hash{$last}}) {
1548 $$hash{$last}[$i] = $$hash{$key}[$i];
1550 #copy saved rule to actual position
1551 foreach my $x (0 .. $#{$tmp{0}}) {
1552 $$hash{$key}[$x] = $tmp{0}[$x];
1557 $fwdfwsettings{'oldrulenumber'}--;
1559 &General
::writehasharray
("$config", $hash);
1561 }elsif($fwdfwsettings{'rulepos'} gt $fwdfwsettings{'oldrulenumber'}){
1563 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1564 for (my $z=0;$z<$val;$z++){
1565 foreach my $key (sort {$a <=> $b} keys %$hash){
1566 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1567 my $next = $key + 1;
1568 if (exists $$hash{$next}){
1570 foreach my $y (0 .. $#{$$hash{$next}}) {
1571 $tmp{0}[$y] = $$hash{$next}[$y];
1573 #copy active rule to next
1574 foreach my $i (0 .. $#{$$hash{$next}}) {
1575 $$hash{$next}[$i] = $$hash{$key}[$i];
1577 #copy saved rule to actual position
1578 foreach my $x (0 .. $#{$tmp{0}}) {
1579 $$hash{$key}[$x] = $tmp{0}[$x];
1584 $fwdfwsettings{'oldrulenumber'}++;
1586 &General
::writehasharray
("$config", $hash);
1593 if ($errormessage) {
1594 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1595 print "<class name='base'>$errormessage\n";
1596 print " </class>\n";
1597 &Header
::closebox
();
1604 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1605 print "<class name='base'>$hint\n";
1606 print " </class>\n";
1607 &Header
::closebox
();
1614 &General
::setup_default_networks
(\
%defaultNetworks);
1615 foreach my $network (sort keys %defaultNetworks)
1617 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1622 # Checks a hostname against RFC1035
1625 # Each part should be at least two characters in length
1626 # but no more than 63 characters
1627 if (length ($remark) < 1 || length ($remark) > 255) {
1629 # Only valid characters are a-z, A-Z, 0-9 and -
1630 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:_\/\s
]*$/) {
1632 # First character can only be a letter or a digit
1633 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1635 # Last character can only be a letter or a digit
1636 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
1642 my %hash=%{(shift)};
1644 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1645 $hash{$key}[10]=~ s/\|/,/g;
1646 print": $hash{$key}[10]";
1647 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1648 print": <br>$hash{$key}[9] ";
1653 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];
1674 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1675 print":<br>$hash{$key}[13]";
1678 sub get_serviceports
1682 &General
::readhasharray
("$configsrv", \
%customservice);
1683 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1687 if($type eq 'service'){
1688 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1689 if ($customservice{$key}[0] eq $name){
1690 $protocols=$customservice{$key}[2];
1694 }elsif($type eq 'group'){
1695 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1696 if ($customservicegrp{$key}[0] eq $name){
1697 if($customservicegrp{$key}[4] eq 'TCP'){$tcp='TCP';}else{$udp='UDP';}
1701 if($tcp){$protocols.="TCP";}
1702 if($udp){$protocols.=",UDP";}
1707 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1708 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1717 if ( ! -z
"$config"){
1718 &Header
::openbox
('100%', 'left',$title);
1726 &General
::readhasharray
("$config", $hash);
1727 print"<b>$title1</b><br>";
1728 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1729 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>";
1730 foreach my $key (sort {$a <=> $b} keys %$hash){
1732 #check if vpn hosts/nets have been deleted
1733 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1734 push (@tmpsrc,$$hash{$key}[4]);
1736 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1737 push (@tmpsrc,$$hash{$key}[6]);
1739 foreach my $host (@tmpsrc){
1740 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1741 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1743 &disable_rule
($key);
1746 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1747 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1749 &disable_rule
($key);
1752 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1753 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1755 &disable_rule
($key);
1758 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1759 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1761 &disable_rule
($key);
1768 $$hash{'ACTIVE'}=$$hash{$key}[2];
1770 if($coloryellow eq 'on'){
1771 print"<tr bgcolor='$color{'color14'}' >";
1773 }elsif($coloryellow eq ''){
1775 print"<tr bgcolor='$color{'color22'}' >";
1778 print"<tr bgcolor='$color{'color20'}' >";
1782 <td align='right'>$key</td>
1784 if ($$hash{$key}[0] eq 'ACCEPT'){
1787 $rulecolor=$color{'color17'};
1788 }elsif($$hash{$key}[0] eq 'DROP'){
1791 $rulecolor=$color{'color25'};
1792 }elsif($$hash{$key}[0] eq 'REJECT'){
1795 $rulecolor=$color{'color16'};
1797 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1798 print"<td align='center' nowrap='nowrap'>";
1799 if ($$hash{$key}[3] eq 'std_net_src'){
1800 print &get_name
($$hash{$key}[4]);
1802 print $$hash{$key}[4];
1804 &getsrcport
(\
%$hash,$key);
1805 if ($$hash{$key}[17] eq 'ON'){
1806 $log="/images/on.gif";
1808 $log="/images/off.gif";
1812 <form method='post'>
1813 <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 ;'/>
1814 <input type='hidden' name='key' value='$key' />
1815 <input type='hidden' name='config' value='$config' />
1816 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1821 <td align='center' nowrap='nowrap'>
1823 if ($$hash{$key}[5] eq 'std_net_tgt'){
1824 print &get_name
($$hash{$key}[6]);
1826 print $$hash{$key}[6];
1828 &gettgtport
(\
%$hash,$key);
1829 ################################################################################
1833 if ($$hash{$key}[12]){ #target prot if manual
1834 $prot=$$hash{$key}[12];
1835 }elsif($$hash{$key}[8]){ #source prot if manual
1836 $prot=$$hash{$key}[8];
1837 }elsif($$hash{$key}[14] eq 'cust_srv'){
1838 $prot=&get_serviceports
("service",$$hash{$key}[15]);
1839 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
1840 $prot=&get_serviceports
("group",$$hash{$key}[15]);
1842 $prot=$Lang::tr
{'all'};
1844 print"<td align='center'>$prot</td>";
1846 print"<td width='20%'>$$hash{$key}[16]</td>";
1848 if($$hash{$key}[2] eq 'ON'){
1849 $gif="/images/on.gif"
1852 $gif="/images/off.gif"
1855 <form method='post'>
1856 <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;' />
1857 <input type='hidden' name='key' value='$key' />
1858 <input type='hidden' name='config' value='$config' />
1859 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1861 <form method='post'>
1862 <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;' />
1863 <input type='hidden' name='key' value='$key' />
1864 <input type='hidden' name='config' value='$config' />
1865 <input type='hidden' name='ACTION' value='editrule' />
1867 <form method='post'>
1868 <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;' />
1869 <input type='hidden' name='key' value='$key' />
1870 <input type='hidden' name='config' value='$config' />
1871 <input type='hidden' name='ACTION' value='copyrule' />
1873 <form method='post'>
1874 <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;' />
1875 <input type='hidden' name='key' value='$key' />
1876 <input type='hidden' name='config' value='$config' />
1877 <input type='hidden' name='ACTION' value='deleterule' />
1880 if (exists $$hash{$key-1}){
1882 <form method='post'>
1883 <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;' />
1884 <input type='hidden' name='key' value='$key' />
1885 <input type='hidden' name='config' value='$config' />
1886 <input type='hidden' name='ACTION' value='moveup' />
1892 if (exists $$hash{$key+1}){
1894 <form method='post'>
1895 <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;' />
1896 <input type='hidden' name='key' value='$key' />
1897 <input type='hidden' name='config' value='$config' />
1898 <input type='hidden' name='ACTION' value='movedown' />
1899 </td></form></td></tr>
1902 print"<td></td></tr>";
1904 #if timeframe set, print new line in table
1905 if ($$hash{$key}[18] eq 'ON'){
1907 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1908 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1909 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1910 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1911 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1912 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1913 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1914 my $weekdays=join(",",@days);
1916 print"<tr bgcolor='#FFE4B5'><td colspan='6'>$Lang::tr{'fwdfw time'} ";
1918 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1923 &Header
::closebox
();
1929 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
1932 &Header
::openbox
('100%', 'center', 'P2P-Block');
1934 <table width='40%' border='0'>
1935 <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>
1937 foreach my $p2pentry (sort @p2ps)
1939 my @p2pline = split( /\;/, $p2pentry );
1940 if($p2pline[2] eq 'on'){
1941 $gif="/images/on.gif"
1943 $gif="/images/off.gif"
1946 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1947 <tr bgcolor='$color{'color20'}'>
1948 <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>
1951 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>";
1952 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>";
1953 &Header
::closebox
();
1957 my %hash=%{(shift)};
1960 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1961 if($hash{$key}[0] eq $val){
1962 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1964 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1970 if (!-f
"${General::swroot}/forward/reread"){
1971 system("touch ${General::swroot}/forward/reread");
1976 system("/usr/local/bin/forwardfwctrl");
1977 system("rm ${General::swroot}/forward/reread");
1979 &Header
::closebigbox
();
1980 &Header
::closepage
();