]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/fwhosts.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2011 IPFire Team <info@ipfire.org> #
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 ###############################################################################
21 # New function for forwarding firewall. To make it comfortable to create #
22 # rules, we need "spelling names" for single Hosts. If you have any questions #
23 # <amarx@ipfire.org> #
24 ###############################################################################
27 # enable only the following on debugging purpose
29 use CGI
::Carp
'fatalsToBrowser';
30 no warnings
'uninitialized';
31 require '/var/ipfire/general-functions.pl';
32 require "${General::swroot}/lang.pl";
33 require "${General::swroot}/header.pl";
35 my %fwhostsettings=();
40 my %customservicegrp=();
46 my %defaultNetworks=();
56 my $confignet = "${General::swroot}/fwhosts/customnetworks";
57 my $confighost = "${General::swroot}/fwhosts/customhosts";
58 my $configgrp = "${General::swroot}/fwhosts/customgroups";
59 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
60 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
61 my $configipsec = "${General::swroot}/vpn/config";
62 my $configsrv = "${General::swroot}/fwhosts/customservices";
63 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
64 my $fwconfigfwd = "${General::swroot}/forward/config";
65 my $fwconfiginp = "${General::swroot}/forward/input";
67 unless (-e
$confignet) { system("touch $confignet"); }
68 unless (-e
$confighost) { system("touch $confighost"); }
69 unless (-e
$configgrp) { system("touch $configgrp"); }
70 unless (-e
$configsrv) { system("touch $configsrv"); }
71 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
73 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
74 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
75 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
76 &Header
::getcgihash
(\
%fwhostsettings);
78 &Header
::showhttpheaders
();
79 &Header
::openpage
($Lang::tr
{'fwhost hosts'}, 1, '');
80 &Header
::openbigbox
('100%', 'center');
83 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
89 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
91 &General
::readhasharray
("$confignet", \
%customnetwork);
92 foreach my $key (keys %customnetwork)
94 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
96 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
97 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
98 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
99 $fwhostsettings{'count'} = $customnetwork{$key}[3];
100 delete $customnetwork{$key};
104 &General
::writehasharray
("$confignet", \
%customnetwork);
105 $fwhostsettings{'actualize'} = 'on';
106 $fwhostsettings{'ACTION'} = 'savenet';
108 if ($fwhostsettings{'ACTION'} eq 'updatehost')
111 &General
::readhasharray
("$confighost", \
%customhost);
112 foreach my $key (keys %customhost)
114 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
116 if ($customhost{$key}[1] eq 'ip'){
117 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
119 $ip = $customhost{$key}[2];
121 $fwhostsettings{'orgip'} = $ip;
122 $fwhostsettings{'count'} = $customhost{$key}[4];
123 delete $customhost{$key};
124 &General
::writehasharray
("$confighost", \
%customhost);
127 $fwhostsettings{'actualize'} = 'on';
128 if($fwhostsettings{'orgip'}){
129 $fwhostsettings{'ACTION'} = 'savehost';
131 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
134 if ($fwhostsettings{'ACTION'} eq 'updateservice')
138 $errormessage=&checkports
(\
%customservice);
140 &General
::readhasharray
("$configsrv", \
%customservice);
141 foreach my $key (keys %customservice)
143 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
145 $count=$customservice{$key}[4];
146 delete $customservice{$key};
147 &General
::writehasharray
("$configsrv", \
%customservice);
151 if ($fwhostsettings{'PROT'} ne 'ICMP'){
152 $fwhostsettings{'ICMP_TYPES'}='BLANK';
154 my $key1 = &General
::findhasharraykey
(\
%customservice);
155 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
156 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
157 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
158 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
159 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
160 $customservice{$key1}[4] = $count;
161 &General
::writehasharray
("$configsrv", \
%customservice);
162 #check if we need to update firewallrules
163 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
164 if ( ! -z
$fwconfigfwd ){
165 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
166 foreach my $key (sort keys %fwfwd){
167 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
168 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
171 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
173 if ( ! -z
$fwconfiginp ){
174 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
175 foreach my $line (sort keys %fwinp){
176 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
177 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
180 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
182 #check if we need to update groups
183 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
184 foreach my $key (sort keys %customservicegrp){
185 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
186 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
189 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
192 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
195 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
198 $fwhostsettings{'SRV_NAME'} = '';
199 $fwhostsettings{'SRV_PORT'} = '';
200 $fwhostsettings{'PROT'} = '';
202 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
203 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
204 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
205 $fwhostsettings{'updatesrv'}= 'on';
207 if($needrules eq 'on'){
213 if ($fwhostsettings{'ACTION'} eq 'savenet' )
217 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
218 #check if all fields are set
219 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
221 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
226 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
228 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
229 $fwhostsettings{'BLK_HOST'} ='readonly';
230 $fwhostsettings{'NOCHECK'} ='false';
231 $fwhostsettings{'error'} ='on';
233 #check if subnet is sigle host
234 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
236 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
238 if($fwhostsettings{'error'} ne 'on'){
239 #check if we use one of ipfire's networks (green,orange,blue)
240 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
242 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
243 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
244 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
246 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
248 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
249 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
250 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
252 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
254 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
255 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
256 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
258 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
260 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
261 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
262 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
265 #only check plausi when no error till now
267 &plausicheck
("editnet");
269 #check if network ip is part of an already used one
270 if(&checksubnet
(\
%customnetwork))
272 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
273 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
275 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
277 $fwhostsettings{'actualize'} = '';
278 my $key = &General
::findhasharraykey
(\
%customnetwork);
279 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
280 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
281 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
282 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
283 $customnetwork{$key}[3] = $fwhostsettings{'count'};
284 &General
::writehasharray
("$confignet", \
%customnetwork);
285 undef %customnetwork;
288 &General
::readhasharray
("$confignet", \
%customnetwork);
289 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
290 if ($fwhostsettings{'update'} == '0'){
291 foreach my $key (keys %customnetwork) {
292 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
293 $count=$customnetwork{$key}[3];
294 delete $customnetwork{$key};
300 #get count if actualize is 'on'
301 if($fwhostsettings{'actualize'} eq 'on'){
302 $fwhostsettings{'actualize'} = '';
303 $count=$fwhostsettings{'count'};
304 #check if we need to reload rules
305 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
308 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
309 #check if we need to update groups
310 &General
::readhasharray
("$configgrp", \
%customgrp);
311 foreach my $key (sort keys %customgrp){
312 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
313 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
317 &General
::writehasharray
("$configgrp", \
%customgrp);
318 #check if we need to update firewallrules
319 if ( ! -z
$fwconfigfwd ){
320 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
321 foreach my $line (sort keys %fwfwd){
322 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
323 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
325 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
326 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
329 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
331 if ( ! -z
$fwconfiginp ){
332 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
333 foreach my $line (sort keys %fwinp){
334 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
335 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
338 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
342 my $key = &General
::findhasharraykey
(\
%customnetwork);
343 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
344 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
345 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
346 #convert ip when leading '0' in byte
347 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
348 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
349 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
350 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
351 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
352 $customnetwork{$key}[3] = $count;
353 &General
::writehasharray
("$confignet", \
%customnetwork);
354 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
355 undef %customnetwork;
356 $fwhostsettings{'HOSTNAME'}='';
357 $fwhostsettings{'IP'}='';
358 $fwhostsettings{'SUBNET'}='';
359 #check if an edited net affected groups and need to reload rules
360 if ($needrules eq 'on'){
372 if ($fwhostsettings{'ACTION'} eq 'savehost')
376 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
377 $fwhostsettings{'SUBNET'}='32';
378 #check if all fields are set
379 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
381 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
382 $fwhostsettings{'ACTION'} = 'edithost';
384 if($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
385 $fwhostsettings{'type'} = 'mac';
386 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
387 $fwhostsettings{'type'} = 'ip';
388 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
389 $fwhostsettings{'type'} = 'mac';
390 }elsif($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
391 $fwhostsettings{'type'} = 'ip';
393 $fwhostsettings{'type'} = '';
394 $errormessage=$Lang::tr
{'fwhost err ipmac'};
396 if($fwhostsettings{'type'} eq 'mac' )
398 if ($fwhostsettings{'IP'}!~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/ )
400 $errormessage=$Lang::tr
{'fwhost err mac'};
404 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
405 $errormessage=$Lang::tr
{'fwhost err remark'};
408 if ($fwhostsettings{'type'} eq 'ip'){
410 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
411 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
413 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
414 $fwhostsettings{'error'}='on';
416 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
417 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
418 $fwhostsettings{'error'}='on';
420 #check if net or broadcast
421 my @tmp= split (/\./,$fwhostsettings{'IP'});
422 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
423 $errormessage=$Lang::tr
{'fwhost err hostip'};
426 #only check plausi when no error till now
428 &plausicheck
("edithost");
430 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
431 $fwhostsettings{'actualize'} = '';
432 my $key = &General
::findhasharraykey
(\
%customhost);
433 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
434 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
435 $customhost{$key}[1] = $fwhostsettings{'type'} ;
436 if($customhost{$key}[1] eq 'ip'){
437 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
439 $customhost{$key}[2] = $fwhostsettings{'orgip'};
441 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
442 $customhost{$key}[4] = $fwhostsettings{'count'};
443 &General
::writehasharray
("$confighost", \
%customhost);
447 #get count if host was edited
448 if($fwhostsettings{'actualize'} eq 'on'){
449 $count=$fwhostsettings{'count'};
450 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
453 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
454 #check if we need to update groups
455 &General
::readhasharray
("$configgrp", \
%customgrp);
456 foreach my $key (sort keys %customgrp){
457 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
458 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
462 &General
::writehasharray
("$configgrp", \
%customgrp);
463 #check if we need to update firewallrules
464 if ( ! -z
$fwconfigfwd ){
465 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
466 foreach my $line (sort keys %fwfwd){
467 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
468 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
470 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
471 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
474 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
476 if ( ! -z
$fwconfiginp ){
477 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
478 foreach my $line (sort keys %fwinp){
479 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
480 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
483 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
487 my $key = &General
::findhasharraykey
(\
%customhost);
488 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
489 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
490 $customhost{$key}[1] = $fwhostsettings{'type'} ;
491 if ($fwhostsettings{'type'} eq 'ip'){
492 #convert ip when leading '0' in byte
493 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
494 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
495 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
497 $customhost{$key}[2] = $fwhostsettings{'IP'};
499 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
500 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
501 $customhost{$key}[4] =$count;
502 &General
::writehasharray
("$confighost", \
%customhost);
504 $fwhostsettings{'HOSTNAME'}='';
505 $fwhostsettings{'IP'}='';
506 $fwhostsettings{'type'}='';
507 $fwhostsettings{'HOSTREMARK'}='';
508 #check if we need to update rules while host was edited
509 if($needrules eq 'on'){
520 if ($fwhostsettings{'ACTION'} eq 'savegrp')
522 my $grp=$fwhostsettings{'grp_name'};;
523 my $rem=$fwhostsettings{'remark'};
526 my $updcounter='off';
529 &General
::readhasharray
("$configgrp", \
%customgrp);
530 &General
::readhasharray
("$confignet", \
%customnetwork);
531 &General
::readhasharray
("$confighost", \
%customhost);
533 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
535 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
536 $errormessage.=$Lang::tr
{'fwhost err remark'};
538 if ($fwhostsettings{'update'} eq 'on'){
539 #check standard networks
540 if ($fwhostsettings{'grp2'} eq 'std_net'){
541 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
542 $type='Standard Network';
544 #check custom networks
545 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
546 @target=$fwhostsettings{'CUST_SRC_NET'};
548 $type='Custom Network';
549 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
550 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
551 $fwhostsettings{'grp_name'}='';
552 $fwhostsettings{'remark'}='';
554 #check custom addresses
555 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
556 @target=$fwhostsettings{'CUST_SRC_HOST'};
559 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
560 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
561 $fwhostsettings{'grp_name'}='';
562 $fwhostsettings{'remark'}='';
564 #get address from ovpn ccd static net
565 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
566 @target=$fwhostsettings{'OVPN_CCD_NET'};
567 $type='OpenVPN static network';
568 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
569 $errormessage=$Lang::tr
{'fwhost err groupempty'};
570 $fwhostsettings{'grp_name'}='';
571 $fwhostsettings{'remark'}='';
573 #get address from ovpn ccd static host
574 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
575 @target=$fwhostsettings{'OVPN_CCD_HOST'};
576 $type='OpenVPN static host';
577 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
578 $errormessage=$Lang::tr
{'fwhost err groupempty'};
580 #get address from ovpn ccd Net-2-Net
581 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
582 @target=$fwhostsettings{'OVPN_N2N'};
583 $type='OpenVPN N-2-N';
584 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
585 $errormessage=$Lang::tr
{'fwhost err groupempty'};
586 $fwhostsettings{'grp_name'}='';
587 $fwhostsettings{'remark'}='';
589 #get address from IPSEC HOST
590 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
591 @target=$fwhostsettings{'IPSEC_HOST'};
593 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
594 $errormessage=$Lang::tr
{'fwhost err groupempty'};
595 $fwhostsettings{'grp_name'}='';
596 $fwhostsettings{'remark'}='';
598 #get address from IPSEC NETWORK
599 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
600 @target=$fwhostsettings{'IPSEC_NET'};
601 $type='IpSec Network';
602 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
603 $errormessage=$Lang::tr
{'fwhost err groupempty'};
604 $fwhostsettings{'grp_name'}='';
605 $fwhostsettings{'remark'}='';
607 #check if host/net exists in grp
609 my $test="$grp,$fwhostsettings{'oldremark'},@target";
610 foreach my $key (keys %customgrp) {
611 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
612 if ($test1 eq $test){
613 $errormessage=$Lang::tr
{'fwhost err isingrp'};
614 $fwhostsettings{'update'} = 'on';
620 #on first save, we have an empty @target, so fill it with nothing
621 my $targetvalues=@target;
622 if ($targetvalues == '0'){
625 #on update, we have to delete the dummy entry
626 foreach my $key (keys %customgrp){
627 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
628 delete $customgrp{$key};
632 &General
::writehasharray
("$configgrp", \
%customgrp);
633 &General
::readhasharray
("$configgrp", \
%customgrp);
635 foreach my $key (keys %customgrp)
637 if($customgrp{$key}[0] eq $grp)
639 $count=$customgrp{$key}[4];
643 if ($count eq '' ){$count='0';}
645 #create array with new lines
646 foreach my $line (@target){
647 push (@newgrp,"$grp,$rem,$line");
650 my $key = &General
::findhasharraykey
(\
%customgrp);
651 foreach my $line (@newgrp){
652 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
653 my ($a,$b,$c,$d) = split (",",$line);
654 $customgrp{$key}[0] = $a;
655 $customgrp{$key}[1] = $b;
656 $customgrp{$key}[2] = $c;
657 $customgrp{$key}[3] = $type;
658 $customgrp{$key}[4] = $count;
660 &General
::writehasharray
("$configgrp", \
%customgrp);
661 #update counter in Host/Net
662 if($updcounter eq 'net'){
663 foreach my $key (keys %customnetwork) {
664 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
665 $customnetwork{$key}[3] = $customnetwork{$key}[3]+1;
669 &General
::writehasharray
("$confignet", \
%customnetwork);
670 }elsif($updcounter eq 'host'){
671 foreach my $key (keys %customhost) {
672 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
673 $customhost{$key}[4]=$customhost{$key}[3]+1;
676 &General
::writehasharray
("$confighost", \
%customhost);
678 $fwhostsettings{'update'}='on';
680 #check if ruleupdate is needed
688 if ($fwhostsettings{'ACTION'} eq 'saveservice')
691 &General
::readhasharray
("$configsrv", \
%customservice );
692 $errormessage=&checkports
(\
%customservice);
693 if ($fwhostsettings{'PROT'} eq 'ICMP'){
694 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
695 foreach my $key (keys %icmptypes){
696 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
697 $ICMP=$icmptypes{$key}[0];
701 if($ICMP eq ''){$ICMP='BLANK';}
703 my $key = &General
::findhasharraykey
(\
%customservice);
704 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
705 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
706 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
707 $customservice{$key}[2] = $fwhostsettings{'PROT'};
708 $customservice{$key}[3] = $ICMP;
709 $customservice{$key}[4] = 0;
710 &General
::writehasharray
("$configsrv", \
%customservice );
712 $fwhostsettings{'SRV_NAME'}='';
713 $fwhostsettings{'SRV_PORT'}='';
714 $fwhostsettings{'PROT'}='';
715 $fwhostsettings{'ICMP_TYPES'}='';
719 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
724 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
725 &General
::readhasharray
("$configsrv", \
%customservice );
726 $errormessage=&checkservicegroup
;
728 #on first save, we have to enter a dummy value
729 if ($fwhostsettings{'CUST_SRV'} eq ''){
730 $fwhostsettings{'CUST_SRV'}='none';
732 #on update, we have to delete the dummy entry
733 foreach my $key (keys %customservicegrp){
734 if ($customservicegrp{$key}[2] eq 'none'){
735 delete $customservicegrp{$key};
739 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
740 #check if remark has also changed
741 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
743 foreach my $key (keys %customservicegrp)
745 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
747 $customservicegrp{$key}[1]='';
748 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
753 foreach my $key (keys %customservicegrp)
755 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
757 $count=$customservicegrp{$key}[3];
761 if ($count eq '' ){$count='0';}
763 foreach my $key (sort keys %customservice){
764 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
765 $port=$customservice{$key}[1];
766 $prot=$customservice{$key}[2];
767 $customservice{$key}[4]++;
770 &General
::writehasharray
("$configsrv", \
%customservice );
771 my $key = &General
::findhasharraykey
(\
%customservicegrp);
772 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
773 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
774 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
775 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
776 $customservicegrp{$key}[3] = $count;
777 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
778 $fwhostsettings{'updatesrvgrp'}='on';
784 &viewtableservicegrp
;
787 if ($fwhostsettings{'ACTION'} eq 'editnet')
792 if ($fwhostsettings{'ACTION'} eq 'edithost')
797 if ($fwhostsettings{'ACTION'} eq 'editgrp')
799 $fwhostsettings{'update'}='on';
803 if ($fwhostsettings{'ACTION'} eq 'editservice')
805 $fwhostsettings{'updatesrv'}='on';
808 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
810 $fwhostsettings{'updatesrvgrp'} = 'on';
812 &viewtableservicegrp
;
815 if ($fwhostsettings{'ACTION'} eq 'resetnet')
817 $fwhostsettings{'HOSTNAME'} ="";
818 $fwhostsettings{'IP'} ="";
819 $fwhostsettings{'SUBNET'} ="";
822 if ($fwhostsettings{'ACTION'} eq 'resethost')
824 $fwhostsettings{'HOSTNAME'} ="";
825 $fwhostsettings{'IP'} ="";
826 $fwhostsettings{'type'} ="";
830 if ($fwhostsettings{'ACTION'} eq 'delnet')
832 &General
::readhasharray
("$confignet", \
%customnetwork);
833 foreach my $key (keys %customnetwork) {
834 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
835 delete $customnetwork{$key};
836 &General
::writehasharray
("$confignet", \
%customnetwork);
843 if ($fwhostsettings{'ACTION'} eq 'delhost')
845 &General
::readhasharray
("$confighost", \
%customhost);
846 foreach my $key (keys %customhost) {
847 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
848 delete $customhost{$key};
849 &General
::writehasharray
("$confighost", \
%customhost);
856 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
860 &General
::readhasharray
("$configgrp", \
%customgrp);
861 foreach my $key (keys %customgrp){
862 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
863 #decrease count from source host/net
864 if ($customgrp{$key}[3] eq 'Custom Network'){
865 &General
::readhasharray
("$confignet", \
%customnetwork);
866 foreach my $key1 (keys %customnetwork){
867 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
868 $customnetwork{$key1}[3] = $customnetwork{$key1}[3]-1;
872 &General
::writehasharray
("$confignet", \
%customnetwork);
874 if ($customgrp{$key}[3] eq 'Custom Host'){
875 &General
::readhasharray
("$confighost", \
%customhost);
876 foreach my $key1 (keys %customhost){
877 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
878 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
882 &General
::writehasharray
("$confighost", \
%customhost);
884 $grpname=$customgrp{$key}[0];
885 $grpremark=$customgrp{$key}[1];
886 delete $customgrp{$key};
889 &General
::writehasharray
("$configgrp", \
%customgrp);
890 if ($fwhostsettings{'grpcnt'} > 0){&rules
;}
891 if ($fwhostsettings{'update'} eq 'on'){
892 $fwhostsettings{'remark'}= $grpremark;
893 $fwhostsettings{'grp_name'}=$grpname;
898 if ($fwhostsettings{'ACTION'} eq 'delgrp')
900 &General
::readhasharray
("$configgrp", \
%customgrp);
901 &decrease
($fwhostsettings{'grp_name'});
902 foreach my $key (sort keys %customgrp)
904 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
906 delete $customgrp{$key};
909 &General
::writehasharray
("$configgrp", \
%customgrp);
910 $fwhostsettings{'grp_name'}='';
914 if ($fwhostsettings{'ACTION'} eq 'delservice')
916 &General
::readhasharray
("$configsrv", \
%customservice);
917 foreach my $key (keys %customservice) {
918 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
919 #&deletefromgrp($customhost{$key}[0],$configgrp);
920 delete $customservice{$key};
921 &General
::writehasharray
("$configsrv", \
%customservice);
925 $fwhostsettings{'SRV_NAME'}='';
926 $fwhostsettings{'SRV_PORT'}='';
927 $fwhostsettings{'PROT'}='';
930 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
932 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
933 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
934 foreach my $key (sort keys %customservicegrp)
936 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
938 delete $customservicegrp{$key};
941 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
942 $fwhostsettings{'SRVGRP_NAME'}='';
944 &viewtableservicegrp
;
946 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
950 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
951 &General
::readhasharray
("$configsrv", \
%customservice);
952 foreach my $key (keys %customservicegrp){
953 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
955 #decrease count from source service
956 foreach my $key1 (sort keys %customservice){
957 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
958 $customservice{$key1}[4]--;
962 &General
::writehasharray
("$configsrv", \
%customservice);
963 $grpname=$customservicegrp{$key}[0];
964 $grpremark=$customservicegrp{$key}[1];
965 delete $customservicegrp{$key};
968 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
970 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
971 #$fwhostsettings{'updatesrvgrp'}='on';
972 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
973 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
976 &viewtableservicegrp
;
979 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
984 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
989 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
994 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
998 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1001 &viewtableservicegrp
;
1003 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1005 &General
::readhasharray
("$configgrp", \
%customgrp);
1006 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1007 foreach my $key (sort keys %customgrp)
1009 #$customgrp{$key}[1]=~ s/\|/,/g;
1010 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1012 #$fwhostsettings{'newrem'}=~ s/,/\|/g;
1013 $customgrp{$key}[1]='';
1014 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1017 &General
::writehasharray
("$configgrp", \
%customgrp);
1018 $fwhostsettings{'update'}='on';
1019 #$fwhostsettings{'newrem'}=~ s/\|/,/g;
1020 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1022 $errormessage=$Lang::tr
{'fwhost err remark'};
1023 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1024 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1025 $fwhostsettings{'update'} = 'on';
1027 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1031 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1033 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1034 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1035 foreach my $key (sort keys %customservicegrp)
1037 #$customservicegrp{$key}[1]=~ s/\|/,/g;
1038 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1040 #$fwhostsettings{'newsrvrem'}=~ s/,/|/g;
1041 $customservicegrp{$key}[1]='';
1042 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1045 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1046 $fwhostsettings{'updatesrvgrp'}='on';
1047 #$fwhostsettings{'newsrvrem'}=~ s/\|/,/g;
1048 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1050 $errormessage=$Lang::tr
{'fwhost err remark'};
1051 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1052 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1053 $fwhostsettings{'updatesrvgrp'} = 'on';
1055 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1057 &viewtableservicegrp
;
1060 if($fwhostsettings{'ACTION'} eq '')
1068 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1070 <table border='0' width='100%'><form method='post'>
1071 <tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newnet'}' /><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newhost'}' /><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newgrp'}' /></td>
1072 <td align='right'><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservice'}' /><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservicegrp'}' /></td></tr>
1073 <tr><td colspan='6'><hr></hr></td>
1077 if (-f
"${General::swroot}/fwhosts/reread"){
1078 print "</tr><tr><td colspan='6'><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: red; font-weight: bold;' >$Lang::tr{'fwhost reread'}</td>";
1080 print"</tr></table></form>";
1082 &Header
::closebox
();
1090 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1091 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1093 <table border='0' width='100%'><form method='post' style='display:inline' >
1094 <tr><td>$Lang::tr{'name'}:</td><td><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'}><script>document.getElementById('textbox1').focus()</script></td><td>$Lang::tr{'fwhost netaddress'}</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='14'></td><td align='right'>$Lang::tr{'netmask'}:</td><td align='right'><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='14'></td></tr>
1095 <tr><td colspan='6'><hr></hr></td></tr><tr>
1097 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1099 print "<td colspan='6' align='right' ><input type='submit' value='$Lang::tr{'update'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='updatenet'><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newnet' value='$fwhostsettings{'newnet'}'>";
1101 print "<td colspan='6' align='right'><input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'/><input type='hidden' name='ACTION' value='savenet'><input type='hidden' name='newnet' value='on'>";
1103 print "</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='resetnet'></td></tr></table></form>";
1104 &Header
::closebox
();
1110 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1111 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1113 <table border='0' width='100%'><form method='post' style='display:inline'>
1114 <tr><td>$Lang::tr{'name'}:</td><td width='35%'><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} ><script>document.getElementById('textbox1').focus()</script></td><td><select name='type'>
1116 if ($fwhostsettings{'type'} eq 'ip'){print "<option value='ip' selected >IP</option>";}else{print "<option value='ip' >IP</option>";}
1117 if ($fwhostsettings{'type'} eq 'mac'){print "<option value='mac' selected >MAC</option>";}else{print "<option value='mac' >MAC</option>";}
1119 </option></select></td><td align='right' width='15%'>IP/MAC:</td><td align='right'><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} ></td></tr>
1120 <tr><td>$Lang::tr{'remark'}:</td><td colspan='5'><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' size='64'></td></tr>
1121 <tr><td colspan='7'><br><br><b>$Lang::tr{'fwhost attention'}</b><br>$Lang::tr{'fwhost macwarn'}</td></tr>
1122 <tr><td colspan='7'><hr></hr></td></tr>
1125 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1128 print " <td colspan='6' align='right'><input type='submit' value='$Lang::tr{'update'}' style='min-width:100px;'/><input type='hidden' name='ACTION' value='updatehost'><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newhost' value='$fwhostsettings{'newhost'}'></form>";
1130 print " <td colspan='6' align='right'><input type='submit' name='savehost' value='$Lang::tr{'save'}'style='min-width:100px;' /><input type='hidden' name='ACTION' value='savehost' /><input type='hidden' name='newhost' value='on'>";
1132 print " </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='resethost'></td></tr></table></form>";
1133 &Header
::closebox
();
1140 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1141 &General
::setup_default_networks
(\
%defaultNetworks);
1143 $checked{'check1'}{'off'} = '';
1144 $checked{'check1'}{'on'} = '';
1145 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1146 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1147 my $grp=$fwhostsettings{'grp_name'};
1148 my $rem=$fwhostsettings{'remark'};
1149 if ($fwhostsettings{'update'} eq ''){
1151 <table width='100%' border='0'><form method='post'>
1152 <tr><td>$Lang::tr{'fwhost addgrpname'}</td><td><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}'></td><td>$Lang::tr{'remark'}:</td><td width='1%'><input type='TEXT' name='remark' size='35' value='$fwhostsettings{'remark'}'></tr>
1153 <tr><td colspan='5'><hr></td></tr></table>
1157 <table width='100%' border='0'><form method='post' style='display:inline'>
1158 <tr><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' readonly ></td><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='newrem' size='35' value='$fwhostsettings{'remark'}'></td><td><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldrem' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='ACTION' value='changegrpremark' ></td></tr></table></form>
1162 if ($fwhostsettings{'update'} eq 'on'){
1164 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'><table width='100%' border='0'><tr><td width='1%'><input type='radio' name='grp2' value='std_net' checked></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost stdnet'}</td><td><select name='DEFAULT_SRC_ADR' style='min-width:185px;'>
1166 foreach my $network (sort keys %defaultNetworks)
1168 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1169 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1170 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1171 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1172 print ">$network</option>";
1175 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_net' $checked{'grp2'}{'ovpn_net'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='OVPN_CCD_NET' style='min-width:185px;'>
1177 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1178 foreach my $key (sort { uc($ccdnet{$a}[0]) cmp uc($ccdnet{$b}[0]) } keys %ccdnet)
1180 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1184 <tr><td><input type='radio' name='grp2' value='cust_net' $checked{'grp2'}{'cust_net'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='CUST_SRC_NET' style='min-width:185px;'>
1186 &General
::readhasharray
("$confignet", \
%customnetwork);
1187 foreach my $key (sort { uc($customnetwork{$a}[0]) cmp uc($customnetwork{$b}[0]) } keys %customnetwork) {
1188 print"<option>$customnetwork{$key}[0]</option>";
1191 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_host' $checked{'grp2'}{'ovpn_host'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='OVPN_CCD_HOST' style='min-width:185px;'>
1193 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1194 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1196 if ($ccdhost{$key}[33] ne ''){
1197 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1202 <tr><td valign='top'><input type='radio' name='grp2' value='cust_host' $checked{'grp2'}{'cust_host'}></td><td valign='top'>$Lang::tr{'fwhost cust addr'}</td><td><select name='CUST_SRC_HOST' style='min-width:185px;'>
1204 &General
::readhasharray
("$confighost", \
%customhost);
1205 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0]) } keys %customhost) {
1206 print"<option>$customhost{$key}[0]</option>";
1209 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_n2n' $checked{'grp2'}{'ovpn_n2n'}></td><td valign='top'>$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='OVPN_N2N' style='min-width:185px;'>
1211 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1212 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1213 if($ccdhost{$key}[3] eq 'net'){
1214 print"<option>$ccdhost{$key}[1]</option>";
1219 <tr><td colspan='3'></td><td valign='top'><input type='radio' name='grp2' value='ipsec_net' $checked{'grp2'}{'ipsec_net'}></td><td valign='top'>$Lang::tr{'fwhost ipsec net'}</td><td><select name='IPSEC_NET' style='min-width:185px;'>
1221 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1222 foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1223 if ($ipsecconf{$key}[3] eq 'net'){
1224 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1228 </select></td></tr></table>
1230 # <td colspan='3'></td><td valign='top'><input type='radio' name='grp2' value='ipsec_host' $checked{'grp2'}{'ipsec_host'}></td><td valign='top'>$Lang::tr{'fwhost ipsec host'}</td><td><select name='IPSEC_HOST' style='min-width:185px;'>
1232 # &General::readhasharray("$configipsec", \%ipsecconf);
1233 # foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1234 # if ($ipsecconf{$key}[3] eq 'host'){
1235 # print"<option>$ipsecconf{$key}[1]</option>";
1239 # </select></td></tr>
1241 print"<br><br><b>$Lang::tr{'fwhost attention'}:</b><br> $Lang::tr{'fwhost macwarn'}<br><hr>";
1243 print"<table border='0' width='100%'>";
1244 print"<tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /><input type='hidden' name='oldremark' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='update' value=$fwhostsettings{'update'} ><input type='hidden' name='ACTION' value='savegrp' ></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></table></form>";
1245 &Header
::closebox
();
1251 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservice'});
1252 if ($fwhostsettings{'updatesrv'} eq 'on')
1254 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1255 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1256 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1259 <table width='100%' border='0'><form method='post'>
1260 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost srv_name'}:</td><td width='1%' nowrap='nowrap'><input type='text' name='SRV_NAME' id='textbox1' value='$fwhostsettings{'SRV_NAME'}'><script>document.getElementById('textbox1').focus()</script></td><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT'>
1262 foreach ("TCP","UDP","ICMP")
1264 if ($_ eq $fwhostsettings{'PROT'})
1266 print"<option selected>$_</option>";
1268 print"<option>$_</option>";
1272 </select></td><td>$Lang::tr{'fwhost port'}:</td><td><input type='text' name='SRV_PORT' value='$fwhostsettings{'SRV_PORT'}' maxlength='11' size='9'></td></tr>
1273 <tr><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='4'><select name='ICMP_TYPES'>
1275 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1276 print"<option>All ICMP-Types</option>";
1277 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1278 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1283 <tr><td colspan='6'><hr></td></tr>
1284 <tr><td colspan='6' align='right'>
1286 if ($fwhostsettings{'updatesrv'} eq 'on')
1289 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1290 <input type='hidden' name='ACTION' value='updateservice'>
1291 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1292 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1293 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1297 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1300 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1305 &Header
::closebox
();
1313 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservicegrp'});
1314 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1315 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1317 <table width='100%' border='0'><form method='post'>
1318 <tr><td>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}'></td><td>$Lang::tr{'remark'}:</td><td width='1%'><input type='text' name='SRVGRP_REMARK' size='35' value='$fwhostsettings{'SRVGRP_REMARK'}'></td></tr>
1319 <tr><td colspan='4'><hr></td></td></tr>
1324 <table width='100%' border='0'><form method='post' style='display:inline'>
1325 <tr><td>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}' readonly ></td><td>$Lang::tr{'remark'}:</td><td width='1%'><input type='text' name='newsrvrem' size='35' value='$fwhostsettings{'SRVGRP_REMARK'}'></td><td><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldsrvrem' value='$fwhostsettings{'oldsrvgrpremark'}'><input type='hidden' name='ACTION' value='changesrvgrpremark' ></td></tr>
1326 <tr><td colspan='5'><hr></td></td></tr>
1330 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1332 <form method='post'><input type='hidden' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}'><input type='hidden' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}'><table border='0' width='100%'>
1333 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1335 &General
::readhasharray
("$configsrv", \
%customservice);
1336 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
1338 print "<option>$customservice{$key}[0]</option>";
1342 <tr><td colspan='4'><br><br><br></td></tr>
1343 <tr><td colspan='4'><hr></td></tr>
1348 <table width='100%' border='0'>
1349 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'><input type='hidden' name='oldsrvgrpremark' value='$fwhostsettings{'oldsrvgrpremark'}'><input type='hidden' name='ACTION' value='saveservicegrp' ></form><form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></td></tr>
1352 &Header
::closebox
();
1357 if(! -z
$confignet){
1358 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1359 &General
::readhasharray
("$confignet", \
%customnetwork);
1360 if (!keys %customnetwork)
1362 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1365 <table border='0' width='100%'>
1366 <tr><td align='center'><b>$Lang::tr{'name'}</td><td align='center'><b>$Lang::tr{'fwhost netaddress'}</td><td align='center'><b>$Lang::tr{'netmask'}</td><td align='center'><b>$Lang::tr{'used'}</td><td></td><td width='3%'></td></tr>
1370 foreach my $key (sort {$a <=> $b} keys %customnetwork) {
1371 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1372 print" <tr bgcolor='${Header::colouryellow}'>";
1375 print" <tr bgcolor='$color{'color22'}'>";
1378 print" <tr bgcolor='$color{'color20'}'>";
1381 <td width='40%'><form method='post'>$customnetwork{$key}[0]</td><td width=25%'>$customnetwork{$key}[1]</td><td width='25%'>$customnetwork{$key}[2]</td><td align='center'>$customnetwork{$key}[3]x</td>
1382 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1383 <input type='hidden' name='ACTION' value='editnet'>
1384 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1385 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1386 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1389 if($customnetwork{$key}[3] == '0')
1391 print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delnet' /><input type='hidden' name='key' value='$customnetwork{$key}[0]' /></td></form></tr>";
1393 print"<td></td></form></tr>";
1398 &Header
::closebox
();
1404 if (! -z
$confighost){
1405 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1406 &General
::readhasharray
("$confighost", \
%customhost);
1407 if (!keys %customhost)
1409 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1412 <table border='0' width='100%'>
1413 <tr><td align='center'><b>$Lang::tr{'name'}</td><td align='center'><b>$Lang::tr{'fwhost ip_mac'}</td><td align='center'><b>$Lang::tr{'remark'}</td><td align='center'><b>$Lang::tr{'used'}</td><td></td><td width='3%'></td></tr>
1417 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0])|| $a <=> $b } keys %customhost) {
1418 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1419 print" <tr bgcolor='${Header::colouryellow}'>";
1420 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1421 else{ print" <tr bgcolor='$color{'color20'}'>";}
1422 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1423 $customhost{$key}[4]=~s/\s+//g;
1425 <td width='20%'><form method='post'>$customhost{$key}[0]</td><td width='20%'>$ip</td><td width='50%'>$customhost{$key}[3]</td><td align='center'>$customhost{$key}[4]x</td>
1426 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1427 <input type='hidden' name='ACTION' value='edithost' />
1428 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1429 <input type='hidden' name='IP' value='$ip' />
1430 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1431 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1434 if($customhost{$key}[4] == '0')
1436 print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delhost' /><input type='hidden' name='key' value='$customhost{$key}[0]' /></td></form></tr>";
1438 print"<td width='1%'></td></tr>";
1443 &Header
::closebox
();
1448 if(! -z
"$configgrp"){
1449 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1450 &General
::readhasharray
("$configgrp", \
%customgrp);
1451 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1452 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1453 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1454 &General
::readhasharray
("$confighost", \
%customhost);
1455 &General
::readhasharray
("$confignet", \
%customnetwork);
1463 if (!keys %customgrp)
1465 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1467 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } sort { uc($customgrp{$a}[2]) cmp uc($customgrp{$b}[2]) } keys %customgrp){
1469 if ($helper ne $customgrp{$key}[0]){
1471 foreach my $key1 (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } sort { uc($customgrp{$a}[2]) cmp uc($customgrp{$b}[2]) } keys %customgrp){
1472 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1481 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost empty'};}
1482 $grpname=$customgrp{$key}[0];
1483 $remark="$customgrp{$key}[1]";
1484 if($count >=2){print"</table>";}
1485 print "<br><b><u>$grpname</u></b>    ";
1486 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1487 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1488 if($customgrp{$key}[4] == '0')
1490 print"<form method='post' style='display:inline'><input type='image' src='/images/delete.gif' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} align='right' /><input type='hidden' name='grp_name' value='$grpname' ><input type='hidden' name='ACTION' value='delgrp'></form>";
1492 print"<form method='post' style='display:inline'><input type='image' src='/images/edit.gif' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} align='right' /><input type='hidden' name='grp_name' value='$grpname' ><input type='hidden' name='remark' value='$remark' ><input type='hidden' name='ACTION' value='editgrp'></form>";
1493 print"<table width='100%' style='border: 1px solid #000000;' rules='none' ><tr><td align='center'><b>Name</b></td><td align='center'><b>$Lang::tr{'ip address'}</b></td><td align='center' width='25%'><b>$Lang::tr{'fwhost type'}</td></tr>";
1496 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1497 print" <tr bgcolor='${Header::colouryellow}'>";
1498 }elsif ($count %2 == 0){
1499 print"<tr bgcolor='$color{'color22'}'>";
1501 print"<tr bgcolor='$color{'color20'}'>";
1503 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1504 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1505 print "<td width='39%'>";
1506 if($customgrp{$key}[3] eq 'Standard Network'){
1507 print &get_name
($customgrp{$key}[2])."</td>";
1509 print "$customgrp{$key}[2]</td>";
1511 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost empty'}){
1512 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1514 print"<td>$ip</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1516 if ($delflag > '1' && $ip ne ''){
1517 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1519 print"<input type='hidden' name='ACTION' value='deletegrphost'><input type='hidden' name='grpcnt' value='$customgrp{$key}[4]'><input type='hidden' name='update' value='$fwhostsettings{'update'}'><input type='hidden' name='delhost' value='$grpname,$remark,$customgrp{$key}[2],$customgrp{$key}[3]'></form></td></tr>";
1521 $helper=$customgrp{$key}[0];
1527 &Header
::closebox
();
1531 sub viewtableservice
1534 if(! -z
"$configsrv")
1536 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1537 &General
::readhasharray
("$configsrv", \
%customservice);
1539 <table width='100%' border='0'>
1540 <tr><td align='center'><b>$Lang::tr{'fwhost srv_name'}</td><td align='center'><b>$Lang::tr{'fwhost prot'}</td><td align='center'><b>$Lang::tr{'fwhost port'}</td><td align='center'><b>ICMP</td><td align='center'><b>$Lang::tr{'fwhost used'}</td><td></td><td width='3%'></td></tr>
1542 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
1545 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1546 print" <tr bgcolor='${Header::colouryellow}'>";
1547 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1549 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1551 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1554 </td><td align='center'>$customservice{$key}[4]x</td>
1555 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} /><input type='hidden' name='ACTION' value='editservice' />
1556 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1557 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1558 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1560 if ($customservice{$key}[4] eq '0')
1562 print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delservice' /><input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]'></td></tr></form>";
1564 print"<td></td></tr>";
1568 &Header
::closebox
();
1571 sub viewtableservicegrp
1580 if (! -z
$configsrvgrp){
1581 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1582 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1583 &General
::readhasharray
("$configsrv", \
%customservice);
1584 my $number= keys %customservicegrp;
1585 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0])|| $a <=> $b } keys %customservicegrp){
1587 if ($helper ne $customservicegrp{$key}[0]){
1589 foreach my $key1 (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } sort { uc($customservicegrp{$a}[2]) cmp uc($customservicegrp{$b}[2]) } keys %customservicegrp){
1590 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1598 $grpname=$customservicegrp{$key}[0];
1599 if ($customservicegrp{$key}[2] eq "none"){
1600 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1604 $remark="$customservicegrp{$key}[1]";
1605 if($count >=2){print"</table>";}
1606 print "<br><b><u>$grpname</u></b>     ";
1607 print "<b>$Lang::tr{'remark'}:</b>  $remark " if ($remark ne '');
1608 print "  <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1609 if($customservicegrp{$key}[3] == '0')
1611 print"<form method='post' style='display:inline'><input type='image' src='/images/delete.gif' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} align='right' /><input type='hidden' name='SRVGRP_NAME' value='$grpname' ><input type='hidden' name='ACTION' value='delservicegrp'></form>";
1613 print"<form method='post' style='display:inline'><input type='image' src='/images/edit.gif' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} align='right' /><input type='hidden' name='SRVGRP_NAME' value='$grpname' ><input type='hidden' name='SRVGRP_REMARK' value='$remark' ><input type='hidden' name='ACTION' value='editservicegrp'></form>";
1614 print"<table width='100%' style='border: 1px solid #000000;' rules='none' ><tr><td align='center'><b>Name</b></td><td align='center'><b>$Lang::tr{'port'}</b></td><td align='center' width='25%'><b>$Lang::tr{'fwhost prot'}</td></tr>";
1616 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1617 print" <tr bgcolor='${Header::colouryellow}'>";
1618 }elsif ($count %2 == 0){
1619 print"<tr bgcolor='$color{'color22'}'>";
1621 print"<tr bgcolor='$color{'color20'}'>";
1623 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1624 foreach my $srv (sort keys %customservice){
1625 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1626 $protocol=$customservice{$srv}[2];
1627 $port=$customservice{$srv}[1];
1631 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1632 if ($number gt '1'){
1633 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1635 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'><input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2],$customservicegrp{$key}[3]'></form></td></tr>";
1636 $helper=$customservicegrp{$key}[0];
1639 &Header
::closebox
();
1645 my %hash=%{(shift)};
1646 foreach my $key (keys %hash) {
1647 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1657 my %hash=%{(shift)};
1659 foreach my $key (keys %hash) {
1660 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1669 my %hash=%{(shift)};
1670 &General
::readhasharray
("$confignet", \
%hash);
1671 foreach my $key (keys %hash) {
1672 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1679 sub checkservicegroup
1681 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1685 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1687 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1688 return $errormessage;
1690 #check empty selectbox
1691 if (keys %customservice lt 1)
1693 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1695 #check if name already exists
1696 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1697 foreach my $key (keys %customservicegrp) {
1698 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1699 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1704 #check if service already exists in group
1705 foreach my $key (keys %customservicegrp) {
1706 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1707 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1710 return $errormessage;
1714 if ($errormessage) {
1715 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1716 print "<class name='base'>$errormessage\n";
1717 print " </class>\n";
1718 &Header
::closebox
();
1724 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1725 print "<class name='base'>$hint\n";
1726 print " </class>\n";
1727 &Header
::closebox
();
1733 &General
::setup_default_networks
(\
%defaultNetworks);
1734 foreach my $network (sort keys %defaultNetworks)
1736 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1744 &General
::readhasharray
("$config",\
%hash);
1745 foreach my $key (keys %hash) {
1746 $errormessage.="lese $hash{$key}[2] und $target<br>";
1747 if($hash{$key}[2] eq $target){
1750 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1753 &General
::writehasharray
("$config",\
%hash);
1760 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
1762 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1763 $fwhostsettings{'BLK_IP'}='readonly';
1764 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1765 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1767 #check if name collides with CCD Netname
1768 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1769 foreach my $key (keys %ccdnet) {
1770 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1771 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1772 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1773 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1777 #check if IP collides with CCD NetIP
1778 if ($fwhostsettings{'type'} ne 'mac'){
1779 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1780 foreach my $key (keys %ccdnet) {
1781 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1782 if($ccdnet{$key}[1] eq $test){
1783 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1784 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1785 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1786 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1791 #check if name collides with CCD Hostname
1792 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1793 foreach my $key (keys %ccdhost) {
1794 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1795 if($ip eq $fwhostsettings{'IP'}){
1796 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1797 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1801 #check if IP collides with CCD HostIP (only hosts)
1802 if ($edit eq 'edithost')
1804 foreach my $key (keys %ccdhost) {
1805 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1806 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1807 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1808 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1813 #check if network with this name already exists
1814 &General
::readhasharray
("$confignet", \
%customnetwork);
1815 if (!&checkname
(\
%customnetwork))
1817 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1818 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1819 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1821 #check if network ip already exists
1822 if (!&checkip
(\
%customnetwork,1))
1824 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1825 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1827 #check if host with this name already exists
1828 &General
::readhasharray
("$confighost", \
%customhost);
1829 if (!&checkname
(\
%customhost))
1831 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1832 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1833 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1835 #check if host with this ip already exists
1836 if (!&checkip
(\
%customhost,2))
1838 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1848 #get address from IPSEC NETWORK
1849 if ($type eq 'IpSec Network'){
1850 foreach my $key (keys %ipsecconf) {
1851 if ($ipsecconf{$key}[1] eq $name){
1852 return $ipsecconf{$key}[11];
1855 &deletefromgrp
($name,$configgrp);
1858 #get address from IPSEC HOST
1859 if ($type eq 'IpSec Host'){
1860 foreach my $key (keys %ipsecconf) {
1861 if ($ipsecconf{$key}[1] eq $name){
1862 return $ipsecconf{$key}[10];
1865 &deletefromgrp
($name,$configgrp);
1868 #get address from ovpn ccd Net-2-Net
1869 if ($type eq 'OpenVPN N-2-N'){
1870 foreach my $key (keys %ccdhost) {
1871 if($ccdhost{$key}[1] eq $name){
1872 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1873 $b=&General
::iporsubtodec
($b);
1877 &deletefromgrp
($name,$configgrp);
1880 #get address from ovpn ccd static host
1881 if ($type eq 'OpenVPN static host'){
1882 foreach my $key (keys %ccdhost) {
1883 if($ccdhost{$key}[1] eq $name){
1884 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1885 $b=&General
::iporsubtodec
($b);
1889 &deletefromgrp
($name,$configgrp);
1892 #get address from ovpn ccd static net
1893 if ($type eq 'OpenVPN static network'){
1894 foreach my $key (keys %ccdnet) {
1895 if ($ccdnet{$key}[0] eq $name){
1896 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1897 $b=&General
::iporsubtodec
($b);
1903 #check custom addresses
1904 if ($type eq 'Custom Host'){
1905 foreach my $key (keys %customhost) {
1906 if ($customhost{$key}[0] eq $name){
1907 return $customhost{$key}[2];
1912 ##check custom networks
1913 if ($type eq 'Custom Network'){
1914 foreach my $key (keys %customnetwork) {
1915 if($customnetwork{$key}[0] eq $name){
1916 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
1921 #check standard networks
1922 if ($type eq 'Standard Network'){
1923 if ($name =~ /OpenVPN/i){
1925 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
1926 return $ovpn{'DOVPN_SUBNET'};
1928 if ($name eq 'GREEN'){
1930 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1931 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
1933 if ($name eq 'BLUE'){
1935 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1936 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
1938 if ($name eq 'ORANGE'){
1940 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1941 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
1943 if ($name eq 'ALL'){
1944 return "0.0.0.0/0.0.0.0";
1946 if ($name =~ /IPsec/i){
1948 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
1949 return $hash{'RW_NET'};
1955 if (!-f
"${General::swroot}/fwhosts/reread"){
1956 system("touch ${General::swroot}/fwhosts/reread");
1957 system("touch ${General::swroot}/forward/reread");
1962 system ("/usr/local/bin/forwardfwctrl");
1963 if ( -f
"${General::swroot}/fwhosts/reread"){
1964 system("rm ${General::swroot}/fwhosts/reread");
1965 system("rm ${General::swroot}/forward/reread");
1972 &General
::readhasharray
("$confignet", \
%customnetwork);
1973 &General
::readhasharray
("$confighost", \
%customhost);
1974 foreach my $key (sort keys %customgrp ){
1975 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
1976 foreach my $key1 (sort keys %customnetwork){
1977 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
1978 $customnetwork{$key1}[3]=$customnetwork{$key1}[3]-1;
1984 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
1985 foreach my $key2 (sort keys %customhost){
1986 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
1987 $customhost{$key2}[3]=$customhost{$key2}[3]-1;
1994 &General
::writehasharray
("$confignet", \
%customnetwork);
1995 &General
::writehasharray
("$confighost", \
%customhost);
2000 &General
::readhasharray
("$configsrv", \
%customservice);
2001 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2003 foreach my $key (sort keys %customservicegrp){
2004 if ($customservicegrp{$key}[0] eq $grp ){
2005 foreach my $key2 (sort keys %customservice){
2006 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2007 $customservice{$key2}[4]--;
2012 &General
::writehasharray
("$configsrv", \
%customservice);
2018 my %hash=%{(shift)};
2020 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2021 $errormessage=$Lang::tr
{'fwhost err name1'};
2023 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2024 $errormessage=$Lang::tr
{'fwhost err port'};
2027 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2028 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2030 #change dashes with :
2031 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2033 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2034 $fwhostsettings{'SRV_PORT'} = "1:65535";
2036 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2037 $fwhostsettings{'SRV_PORT'} = "1:$2";
2039 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2040 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2042 if($fwhostsettings{'PROT'} ne 'ICMP'){
2043 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2045 # a new service has to have a different name
2046 foreach my $key (keys %hash){
2047 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2048 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2052 return $errormessage;
2056 # Checks a hostname against RFC1035
2057 my $hostname = $_[0];
2059 # Each part should be at least two characters in length
2060 # but no more than 63 characters
2061 if (length ($hostname) < 1 || length ($hostname) > 63) {
2063 # Only valid characters are a-z, A-Z, 0-9 and -
2064 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2066 # First character can only be a letter or a digit
2067 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2069 # Last character can only be a letter or a digit
2070 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2076 # Checks a hostname against RFC1035
2078 # Each part should be at least two characters in length
2079 # but no more than 63 characters
2080 if (length ($remark) < 1 || length ($remark) > 255) {
2082 # Only valid characters are a-z, A-Z, 0-9 and -
2083 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2085 # First character can only be a letter or a digit
2086 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2088 # Last character can only be a letter or a digit
2089 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2093 &Header
::closebigbox
();
2094 &Header
::closepage
();