]>
git.ipfire.org Git - 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');
84 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
86 &General
::readhasharray
("$confignet", \
%customnetwork);
87 foreach my $key (keys %customnetwork)
89 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
91 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
92 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
93 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
94 $fwhostsettings{'count'} = $customnetwork{$key}[3];
95 delete $customnetwork{$key};
99 &General
::writehasharray
("$confignet", \
%customnetwork);
100 $fwhostsettings{'actualize'} = 'on';
101 $fwhostsettings{'ACTION'} = 'savenet';
103 if ($fwhostsettings{'ACTION'} eq 'updatehost')
106 &General
::readhasharray
("$confighost", \
%customhost);
107 foreach my $key (keys %customhost)
109 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
111 if ($customhost{$key}[1] eq 'ip'){
112 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
114 $ip = $customhost{$key}[2];
116 $fwhostsettings{'orgip'} = $ip;
117 $fwhostsettings{'count'} = $customhost{$key}[3];
118 delete $customhost{$key};
119 &General
::writehasharray
("$confighost", \
%customhost);
122 $fwhostsettings{'actualize'} = 'on';
123 if($fwhostsettings{'orgip'}){
124 $fwhostsettings{'ACTION'} = 'savehost';
126 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
129 if ($fwhostsettings{'ACTION'} eq 'updateservice')
133 $errormessage=&checkports
(\
%customservice);
135 &General
::readhasharray
("$configsrv", \
%customservice);
136 foreach my $key (keys %customservice)
138 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
140 $count=$customservice{$key}[4];
141 delete $customservice{$key};
142 &General
::writehasharray
("$configsrv", \
%customservice);
146 if ($fwhostsettings{'PROT'} ne 'ICMP'){
147 $fwhostsettings{'ICMP_TYPES'}='BLANK';
149 my $key1 = &General
::findhasharraykey
(\
%customservice);
150 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
151 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
152 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
153 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
154 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
155 $customservice{$key1}[4] = $count;
156 &General
::writehasharray
("$configsrv", \
%customservice);
157 #check if we need to update firewallrules
158 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
159 if ( ! -z
$fwconfigfwd ){
160 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
161 foreach my $key (sort keys %fwfwd){
162 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
163 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
166 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
168 if ( ! -z
$fwconfiginp ){
169 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
170 foreach my $line (sort keys %fwinp){
171 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
172 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
175 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
177 #check if we need to update groups
178 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
179 foreach my $key (sort keys %customservicegrp){
180 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
181 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
184 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
190 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
193 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
197 $fwhostsettings{'SRV_NAME'} = '';
198 $fwhostsettings{'SRV_PORT'} = '';
199 $fwhostsettings{'PROT'} = '';
201 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
202 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
203 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
204 $fwhostsettings{'updatesrv'}= 'on';
206 if($needrules eq 'on'){
212 if ($fwhostsettings{'ACTION'} eq 'savenet' )
216 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
217 #check if all fields are set
218 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
220 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
225 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
227 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
228 $fwhostsettings{'BLK_HOST'} ='readonly';
229 $fwhostsettings{'NOCHECK'} ='false';
230 $fwhostsettings{'error'} ='on';
232 #check if subnet is sigle host
233 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
235 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
237 if($fwhostsettings{'error'} ne 'on'){
238 #check if we use one of ipfire's networks (green,orange,blue)
239 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
241 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
242 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
243 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
245 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
247 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
248 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
249 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
251 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
253 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
254 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
255 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
257 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
259 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
260 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
261 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
264 #only check plausi when no error till now
266 &plausicheck
("editnet");
268 #check if network ip is part of an already used one
269 if(&checksubnet
(\
%customnetwork))
271 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
272 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
274 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
276 $fwhostsettings{'actualize'} = '';
277 my $key = &General
::findhasharraykey
(\
%customnetwork);
278 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
279 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
280 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
281 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
282 $customnetwork{$key}[3] = $fwhostsettings{'count'};
283 &General
::writehasharray
("$confignet", \
%customnetwork);
284 undef %customnetwork;
287 &General
::readhasharray
("$confignet", \
%customnetwork);
288 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
289 if ($fwhostsettings{'update'} == '0'){
290 foreach my $key (keys %customnetwork) {
291 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
292 $count=$customnetwork{$key}[3];
293 delete $customnetwork{$key};
299 #get count if actualize is 'on'
300 if($fwhostsettings{'actualize'} eq 'on'){
301 $fwhostsettings{'actualize'} = '';
302 $count=$fwhostsettings{'count'};
303 #check if we need to reload rules
304 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
307 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
308 #check if we need to update groups
309 &General
::readhasharray
("$configgrp", \
%customgrp);
310 foreach my $key (sort keys %customgrp){
311 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
312 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
316 &General
::writehasharray
("$configgrp", \
%customgrp);
317 #check if we need to update firewallrules
318 if ( ! -z
$fwconfigfwd ){
319 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
320 foreach my $line (sort keys %fwfwd){
321 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
322 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
324 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
325 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
328 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
330 if ( ! -z
$fwconfiginp ){
331 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
332 foreach my $line (sort keys %fwinp){
333 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
334 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
337 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
341 my $key = &General
::findhasharraykey
(\
%customnetwork);
342 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
343 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
344 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
345 #convert ip when leading '0' in byte
346 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
347 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
348 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
349 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
350 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
351 $customnetwork{$key}[3] = $count;
352 &General
::writehasharray
("$confignet", \
%customnetwork);
353 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
354 undef %customnetwork;
355 $fwhostsettings{'HOSTNAME'}='';
356 $fwhostsettings{'IP'}='';
357 $fwhostsettings{'SUBNET'}='';
358 #check if an edited net affected groups and need to reload rules
359 if ($needrules eq 'on'){
371 if ($fwhostsettings{'ACTION'} eq 'savehost')
375 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
376 $fwhostsettings{'SUBNET'}='32';
377 #check if all fields are set
378 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
380 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
381 $fwhostsettings{'ACTION'} = 'edithost';
383 if($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
384 $fwhostsettings{'type'} = 'mac';
385 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
386 $fwhostsettings{'type'} = 'ip';
387 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
388 $fwhostsettings{'type'} = 'mac';
389 }elsif($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
390 $fwhostsettings{'type'} = 'ip';
392 $fwhostsettings{'type'} = '';
393 $errormessage=$Lang::tr
{'fwhost err ipmac'};
395 if($fwhostsettings{'type'} eq 'mac' )
397 if ($fwhostsettings{'IP'}!~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/ )
399 $errormessage=$Lang::tr
{'fwhost err mac'};
403 if ($fwhostsettings{'type'} eq 'ip'){
405 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
406 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
408 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
409 $fwhostsettings{'error'}='on';
411 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
412 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
413 $fwhostsettings{'error'}='on';
415 #check if net or broadcast
416 my @tmp= split (/\./,$fwhostsettings{'IP'});
417 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
418 $errormessage=$Lang::tr
{'fwhost err hostip'};
421 #only check plausi when no error till now
423 &plausicheck
("edithost");
425 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
426 $fwhostsettings{'actualize'} = '';
427 my $key = &General
::findhasharraykey
(\
%customhost);
428 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
429 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
430 $customhost{$key}[1] = $fwhostsettings{'type'} ;
431 if($customhost{$key}[1] eq 'ip'){
432 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
434 $customhost{$key}[2] = $fwhostsettings{'orgip'};
436 $customhost{$key}[3] = $fwhostsettings{'count'};
437 &General
::writehasharray
("$confighost", \
%customhost);
441 #get count if host was edited
442 if($fwhostsettings{'actualize'} eq 'on'){
443 $count=$fwhostsettings{'count'};
444 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
447 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
448 #check if we need to update groups
449 &General
::readhasharray
("$configgrp", \
%customgrp);
450 foreach my $key (sort keys %customgrp){
451 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
452 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
456 &General
::writehasharray
("$configgrp", \
%customgrp);
457 #check if we need to update firewallrules
458 if ( ! -z
$fwconfigfwd ){
459 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
460 foreach my $line (sort keys %fwfwd){
461 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
462 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
464 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
465 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
468 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
470 if ( ! -z
$fwconfiginp ){
471 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
472 foreach my $line (sort keys %fwinp){
473 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
474 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
477 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
481 my $key = &General
::findhasharraykey
(\
%customhost);
482 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
483 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
484 $customhost{$key}[1] = $fwhostsettings{'type'} ;
485 if ($fwhostsettings{'type'} eq 'ip'){
486 #convert ip when leading '0' in byte
487 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
488 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
489 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
491 $customhost{$key}[2] = $fwhostsettings{'IP'};
493 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
494 $customhost{$key}[3] = $count;
495 &General
::writehasharray
("$confighost", \
%customhost);
497 $fwhostsettings{'HOSTNAME'}='';
498 $fwhostsettings{'IP'}='';
499 $fwhostsettings{'type'}='';
500 #check if we need to update rules while host was edited
501 if($needrules eq 'on'){
512 if ($fwhostsettings{'ACTION'} eq 'savegrp')
515 my $rem=$fwhostsettings{'remark'};
518 my $updcounter='off';
521 &General
::readhasharray
("$configgrp", \
%customgrp);
522 &General
::readhasharray
("$confignet", \
%customnetwork);
523 &General
::readhasharray
("$confighost", \
%customhost);
524 $grp=$fwhostsettings{'grp_name'};
525 if (!&validhostname
($grp)){$errormessage=$errormessage.$Lang::tr
{'fwhost err name'};}
526 ###check standard networks
527 if ($fwhostsettings{'grp2'} eq 'std_net'){
528 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
529 $type='Standard Network';
531 ##check custom networks
532 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
533 @target=$fwhostsettings{'CUST_SRC_NET'};
535 $type='Custom Network';
536 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
537 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
538 $fwhostsettings{'grp_name'}='';
539 $fwhostsettings{'remark'}='';
541 #check custom addresses
542 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
543 @target=$fwhostsettings{'CUST_SRC_HOST'};
546 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
547 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
548 $fwhostsettings{'grp_name'}='';
549 $fwhostsettings{'remark'}='';
551 #get address from ovpn ccd static net
552 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
553 @target=$fwhostsettings{'OVPN_CCD_NET'};
554 $type='OpenVPN static network';
555 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
556 $errormessage=$Lang::tr
{'fwhost err groupempty'};
557 $fwhostsettings{'grp_name'}='';
558 $fwhostsettings{'remark'}='';
560 #get address from ovpn ccd static host
561 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
562 @target=$fwhostsettings{'OVPN_CCD_HOST'};
563 $type='OpenVPN static host';
564 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
565 $errormessage=$Lang::tr
{'fwhost err groupempty'};
567 #get address from ovpn ccd Net-2-Net
568 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
569 @target=$fwhostsettings{'OVPN_N2N'};
570 $type='OpenVPN N-2-N';
571 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
572 $errormessage=$Lang::tr
{'fwhost err groupempty'};
573 $fwhostsettings{'grp_name'}='';
574 $fwhostsettings{'remark'}='';
576 #get address from IPSEC HOST
577 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
578 @target=$fwhostsettings{'IPSEC_HOST'};
580 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
581 $errormessage=$Lang::tr
{'fwhost err groupempty'};
582 $fwhostsettings{'grp_name'}='';
583 $fwhostsettings{'remark'}='';
585 #get address from IPSEC NETWORK
586 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
587 @target=$fwhostsettings{'IPSEC_NET'};
588 $type='IpSec Network';
589 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
590 $errormessage=$Lang::tr
{'fwhost err groupempty'};
591 $fwhostsettings{'grp_name'}='';
592 $fwhostsettings{'remark'}='';
594 #check if host/net exists in grp
595 my $test="$grp,$fwhostsettings{'oldremark'},@target";
596 foreach my $key (keys %customgrp) {
597 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
598 if ($test1 eq $test){
599 $errormessage=$Lang::tr
{'fwhost err isingrp'};
600 $fwhostsettings{'update'} = 'on';
604 #on first save, we have an empty @target, so fill it with nothing
605 my $targetvalues=@target;
606 if ($targetvalues == '0'){
607 @target=$Lang::tr
{'fwhost empty'};
609 #on update, we have to delete the dummy entry
610 foreach my $key (keys %customgrp){
611 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq $Lang::tr
{'fwhost empty'}){
612 delete $customgrp{$key};
616 &General
::writehasharray
("$configgrp", \
%customgrp);
617 &General
::readhasharray
("$configgrp", \
%customgrp);
619 foreach my $key (keys %customgrp)
621 if($customgrp{$key}[0] eq $grp)
623 $count=$customgrp{$key}[4];
627 if ($count eq '' ){$count='0';}
629 #create array with new lines
630 foreach my $line (@target){
631 push (@newgrp,"$grp,$rem,$line");
634 my $key = &General
::findhasharraykey
(\
%customgrp);
635 foreach my $line (@newgrp){
636 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
637 my ($a,$b,$c,$d) = split (",",$line);
638 $customgrp{$key}[0] = $a;
639 $customgrp{$key}[1] = $b;
640 $customgrp{$key}[2] = $c;
641 $customgrp{$key}[3] = $type;
642 $customgrp{$key}[4] = $count;
644 &General
::writehasharray
("$configgrp", \
%customgrp);
645 #update counter in Host/Net
646 if($updcounter eq 'net'){
647 foreach my $key (keys %customnetwork) {
648 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
649 $customnetwork{$key}[3] = $customnetwork{$key}[3]+1;
653 &General
::writehasharray
("$confignet", \
%customnetwork);
654 }elsif($updcounter eq 'host'){
655 foreach my $key (keys %customhost) {
656 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
657 $customhost{$key}[3]=$customhost{$key}[3]+1;
660 &General
::writehasharray
("$confighost", \
%customhost);
662 $fwhostsettings{'update'}='on';
664 if ($fwhostsettings{'remark'} ne $fwhostsettings{'oldremark'} )
666 foreach my $key (sort keys %customgrp)
668 if($customgrp{$key}[0] eq $grp && $customgrp{$key}[1] eq $fwhostsettings{'oldremark'})
670 $customgrp{$key}[1]='';
671 $customgrp{$key}[1]=$rem;
674 &General
::writehasharray
("$configgrp", \
%customgrp);
676 $fwhostsettings{'update'}='on';
678 #check if ruleupdate is needed
686 if ($fwhostsettings{'ACTION'} eq 'saveservice')
689 &General
::readhasharray
("$configsrv", \
%customservice );
690 $errormessage=&checkports
(\
%customservice);
691 if ($fwhostsettings{'PROT'} eq 'ICMP'){
692 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
693 foreach my $key (keys %icmptypes){
694 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
695 $ICMP=$icmptypes{$key}[0];
699 if($ICMP eq ''){$ICMP='BLANK';}
701 my $key = &General
::findhasharraykey
(\
%customservice);
702 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
703 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
704 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
705 $customservice{$key}[2] = $fwhostsettings{'PROT'};
706 $customservice{$key}[3] = $ICMP;
707 $customservice{$key}[4] = 0;
708 &General
::writehasharray
("$configsrv", \
%customservice );
710 $fwhostsettings{'SRV_NAME'}='';
711 $fwhostsettings{'SRV_PORT'}='';
712 $fwhostsettings{'PROT'}='';
713 $fwhostsettings{'ICMP_TYPES'}='';
717 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
722 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
723 &General
::readhasharray
("$configsrv", \
%customservice );
724 $errormessage=&checkservicegroup
;
726 #on first save, we have to enter a dummy value
727 if ($fwhostsettings{'CUST_SRV'} eq ''){$fwhostsettings{'CUST_SRV'}=$Lang::tr
{'fwhost empty'};}
728 #on update, we have to delete the dummy entry
729 foreach my $key (keys %customservicegrp){
730 if ($customservicegrp{$key}[2] eq $Lang::tr
{'fwhost empty'}){
731 delete $customservicegrp{$key};
735 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
736 #check if remark has also changed
737 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
739 foreach my $key (keys %customservicegrp)
741 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
743 $customservicegrp{$key}[1]='';
744 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
749 foreach my $key (keys %customservicegrp)
751 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
753 $count=$customservicegrp{$key}[3];
757 if ($count eq '' ){$count='0';}
759 foreach my $key (sort keys %customservice){
760 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
761 $port=$customservice{$key}[1];
762 $prot=$customservice{$key}[2];
763 $customservice{$key}[4]++;
766 &General
::writehasharray
("$configsrv", \
%customservice );
767 my $key = &General
::findhasharraykey
(\
%customservicegrp);
768 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
769 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
770 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
771 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
772 $customservicegrp{$key}[3] = $count;
773 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
774 $fwhostsettings{'updatesrvgrp'}='on';
776 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $errormessage){
777 foreach my $key (keys %customservicegrp)
779 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
781 $customservicegrp{$key}[1]='';
782 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
785 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
787 $hint=$Lang::tr
{'fwhost changeremark'};
788 $fwhostsettings{'update'}='on';
794 &viewtableservicegrp
;
797 if ($fwhostsettings{'ACTION'} eq 'editnet')
802 if ($fwhostsettings{'ACTION'} eq 'edithost')
807 if ($fwhostsettings{'ACTION'} eq 'editgrp')
809 $fwhostsettings{'update'}='on';
813 if ($fwhostsettings{'ACTION'} eq 'editservice')
815 $fwhostsettings{'updatesrv'}='on';
818 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
820 $fwhostsettings{'updatesrvgrp'} = 'on';
822 &viewtableservicegrp
;
825 if ($fwhostsettings{'ACTION'} eq 'resetnet')
827 $fwhostsettings{'HOSTNAME'} ="";
828 $fwhostsettings{'IP'} ="";
829 $fwhostsettings{'SUBNET'} ="";
832 if ($fwhostsettings{'ACTION'} eq 'resethost')
834 $fwhostsettings{'HOSTNAME'} ="";
835 $fwhostsettings{'IP'} ="";
836 $fwhostsettings{'type'} ="";
840 if ($fwhostsettings{'ACTION'} eq 'delnet')
842 &General
::readhasharray
("$confignet", \
%customnetwork);
843 foreach my $key (keys %customnetwork) {
844 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
845 delete $customnetwork{$key};
846 &General
::writehasharray
("$confignet", \
%customnetwork);
853 if ($fwhostsettings{'ACTION'} eq 'delhost')
855 &General
::readhasharray
("$confighost", \
%customhost);
856 foreach my $key (keys %customhost) {
857 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
858 delete $customhost{$key};
859 &General
::writehasharray
("$confighost", \
%customhost);
866 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
868 &General
::readhasharray
("$configgrp", \
%customgrp);
869 foreach my $key (keys %customgrp){
870 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
871 #decrease count from source host/net
872 if ($customgrp{$key}[3] eq 'Custom Network'){
873 &General
::readhasharray
("$confignet", \
%customnetwork);
874 foreach my $key1 (keys %customnetwork){
875 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
876 $customnetwork{$key1}[3] = $customnetwork{$key1}[3]-1;
880 &General
::writehasharray
("$confignet", \
%customnetwork);
882 if ($customgrp{$key}[3] eq 'Custom Host'){
883 &General
::readhasharray
("$confighost", \
%customhost);
884 foreach my $key1 (keys %customhost){
885 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
886 $customhost{$key1}[3] = $customhost{$key1}[3]-1;
890 &General
::writehasharray
("$confighost", \
%customhost);
892 delete $customgrp{$key};
895 &General
::writehasharray
("$configgrp", \
%customgrp);
900 if ($fwhostsettings{'ACTION'} eq 'delgrp')
902 &General
::readhasharray
("$configgrp", \
%customgrp);
903 &decrease
($fwhostsettings{'grp_name'});
904 foreach my $key (sort keys %customgrp)
906 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
908 delete $customgrp{$key};
911 &General
::writehasharray
("$configgrp", \
%customgrp);
912 $fwhostsettings{'grp_name'}='';
916 if ($fwhostsettings{'ACTION'} eq 'delservice')
918 &General
::readhasharray
("$configsrv", \
%customservice);
919 foreach my $key (keys %customservice) {
920 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
921 #&deletefromgrp($customhost{$key}[0],$configgrp);
922 delete $customservice{$key};
923 &General
::writehasharray
("$configsrv", \
%customservice);
927 $fwhostsettings{'SRV_NAME'}='';
928 $fwhostsettings{'SRV_PORT'}='';
929 $fwhostsettings{'PROT'}='';
932 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
934 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
935 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
936 foreach my $key (sort keys %customservicegrp)
938 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
940 delete $customservicegrp{$key};
943 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
944 $fwhostsettings{'SRVGRP_NAME'}='';
946 &viewtableservicegrp
;
948 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 delete $customservicegrp{$key}
966 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
969 &viewtableservicegrp
;
972 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
977 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
982 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
987 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
991 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
994 &viewtableservicegrp
;
997 if($fwhostsettings{'ACTION'} eq '')
1005 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1007 <table border='0' width='100%'><form method='post'>
1008 <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>
1009 <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>
1010 <tr><td colspan='6'><hr></hr></td></tr></table></form>
1013 &Header
::closebox
();
1021 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1022 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1024 <table border='0' width='100%'><form method='post' style='display:inline' >
1025 <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>
1026 <tr><td colspan='6'><hr></hr></td></tr><tr>
1028 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1030 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'}'>";
1032 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'>";
1034 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>";
1035 &Header
::closebox
();
1041 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1042 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1044 <table border='0' width='100%'><form method='post' style='display:inline'>
1045 <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'>
1047 if ($fwhostsettings{'type'} eq 'ip'){print "<option value='ip' selected >IP</option>";}else{print "<option value='ip' >IP</option>";}
1048 if ($fwhostsettings{'type'} eq 'mac'){print "<option value='mac' selected >MAC</option>";}else{print "<option value='mac' >MAC</option>";}
1050 </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>
1051 <tr><td colspan='7'><br><br><b>$Lang::tr{'fwhost attention'}</b><br>$Lang::tr{'fwhost macwarn'}</td></tr>
1052 <tr><td colspan='7'><hr></hr></td></tr>
1055 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1058 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>";
1060 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'>";
1062 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>";
1063 &Header
::closebox
();
1070 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1071 &General
::setup_default_networks
(\
%defaultNetworks);
1073 $checked{'check1'}{'off'} = '';
1074 $checked{'check1'}{'on'} = '';
1075 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1076 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1078 if ($fwhostsettings{'update'} eq ''){
1080 <table width='100%' border='0'><form method='post'>
1081 <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>
1082 <tr><td colspan='5'><hr></td></tr></table>
1086 <table width='100%' border='0'><form method='post'>
1087 <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>
1088 <tr><td colspan='5'><hr></td></tr></table>
1092 if ($fwhostsettings{'update'} eq 'on'){
1096 <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;'>
1099 foreach my $network (sort keys %defaultNetworks)
1101 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1102 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1103 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1104 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1105 print ">$network</option>";
1109 </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;'>
1111 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1112 foreach my $key (sort { uc($ccdnet{$a}[0]) cmp uc($ccdnet{$b}[0]) } keys %ccdnet)
1114 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1119 <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;'>
1121 &General
::readhasharray
("$confignet", \
%customnetwork);
1122 foreach my $key (sort { uc($customnetwork{$a}[0]) cmp uc($customnetwork{$b}[0]) } keys %customnetwork) {
1123 print"<option>$customnetwork{$key}[0]</option>";
1127 </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;'>
1129 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1130 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1132 if ($ccdhost{$key}[33] ne ''){
1133 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1139 <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;'>
1141 &General
::readhasharray
("$confighost", \
%customhost);
1142 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0]) } keys %customhost) {
1143 print"<option>$customhost{$key}[0]</option>";
1146 </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;'>
1148 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1149 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1150 if($ccdhost{$key}[3] eq 'net'){
1151 print"<option>$ccdhost{$key}[1]</option>";
1156 <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;'>
1158 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1159 foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1160 if ($ipsecconf{$key}[3] eq 'net'){
1161 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1165 </select></td></tr></table>
1167 # <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;'>
1169 # &General::readhasharray("$configipsec", \%ipsecconf);
1170 # foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1171 # if ($ipsecconf{$key}[3] eq 'host'){
1172 # print"<option>$ipsecconf{$key}[1]</option>";
1176 # </select></td></tr>
1180 <b>$Lang::tr{'fwhost attention'}:</b><br>
1181 $Lang::tr{'fwhost macwarn'}<br><hr>
1185 <table border='0' width='100%'>
1186 <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>
1190 &Header
::closebox
();
1196 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservice'});
1197 if ($fwhostsettings{'updatesrv'} eq 'on')
1199 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1200 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1201 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1204 <table width='100%' border='0'><form method='post'>
1205 <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'>
1207 foreach ("TCP","UDP","ICMP")
1209 if ($_ eq $fwhostsettings{'PROT'})
1211 print"<option selected>$_</option>";
1213 print"<option>$_</option>";
1217 </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>
1218 <tr><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='4'><select name='ICMP_TYPES'>
1220 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1221 print"<option>All ICMP-Types</option>";
1222 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1223 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1228 <tr><td colspan='6'><hr></td></tr>
1229 <tr><td colspan='6' align='right'>
1231 if ($fwhostsettings{'updatesrv'} eq 'on')
1234 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1235 <input type='hidden' name='ACTION' value='updateservice'>
1236 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1237 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1238 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1242 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1245 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1250 &Header
::closebox
();
1258 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservicegrp'});
1259 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1261 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1263 <table width='100%' border='0'><form method='post'>
1264 <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>
1265 <tr><td colspan='4'><hr></td></td></tr>
1270 <table width='100%' border='0'><form method='post'>
1271 <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>
1272 <tr><td colspan='4'><hr></td></td></tr>
1276 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1278 <table border='0' width='100%'>
1279 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1281 &General
::readhasharray
("$configsrv", \
%customservice);
1282 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
1284 print "<option>$customservice{$key}[0]</option>";
1288 <tr><td colspan='4'><br><br><br></td></tr>
1289 <tr><td colspan='4'><hr></td></tr>
1294 <table width='100%' border='0'>
1295 <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>
1299 &Header
::closebox
();
1304 if(! -z
$confignet){
1305 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1306 &General
::readhasharray
("$confignet", \
%customnetwork);
1307 if (!keys %customnetwork)
1309 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1312 <table border='0' width='100%'>
1313 <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>
1317 foreach my $key (sort {$a <=> $b} keys %customnetwork) {
1318 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1319 print" <tr bgcolor='${Header::colouryellow}'>";
1322 print" <tr bgcolor='$color{'color22'}'>";
1325 print" <tr bgcolor='$color{'color20'}'>";
1328 <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>
1329 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1330 <input type='hidden' name='ACTION' value='editnet'>
1331 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1332 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1333 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1336 if($customnetwork{$key}[3] == '0')
1338 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>";
1340 print"<td></td></form></tr>";
1345 &Header
::closebox
();
1351 if (! -z
$confighost){
1352 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1353 &General
::readhasharray
("$confighost", \
%customhost);
1354 if (!keys %customhost)
1356 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1359 <table border='0' width='100%'>
1360 <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>
1364 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0])|| $a <=> $b } keys %customhost) {
1365 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1366 print" <tr bgcolor='${Header::colouryellow}'>";
1367 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1368 else{ print" <tr bgcolor='$color{'color20'}'>";}
1369 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1371 <td width='40%'><form method='post'>$customhost{$key}[0]</td><td width='50%'>$ip</td><td align='center'>$customhost{$key}[3]x</td>
1372 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1373 <input type='hidden' name='ACTION' value='edithost' />
1374 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1375 <input type='hidden' name='IP' value='$ip' />
1376 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1379 if($customhost{$key}[3] == '0')
1381 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>";
1383 print"<td width='1%'></td></tr>";
1388 &Header
::closebox
();
1393 if(! -z
"$configgrp"){
1394 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1395 &General
::readhasharray
("$configgrp", \
%customgrp);
1396 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1397 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1398 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1399 &General
::readhasharray
("$confighost", \
%customhost);
1400 &General
::readhasharray
("$confignet", \
%customnetwork);
1406 my $number=keys %customgrp;
1407 if (!keys %customgrp)
1409 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1411 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){
1414 if ($helper ne $customgrp{$key}[0]){
1415 $grpname=$customgrp{$key}[0];
1416 $remark=$customgrp{$key}[1];
1417 if($count >=2){print"</table>";}
1418 print "<br><b><u>$grpname</u></b>    ";
1419 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1420 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1421 if($customgrp{$key}[4] == '0')
1423 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>";
1425 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>";
1426 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>";
1428 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1429 print" <tr bgcolor='${Header::colouryellow}'>";
1430 }elsif ($count %2 == 0){print"<tr bgcolor='$color{'color22'}'>";}else{print"<tr bgcolor='$color{'color20'}'>";}
1431 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1432 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1435 print "<td width='39%'>";
1436 if($customgrp{$key}[3] eq 'Standard Network'){
1437 print &get_name
($customgrp{$key}[2])."</td>";
1439 print "$customgrp{$key}[2]</td>";
1441 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost empty'}){
1442 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1444 print"<td>$ip</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1446 if ($number gt '1' && $ip ne ''){
1447 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1449 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>";
1451 $helper=$customgrp{$key}[0];
1456 &Header
::closebox
();
1460 sub viewtableservice
1463 if(! -z
"$configsrv")
1465 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1466 &General
::readhasharray
("$configsrv", \
%customservice);
1468 <table width='100%' border='0'>
1469 <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>
1471 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
1474 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1475 print" <tr bgcolor='${Header::colouryellow}'>";
1476 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1478 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1480 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1483 </td><td align='center'>$customservice{$key}[4]x</td>
1484 <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' />
1485 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1486 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1487 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1489 if ($customservice{$key}[4] eq '0')
1491 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>";
1493 print"<td></td></tr>";
1497 &Header
::closebox
();
1500 sub viewtableservicegrp
1508 if (! -z
$configsrvgrp){
1509 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1510 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1511 &General
::readhasharray
("$configsrv", \
%customservice);
1512 my $number= keys %customservicegrp;
1513 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0])|| $a <=> $b } keys %customservicegrp){
1515 if ($helper ne $customservicegrp{$key}[0]){
1516 $grpname=$customservicegrp{$key}[0];
1517 $remark=$customservicegrp{$key}[1];
1518 if($count >=2){print"</table>";}
1519 print "<br><b><u>$grpname</u></b>     ";
1520 print "<b>$Lang::tr{'remark'}:</b>  $remark " if ($remark ne '');
1521 print "  <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1522 if($customservicegrp{$key}[3] == '0')
1524 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>";
1526 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>";
1527 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>";
1529 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1530 print" <tr bgcolor='${Header::colouryellow}'>";
1532 if ($count %2 == 0){
1533 print"<tr bgcolor='$color{'color22'}'>";
1535 print"<tr bgcolor='$color{'color20'}'>";
1537 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1538 foreach my $srv (sort keys %customservice){
1539 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1540 $protocol=$customservice{$srv}[2];
1541 $port=$customservice{$srv}[1];
1545 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1546 if ($number gt '1'){
1547 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1549 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>";
1550 $helper=$customservicegrp{$key}[0];
1553 &Header
::closebox
();
1559 my %hash=%{(shift)};
1560 foreach my $key (keys %hash) {
1561 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1571 my %hash=%{(shift)};
1573 foreach my $key (keys %hash) {
1574 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1583 my %hash=%{(shift)};
1584 &General
::readhasharray
("$confignet", \
%hash);
1585 foreach my $key (keys %hash) {
1586 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1593 sub checkservicegroup
1595 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1599 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1601 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1602 return $errormessage;
1605 if ( ($fwhostsettings{'SRVGRP_REMARK'} ne '') && (! &validhostname
($fwhostsettings{'SRVGRP_REMARK'})))
1607 $errormessage.=$Lang::tr
{'fwhost err remark'}."<br>";
1609 #check empty selectbox
1610 if (keys %customservice lt 1)
1612 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1614 #check if name already exists
1615 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1616 foreach my $key (keys %customservicegrp) {
1617 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1618 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1623 #check if service already exists in group
1624 foreach my $key (keys %customservicegrp) {
1625 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1626 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1629 return $errormessage;
1633 if ($errormessage) {
1634 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1635 print "<class name='base'>$errormessage\n";
1636 print " </class>\n";
1637 &Header
::closebox
();
1643 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1644 print "<class name='base'>$hint\n";
1645 print " </class>\n";
1646 &Header
::closebox
();
1652 &General
::setup_default_networks
(\
%defaultNetworks);
1653 foreach my $network (sort keys %defaultNetworks)
1655 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1663 &General
::readhasharray
("$config",\
%hash);
1664 foreach my $key (keys %hash) {
1665 $errormessage.="lese $hash{$key}[2] und $target<br>";
1666 if($hash{$key}[2] eq $target){
1669 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1672 &General
::writehasharray
("$config",\
%hash);
1680 if (!&General
::validhostname
($fwhostsettings{'HOSTNAME'}))
1682 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1683 $fwhostsettings{'BLK_IP'}='readonly';
1684 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1685 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1687 #check if name collides with CCD Netname
1689 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1690 foreach my $key (keys %ccdnet) {
1691 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1692 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1693 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1694 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1699 #check if IP collides with CCD NetIP
1700 if ($fwhostsettings{'type'} ne 'mac'){
1701 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1702 foreach my $key (keys %ccdnet) {
1703 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1704 if($ccdnet{$key}[1] eq $test){
1705 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1706 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1707 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1708 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1716 #check if name collides with CCD Hostname
1717 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1718 foreach my $key (keys %ccdhost) {
1719 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1720 if($ip eq $fwhostsettings{'IP'}){
1721 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1722 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1726 #check if IP collides with CCD HostIP (only hosts)
1727 if ($edit eq 'edithost')
1729 foreach my $key (keys %ccdhost) {
1730 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1731 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1732 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1733 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1738 #check if network with this name already exists
1739 &General
::readhasharray
("$confignet", \
%customnetwork);
1740 if (!&checkname
(\
%customnetwork))
1742 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1743 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1744 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1746 #check if network ip already exists
1747 if (!&checkip
(\
%customnetwork,1))
1749 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1750 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1752 #check if host with this name already exists
1753 &General
::readhasharray
("$confighost", \
%customhost);
1754 if (!&checkname
(\
%customhost))
1756 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1757 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1758 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1760 #check if host with this ip already exists
1761 if (!&checkip
(\
%customhost,2))
1763 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1775 #get address from IPSEC NETWORK
1776 if ($type eq 'IpSec Network'){
1777 foreach my $key (keys %ipsecconf) {
1778 if ($ipsecconf{$key}[1] eq $name){
1779 return $ipsecconf{$key}[11];
1782 &deletefromgrp
($name,$configgrp);
1785 #get address from IPSEC HOST
1786 if ($type eq 'IpSec Host'){
1787 foreach my $key (keys %ipsecconf) {
1788 if ($ipsecconf{$key}[1] eq $name){
1789 return $ipsecconf{$key}[10];
1792 &deletefromgrp
($name,$configgrp);
1795 #get address from ovpn ccd Net-2-Net
1796 if ($type eq 'OpenVPN N-2-N'){
1797 foreach my $key (keys %ccdhost) {
1798 if($ccdhost{$key}[1] eq $name){
1799 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1800 $b=&General
::iporsubtodec
($b);
1804 &deletefromgrp
($name,$configgrp);
1807 #get address from ovpn ccd static host
1808 if ($type eq 'OpenVPN static host'){
1809 foreach my $key (keys %ccdhost) {
1810 if($ccdhost{$key}[1] eq $name){
1811 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1812 $b=&General
::iporsubtodec
($b);
1816 &deletefromgrp
($name,$configgrp);
1819 #get address from ovpn ccd static net
1820 if ($type eq 'OpenVPN static network'){
1821 foreach my $key (keys %ccdnet) {
1822 if ($ccdnet{$key}[0] eq $name){
1823 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1824 $b=&General
::iporsubtodec
($b);
1830 #check custom addresses
1831 if ($type eq 'Custom Host'){
1832 foreach my $key (keys %customhost) {
1833 if ($customhost{$key}[0] eq $name){
1834 return $customhost{$key}[2];
1839 ##check custom networks
1840 if ($type eq 'Custom Network'){
1841 foreach my $key (keys %customnetwork) {
1842 if($customnetwork{$key}[0] eq $name){
1843 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
1848 #check standard networks
1849 if ($type eq 'Standard Network'){
1850 if ($name =~ /OpenVPN/i){
1852 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
1853 return $ovpn{'DOVPN_SUBNET'};
1855 if ($name eq 'GREEN'){
1857 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1858 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
1860 if ($name eq 'BLUE'){
1862 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1863 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
1865 if ($name eq 'ORANGE'){
1867 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1868 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
1870 if ($name eq 'ALL'){
1871 return "0.0.0.0/0.0.0.0";
1873 if ($name =~ /IPsec/i){
1875 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
1876 return $hash{'RW_NET'};
1882 system ("/usr/local/bin/forwardfwctrl");
1883 system("rm ${General::swroot}/forward/reread");
1888 &General
::readhasharray
("$confignet", \
%customnetwork);
1889 &General
::readhasharray
("$confighost", \
%customhost);
1890 foreach my $key (sort keys %customgrp ){
1891 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
1892 foreach my $key1 (sort keys %customnetwork){
1893 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
1894 $customnetwork{$key1}[3]=$customnetwork{$key1}[3]-1;
1900 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
1901 foreach my $key2 (sort keys %customhost){
1902 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
1903 $customhost{$key2}[3]=$customhost{$key2}[3]-1;
1910 &General
::writehasharray
("$confignet", \
%customnetwork);
1911 &General
::writehasharray
("$confighost", \
%customhost);
1916 &General
::readhasharray
("$configsrv", \
%customservice);
1917 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1919 foreach my $key (sort keys %customservicegrp){
1920 if ($customservicegrp{$key}[0] eq $grp ){
1921 foreach my $key2 (sort keys %customservice){
1922 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
1923 $customservice{$key2}[4]--;
1928 &General
::writehasharray
("$configsrv", \
%customservice);
1934 my %hash=%{(shift)};
1936 if ($fwhostsettings{'SRV_NAME'} eq '' ){
1937 $errormessage=$Lang::tr
{'fwhost err name1'};
1939 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
1940 $errormessage=$Lang::tr
{'fwhost err port'};
1943 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
1944 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
1946 #change dashes with :
1947 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
1949 if ($fwhostsettings{'SRV_PORT'} eq "*") {
1950 $fwhostsettings{'SRV_PORT'} = "1:65535";
1952 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
1953 $fwhostsettings{'SRV_PORT'} = "1:$2";
1955 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
1956 $fwhostsettings{'SRV_PORT'} = "$1:65535";
1958 if($fwhostsettings{'PROT'} ne 'ICMP'){
1959 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
1961 # a new service has to have a different name
1962 foreach my $key (keys %hash){
1963 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
1964 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
1968 return $errormessage;
1972 # Checks a hostname against RFC1035
1973 my $hostname = $_[0];
1975 # Each part should be at least two characters in length
1976 # but no more than 63 characters
1977 if (length ($hostname) < 1 || length ($hostname) > 63) {
1979 # Only valid characters are a-z, A-Z, 0-9 and -
1980 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_()\/\s
]*$/) {
1982 # First character can only be a letter or a digit
1983 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
1985 # Last character can only be a letter or a digit
1986 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
1991 &Header
::closebigbox
();
1992 &Header
::closepage
();