]>
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=();
54 my $confignet = "${General::swroot}/fwhosts/customnetworks";
55 my $confighost = "${General::swroot}/fwhosts/customhosts";
56 my $configgrp = "${General::swroot}/fwhosts/customgroups";
57 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
58 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
59 my $configipsec = "${General::swroot}/vpn/config";
60 my $configsrv = "${General::swroot}/fwhosts/customservices";
61 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
63 unless (-e
$confignet) { system("touch $confignet"); }
64 unless (-e
$confighost) { system("touch $confighost"); }
65 unless (-e
$configgrp) { system("touch $configgrp"); }
66 unless (-e
$configsrv) { system("touch $configsrv"); }
67 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
69 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
70 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
71 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
72 &Header
::getcgihash
(\
%fwhostsettings);
74 &Header
::showhttpheaders
();
75 &Header
::openpage
($Lang::tr
{'fwhost hosts'}, 1, '');
76 &Header
::openbigbox
('100%', 'center');
80 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
82 &General
::readhasharray
("$confignet", \
%customnetwork);
83 foreach my $key (keys %customnetwork)
85 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
87 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
88 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
89 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
90 $fwhostsettings{'count'} = $customnetwork{$key}[3];
91 delete $customnetwork{$key};
95 &General
::writehasharray
("$confignet", \
%customnetwork);
96 $fwhostsettings{'actualize'} = 'on';
97 $fwhostsettings{'ACTION'} = 'savenet';
99 if ($fwhostsettings{'ACTION'} eq 'updatehost')
102 &General
::readhasharray
("$confighost", \
%customhost);
103 foreach my $key (keys %customhost)
105 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
107 $fwhostsettings{'orgname'} = $customhost{$key}[0];
108 if ($customhost{$key}[1] eq 'ip'){
109 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
111 $ip = $customhost{$key}[2];
113 $fwhostsettings{'orgip'} = $ip;
114 $fwhostsettings{'count'} = $customhost{$key}[3];
115 delete $customhost{$key};
118 &General
::writehasharray
("$confighost", \
%customhost);
119 $fwhostsettings{'actualize'} = 'on';
120 $fwhostsettings{'ACTION'} = 'savehost';
122 if ($fwhostsettings{'ACTION'} eq 'updateservice')
126 $errormessage=&checkports
(\
%customservice);
129 &General
::readhasharray
("$configsrv", \
%customservice);
130 foreach my $key (keys %customservice)
132 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
134 $count=$customservice{$key}[4];
135 delete $customservice{$key};
136 &General
::writehasharray
("$configsrv", \
%customservice);
140 if ($fwhostsettings{'PROT'} ne 'ICMP'){
141 $fwhostsettings{'ICMP_TYPES'}='BLANK';
143 my $key1 = &General
::findhasharraykey
(\
%customservice);
144 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
145 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
146 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
147 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
148 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
149 $customservice{$key1}[4] = $count;
150 &General
::writehasharray
("$configsrv", \
%customservice);
151 if($fwhostsettings{'updatesrv'} eq 'on'){
152 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
155 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
159 $fwhostsettings{'SRV_NAME'} = '';
160 $fwhostsettings{'SRV_PORT'} = '';
161 $fwhostsettings{'PROT'} = '';
164 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
165 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
166 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
167 $fwhostsettings{'updatesrv'}= 'on';
170 if($needrules eq 'on'){
171 $errormessage="reread!";
178 if ($fwhostsettings{'ACTION'} eq 'savenet' )
182 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
184 #check if all fields are set
185 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
187 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
192 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
194 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
195 $fwhostsettings{'BLK_HOST'} ='readonly';
196 $fwhostsettings{'NOCHECK'} ='false';
197 $fwhostsettings{'error'} ='on';
199 #check if subnet is sigle host
200 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
202 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
205 if($fwhostsettings{'error'} ne 'on'){
206 #check if we use one of ipfire's networks (green,orange,blue)
207 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
209 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
210 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
211 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
213 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
215 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
216 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
217 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
219 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
221 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
222 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
223 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
225 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
227 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
228 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
229 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
232 #only check plausi when no error till now
234 &plausicheck
("editnet");
237 #check if network ip is part of an already used one
238 if(&checksubnet
(\
%customnetwork))
240 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
241 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
244 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
246 $fwhostsettings{'actualize'} = '';
247 my $key = &General
::findhasharraykey
(\
%customnetwork);
248 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
249 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
250 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
251 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
252 $customnetwork{$key}[3] = $fwhostsettings{'count'};
253 &General
::writehasharray
("$confignet", \
%customnetwork);
254 undef %customnetwork;
258 &General
::readhasharray
("$confignet", \
%customnetwork);
259 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
260 if ($fwhostsettings{'update'} == '0'){
261 foreach my $key (keys %customnetwork) {
262 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
263 $count=$customnetwork{$key}[3];
264 delete $customnetwork{$key};
270 #get count if actualize is 'on'
271 if($fwhostsettings{'actualize'} eq 'on'){
272 $fwhostsettings{'actualize'} = '';
273 $count=$fwhostsettings{'count'};
274 #check if we need to reload rules
275 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
278 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
279 #check if we need to update groups
280 &General
::readhasharray
("$configgrp", \
%customgrp);
281 foreach my $key (sort keys %customgrp){
282 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
283 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
287 &General
::writehasharray
("$configgrp", \
%customgrp);
290 my $key = &General
::findhasharraykey
(\
%customnetwork);
291 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
292 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
293 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
294 #convert ip when leading '0' in byte
295 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
296 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
297 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
298 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
299 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
300 $customnetwork{$key}[3] = $count;
301 &General
::writehasharray
("$confignet", \
%customnetwork);
302 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
303 undef %customnetwork;
304 $fwhostsettings{'HOSTNAME'}='';
305 $fwhostsettings{'IP'}='';
306 $fwhostsettings{'SUBNET'}='';
307 #check if an edited net affected groups and need to reload rules
308 if ($needrules eq 'on'){
321 if ($fwhostsettings{'ACTION'} eq 'savehost')
325 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
327 $fwhostsettings{'SUBNET'}='32';
329 #check if all fields are set
330 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
332 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
333 $fwhostsettings{'ACTION'} = 'edithost';
336 if($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
337 $fwhostsettings{'type'} = 'mac';
338 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
339 $fwhostsettings{'type'} = 'ip';
340 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
341 $fwhostsettings{'type'} = 'mac';
342 }elsif($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
343 $fwhostsettings{'type'} = 'ip';
345 $fwhostsettings{'type'} = '';
346 $errormessage=$Lang::tr
{'fwhost err ipmac'};
349 if($fwhostsettings{'type'} eq 'mac' )
351 if ($fwhostsettings{'IP'}!~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/ )
353 $errormessage=$Lang::tr
{'fwhost err mac'};
358 if ($fwhostsettings{'type'} eq 'ip'){
360 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
361 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
363 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
364 $fwhostsettings{'error'}='on';
367 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
368 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
369 $fwhostsettings{'error'}='on';
371 #check if net or broadcast
372 my @tmp= split (/\./,$fwhostsettings{'IP'});
373 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
374 $errormessage=$Lang::tr
{'fwhost err hostip'};
380 #only check plausi when no error till now
382 &plausicheck
("edithost");
385 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
386 $fwhostsettings{'actualize'} = '';
387 my $key = &General
::findhasharraykey
(\
%customhost);
388 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
389 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
390 $customhost{$key}[1] = $fwhostsettings{'type'} ;
391 if($customhost{$key}[1] eq 'ip'){
392 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
394 $customhost{$key}[2] = $fwhostsettings{'orgip'};
396 $customhost{$key}[3] = $fwhostsettings{'count'};
397 &General
::writehasharray
("$confighost", \
%customhost);
403 #get count if host was edited
404 if($fwhostsettings{'actualize'} eq 'on'){
405 $count=$fwhostsettings{'count'};
406 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
409 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
410 #check if we need to update groups
411 &General
::readhasharray
("$configgrp", \
%customgrp);
412 foreach my $key (sort keys %customgrp){
413 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
414 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
418 &General
::writehasharray
("$configgrp", \
%customgrp);
423 my $key = &General
::findhasharraykey
(\
%customhost);
424 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
425 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
426 $customhost{$key}[1] = $fwhostsettings{'type'} ;
427 if ($fwhostsettings{'type'} eq 'ip'){
428 #convert ip when leading '0' in byte
429 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
430 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
431 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
433 $customhost{$key}[2] = $fwhostsettings{'IP'};
435 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
436 $customhost{$key}[3] = $count;
437 &General
::writehasharray
("$confighost", \
%customhost);
439 #$fwhostsettings{'IP'} = $fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'});
441 $fwhostsettings{'HOSTNAME'}='';
442 $fwhostsettings{'IP'}='';
443 $fwhostsettings{'type'}='';
444 #check if we need to update rules while host was edited
445 if($needrules eq 'on'){
458 if ($fwhostsettings{'ACTION'} eq 'savegrp')
461 my $rem=$fwhostsettings{'remark'};
464 my $updcounter='off';
467 &General
::readhasharray
("$configgrp", \
%customgrp);
468 &General
::readhasharray
("$confignet", \
%customnetwork);
469 &General
::readhasharray
("$confighost", \
%customhost);
470 $grp=$fwhostsettings{'grp_name'};
472 if (!&General
::validhostname
($grp)){$errormessage=$errormessage.$Lang::tr
{'fwhost err name'};}
474 ###check standard networks
475 if ($fwhostsettings{'grp2'} eq 'std_net'){
476 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
477 $type='Standard Network';
479 ##check custom networks
480 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
481 @target=$fwhostsettings{'CUST_SRC_NET'};
483 $type='Custom Network';
484 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
485 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
486 $fwhostsettings{'grp_name'}='';
487 $fwhostsettings{'remark'}='';
489 #check custom addresses
490 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
491 @target=$fwhostsettings{'CUST_SRC_HOST'};
494 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
495 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
496 $fwhostsettings{'grp_name'}='';
497 $fwhostsettings{'remark'}='';
499 #get address from ovpn ccd static net
500 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
501 @target=$fwhostsettings{'OVPN_CCD_NET'};
502 $type='OpenVPN static network';
503 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
504 $errormessage=$Lang::tr
{'fwhost err groupempty'};
505 $fwhostsettings{'grp_name'}='';
506 $fwhostsettings{'remark'}='';
508 #get address from ovpn ccd static host
509 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
510 @target=$fwhostsettings{'OVPN_CCD_HOST'};
511 $type='OpenVPN static host';
512 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
513 $errormessage=$Lang::tr
{'fwhost err groupempty'};
515 #get address from ovpn ccd Net-2-Net
516 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
517 @target=$fwhostsettings{'OVPN_N2N'};
518 $type='OpenVPN N-2-N';
519 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
520 $errormessage=$Lang::tr
{'fwhost err groupempty'};
521 $fwhostsettings{'grp_name'}='';
522 $fwhostsettings{'remark'}='';
525 #get address from IPSEC HOST
526 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
527 @target=$fwhostsettings{'IPSEC_HOST'};
529 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
530 $errormessage=$Lang::tr
{'fwhost err groupempty'};
531 $fwhostsettings{'grp_name'}='';
532 $fwhostsettings{'remark'}='';
534 #get address from IPSEC NETWORK
535 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
536 @target=$fwhostsettings{'IPSEC_NET'};
537 $type='IpSec Network';
538 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
539 $errormessage=$Lang::tr
{'fwhost err groupempty'};
540 $fwhostsettings{'grp_name'}='';
541 $fwhostsettings{'remark'}='';
544 #check if host/net exists in grp
545 my $test="$grp,$fwhostsettings{'oldremark'},@target";
546 foreach my $key (keys %customgrp) {
547 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
548 if ($test1 eq $test){
549 $errormessage=$Lang::tr
{'fwhost err isingrp'};
550 $fwhostsettings{'update'} = 'on';
555 #on first save, we have an empty @target, so fill it with nothing
556 my $targetvalues=@target;
557 if ($targetvalues == '0'){
558 @target=$Lang::tr
{'fwhost empty'};
560 #on update, we have to delete the dummy entry
562 foreach my $key (keys %customgrp){
563 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq $Lang::tr
{'fwhost empty'}){
564 delete $customgrp{$key};
568 &General
::writehasharray
("$configgrp", \
%customgrp);
569 &General
::readhasharray
("$configgrp", \
%customgrp);
573 #check if remark has also changed
574 if ($fwhostsettings{'remark'} ne $fwhostsettings{'oldremark'} && $fwhostsettings{'update'} eq 'on')
576 foreach my $key (keys %customgrp)
578 if($customgrp{$key}[0] eq $grp && $customgrp{$key}[1] eq $fwhostsettings{'oldremark'})
580 $customgrp{$key}[1]='';
581 $customgrp{$key}[1]=$rem;
586 foreach my $key (keys %customgrp)
588 if($customgrp{$key}[0] eq $grp)
590 $count=$customgrp{$key}[4];
594 if ($count eq '' ){$count='0';}
596 #create array with new lines
597 foreach my $line (@target){
598 push (@newgrp,"$grp,$rem,$line");
601 my $key = &General
::findhasharraykey
(\
%customgrp);
602 foreach my $line (@newgrp){
603 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
604 my ($a,$b,$c,$d) = split (",",$line);
605 $customgrp{$key}[0] = $a;
606 $customgrp{$key}[1] = $b;
607 $customgrp{$key}[2] = $c;
608 $customgrp{$key}[3] = $type;
609 $customgrp{$key}[4] = $count;
611 &General
::writehasharray
("$configgrp", \
%customgrp);
613 #update counter in Host/Net
614 if($updcounter eq 'net'){
615 foreach my $key (keys %customnetwork) {
616 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
617 $customnetwork{$key}[3] = $customnetwork{$key}[3]+1;
621 &General
::writehasharray
("$confignet", \
%customnetwork);
622 }elsif($updcounter eq 'host'){
623 foreach my $key (keys %customhost) {
624 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
625 $customhost{$key}[3]=$customhost{$key}[3]+1;
628 &General
::writehasharray
("$confighost", \
%customhost);
631 $fwhostsettings{'update'}='on';
634 if ($fwhostsettings{'remark'} ne $fwhostsettings{'oldremark'} && $errormessage)
636 foreach my $key (keys %customgrp)
638 if($customgrp{$key}[0] eq $grp && $customgrp{$key}[1] eq $fwhostsettings{'oldremark'})
640 $customgrp{$key}[1]='';
641 $customgrp{$key}[1]=$rem;
644 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
646 $hint=$Lang::tr
{'fwhost changeremark'};
647 $fwhostsettings{'update'}='on';
649 #check if ruleupdate is needed
658 if ($fwhostsettings{'ACTION'} eq 'saveservice')
662 &General
::readhasharray
("$configsrv", \
%customservice );
663 $errormessage=&checkports
(\
%customservice);
665 if ($fwhostsettings{'PROT'} eq 'ICMP'){
666 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
667 foreach my $key (keys %icmptypes){
668 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
669 $ICMP=$icmptypes{$key}[0];
673 if($ICMP eq ''){$ICMP='BLANK';}
676 my $key = &General
::findhasharraykey
(\
%customservice);
677 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
678 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
679 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
680 $customservice{$key}[2] = $fwhostsettings{'PROT'};
681 $customservice{$key}[3] = $ICMP;
682 $customservice{$key}[4] = 0;
683 &General
::writehasharray
("$configsrv", \
%customservice );
685 $fwhostsettings{'SRV_NAME'}='';
686 $fwhostsettings{'SRV_PORT'}='';
687 $fwhostsettings{'PROT'}='';
688 $fwhostsettings{'ICMP_TYPES'}='';
695 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
700 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
701 &General
::readhasharray
("$configsrv", \
%customservice );
703 $errormessage=&checkservicegroup
;
706 #on first save, we have to enter a dummy value
707 if ($fwhostsettings{'CUST_SRV'} eq ''){$fwhostsettings{'CUST_SRV'}=$Lang::tr
{'fwhost empty'};}
709 #on update, we have to delete the dummy entry
710 foreach my $key (keys %customservicegrp){
711 if ($customservicegrp{$key}[2] eq $Lang::tr
{'fwhost empty'}){
712 delete $customservicegrp{$key};
716 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
717 #check if remark has also changed
718 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
720 foreach my $key (keys %customservicegrp)
722 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
724 $customservicegrp{$key}[1]='';
725 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
730 foreach my $key (keys %customservicegrp)
732 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
734 $count=$customservicegrp{$key}[5];
738 if ($count eq '' ){$count='0';}
740 foreach my $key (sort keys %customservice){
741 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
742 $port=$customservice{$key}[1];
743 $prot=$customservice{$key}[2];
744 $customservice{$key}[4]++;
747 &General
::writehasharray
("$configsrv", \
%customservice );
749 my $key = &General
::findhasharraykey
(\
%customservicegrp);
750 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
751 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
752 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
753 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
754 $customservicegrp{$key}[3] = $port;
755 $customservicegrp{$key}[4] = $prot;
756 $customservicegrp{$key}[5] = $count;
757 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
758 $fwhostsettings{'updatesrvgrp'}='on';
760 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $errormessage){
761 foreach my $key (keys %customservicegrp)
763 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
765 $customservicegrp{$key}[1]='';
766 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
769 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
771 $hint=$Lang::tr
{'fwhost changeremark'};
772 $fwhostsettings{'update'}='on';
778 &viewtableservicegrp
;
781 if ($fwhostsettings{'ACTION'} eq 'editnet')
786 if ($fwhostsettings{'ACTION'} eq 'edithost')
791 if ($fwhostsettings{'ACTION'} eq 'editgrp')
793 $fwhostsettings{'update'}='on';
797 if ($fwhostsettings{'ACTION'} eq 'editservice')
799 $fwhostsettings{'updatesrv'}='on';
802 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
804 $fwhostsettings{'updatesrvgrp'} = 'on';
806 &viewtableservicegrp
;
809 if ($fwhostsettings{'ACTION'} eq 'resetnet')
811 $fwhostsettings{'HOSTNAME'} ="";
812 $fwhostsettings{'IP'} ="";
813 $fwhostsettings{'SUBNET'} ="";
816 if ($fwhostsettings{'ACTION'} eq 'resethost')
818 $fwhostsettings{'HOSTNAME'} ="";
819 $fwhostsettings{'IP'} ="";
820 $fwhostsettings{'type'} ="";
824 if ($fwhostsettings{'ACTION'} eq 'delnet')
826 &General
::readhasharray
("$confignet", \
%customnetwork);
827 foreach my $key (keys %customnetwork) {
828 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
829 delete $customnetwork{$key};
830 &General
::writehasharray
("$confignet", \
%customnetwork);
837 if ($fwhostsettings{'ACTION'} eq 'delhost')
839 &General
::readhasharray
("$confighost", \
%customhost);
840 foreach my $key (keys %customhost) {
841 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
842 delete $customhost{$key};
843 &General
::writehasharray
("$confighost", \
%customhost);
851 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
853 &General
::readhasharray
("$configgrp", \
%customgrp);
854 foreach my $key (keys %customgrp){
855 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
856 #decrease count from source host/net
857 if ($customgrp{$key}[3] eq 'Custom Network'){
858 &General
::readhasharray
("$confignet", \
%customnetwork);
859 foreach my $key1 (keys %customnetwork){
860 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
861 $customnetwork{$key1}[3] = $customnetwork{$key1}[3]-1;
865 &General
::writehasharray
("$confignet", \
%customnetwork);
867 if ($customgrp{$key}[3] eq 'Custom Host'){
868 &General
::readhasharray
("$confighost", \
%customhost);
869 foreach my $key1 (keys %customhost){
870 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
871 $customhost{$key1}[3] = $customhost{$key1}[3]-1;
875 &General
::writehasharray
("$confighost", \
%customhost);
877 delete $customgrp{$key};
880 &General
::writehasharray
("$configgrp", \
%customgrp);
885 if ($fwhostsettings{'ACTION'} eq 'delgrp')
887 &General
::readhasharray
("$configgrp", \
%customgrp);
888 &decrease
($fwhostsettings{'grp_name'});
889 foreach my $key (sort keys %customgrp)
891 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
893 delete $customgrp{$key};
896 &General
::writehasharray
("$configgrp", \
%customgrp);
897 $fwhostsettings{'grp_name'}='';
901 if ($fwhostsettings{'ACTION'} eq 'delservice')
903 &General
::readhasharray
("$configsrv", \
%customservice);
904 foreach my $key (keys %customservice) {
905 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
906 #&deletefromgrp($customhost{$key}[0],$configgrp);
907 delete $customservice{$key};
908 &General
::writehasharray
("$configsrv", \
%customservice);
912 $fwhostsettings{'SRV_NAME'}='';
913 $fwhostsettings{'SRV_PORT'}='';
914 $fwhostsettings{'PROT'}='';
917 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
919 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
920 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
921 foreach my $key (sort keys %customservicegrp)
923 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
925 delete $customservicegrp{$key};
928 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
929 $fwhostsettings{'SRVGRP_NAME'}='';
931 &viewtableservicegrp
;
933 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
935 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
936 &General
::readhasharray
("$configsrv", \
%customservice);
937 foreach my $key (keys %customservicegrp){
938 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
940 #decrease count from source service
941 foreach my $key1 (sort keys %customservice){
942 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
943 $customservice{$key1}[4]--;
947 &General
::writehasharray
("$configsrv", \
%customservice);
948 delete $customservicegrp{$key}
951 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
954 &viewtableservicegrp
;
957 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
962 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
967 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
972 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
976 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
979 &viewtableservicegrp
;
982 if($fwhostsettings{'ACTION'} eq '')
990 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
992 <table border='0' width='100%'><form method='post'>
993 <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>
994 <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>
995 <tr><td colspan='6'><hr></hr></td></tr></table></form>
1006 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1007 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1009 <table border='0' width='100%'><form method='post' style='display:inline' >
1010 <tr><td>$Lang::tr{'name'}:</td><td><input type='TEXT' name='HOSTNAME' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'}></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>
1011 <tr><td colspan='6'><hr></hr></td></tr><tr>
1013 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1015 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'}'>";
1017 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'>";
1019 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>";
1020 &Header
::closebox
();
1026 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1027 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1029 <table border='0' width='100%'><form method='post' style='display:inline'>
1030 <tr><td>$Lang::tr{'name'}:</td><td width='35%'><input type='TEXT' name='HOSTNAME' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} ></td><td><select name='type'>
1032 if ($fwhostsettings{'type'} eq 'ip'){print "<option value='ip' selected >IP</option>";}else{print "<option value='ip' >IP</option>";}
1033 if ($fwhostsettings{'type'} eq 'mac'){print "<option value='mac' selected >MAC</option>";}else{print "<option value='mac' >MAC</option>";}
1035 </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>
1036 <tr><td colspan='7'><br><br><b>$Lang::tr{'fwhost attention'}</b><br>$Lang::tr{'fwhost macwarn'}</td></tr>
1037 <tr><td colspan='7'><hr></hr></td></tr>
1040 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1043 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>";
1045 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'>";
1047 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>";
1048 &Header
::closebox
();
1055 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1056 &General
::setup_default_networks
(\
%defaultNetworks);
1058 $checked{'check1'}{'off'} = '';
1059 $checked{'check1'}{'on'} = '';
1060 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1061 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1063 if ($fwhostsettings{'update'} eq ''){
1065 <table width='100%' border='0'><form method='post'>
1066 <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>
1067 <tr><td colspan='5'><hr></td></tr></table>
1071 <table width='100%' border='0'><form method='post'>
1072 <tr><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' readonly ></td><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='remark' size='35' value='$fwhostsettings{'remark'}'></tr>
1073 <tr><td colspan='5'><hr></td></tr></table>
1077 if ($fwhostsettings{'update'} eq 'on'){
1081 <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;'>
1084 foreach my $network (sort keys %defaultNetworks)
1086 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1087 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1088 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1089 print ">$network</option>";
1093 </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;'>
1095 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1096 foreach my $key (sort { uc($ccdnet{$a}[0]) cmp uc($ccdnet{$b}[0]) } keys %ccdnet)
1098 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1103 <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;'>
1105 &General
::readhasharray
("$confignet", \
%customnetwork);
1106 foreach my $key (sort { uc($customnetwork{$a}[0]) cmp uc($customnetwork{$b}[0]) } keys %customnetwork) {
1107 print"<option>$customnetwork{$key}[0]</option>";
1111 </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;'>
1113 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1114 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1116 if ($ccdhost{$key}[33] ne ''){
1117 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1123 <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;'>
1125 &General
::readhasharray
("$confighost", \
%customhost);
1126 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0]) } keys %customhost) {
1127 print"<option>$customhost{$key}[0]</option>";
1130 </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;'>
1132 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1133 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1134 if($ccdhost{$key}[3] eq 'net'){
1135 print"<option>$ccdhost{$key}[1]</option>";
1140 <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;'>
1142 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1143 foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1144 if ($ipsecconf{$key}[3] eq 'net'){
1145 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1149 </select></td></tr></table>
1151 # <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;'>
1153 # &General::readhasharray("$configipsec", \%ipsecconf);
1154 # foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1155 # if ($ipsecconf{$key}[3] eq 'host'){
1156 # print"<option>$ipsecconf{$key}[1]</option>";
1160 # </select></td></tr>
1164 <b>$Lang::tr{'fwhost attention'}:</b><br>
1165 $Lang::tr{'fwhost macwarn'}<br><hr>
1169 <table border='0' width='100%'>
1170 <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='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>
1174 &Header
::closebox
();
1180 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservice'});
1181 if ($fwhostsettings{'updatesrv'} eq 'on')
1183 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1184 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1185 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1188 <table width='100%' border='0'><form method='post'>
1189 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost srv_name'}:</td><td width='1%' nowrap='nowrap'><input type='text' name='SRV_NAME' value='$fwhostsettings{'SRV_NAME'}'></td><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT'>
1191 foreach ("TCP","UDP","ICMP")
1193 if ($_ eq $fwhostsettings{'PROT'})
1195 print"<option selected>$_</option>";
1197 print"<option>$_</option>";
1201 </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>
1202 <tr><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='4'><select name='ICMP_TYPES'>
1204 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1205 print"<option>All ICMP-Types</option>";
1206 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1207 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1212 <tr><td colspan='6'><hr></td></tr>
1213 <tr><td colspan='6' align='right'>
1215 if ($fwhostsettings{'updatesrv'} eq 'on')
1218 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1219 <input type='hidden' name='ACTION' value='updateservice'>
1220 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1221 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1222 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1226 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1229 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1234 &Header
::closebox
();
1242 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservicegrp'});
1243 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1245 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1247 <table width='100%' border='0'><form method='post'>
1248 <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>
1249 <tr><td colspan='4'><hr></td></td></tr>
1254 <table width='100%' border='0'><form method='post'>
1255 <tr><td>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' readonly ></td><td>$Lang::tr{'remark'}:</td><td width='1%'><input type='text' name='SRVGRP_REMARK' size='35' value='$fwhostsettings{'SRVGRP_REMARK'}'></td></tr>
1256 <tr><td colspan='4'><hr></td></td></tr>
1260 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1262 <table border='0' width='100%'>
1263 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1265 &General
::readhasharray
("$configsrv", \
%customservice);
1266 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice)
1268 print "<option>$customservice{$key}[0]</option>";
1272 <tr><td colspan='4'><br><br><br></td></tr>
1273 <tr><td colspan='4'><hr></td></tr>
1278 <table width='100%' border='0'>
1279 <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>
1283 &Header
::closebox
();
1288 if(! -z
$confignet){
1289 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1290 &General
::readhasharray
("$confignet", \
%customnetwork);
1291 if (!keys %customnetwork)
1293 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1296 <table border='0' width='100%'>
1297 <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>
1301 foreach my $key (sort { uc($customnetwork{$a}[0]) cmp uc($customnetwork{$b}[0]) } keys %customnetwork) {
1302 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1303 print" <tr bgcolor='${Header::colouryellow}'>";
1306 print" <tr bgcolor='$color{'color22'}'>";
1309 print" <tr bgcolor='$color{'color20'}'>";
1312 <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>
1313 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1314 <input type='hidden' name='ACTION' value='editnet'>
1315 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1316 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1317 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1320 if($customnetwork{$key}[3] == '0')
1322 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>";
1324 print"<td></td></form></tr>";
1329 &Header
::closebox
();
1335 if (! -z
$confighost){
1336 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1337 &General
::readhasharray
("$confighost", \
%customhost);
1338 if (!keys %customhost)
1340 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1343 <table border='0' width='100%'>
1344 <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{'used'}</td><td></td><td width='3%'></td></tr>
1348 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0]) } keys %customhost) {
1349 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1350 print" <tr bgcolor='${Header::colouryellow}'>";
1351 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1352 else{ print" <tr bgcolor='$color{'color20'}'>";}
1353 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1355 <td width='40%'><form method='post'>$customhost{$key}[0]</td><td width='50%'>$customhost{$key}[2]</td><td align='center'>$customhost{$key}[3] x</td>
1356 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1357 <input type='hidden' name='ACTION' value='edithost' />
1358 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1359 <input type='hidden' name='IP' value='$ip' />
1360 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1363 if($customhost{$key}[3] == '0')
1365 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>";
1367 print"<td width='1%'></td></tr>";
1372 &Header
::closebox
();
1377 if(! -z
"$configgrp"){
1378 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1379 &General
::readhasharray
("$configgrp", \
%customgrp);
1380 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1381 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1382 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1383 &General
::readhasharray
("$confighost", \
%customhost);
1384 &General
::readhasharray
("$confignet", \
%customnetwork);
1390 my $number=keys %customgrp;
1391 if (!keys %customgrp)
1393 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1395 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){
1398 if ($helper ne $customgrp{$key}[0]){
1399 $grpname=$customgrp{$key}[0];
1400 $remark=$customgrp{$key}[1];
1401 if($count >=2){print"</table>";}
1402 print "<br><b><u>$grpname</u></b>    ";
1403 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1404 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4] x";
1405 if($customgrp{$key}[4] == '0')
1407 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>";
1409 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>";
1410 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>";
1412 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1413 print" <tr bgcolor='${Header::colouryellow}'>";
1414 }elsif ($count %2 == 0){print"<tr bgcolor='$color{'color22'}'>";}else{print"<tr bgcolor='$color{'color20'}'>";}
1415 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1416 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1419 print "<td width='39%'>";
1420 if($customgrp{$key}[3] eq 'Standard Network'){
1421 print &get_name
($customgrp{$key}[2])."</td>";
1423 print "$customgrp{$key}[2]</td>";
1425 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost empty'}){
1426 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1428 print"<td>$ip</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1430 if ($number gt '1' && $ip ne ''){
1431 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1433 print"<input type='hidden' name='ACTION' value='deletegrphost'><input type='hidden' name='delhost' value='$grpname,$remark,$customgrp{$key}[2],$customgrp{$key}[3]'></form></td></tr>";
1435 $helper=$customgrp{$key}[0];
1440 &Header
::closebox
();
1444 sub viewtableservice
1447 if(! -z
"$configsrv")
1449 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1450 &General
::readhasharray
("$configsrv", \
%customservice);
1452 <table width='100%' border='0'>
1453 <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>
1455 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice)
1458 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1459 print" <tr bgcolor='${Header::colouryellow}'>";
1460 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1462 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1464 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1467 </td><td align='center'>$customservice{$key}[4]x</td>
1468 <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' />
1469 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1470 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1471 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1473 if ($customservice{$key}[4] eq '0')
1475 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>";
1477 print"<td></td></tr>";
1481 &Header
::closebox
();
1484 sub viewtableservicegrp
1490 if (! -z
$configsrvgrp){
1492 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1493 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1494 my $number= keys %customservicegrp;
1495 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1497 if ($helper ne $customservicegrp{$key}[0]){
1498 $grpname=$customservicegrp{$key}[0];
1499 $remark=$customservicegrp{$key}[1];
1500 if($count >=2){print"</table>";}
1501 print "<br><b><u>$grpname</u></b>     ";
1502 print "<b>$Lang::tr{'remark'}:</b>  $remark " if ($remark ne '');
1503 print "  <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[5] x";
1504 if($customservicegrp{$key}[5] == '0')
1506 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>";
1508 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>";
1509 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>";
1511 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1512 print" <tr bgcolor='${Header::colouryellow}'>";
1513 }elsif ($count %2 == 0){print"<tr bgcolor='$color{'color22'}'>";}else{print"<tr bgcolor='$color{'color20'}'>";}
1514 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1515 print"<td align='center'>$customservicegrp{$key}[3]</td><td align='center'>$customservicegrp{$key}[4]</td><td width='1%'><form method='post'>";
1516 if ($number gt '1'){
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='delgrpservice'><input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2],$customservicegrp{$key}[3]'></form></td></tr>";
1520 $helper=$customservicegrp{$key}[0];
1523 &Header
::closebox
();
1529 my %hash=%{(shift)};
1530 foreach my $key (keys %hash) {
1531 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1541 my %hash=%{(shift)};
1543 foreach my $key (keys %hash) {
1544 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1553 my %hash=%{(shift)};
1554 &General
::readhasharray
("$confignet", \
%hash);
1555 foreach my $key (keys %hash) {
1556 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1563 sub checkservicegroup
1565 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1569 if ( ! &General
::validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1571 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1572 return $errormessage;
1575 if ( ($fwhostsettings{'SRVGRP_REMARK'} ne '') && (! &validhostname
($fwhostsettings{'SRVGRP_REMARK'})))
1577 $errormessage.=$Lang::tr
{'fwhost err remark'}."<br>";
1579 #check empty selectbox
1580 if (keys %customservice lt 1)
1582 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1585 #check if name already exists
1586 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1587 foreach my $key (keys %customservicegrp) {
1588 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1589 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1594 #check if service already exists in group
1595 foreach my $key (keys %customservicegrp) {
1596 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1597 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1604 return $errormessage;
1608 if ($errormessage) {
1609 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1610 print "<class name='base'>$errormessage\n";
1611 print " </class>\n";
1612 &Header
::closebox
();
1618 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1619 print "<class name='base'>$hint\n";
1620 print " </class>\n";
1621 &Header
::closebox
();
1627 &General
::setup_default_networks
(\
%defaultNetworks);
1628 foreach my $network (sort keys %defaultNetworks)
1630 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1638 &General
::readhasharray
("$config",\
%hash);
1639 foreach my $key (keys %hash) {
1640 $errormessage.="lese $hash{$key}[2] und $target<br>";
1641 if($hash{$key}[2] eq $target){
1644 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1647 &General
::writehasharray
("$config",\
%hash);
1655 if (!&General
::validhostname
($fwhostsettings{'HOSTNAME'}))
1657 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1658 $fwhostsettings{'BLK_IP'}='readonly';
1659 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1660 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1662 #check if name collides with CCD Netname
1664 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1665 foreach my $key (keys %ccdnet) {
1666 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1667 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1668 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1669 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1674 #check if IP collides with CCD NetIP
1675 if ($fwhostsettings{'type'} ne 'mac'){
1676 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1677 foreach my $key (keys %ccdnet) {
1678 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1679 if($ccdnet{$key}[1] eq $test){
1680 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1681 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1682 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1683 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1691 #check if name collides with CCD Hostname
1692 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1693 foreach my $key (keys %ccdhost) {
1694 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1695 if($ip eq $fwhostsettings{'IP'}){
1696 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1697 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1701 #check if IP collides with CCD HostIP (only hosts)
1702 if ($edit eq 'edithost')
1704 foreach my $key (keys %ccdhost) {
1705 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1706 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1707 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1708 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1713 #check if network with this name already exists
1714 &General
::readhasharray
("$confignet", \
%customnetwork);
1715 if (!&checkname
(\
%customnetwork))
1717 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1718 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1719 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1721 #check if network ip already exists
1722 if (!&checkip
(\
%customnetwork,1))
1724 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1725 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1727 #check if host with this name already exists
1728 &General
::readhasharray
("$confighost", \
%customhost);
1729 if (!&checkname
(\
%customhost))
1731 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err hostexist'};
1732 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1733 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1735 #check if host with this ip already exists
1736 if (!&checkip
(\
%customhost,2))
1738 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1751 #get address from IPSEC NETWORK
1752 if ($type eq 'IpSec Network'){
1753 foreach my $key (keys %ipsecconf) {
1754 if ($ipsecconf{$key}[1] eq $name){
1755 return $ipsecconf{$key}[11];
1758 &deletefromgrp
($name,$configgrp);
1761 #get address from IPSEC HOST
1762 if ($type eq 'IpSec Host'){
1763 foreach my $key (keys %ipsecconf) {
1764 if ($ipsecconf{$key}[1] eq $name){
1765 return $ipsecconf{$key}[10];
1768 &deletefromgrp
($name,$configgrp);
1771 #get address from ovpn ccd Net-2-Net
1772 if ($type eq 'OpenVPN N-2-N'){
1773 foreach my $key (keys %ccdhost) {
1774 if($ccdhost{$key}[1] eq $name){
1775 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1776 $b=&General
::iporsubtodec
($b);
1780 &deletefromgrp
($name,$configgrp);
1783 #get address from ovpn ccd static host
1784 if ($type eq 'OpenVPN static host'){
1785 foreach my $key (keys %ccdhost) {
1786 if($ccdhost{$key}[1] eq $name){
1787 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1788 $b=&General
::iporsubtodec
($b);
1792 &deletefromgrp
($name,$configgrp);
1795 #get address from ovpn ccd static net
1796 if ($type eq 'OpenVPN static network'){
1797 foreach my $key (keys %ccdnet) {
1798 if ($ccdnet{$key}[0] eq $name){
1799 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1800 $b=&General
::iporsubtodec
($b);
1806 #check custom addresses
1807 if ($type eq 'Custom Host'){
1808 foreach my $key (keys %customhost) {
1809 if ($customhost{$key}[0] eq $name){
1810 return $customhost{$key}[2];
1815 ##check custom networks
1816 if ($type eq 'Custom Network'){
1817 foreach my $key (keys %customnetwork) {
1818 if($customnetwork{$key}[0] eq $name){
1819 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
1824 #check standard networks
1825 if ($type eq 'Standard Network'){
1826 if ($name =~ /OpenVPN/i){
1828 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
1829 return $ovpn{'DOVPN_SUBNET'};
1831 if ($name eq 'GREEN'){
1833 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1834 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
1836 if ($name eq 'BLUE'){
1838 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1839 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
1841 if ($name eq 'ORANGE'){
1843 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1844 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
1846 if ($name eq 'ALL'){
1847 return "0.0.0.0/0.0.0.0";
1849 if ($name =~ /IPsec/i){
1851 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
1852 return $hash{'RW_NET'};
1858 system ("/usr/local/bin/forwardfwctrl");
1859 system("rm ${General::swroot}/forward/reread");
1864 &General
::readhasharray
("$confignet", \
%customnetwork);
1865 &General
::readhasharray
("$confighost", \
%customhost);
1866 foreach my $key (sort keys %customgrp ){
1867 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
1868 foreach my $key1 (sort keys %customnetwork){
1869 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
1870 $customnetwork{$key1}[3]=$customnetwork{$key1}[3]-1;
1876 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
1877 foreach my $key2 (sort keys %customhost){
1878 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
1879 $customhost{$key2}[3]=$customhost{$key2}[3]-1;
1886 &General
::writehasharray
("$confignet", \
%customnetwork);
1887 &General
::writehasharray
("$confighost", \
%customhost);
1892 &General
::readhasharray
("$configsrv", \
%customservice);
1893 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1895 foreach my $key (sort keys %customservicegrp){
1896 if ($customservicegrp{$key}[0] eq $grp ){
1897 foreach my $key2 (sort keys %customservice){
1898 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
1899 $customservice{$key2}[4]--;
1904 &General
::writehasharray
("$configsrv", \
%customservice);
1910 my %hash=%{(shift)};
1912 if ($fwhostsettings{'SRV_NAME'} eq '' ){
1913 $errormessage=$Lang::tr
{'fwhost err name1'};
1915 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
1916 $errormessage=$Lang::tr
{'fwhost err port'};
1919 if (! &General
::validhostname
($fwhostsettings{'SRV_NAME'})){
1920 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
1922 #change dashes with :
1923 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
1925 if ($fwhostsettings{'SRV_PORT'} eq "*") {
1926 $fwhostsettings{'SRV_PORT'} = "1:65535";
1928 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
1929 $fwhostsettings{'SRV_PORT'} = "1:$2";
1931 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
1932 $fwhostsettings{'SRV_PORT'} = "$1:65535";
1934 if($fwhostsettings{'PROT'} ne 'ICMP'){
1935 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
1937 # a new service has to have a different name
1938 foreach my $key (keys %hash){
1939 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
1940 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
1944 return $errormessage;
1948 # Checks a hostname against RFC1035
1949 my $hostname = $_[0];
1951 # Each part should be at least two characters in length
1952 # but no more than 63 characters
1953 if (length ($hostname) < 1 || length ($hostname) > 63) {
1955 # Only valid characters are a-z, A-Z, 0-9 and -
1956 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-\s]*$/) {
1958 # First character can only be a letter or a digit
1959 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
1961 # Last character can only be a letter or a digit
1962 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
1967 &Header
::closebigbox
();
1968 &Header
::closepage
();