]>
git.ipfire.org Git - people/pmueller/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=();
72 my $confignet = "${General::swroot}/fwhosts/customnetworks";
73 my $confighost = "${General::swroot}/fwhosts/customhosts";
74 my $configgrp = "${General::swroot}/fwhosts/customgroups";
75 my $configsrv = "${General::swroot}/fwhosts/customservices";
76 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
77 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
78 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
79 my $configipsec = "${General::swroot}/vpn/config";
80 my $configipsecrw = "${General::swroot}/vpn/settings";
81 my $configfwdfw = "${General::swroot}/forward/config";
82 my $configinput = "${General::swroot}/forward/input";
83 my $configovpn = "${General::swroot}/ovpn/settings";
87 my $ipgrp="${General::swroot}/outgoing/groups";
90 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
91 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
92 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
94 &Header
::showhttpheaders
();
95 &Header
::getcgihash
(\
%fwdfwsettings);
96 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
97 &Header
::openbigbox
('100%', 'center',$errormessage);
100 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
102 my $MODE = $fwdfwsettings{'POLICY'};
104 $fwdfwsettings{'POLICY'} = "$MODE";
105 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
108 if ($fwdfwsettings{'ACTION'} eq 'saverule')
110 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
111 &General
::readhasharray
("$configinput", \
%configinputfw);
112 $errormessage=&checksource
;
113 if(!$errormessage){&checktarget
;}
114 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'}});
126 #check if we change an external access rule to an forward
127 if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
128 $fwdfwsettings{'updatefwrule'}='';
129 $fwdfwsettings{'config'}=$configinput;
130 $fwdfwsettings{'nobase'}='on';
132 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
133 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
136 if($fwdfwsettings{'grp2'} eq 'ipfire'){
137 $fwdfwsettings{'chain'} = 'INPUTFW';
138 #check if we have an identical rule already
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{'ruleremark'},$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}[16],$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'};
146 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
147 if ($fwdfwsettings{'nobase'} ne 'on'){
148 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
150 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
151 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
152 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
153 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
154 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
155 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
158 &saverule
(\
%configinputfw,$configinput);
159 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
160 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
161 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
162 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
163 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
164 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
165 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
166 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
167 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
168 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
169 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
170 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
171 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
172 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
173 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
174 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
176 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
177 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
178 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
179 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
181 $fwdfwsettings{'chain'} = 'FORWARDFW';
182 #check if we have an identical rule already
183 foreach my $key (sort keys %configfwdfw){
185 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{'ruleremark'},$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'}"
186 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}[16],$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]"){
187 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
191 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
193 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
195 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
196 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
197 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
198 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
199 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
200 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
202 if ($fwdfwsettings{'nobase'} eq 'on'){
203 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
205 &saverule
(\
%configfwdfw,$configfwdfw);
207 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
208 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
209 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
210 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
211 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
212 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
213 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
214 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
215 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
216 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
217 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
218 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
219 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
220 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
221 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
222 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
224 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
225 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
226 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
227 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
236 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
238 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
239 foreach my $key (sort keys %configfwdfw){
240 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
241 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
242 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
244 &General
::readhasharray
("$configinput", \
%configinputfw);
245 foreach my $key (sort keys %configinputfw){
246 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
247 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
248 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
250 $fwdfwsettings{'POLICY'}='MODE0';
251 system("rm ${General::swroot}/forward/config");
252 system("rm ${General::swroot}/forward/input");
253 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
254 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
255 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
260 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
264 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
267 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
268 foreach my $key (sort keys %togglehash){
269 if ($key eq $fwdfwsettings{'key'}){
270 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
273 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
277 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
280 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
281 foreach my $key (sort keys %togglehash){
282 if ($key eq $fwdfwsettings{'key'}){
283 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
286 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
290 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
295 if ($fwdfwsettings{'ACTION'} eq 'editrule')
297 $fwdfwsettings{'updatefwrule'}='on';
300 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
304 if ($fwdfwsettings{'ACTION'} eq 'moveup')
309 if ($fwdfwsettings{'ACTION'} eq 'movedown')
314 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
316 $fwdfwsettings{'copyfwrule'}='on';
317 #$fwdfwsettings{'updatefwrule'}='on';
320 if ($fwdfwsettings{'ACTION'} eq '')
329 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
330 foreach my $key (sort keys %uphash){
331 if ($key eq $fwdfwsettings{'key'}) {
333 if (exists $uphash{$last}){
335 foreach my $y (0 .. $#{$uphash{$last}}) {
336 $tmp{0}[$y] = $uphash{$last}[$y];
338 #copy active rule to last
339 foreach my $i (0 .. $#{$uphash{$last}}) {
340 $uphash{$last}[$i] = $uphash{$key}[$i];
342 #copy saved rule to actual position
343 foreach my $x (0 .. $#{$tmp{0}}) {
344 $uphash{$key}[$x] = $tmp{0}[$x];
349 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
356 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
357 foreach my $key (sort keys %downhash){
358 if ($key eq $fwdfwsettings{'key'}) {
360 if (exists $downhash{$next}){
362 foreach my $y (0 .. $#{$downhash{$next}}) {
363 $tmp{0}[$y] = $downhash{$next}[$y];
365 #copy active rule to next
366 foreach my $i (0 .. $#{$downhash{$next}}) {
367 $downhash{$next}[$i] = $downhash{$key}[$i];
369 #copy saved rule to actual position
370 foreach my $x (0 .. $#{$tmp{0}}) {
371 $downhash{$key}[$x] = $tmp{0}[$x];
376 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
381 my ($base1,$val1,$base2,$val2) = @_;
383 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
384 &dec_counter
($confignet,\
%customnetwork,$val1);
385 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
386 &dec_counter
($confighost,\
%customhost,$val1);
387 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
388 &dec_counter
($configgrp,\
%customgrp,$val1);
389 }elsif($base1 eq 'cust_srv'){
390 &dec_counter
($configsrv,\
%customservice,$val1);
391 }elsif($base1 eq 'cust_srvgrp'){
392 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
395 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
396 &inc_counter
($confignet,\
%customnetwork,$val2);
397 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
398 &inc_counter
($confighost,\
%customhost,$val2);
399 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
400 &inc_counter
($configgrp,\
%customgrp,$val2);
401 }elsif($base2 eq 'cust_srv'){
402 &inc_counter
($configsrv,\
%customservice,$val2);
403 }elsif($base2 eq 'cust_srvgrp'){
404 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
414 &General
::readhasharray
($config, \
%hash);
415 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
416 if($hash{$key}[0] eq $val){
417 $pos=$#{$hash{$key}};
418 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
421 &General
::writehasharray
($config, \
%hash);
429 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
430 &General
::readhasharray
($config, \
%hash);
431 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
432 if($hash{$key}[0] eq $val){
433 $pos=$#{$hash{$key}};
434 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
437 &General
::writehasharray
($config, \
%hash);
441 if ($fwdfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
442 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
443 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
446 if ($fwdfwsettings{'POLICY'} ne 'MODE0' && $fwdfwsettings{'POLICY'} ne '') {
450 #print"<table width='100' border='1'><tr>";
453 #print"<td bgcolor='$color{$i}'>$_</td>";
455 #print"</tr></table>";
456 &Header
::openbox
('100%', 'center', 'Policy');
458 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
460 <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>
461 <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>
462 <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>
463 <tr><td colspan='3'><hr /></td></tr>
464 <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>
465 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
466 <td width='45%' align='left'>
468 if ($fwdfwsettings{'POLICY'} ne 'MODE0'&& $fwdfwsettings{'POLICY'} ne '' ) {
469 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
471 print "</table></form>";
477 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
479 print "<form method='post'>";
480 print "<table border='0'>";
481 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
482 if (-f
"${General::swroot}/forward/reread"){
483 print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'></td>";
485 print"</tr></table></form><hr>";
493 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
494 foreach my $key (sort keys %delhash){
496 if ($key eq $fwdfwsettings{'key'}){
497 #check hosts/net and groups
498 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
499 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
500 #check services and groups
501 if ($delhash{$key}[11] eq 'ON'){
502 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
505 if ($key ge $fwdfwsettings{'key'}) {
507 if (exists $delhash{$next}) {
508 foreach my $i (0 .. $#{$delhash{$next}}) {
509 $delhash{$key}[$i] = $delhash{$next}[$i];
514 # Remove the very last entry.
515 my $last_key = (sort keys %delhash)[-1];
516 delete $delhash{$last_key};
518 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
521 if($fwdfwsettings{'nobase'} ne 'on'){
528 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
529 foreach my $key (sort keys %configfwdfw){
531 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
534 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
541 #check ip-address if manual
542 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
543 #check if ip with subnet
544 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
545 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
546 $subnet = &General
::iporsubtocidr
($subnet);
549 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
550 $ip=$fwdfwsettings{'src_addr'};
553 #check and form valid IP
554 $ip=&General
::ip2dec
($ip);
555 $ip=&General
::dec2ip
($ip);
556 #check if net or broadcast
557 my @tmp= split (/\./,$ip);
558 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
560 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
562 $fwdfwsettings{'src_addr'}="$ip/$subnet";
564 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
565 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
567 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
568 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
569 return $errormessage;
573 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
575 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
576 $fwdfwsettings{'SRC_PORT'}='';
577 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
578 foreach my $key (keys %icmptypes){
579 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
580 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
583 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
584 $fwdfwsettings{'SRC_PORT'}='';
585 $fwdfwsettings{'ICMP_TYPES'}='';
586 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
587 $fwdfwsettings{'SRC_PORT'}='';
588 $fwdfwsettings{'ICMP_TYPES'}='';
589 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
590 $fwdfwsettings{'ICMP_TYPES'}='';
592 $fwdfwsettings{'ICMP_TYPES'}='';
593 $fwdfwsettings{'SRC_PORT'}='';
594 $fwdfwsettings{'PROT'}='';
597 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP' && $fwdfwsettings{'SRC_PORT'} ne ''){
598 #change dashes with :
599 $fwdfwsettings{'SRC_PORT'}=~ tr/-/:/;
601 if ($fwdfwsettings{'SRC_PORT'} eq "*") {
602 $fwdfwsettings{'SRC_PORT'} = "1:65535";
604 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\D)\:(\d+)$/) {
605 $fwdfwsettings{'SRC_PORT'} = "1:$2";
607 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\d+)\:(\D)$/) {
608 $fwdfwsettings{'SRC_PORT'} = "$1:65535";
611 $errormessage.=&General
::validportrange
($fwdfwsettings{'SRC_PORT'},'src');
613 return $errormessage;
619 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
620 #check if ip with subnet
621 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
622 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
623 $subnet = &General
::iporsubtocidr
($subnet);
626 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
627 $ip=$fwdfwsettings{'tgt_addr'};
630 #check and form valid IP
631 $ip=&General
::ip2dec
($ip);
632 $ip=&General
::dec2ip
($ip);
634 #check if net or broadcast
635 my @tmp= split (/\./,$ip);
636 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
638 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
640 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
642 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
643 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
646 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
647 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
648 return $errormessage;
652 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
655 if ($fwdfwsettings{'USESRV'} eq 'ON'){
656 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
657 $fwdfwsettings{'TGT_PROT'}='';
658 $fwdfwsettings{'ICMP_TGT'}='';
660 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
661 $fwdfwsettings{'TGT_PROT'}='';
662 $fwdfwsettings{'ICMP_TGT'}='';
663 #check target service
664 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
665 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
668 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
669 if ($fwdfwsettings{'TGT_PROT'} ne 'ICMP' && $fwdfwsettings{'TGT_PROT'} ne 'GRE'){
670 if ($fwdfwsettings{'TGT_PORT'} ne ''){
671 #change dashes with :
672 $fwdfwsettings{'TGT_PORT'}=~ tr/-/:/;
673 if ($fwdfwsettings{'TGT_PORT'} eq "*") {
674 $fwdfwsettings{'TGT_PORT'} = "1:65535";
676 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\D)\:(\d+)$/) {
677 $fwdfwsettings{'TGT_PORT'} = "1:$2";
679 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\d+)\:(\D)$/) {
680 $fwdfwsettings{'TGT_PORT'} = "$1:65535";
682 $errormessage .= &General
::validportrange
($fwdfwsettings{'TGT_PORT'}, 'destination');
684 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
685 $fwdfwsettings{'TGT_PORT'} = '';
686 $fwdfwsettings{'ICMP_TGT'} = '';
687 }elsif($fwdfwsettings{'TGT_PORT'} eq 'ESP'){
688 $fwdfwsettings{'TGT_PORT'}='';
689 $fwdfwsettings{'ICMP_TGT'}='';
690 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
691 $fwdfwsettings{'TGT_PORT'} = '';
692 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
693 foreach my $key (keys %icmptypes){
695 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
696 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
704 if ($fwdfwsettings{'USESRV'} ne 'ON'){
705 $fwdfwsettings{'grp3'}='';
706 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
707 $fwdfwsettings{'TGT_PROT'}='';
708 $fwdfwsettings{'ICMP_TGT'}='';
711 if($fwdfwsettings{'TIME'} eq 'ON'){
712 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 ''){
713 $errormessage=$Lang::tr
{'fwdfw err time'};
716 return $errormessage;
721 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
722 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
724 #check if source and target identical
725 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}}){
726 $errormessage.=$Lang::tr
{'fwdfw err same'};
727 return $errormessage;
730 #get source and targetip address if possible
731 my ($sip,$scidr,$tip,$tcidr);
732 ($sip,$scidr)=&get_ip
("src","grp1");
733 ($tip,$tcidr)=&get_ip
("tgt","grp2");
735 #check same iprange in source and target
736 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
737 my $networkip1=&General
::getnetworkip
($sip,$scidr);
738 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
739 if ($scidr gt $tcidr){
740 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr)) ){
741 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
743 }elsif($scidr eq $tcidr && $scidr eq '32'){
744 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
745 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
746 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
747 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
748 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
751 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
752 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
757 #check source and destination protocol if manual
758 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
759 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
760 $errormessage.=$Lang::tr
{'fwdfw err prot'};
762 #check source and destination protocol if source manual and dest servicegrp
763 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
764 &General
::readhasharray
("$configsrv", \
%customservice);
765 foreach my $key (sort keys %customservice){
766 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
767 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
768 $errormessage.=$Lang::tr
{'fwdfw err prot'};
782 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
783 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
784 if ($fwdfwsettings{$grp} eq $val.'_addr'){
785 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
786 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
787 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
788 $a=$netsettings{'GREEN_NETADDRESS'};
789 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
790 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
791 $a=$netsettings{'ORANGE_NETADDRESS'};
792 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
793 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
794 $a=$netsettings{'BLUE_NETADDRESS'};
795 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
796 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
797 &General
::readhash
("$configovpn",\
%ovpnsettings);
798 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
799 $b=&General
::iporsubtocidr
($b);
801 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
802 &General
::readhasharray
("$confignet", \
%customnetwork);
803 foreach my $key (keys %customnetwork){
804 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
805 $a=$customnetwork{$key}[1];
806 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
809 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
810 &General
::readhasharray
("$confighost", \
%customhost);
811 foreach my $key (keys %customhost){
812 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
813 if ($customhost{$key}[1] eq 'ip'){
814 ($a,$b)=split (/\//,$customhost{$key}[2]);
815 $b=&General
::iporsubtocidr
($b);
818 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
830 &General
::setup_default_networks
(\
%defaultNetworks);
831 #read all configfiles
832 &General
::readhasharray
("$configccdnet", \
%ccdnet);
833 &General
::readhasharray
("$confignet", \
%customnetwork);
834 &General
::readhasharray
("$configccdhost", \
%ccdhost);
835 &General
::readhasharray
("$confighost", \
%customhost);
836 &General
::readhasharray
("$configccdhost", \
%ccdhost);
837 &General
::readhasharray
("$configgrp", \
%customgrp);
838 &General
::readhasharray
("$configipsec", \
%ipsecconf);
839 &General
::get_aliases
(\
%aliases);
842 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
843 my $config=$fwdfwsettings{'config'};
845 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
846 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
847 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
848 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
849 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
850 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
851 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
852 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
853 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
854 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
855 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
856 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
857 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
858 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
859 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
860 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
861 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
862 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
863 #check if update and get values
864 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
865 &General
::readhasharray
("$config", \
%hash);
866 foreach my $key (sort keys %hash){
867 if ($key eq $fwdfwsettings{'key'}){
868 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
869 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
870 $fwdfwsettings{'grp1'} = $hash{$key}[3];
871 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
872 $fwdfwsettings{'grp2'} = $hash{$key}[5];
873 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
874 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
875 $fwdfwsettings{'PROT'} = $hash{$key}[8];
876 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
877 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
878 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
879 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
880 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
881 $fwdfwsettings{'grp3'} = $hash{$key}[14];
882 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
883 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
884 $fwdfwsettings{'LOG'} = $hash{$key}[17];
885 $fwdfwsettings{'TIME'} = $hash{$key}[18];
886 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
887 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
888 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
889 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
890 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
891 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
892 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
893 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
894 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
895 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
896 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
897 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
898 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
899 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
900 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
901 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
902 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
903 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
904 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
905 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
906 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
907 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
908 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
909 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
910 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
911 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
912 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
915 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
916 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
917 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
918 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
919 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
920 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
921 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
923 $fwdfwsettings{'ACTIVE'}='ON';
924 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
927 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
932 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
934 foreach ("ACCEPT","DROP","REJECT")
936 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
937 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
940 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
942 print"<option selected>$_</option>";
944 print"<option>$_</option>";
947 print"</select></td></tr></table><hr>";
951 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
954 #------SOURCE-------------------------------------------------------
956 <table width='100%' border='0'>
957 <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>
958 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
959 <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;'>
961 foreach my $network (sort keys %defaultNetworks)
963 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
964 next if($defaultNetworks{$network}{'NAME'} eq "RED");
965 print "<option value='$defaultNetworks{$network}{'NAME'}'";
966 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
967 print ">$network</option>";
970 </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;'>
972 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
975 <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;'>
977 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
979 </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;'>
981 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
983 if ($ccdhost{$key}[33] ne ''){
985 print "<option value='$ccdhost{$key}[1]'";
986 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
987 print ">$ccdhost{$key}[1]</option>";
992 <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;'>
994 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
996 </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;'>
998 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
999 if($ccdhost{$key}[3] eq 'net'){
1001 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1002 print ">$ccdhost{$key}[1]</option>";
1008 <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;'>
1010 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1011 if($helper ne $customgrp{$key}[0]){
1013 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1014 print ">$customgrp{$key}[0]</option>";
1016 $helper=$customgrp{$key}[0];
1020 <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;'>
1022 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1023 if ($ipsecconf{$key}[3] eq 'net'){
1025 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1026 print ">$ipsecconf{$key}[1]</option>";
1034 # <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;'>
1036 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1037 # if ($ipsecconf{$key}[3] eq 'host'){
1039 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1040 # print ">$ipsecconf{$key}[1]</option>";
1044 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1045 <table width='100%' border='0'>
1046 <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>
1047 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1049 foreach ("TCP","UDP","GRE","ESP","ICMP")
1051 if ($_ eq $fwdfwsettings{'PROT'})
1053 print"<option selected>$_</option>";
1055 print"<option>$_</option>";
1059 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='11' size='9' ></td></tr>
1060 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1062 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1063 print"<option>All ICMP-Types</option>";
1064 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1065 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1066 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1068 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1072 </select></td></tr></table><hr>
1074 &Header
::closebox
();
1076 #---TARGET------------------------------------------------------
1077 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1079 <table width='100%' border='0'>
1080 <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;'>
1082 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1084 foreach my $alias (sort keys %aliases)
1086 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1091 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1092 <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;'>
1094 foreach my $network (sort keys %defaultNetworks)
1096 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1097 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1098 print ">$network</option>";
1101 </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;'>
1103 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1106 <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;'>
1108 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1110 </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;'>
1112 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1114 if ($ccdhost{$key}[33] ne ''){
1115 print "<option value='$ccdhost{$key}[1]' ";
1116 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1117 print ">$ccdhost{$key}[1]</option>";
1122 <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;'>
1124 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1126 </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;'>
1128 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1129 if($ccdhost{$key}[3] eq 'net'){
1131 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1132 print ">$ccdhost{$key}[1]</option>";
1137 <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;'>
1140 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1141 if($helper ne $customgrp{$key}[0]){
1143 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1144 print">$customgrp{$key}[0]</option>";
1146 $helper=$customgrp{$key}[0];
1150 <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;'>
1152 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1153 if ($ipsecconf{$key}[3] eq 'net'){
1155 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1156 print">$ipsecconf{$key}[1]</option>";
1162 # <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;'>
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{'grp2'}} eq $ipsecconf{$key}[1]);
1168 # print">$ipsecconf{$key}[1]</option>";
1173 <b>$Lang::tr{'fwhost attention'}:</b><br>
1174 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1176 <table width='100%' border='0'>
1177 <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;' >
1179 &General
::readhasharray
("$configsrv", \
%customservice);
1180 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1182 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1183 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1187 <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;' >
1189 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1191 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1192 if ($helper ne $customservicegrp{$key}[0]){
1194 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1195 print">$customservicegrp{$key}[0]</option>";
1197 $helper=$customservicegrp{$key}[0];
1201 <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'>
1203 foreach ("TCP","UDP","GRE","ESP","ICMP")
1205 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1207 print"<option selected>$_</option>";
1209 print"<option>$_</option>";
1213 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='11' size='9' ></td></tr>
1214 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1216 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1217 print"<option>All ICMP-Types</option>";
1218 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1219 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1220 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1222 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1227 </table><hr><br><br>
1230 #---Activate/logging/remark-------------------------------------
1231 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1233 <table width='100%' border='0'>
1234 <tr><td colspan='2' >$Lang::tr{'remark'}:<input type='text' name='ruleremark' size='40' maxlength='255' value='$fwdfwsettings{'ruleremark'}'></td></tr>
1235 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1236 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1239 &Header
::closebox
();
1240 #---ADD TIMEFRAME-----------------------------------------------
1241 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1243 <table width='70%' border='0'>
1244 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1245 <tr><td colspan='7'> </td></tr>
1247 <td align='left'>$Lang::tr{'time'}:</td>
1248 <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>
1249 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1250 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1253 <td align='right'></td>
1254 <td width='30%' align='left'>
1255 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1256 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1257 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1258 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1259 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1260 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1261 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{$Lang::tr{'fwdfw wd_sun'}} />
1263 <td><select name='TIME_FROM'>
1265 for (my $i=0;$i<=23;$i++) {
1266 $i = sprintf("%02s",$i);
1267 for (my $j=0;$j<=45;$j+=15) {
1268 $j = sprintf("%02s",$j);
1269 my $time = $i.":".$j;
1270 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1275 <td><select name='TIME_TO'>
1277 for (my $i=0;$i<=23;$i++) {
1278 $i = sprintf("%02s",$i);
1279 for (my $j=0;$j<=45;$j+=15) {
1280 $j = sprintf("%02s",$j);
1281 my $time = $i.":".$j;
1282 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1289 &Header
::closebox
();
1290 #---ACTION------------------------------------------------------
1291 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1293 <table border='0' width='100%'>
1294 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1295 <input type='hidden' name='config' value='$config' >
1296 <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>
1301 <table border='0' width='100%'>
1302 <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'}'>
1303 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1304 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1305 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1306 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1307 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1308 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1309 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1310 <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>
1314 &Header
::closebox
();
1320 &General
::readhasharray
("$config", $hash);
1321 if (!$errormessage){
1322 if ($fwdfwsettings{'updatefwrule'} ne 'on' ){
1323 my $key = &General
::findhasharraykey
($hash);
1324 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1325 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1326 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1327 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1328 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1329 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1330 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1331 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1332 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1333 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1334 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1335 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1336 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1337 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1338 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1339 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1340 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1341 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1342 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1343 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1344 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1345 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1346 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1347 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1348 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1349 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1350 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1351 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1352 &General
::writehasharray
("$config", $hash);
1354 foreach my $key (sort keys %$hash){
1355 if($key eq $fwdfwsettings{'key'}){
1356 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1357 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1358 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1359 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1360 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1361 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1362 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1363 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1364 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1365 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1366 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1367 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1368 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1369 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1370 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1371 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1372 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1373 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1374 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1375 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1376 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1377 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1378 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1379 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1380 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1381 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1382 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1383 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1387 &General
::writehasharray
("$config", $hash);
1393 if ($errormessage) {
1394 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1395 print "<class name='base'>$errormessage\n";
1396 print " </class>\n";
1397 &Header
::closebox
();
1404 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1405 print "<class name='base'>$hint\n";
1406 print " </class>\n";
1407 &Header
::closebox
();
1414 &General
::setup_default_networks
(\
%defaultNetworks);
1415 foreach my $network (sort keys %defaultNetworks)
1417 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1422 # Checks a hostname against RFC1035
1425 # Each part should be at least two characters in length
1426 # but no more than 63 characters
1427 if (length ($remark) < 1 || length ($remark) > 255) {
1429 # Only valid characters are a-z, A-Z, 0-9 and -
1430 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:\/\s
]*$/) {
1432 # First character can only be a letter or a digit
1433 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1435 # Last character can only be a letter or a digit
1436 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
1442 my %hash=%{(shift)};
1444 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne 'ICMP'){
1445 print" : ($hash{$key}[8]) $hash{$key}[10]";
1446 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1447 print" : ($hash{$key}[8]) <br> $hash{$key}[9]";
1452 my %hash=%{(shift)};
1457 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1458 if($hash{$key}[14] eq 'cust_srv'){
1459 &General
::readhasharray
("$configsrv", \
%customservice);
1460 foreach my $i (sort keys %customservice){
1461 #print "HHUHU: $customservice{$i}[0] und $hash{$key}[15]<br>";
1462 if($customservice{$i}[0] eq $hash{$key}[15]){
1463 $prot = $hash{$key}[12];
1464 $service = $customservice{$i}[0];
1467 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1469 $service=$hash{$key}[15];
1470 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1471 $service=$hash{$key}[15];
1472 $prot=$hash{$key}[12];
1474 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1475 print" : ($hash{$key}[12]) <br>$hash{$key}[13]";
1478 if ($prot ne '' || $service ne ''){
1488 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1489 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1498 if ( ! -z
"$config"){
1499 &Header
::openbox
('100%', 'left',$title);
1507 &General
::readhasharray
("$config", $hash);
1508 print"<b>$title1</b><br>";
1509 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1510 print"<tr><td align='center' width='1%'><b>#</td><td width='1%'></td><td align='center' width='20%'><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' width='70%'><b>$Lang::tr{'remark'}</td><td align='center' colspan='3' width='1%'><b>$Lang::tr{'fwdfw action'}</td></tr>";
1511 foreach my $key (sort {$a <=> $b} keys %$hash){
1513 #check if vpn hosts/nets have been deleted
1514 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1515 push (@tmpsrc,$$hash{$key}[4]);
1517 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1518 push (@tmpsrc,$$hash{$key}[6]);
1520 foreach my $host (@tmpsrc){
1521 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1522 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1524 &disable_rule
($key);
1527 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1528 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1530 &disable_rule
($key);
1533 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1534 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1536 &disable_rule
($key);
1539 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1540 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1542 &disable_rule
($key);
1549 $$hash{'ACTIVE'}=$$hash{$key}[2];
1551 if($coloryellow eq 'on'){
1552 print"<tr bgcolor='$color{'color14'}' >";
1554 }elsif($coloryellow eq ''){
1556 print"<tr bgcolor='$color{'color22'}' >";
1559 print"<tr bgcolor='$color{'color20'}' >";
1563 <td align='right'>$key</td>
1565 if ($$hash{$key}[0] eq 'ACCEPT'){
1568 $rulecolor=$color{'color17'};
1569 }elsif($$hash{$key}[0] eq 'DROP'){
1572 $rulecolor=$color{'color25'};
1573 }elsif($$hash{$key}[0] eq 'REJECT'){
1576 $rulecolor=$color{'color16'};
1578 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1579 print"<td align='center'>";
1580 if ($$hash{$key}[3] eq 'std_net_src'){
1581 print &get_name
($$hash{$key}[4]);
1583 print $$hash{$key}[4];
1585 &getsrcport
(\
%$hash,$key);
1586 if ($$hash{$key}[17] eq 'ON'){
1587 $log="/images/on.gif";
1589 $log="/images/off.gif";
1593 <form method='post'>
1594 <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 ;'/>
1595 <input type='hidden' name='key' value='$key' />
1596 <input type='hidden' name='config' value='$config' />
1597 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1602 <td align='center' nowrap='nowrap'>
1604 if ($$hash{$key}[5] eq 'std_net_tgt'){
1605 print &get_name
($$hash{$key}[6]);
1607 print $$hash{$key}[6];
1609 &gettgtport
(\
%$hash,$key);
1610 ################################################################################
1611 print"</td><td width='20%'>$$hash{$key}[16]</td>";
1613 if($$hash{$key}[2] eq 'ON'){
1614 $gif="/images/on.gif"
1617 $gif="/images/off.gif"
1620 <form method='post'>
1621 <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;' />
1622 <input type='hidden' name='key' value='$key' />
1623 <input type='hidden' name='config' value='$config' />
1624 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1626 <form method='post'>
1627 <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;' />
1628 <input type='hidden' name='key' value='$key' />
1629 <input type='hidden' name='config' value='$config' />
1630 <input type='hidden' name='ACTION' value='editrule' />
1632 <form method='post'>
1633 <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;' />
1634 <input type='hidden' name='key' value='$key' />
1635 <input type='hidden' name='config' value='$config' />
1636 <input type='hidden' name='ACTION' value='copyrule' />
1638 <form method='post'>
1639 <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;' />
1640 <input type='hidden' name='key' value='$key' />
1641 <input type='hidden' name='config' value='$config' />
1642 <input type='hidden' name='ACTION' value='deleterule' />
1645 if (exists $$hash{$key-1}){
1647 <form method='post'>
1648 <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;' />
1649 <input type='hidden' name='key' value='$key' />
1650 <input type='hidden' name='config' value='$config' />
1651 <input type='hidden' name='ACTION' value='moveup' />
1657 if (exists $$hash{$key+1}){
1659 <form method='post'>
1660 <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;' />
1661 <input type='hidden' name='key' value='$key' />
1662 <input type='hidden' name='config' value='$config' />
1663 <input type='hidden' name='ACTION' value='movedown' />
1664 </td></form></td></tr>
1667 print"<td></td></tr>";
1669 #if timeframe set, print new line in table
1670 if ($$hash{$key}[18] eq 'ON'){
1672 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1673 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1674 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1675 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1676 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1677 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1678 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1679 my $weekdays=join(",",@days);
1681 print"<tr bgcolor='#FFE4B5'><td colspan='4'>$Lang::tr{'fwdfw time'} ";
1683 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1688 &Header
::closebox
();
1693 my %hash=%{(shift)};
1696 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1697 if($hash{$key}[0] eq $val){
1698 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1700 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1706 if (!-f
"${General::swroot}/forward/reread"){
1707 system("touch ${General::swroot}/forward/reread");
1712 system("/usr/local/bin/forwardfwctrl");
1713 system("rm ${General::swroot}/forward/reread");
1715 &Header
::closebigbox
();
1716 &Header
::closepage
();