]>
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=();
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'){
118 $fwdfwsettings{'updatefwrule'}='';
119 $fwdfwsettings{'config'}=$configfwdfw;
120 $fwdfwsettings{'nobase'}='on';
124 #check if we change an external access rule to an forward
125 if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire'){
126 $fwdfwsettings{'updatefwrule'}='';
127 $fwdfwsettings{'config'}=$configinput;
128 $fwdfwsettings{'nobase'}='on';
133 if($fwdfwsettings{'grp2'} eq 'ipfire'){
134 $fwdfwsettings{'chain'} = 'INPUTFW';
135 #check if we have an identical rule already
136 foreach my $key (sort keys %configinputfw){
137 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'}"
138 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]"){
139 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
143 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
144 if ($fwdfwsettings{'nobase'} ne 'on'){
145 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
148 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
149 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
150 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
151 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
152 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
153 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
156 if ($fwdfwsettings{'nobase'} eq 'on'){
157 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
161 &saverule
(\
%configinputfw,$configinput);
163 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
164 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
165 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
166 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
167 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
168 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
169 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
170 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
171 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
172 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
173 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
174 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
175 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
176 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
177 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
178 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
180 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
181 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
182 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
183 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
188 $fwdfwsettings{'chain'} = 'FORWARDFW';
189 #check if we have an identical rule already
190 foreach my $key (sort keys %configfwdfw){
192 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'}"
193 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]"){
194 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
198 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
200 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
202 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
203 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
204 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
205 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
206 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
207 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
210 if ($fwdfwsettings{'nobase'} eq 'on'){
211 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
215 &saverule
(\
%configfwdfw,$configfwdfw);
217 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
218 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
219 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
220 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
221 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
222 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
223 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
224 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
225 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
226 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
227 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
228 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
229 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
230 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
231 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
232 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
234 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
235 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
236 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
237 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
250 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
252 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
253 foreach my $key (sort keys %configfwdfw){
254 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
255 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
256 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
258 &General
::readhasharray
("$configinput", \
%configinputfw);
259 foreach my $key (sort keys %configinputfw){
260 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
261 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
262 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
264 $fwdfwsettings{'POLICY'}='MODE0';
265 system("rm ${General::swroot}/forward/config");
266 system("rm ${General::swroot}/forward/input");
269 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
270 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
271 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
276 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
280 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
283 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
284 foreach my $key (sort keys %togglehash){
285 if ($key eq $fwdfwsettings{'key'}){
286 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
289 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
293 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
296 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
297 foreach my $key (sort keys %togglehash){
298 if ($key eq $fwdfwsettings{'key'}){
299 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
302 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
306 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
311 if ($fwdfwsettings{'ACTION'} eq 'editrule')
313 $fwdfwsettings{'updatefwrule'}='on';
316 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
320 if ($fwdfwsettings{'ACTION'} eq 'moveup')
325 if ($fwdfwsettings{'ACTION'} eq 'movedown')
330 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
332 $fwdfwsettings{'copyfwrule'}='on';
333 #$fwdfwsettings{'updatefwrule'}='on';
336 if ($fwdfwsettings{'ACTION'} eq '')
345 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
346 foreach my $key (sort keys %uphash){
347 if ($key eq $fwdfwsettings{'key'}) {
349 if (exists $uphash{$last}){
351 foreach my $y (0 .. $#{$uphash{$last}}) {
352 $tmp{0}[$y] = $uphash{$last}[$y];
354 #copy active rule to last
355 foreach my $i (0 .. $#{$uphash{$last}}) {
356 $uphash{$last}[$i] = $uphash{$key}[$i];
358 #copy saved rule to actual position
359 foreach my $x (0 .. $#{$tmp{0}}) {
360 $uphash{$key}[$x] = $tmp{0}[$x];
365 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
372 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
373 foreach my $key (sort keys %downhash){
374 if ($key eq $fwdfwsettings{'key'}) {
376 if (exists $downhash{$next}){
378 foreach my $y (0 .. $#{$downhash{$next}}) {
379 $tmp{0}[$y] = $downhash{$next}[$y];
381 #copy active rule to next
382 foreach my $i (0 .. $#{$downhash{$next}}) {
383 $downhash{$next}[$i] = $downhash{$key}[$i];
385 #copy saved rule to actual position
386 foreach my $x (0 .. $#{$tmp{0}}) {
387 $downhash{$key}[$x] = $tmp{0}[$x];
392 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
397 my ($base1,$val1,$base2,$val2) = @_;
399 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
400 &dec_counter
($confignet,\
%customnetwork,$val1);
401 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
402 &dec_counter
($confighost,\
%customhost,$val1);
403 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
404 &dec_counter
($configgrp,\
%customgrp,$val1);
405 }elsif($base1 eq 'cust_srv'){
406 &dec_counter
($configsrv,\
%customservice,$val1);
407 }elsif($base1 eq 'cust_srvgrp'){
408 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
411 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
412 &inc_counter
($confignet,\
%customnetwork,$val2);
413 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
414 &inc_counter
($confighost,\
%customhost,$val2);
415 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
416 &inc_counter
($configgrp,\
%customgrp,$val2);
417 }elsif($base2 eq 'cust_srv'){
418 &inc_counter
($configsrv,\
%customservice,$val2);
419 }elsif($base2 eq 'cust_srvgrp'){
420 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
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;
438 &General
::writehasharray
($config, \
%hash);
446 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
447 &General
::readhasharray
($config, \
%hash);
448 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
449 if($hash{$key}[0] eq $val){
450 $pos=$#{$hash{$key}};
451 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
455 &General
::writehasharray
($config, \
%hash);
460 if ($fwdfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
461 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
462 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
465 if ($fwdfwsettings{'POLICY'} ne 'MODE0' && $fwdfwsettings{'POLICY'} ne '') {
469 #print"<table width='100' border='1'><tr>";
472 #print"<td bgcolor='$color{$i}'>$_</td>";
474 #print"</tr></table>";
475 &Header
::openbox
('100%', 'center', 'Policy');
477 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
479 <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>
480 <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>
481 <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>
482 <tr><td colspan='3'><hr /></td></tr>
483 <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>
484 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
485 <td width='45%' align='left'>
487 if ($fwdfwsettings{'POLICY'} ne 'MODE0'&& $fwdfwsettings{'POLICY'} ne '' ) {
488 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
490 print "</table></form>";
496 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
498 print "<form method='post'>";
499 print "<table border='0'>";
500 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
501 if (-f
"${General::swroot}/forward/reread"){
502 print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'></td>";
504 print"</tr></table></form><hr>";
513 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
514 foreach my $key (sort keys %delhash){
515 if ($key eq $fwdfwsettings{'key'}){
516 #check hosts/net and groups
517 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
518 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
519 #check services and groups
520 if ($delhash{$key}[11] eq 'ON'){
521 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
525 if ($key ge $fwdfwsettings{'key'}) {
527 if (exists $delhash{$next}) {
528 foreach my $i (0 .. $#{$configfwdfw{$next}}) {
529 $delhash{$key}[$i] = $delhash{$next}[$i];
534 # Remove the very last entry.
535 my $last_key = (sort keys %delhash)[-1];
536 delete $delhash{$last_key};
538 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
540 if($fwdfwsettings{'nobase'} ne 'on'){
547 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
548 foreach my $key (sort keys %configfwdfw){
550 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
553 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
561 #check ip-address if manual
562 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
563 #check if ip with subnet
564 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
565 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
566 $subnet = &General
::iporsubtocidr
($subnet);
569 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
570 $ip=$fwdfwsettings{'src_addr'};
573 #check and form valid IP
574 $ip=&General
::ip2dec
($ip);
575 $ip=&General
::dec2ip
($ip);
576 #check if net or broadcast
577 my @tmp= split (/\./,$ip);
578 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
580 $errormessage=$Lang::tr
{'fwhost err hostip'};
582 $fwdfwsettings{'src_addr'}="$ip/$subnet";
584 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
585 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
587 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
588 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
589 return $errormessage;
593 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
595 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
596 $fwdfwsettings{'SRC_PORT'}='';
597 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
598 foreach my $key (keys %icmptypes){
599 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
600 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
603 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
604 $fwdfwsettings{'ICMP_TYPES'}='';
606 $fwdfwsettings{'ICMP_TYPES'}='';
607 $fwdfwsettings{'SRC_PORT'}='';
608 $fwdfwsettings{'PROT'}='';
611 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP' && $fwdfwsettings{'SRC_PORT'} ne ''){
612 #change dashes with :
613 $fwdfwsettings{'SRC_PORT'}=~ tr/-/:/;
615 if ($fwdfwsettings{'SRC_PORT'} eq "*") {
616 $fwdfwsettings{'SRC_PORT'} = "1:65535";
618 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\D)\:(\d+)$/) {
619 $fwdfwsettings{'SRC_PORT'} = "1:$2";
621 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\d+)\:(\D)$/) {
622 $fwdfwsettings{'SRC_PORT'} = "$1:65535";
625 $errormessage.=&General
::validportrange
($fwdfwsettings{'SRC_PORT'},'src');
627 return $errormessage;
634 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
635 #check if ip with subnet
636 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
637 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
638 $subnet = &General
::iporsubtocidr
($subnet);
641 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
642 $ip=$fwdfwsettings{'tgt_addr'};
645 #check and form valid IP
646 $ip=&General
::ip2dec
($ip);
647 $ip=&General
::dec2ip
($ip);
649 #check if net or broadcast
650 my @tmp= split (/\./,$ip);
651 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
653 $errormessage=$Lang::tr
{'fwhost err hostip'};
655 $fwdfwsettings{'tgt_addr'}=$ip."/".$subnet;
657 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
658 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
661 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
662 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
663 return $errormessage;
667 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
670 if ($fwdfwsettings{'USESRV'} eq 'ON'){
671 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
672 $fwdfwsettings{'TGT_PROT'}='';
673 $fwdfwsettings{'ICMP_TGT'}='';
675 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
676 $fwdfwsettings{'TGT_PROT'}='';
677 $fwdfwsettings{'ICMP_TGT'}='';
678 #check target service
679 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
680 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
683 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
684 if ($fwdfwsettings{'TGT_PROT'} ne 'ICMP'){
685 if ($fwdfwsettings{'TGT_PORT'} ne ''){
686 #change dashes with :
687 $fwdfwsettings{'TGT_PORT'}=~ tr/-/:/;
688 if ($fwdfwsettings{'TGT_PORT'} eq "*") {
689 $fwdfwsettings{'TGT_PORT'} = "1:65535";
691 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\D)\:(\d+)$/) {
692 $fwdfwsettings{'TGT_PORT'} = "1:$2";
694 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\d+)\:(\D)$/) {
695 $fwdfwsettings{'TGT_PORT'} = "$1:65535";
697 $errormessage .= &General
::validportrange
($fwdfwsettings{'TGT_PORT'}, 'destination');
699 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
700 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
701 foreach my $key (keys %icmptypes){
703 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
705 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
713 if ($fwdfwsettings{'USESRV'} ne 'ON'){
714 $fwdfwsettings{'grp3'}='';
715 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
716 $fwdfwsettings{'TGT_PROT'}='';
717 $fwdfwsettings{'ICMP_TGT'}='';
722 if($fwdfwsettings{'TIME'} eq 'ON'){
723 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 ''){
724 $errormessage=$Lang::tr
{'fwdfw err time'};
730 return $errormessage;
735 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
736 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
738 #check if source and target identical
739 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}}){
740 $errormessage.=$Lang::tr
{'fwdfw err same'};
741 return $errormessage;
744 #get source and targetip address if possible
745 my ($sip,$scidr,$tip,$tcidr);
746 ($sip,$scidr)=&get_ip
("src","grp1");
747 ($tip,$tcidr)=&get_ip
("tgt","grp2");
751 #check same iprange in source and target
752 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
754 my $networkip1=&General
::getnetworkip
($sip,$scidr);
755 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
756 if ($scidr gt $tcidr){
757 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr)) ){
758 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
760 }elsif($scidr eq $tcidr && $scidr eq '32'){
761 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(".",$networkip1);
762 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(".",$networkip2);
763 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
764 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
765 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target:$networkip2/$tcidr<br>";
769 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
770 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
775 #check source and destination protocol if manual
776 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
777 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
778 $errormessage.=$Lang::tr
{'fwdfw err prot'};
780 #check source and destination protocol if source manual and dest servicegrp
781 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
782 &General
::readhasharray
("$configsrv", \
%customservice);
783 foreach my $key (sort keys %customservice){
784 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
785 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
786 $errormessage.=$Lang::tr
{'fwdfw err prot'};
801 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
802 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
803 if ($fwdfwsettings{$grp} eq $val.'_addr'){
804 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
805 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
806 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
807 $a=$netsettings{'GREEN_NETADDRESS'};
808 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
809 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
810 $a=$netsettings{'ORANGE_NETADDRESS'};
811 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
812 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
813 $a=$netsettings{'BLUE_NETADDRESS'};
814 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
815 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
816 &General
::readhash
("$configovpn",\
%ovpnsettings);
817 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
818 $b=&General
::iporsubtocidr
($b);
820 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
821 &General
::readhasharray
("$confignet", \
%customnetwork);
822 foreach my $key (keys %customnetwork){
823 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
824 $a=$customnetwork{$key}[1];
825 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
828 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
829 &General
::readhasharray
("$confighost", \
%customhost);
830 foreach my $key (keys %customhost){
831 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
832 if ($customhost{$key}[1] eq 'ip'){
833 ($a,$b)=split (/\//,$customhost{$key}[2]);
834 $b=&General
::iporsubtocidr
($b);
837 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
850 &General
::setup_default_networks
(\
%defaultNetworks);
851 #read all configfiles
852 &General
::readhasharray
("$configccdnet", \
%ccdnet);
853 &General
::readhasharray
("$confignet", \
%customnetwork);
854 &General
::readhasharray
("$configccdhost", \
%ccdhost);
855 &General
::readhasharray
("$confighost", \
%customhost);
856 &General
::readhasharray
("$configccdhost", \
%ccdhost);
857 &General
::readhasharray
("$configgrp", \
%customgrp);
858 &General
::readhasharray
("$configipsec", \
%ipsecconf);
859 &General
::get_aliases
(\
%aliases);
864 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
865 my $config=$fwdfwsettings{'config'};
868 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
869 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
870 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
871 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
872 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
873 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
874 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
875 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
876 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
877 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
878 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
879 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
880 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
881 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
882 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
883 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
884 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
885 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
887 #check if update and get values
888 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
889 &General
::readhasharray
("$config", \
%hash);
890 foreach my $key (sort keys %hash){
891 if ($key eq $fwdfwsettings{'key'}){
892 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
893 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
894 $fwdfwsettings{'grp1'} = $hash{$key}[3];
895 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
896 $fwdfwsettings{'grp2'} = $hash{$key}[5];
897 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
898 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
899 $fwdfwsettings{'PROT'} = $hash{$key}[8];
900 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
901 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
902 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
903 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
904 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
905 $fwdfwsettings{'grp3'} = $hash{$key}[14];
906 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
907 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
908 $fwdfwsettings{'LOG'} = $hash{$key}[17];
909 $fwdfwsettings{'TIME'} = $hash{$key}[18];
910 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
911 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
912 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
913 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
914 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
915 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
916 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
917 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
918 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
920 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
921 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
922 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
923 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
924 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
925 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
926 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
927 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
928 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
929 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
930 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
931 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
932 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
933 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
934 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
935 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
936 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
937 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
940 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
941 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
942 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
943 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
944 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
945 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
946 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
948 $fwdfwsettings{'ACTIVE'}='ON';
949 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
952 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
957 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
959 foreach ("ACCEPT","DROP","REJECT")
961 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
962 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
965 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
967 print"<option selected>$_</option>";
969 print"<option>$_</option>";
972 print"</select></td></tr></table><hr>";
976 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
979 #------SOURCE-------------------------------------------------------
981 <table width='100%' border='0'>
982 <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>
983 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
984 <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;'>
987 foreach my $network (sort keys %defaultNetworks)
989 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
990 print "<option value='$defaultNetworks{$network}{'NAME'}'";
991 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
992 print ">$network</option>";
995 </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;'>
997 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1000 <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;'>
1002 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1004 </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;'>
1006 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1008 if ($ccdhost{$key}[33] ne ''){
1010 print "<option value='$ccdhost{$key}[1]'";
1011 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1012 print ">$ccdhost{$key}[1]</option>";
1017 <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;'>
1019 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1021 </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;'>
1023 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1024 if($ccdhost{$key}[3] eq 'net'){
1026 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1027 print ">$ccdhost{$key}[1]</option>";
1033 <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;'>
1035 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1036 if($helper ne $customgrp{$key}[0]){
1038 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1039 print ">$customgrp{$key}[0]</option>";
1043 $helper=$customgrp{$key}[0];
1047 <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;'>
1049 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1050 if ($ipsecconf{$key}[3] eq 'net'){
1052 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1053 print ">$ipsecconf{$key}[1]</option>";
1061 # <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;'>
1063 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1064 # if ($ipsecconf{$key}[3] eq 'host'){
1066 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1067 # print ">$ipsecconf{$key}[1]</option>";
1072 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1075 <table width='100%' border='0'>
1076 <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>
1077 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1079 foreach ("TCP","UDP","GRE","ICMP")
1081 if ($_ eq $fwdfwsettings{'PROT'})
1083 print"<option selected>$_</option>";
1085 print"<option>$_</option>";
1089 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='11' size='9' ></td></tr>
1090 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1092 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1093 print"<option>All ICMP-Types</option>";
1094 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1095 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1096 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1098 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1102 </select></td></tr></table><hr>
1104 &Header
::closebox
();
1106 #---TARGET------------------------------------------------------
1107 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1109 <table width='100%' border='0'>
1110 <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;'>
1112 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1114 foreach my $alias (sort keys %aliases)
1116 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1121 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1122 <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;'>
1126 foreach my $network (sort keys %defaultNetworks)
1128 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1129 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1130 print ">$network</option>";
1133 </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;'>
1135 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1139 <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;'>
1141 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1143 </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;'>
1145 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1147 if ($ccdhost{$key}[33] ne ''){
1148 print "<option value='$ccdhost{$key}[1]' ";
1149 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1150 print ">$ccdhost{$key}[1]</option>";
1155 <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;'>
1157 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1159 </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;'>
1161 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1162 if($ccdhost{$key}[3] eq 'net'){
1164 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1165 print ">$ccdhost{$key}[1]</option>";
1171 <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;'>
1174 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1175 if($helper ne $customgrp{$key}[0]){
1177 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1178 print">$customgrp{$key}[0]</option>";
1180 $helper=$customgrp{$key}[0];
1184 <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;'>
1186 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1187 if ($ipsecconf{$key}[3] eq 'net'){
1189 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1190 print">$ipsecconf{$key}[1]</option>";
1197 # <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;'>
1199 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1200 # if ($ipsecconf{$key}[3] eq 'host'){
1202 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1203 # print">$ipsecconf{$key}[1]</option>";
1208 <b>$Lang::tr{'fwhost attention'}:</b><br>
1209 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1211 <table width='100%' border='0'>
1212 <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;' >
1214 &General
::readhasharray
("$configsrv", \
%customservice);
1215 foreach my $key (sort keys %customservice){
1217 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1218 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1222 <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;' >
1224 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1226 foreach my $key (sort keys %customservicegrp){
1227 if ($helper ne $customservicegrp{$key}[0]){
1229 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1230 print">$customservicegrp{$key}[0]</option>";
1232 $helper=$customservicegrp{$key}[0];
1236 <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'>
1238 foreach ("TCP","UDP","GRE","ICMP")
1240 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1242 print"<option selected>$_</option>";
1244 print"<option>$_</option>";
1248 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='11' size='9' ></td></tr>
1249 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1251 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1252 print"<option>All ICMP-Types</option>";
1253 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1254 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1255 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1257 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1262 </table><hr><br><br>
1265 #---Activate/logging/remark-------------------------------------
1266 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1268 <table width='100%' border='0'>
1269 <tr><td colspan='2' >$Lang::tr{'remark'}:<input type='text' name='ruleremark' size='40' value='$fwdfwsettings{'ruleremark'}'></td></tr>
1270 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1271 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1274 &Header
::closebox
();
1275 #---ADD TIMEFRAME-----------------------------------------------
1276 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1278 <table width='70%' border='0'>
1279 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1280 <tr><td colspan='7'> </td></tr>
1282 <td align='left'>$Lang::tr{'time'}:</td>
1283 <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>
1285 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1286 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1289 <td align='right'></td>
1290 <td width='30%' align='left'>
1291 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1292 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1293 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1294 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1295 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1296 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1297 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{$Lang::tr{'fwdfw wd_sun'}} />
1300 <td><select name='TIME_FROM'>
1302 for (my $i=0;$i<=23;$i++) {
1303 $i = sprintf("%02s",$i);
1304 for (my $j=0;$j<=45;$j+=15) {
1305 $j = sprintf("%02s",$j);
1306 my $time = $i.":".$j;
1307 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1312 <td><select name='TIME_TO'>
1314 for (my $i=0;$i<=23;$i++) {
1315 $i = sprintf("%02s",$i);
1316 for (my $j=0;$j<=45;$j+=15) {
1317 $j = sprintf("%02s",$j);
1318 my $time = $i.":".$j;
1319 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1326 &Header
::closebox
();
1327 #---ACTION------------------------------------------------------
1328 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1330 <table border='0' width='100%'>
1331 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1332 <input type='hidden' name='config' value='$config' >
1333 <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>
1338 <table border='0' width='100%'>
1339 <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'}'>
1340 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1341 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1342 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1343 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1344 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1345 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1346 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1348 <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>
1353 &Header
::closebox
();
1360 &General
::readhasharray
("$config", $hash);
1361 if (!$errormessage){
1362 if ($fwdfwsettings{'updatefwrule'} ne 'on' ){
1363 my $key = &General
::findhasharraykey
($hash);
1364 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1365 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1366 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1367 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1368 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1369 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1370 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1371 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1372 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1373 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1374 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1375 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1376 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1377 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1378 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1379 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1380 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1381 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1382 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1383 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1384 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1385 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1386 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1387 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1388 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1389 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1390 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1391 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1392 &General
::writehasharray
("$config", $hash);
1394 foreach my $key (sort keys %$hash){
1395 if($key eq $fwdfwsettings{'key'}){
1396 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1397 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1398 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1399 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1400 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1401 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1402 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1403 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1404 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1405 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1406 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1407 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1408 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1409 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1410 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1411 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1412 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1413 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1414 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1415 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1416 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1417 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1418 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1419 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1420 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1421 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1422 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1423 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1427 &General
::writehasharray
("$config", $hash);
1433 if ($errormessage) {
1434 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1435 print "<class name='base'>$errormessage\n";
1436 print " </class>\n";
1437 &Header
::closebox
();
1444 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1445 print "<class name='base'>$hint\n";
1446 print " </class>\n";
1447 &Header
::closebox
();
1454 &General
::setup_default_networks
(\
%defaultNetworks);
1455 foreach my $network (sort keys %defaultNetworks)
1457 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1462 # Checks a hostname against RFC1035
1465 # Each part should be at least two characters in length
1466 # but no more than 63 characters
1467 if (length ($remark) < 1 || length ($remark) > 63) {
1469 # Only valid characters are a-z, A-Z, 0-9 and -
1470 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-\s]*$/) {
1472 # First character can only be a letter or a digit
1473 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1475 # Last character can only be a letter or a digit
1476 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9]*$/) {
1482 my %hash=%{(shift)};
1484 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne 'ICMP'){
1485 print" : ($hash{$key}[8]) $hash{$key}[10]";
1486 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1487 print" : ($hash{$key}[8]) <br> $hash{$key}[9]";
1492 my %hash=%{(shift)};
1497 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1498 if($hash{$key}[14] eq 'cust_srv'){
1499 &General
::readhasharray
("$configsrv", \
%customservice);
1500 foreach my $i (sort keys %customservice){
1501 #print "HHUHU: $customservice{$i}[0] und $hash{$key}[15]<br>";
1502 if($customservice{$i}[0] eq $hash{$key}[15]){
1503 $prot = $hash{$key}[12];
1504 $service = $customservice{$i}[0];
1507 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1509 $service=$hash{$key}[15];
1510 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1511 $service=$hash{$key}[15];
1512 $prot=$hash{$key}[12];
1514 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1515 print" : ($hash{$key}[12]) <br>$hash{$key}[13]";
1518 if ($prot ne '' || $service ne ''){
1528 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1529 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1538 if ( ! -z
"$config"){
1539 &Header
::openbox
('100%', 'left',$title);
1547 &General
::readhasharray
("$config", $hash);
1548 print"<b>$title1</b><br>";
1549 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1550 print"<tr><td align='center' width='1%'><b>#</td><td></td><td align='center'><b>$Lang::tr{'fwdfw source'}</td><td><b>Log</td><td align='center'><b>$Lang::tr{'fwdfw target'}</td><td align='center'><b>$Lang::tr{'remark'}</td><td align='center' colspan='3'><b>$Lang::tr{'fwdfw action'}</td></tr>";
1551 foreach my $key (sort keys %$hash){
1553 #check if vpn hosts/nets have been deleted
1554 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1555 push (@tmpsrc,$$hash{$key}[4]);
1557 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1558 push (@tmpsrc,$$hash{$key}[6]);
1561 foreach my $host (@tmpsrc){
1562 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1563 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1565 &disable_rule
($key);
1569 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1570 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1572 &disable_rule
($key);
1575 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1576 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1578 &disable_rule
($key);
1581 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1582 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1584 &disable_rule
($key);
1592 $$hash{'ACTIVE'}=$$hash{$key}[2];
1595 if($coloryellow eq 'on'){
1596 print"<tr bgcolor='$color{'color14'}' >";
1598 }elsif($coloryellow eq ''){
1600 print"<tr bgcolor='$color{'color22'}' >";
1603 print"<tr bgcolor='$color{'color20'}' >";
1608 <td align='right'>$key</td>
1610 if ($$hash{$key}[0] eq 'ACCEPT'){
1613 $rulecolor=$color{'color17'};
1614 }elsif($$hash{$key}[0] eq 'DROP'){
1617 $rulecolor=$color{'color25'};
1618 }elsif($$hash{$key}[0] eq 'REJECT'){
1621 $rulecolor=$color{'color16'};
1623 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1624 print"<td align='center'>";
1625 if ($$hash{$key}[3] eq 'std_net_src'){
1626 print &get_name
($$hash{$key}[4]);
1628 print $$hash{$key}[4];
1630 &getsrcport
(\
%$hash,$key);
1631 if ($$hash{$key}[17] eq 'ON'){
1632 $log="/images/on.gif";
1634 $log="/images/off.gif";
1639 <form method='post'>
1640 <td width='1%'><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 ;display: block;'/>
1641 <input type='hidden' name='key' value='$key' />
1642 <input type='hidden' name='config' value='$config' />
1643 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1650 if ($$hash{$key}[5] eq 'std_net_tgt'){
1651 print &get_name
($$hash{$key}[6]);
1653 print $$hash{$key}[6];
1655 &gettgtport
(\
%$hash,$key);
1656 ################################################################################
1657 print"</td><td width='20%'>$$hash{$key}[16]</td>";
1659 if($$hash{$key}[2] eq 'ON'){
1660 $gif="/images/on.gif"
1663 $gif="/images/off.gif"
1667 <form method='post'>
1668 <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;' />
1669 <input type='hidden' name='key' value='$key' />
1670 <input type='hidden' name='config' value='$config' />
1671 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1674 <form method='post'>
1675 <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;' />
1676 <input type='hidden' name='key' value='$key' />
1677 <input type='hidden' name='config' value='$config' />
1678 <input type='hidden' name='ACTION' value='editrule' />
1681 <form method='post'>
1682 <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;' />
1683 <input type='hidden' name='key' value='$key' />
1684 <input type='hidden' name='config' value='$config' />
1685 <input type='hidden' name='ACTION' value='copyrule' />
1689 <form method='post'>
1690 <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;' />
1691 <input type='hidden' name='key' value='$key' />
1692 <input type='hidden' name='config' value='$config' />
1693 <input type='hidden' name='ACTION' value='deleterule' />
1696 if (exists $$hash{$key-1}){
1698 <form method='post'>
1699 <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;' />
1700 <input type='hidden' name='key' value='$key' />
1701 <input type='hidden' name='config' value='$config' />
1702 <input type='hidden' name='ACTION' value='moveup' />
1709 if (exists $$hash{$key+1}){
1711 <form method='post'>
1712 <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;' />
1713 <input type='hidden' name='key' value='$key' />
1714 <input type='hidden' name='config' value='$config' />
1715 <input type='hidden' name='ACTION' value='movedown' />
1716 </td></form></td></tr>
1719 print"<td></td></tr>";
1721 #if timeframe set, print new line in table
1722 if ($$hash{$key}[18] eq 'ON'){
1724 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1725 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1726 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1727 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1728 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1729 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1730 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1732 my $weekdays=join(",",@days);
1735 print"<tr bgcolor='#FFE4B5'><td colspan='4'>$Lang::tr{'fwdfw time'} ";
1737 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1742 &Header
::closebox
();
1748 my %hash=%{(shift)};
1751 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash)
1753 if($hash{$key}[0] eq $val){
1754 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1756 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1762 if (!-f
"${General::swroot}/forward/reread"){
1763 system("touch ${General::swroot}/forward/reread");
1768 system("/usr/local/bin/forwardfwctrl");
1769 system("rm ${General::swroot}/forward/reread");
1771 &Header
::closebigbox
();
1772 &Header
::closepage
();