]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/fwhosts.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2011 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
21 # New function for forwarding firewall. To make it comfortable to create #
22 # rules, we need "spelling names" for single Hosts. If you have any questions #
23 # <amarx@ipfire.org> #
24 ###############################################################################
27 # enable only the following on debugging purpose
29 use CGI
::Carp
'fatalsToBrowser';
30 no warnings
'uninitialized';
31 require '/var/ipfire/general-functions.pl';
32 require "${General::swroot}/lang.pl";
33 require "${General::swroot}/header.pl";
35 my %fwhostsettings=();
40 my %customservicegrp=();
46 my %defaultNetworks=();
56 my $confignet = "${General::swroot}/fwhosts/customnetworks";
57 my $confighost = "${General::swroot}/fwhosts/customhosts";
58 my $configgrp = "${General::swroot}/fwhosts/customgroups";
59 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
60 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
61 my $configipsec = "${General::swroot}/vpn/config";
62 my $configsrv = "${General::swroot}/fwhosts/customservices";
63 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
64 my $fwconfigfwd = "${General::swroot}/forward/config";
65 my $fwconfiginp = "${General::swroot}/forward/input";
67 unless (-e
$confignet) { system("touch $confignet"); }
68 unless (-e
$confighost) { system("touch $confighost"); }
69 unless (-e
$configgrp) { system("touch $configgrp"); }
70 unless (-e
$configsrv) { system("touch $configsrv"); }
71 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
73 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
74 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
75 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
76 &Header
::getcgihash
(\
%fwhostsettings);
78 &Header
::showhttpheaders
();
79 &Header
::openpage
($Lang::tr
{'fwhost hosts'}, 1, '');
80 &Header
::openbigbox
('100%', 'center');
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 $fwhostsettings{'orgname'} = $customhost{$key}[0];
112 if ($customhost{$key}[1] eq 'ip'){
113 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
115 $ip = $customhost{$key}[2];
117 $fwhostsettings{'orgip'} = $ip;
118 $fwhostsettings{'count'} = $customhost{$key}[3];
119 delete $customhost{$key};
122 &General
::writehasharray
("$confighost", \
%customhost);
126 $fwhostsettings{'actualize'} = 'on';
127 $fwhostsettings{'ACTION'} = 'savehost';
129 if ($fwhostsettings{'ACTION'} eq 'updateservice')
133 $errormessage=&checkports
(\
%customservice);
136 &General
::readhasharray
("$configsrv", \
%customservice);
137 foreach my $key (keys %customservice)
139 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
141 $count=$customservice{$key}[4];
142 delete $customservice{$key};
143 &General
::writehasharray
("$configsrv", \
%customservice);
147 if ($fwhostsettings{'PROT'} ne 'ICMP'){
148 $fwhostsettings{'ICMP_TYPES'}='BLANK';
150 my $key1 = &General
::findhasharraykey
(\
%customservice);
151 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
152 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
153 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
154 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
155 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
156 $customservice{$key1}[4] = $count;
157 &General
::writehasharray
("$configsrv", \
%customservice);
158 if($fwhostsettings{'updatesrv'} eq 'on'){
159 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
162 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
166 $fwhostsettings{'SRV_NAME'} = '';
167 $fwhostsettings{'SRV_PORT'} = '';
168 $fwhostsettings{'PROT'} = '';
171 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
172 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
173 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
174 $fwhostsettings{'updatesrv'}= 'on';
177 if($needrules eq 'on'){
178 $errormessage="reread!";
185 if ($fwhostsettings{'ACTION'} eq 'savenet' )
189 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
191 #check if all fields are set
192 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
194 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
199 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
201 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
202 $fwhostsettings{'BLK_HOST'} ='readonly';
203 $fwhostsettings{'NOCHECK'} ='false';
204 $fwhostsettings{'error'} ='on';
206 #check if subnet is sigle host
207 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
209 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
212 if($fwhostsettings{'error'} ne 'on'){
213 #check if we use one of ipfire's networks (green,orange,blue)
214 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
216 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
217 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
218 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
220 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
222 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
223 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
224 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
226 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
228 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
229 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
230 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
232 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
234 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
235 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
236 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
239 #only check plausi when no error till now
241 &plausicheck
("editnet");
244 #check if network ip is part of an already used one
245 if(&checksubnet
(\
%customnetwork))
247 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
248 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
251 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
253 $fwhostsettings{'actualize'} = '';
254 my $key = &General
::findhasharraykey
(\
%customnetwork);
255 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
256 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
257 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
258 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
259 $customnetwork{$key}[3] = $fwhostsettings{'count'};
260 &General
::writehasharray
("$confignet", \
%customnetwork);
261 undef %customnetwork;
265 &General
::readhasharray
("$confignet", \
%customnetwork);
266 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
267 if ($fwhostsettings{'update'} == '0'){
268 foreach my $key (keys %customnetwork) {
269 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
270 $count=$customnetwork{$key}[3];
271 delete $customnetwork{$key};
277 #get count if actualize is 'on'
278 if($fwhostsettings{'actualize'} eq 'on'){
279 $fwhostsettings{'actualize'} = '';
280 $count=$fwhostsettings{'count'};
281 #check if we need to reload rules
282 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
285 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
286 #check if we need to update groups
287 &General
::readhasharray
("$configgrp", \
%customgrp);
288 foreach my $key (sort keys %customgrp){
289 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
290 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
294 &General
::writehasharray
("$configgrp", \
%customgrp);
295 #check if we need to update firewallrules
296 if ( ! -z
$fwconfigfwd ){
297 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
298 foreach my $line (sort keys %fwfwd){
299 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
300 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
302 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
303 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
306 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
308 if ( ! -z
$fwconfiginp ){
309 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
310 foreach my $line (sort keys %fwinp){
311 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
312 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
315 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
319 my $key = &General
::findhasharraykey
(\
%customnetwork);
320 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
321 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
322 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
323 #convert ip when leading '0' in byte
324 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
325 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
326 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
327 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
328 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
329 $customnetwork{$key}[3] = $count;
330 &General
::writehasharray
("$confignet", \
%customnetwork);
331 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
332 undef %customnetwork;
333 $fwhostsettings{'HOSTNAME'}='';
334 $fwhostsettings{'IP'}='';
335 $fwhostsettings{'SUBNET'}='';
336 #check if an edited net affected groups and need to reload rules
337 if ($needrules eq 'on'){
350 if ($fwhostsettings{'ACTION'} eq 'savehost')
354 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
356 $fwhostsettings{'SUBNET'}='32';
358 #check if all fields are set
359 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
361 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
362 $fwhostsettings{'ACTION'} = 'edithost';
365 if($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
366 $fwhostsettings{'type'} = 'mac';
367 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
368 $fwhostsettings{'type'} = 'ip';
369 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
370 $fwhostsettings{'type'} = 'mac';
371 }elsif($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
372 $fwhostsettings{'type'} = 'ip';
374 $fwhostsettings{'type'} = '';
375 $errormessage=$Lang::tr
{'fwhost err ipmac'};
378 if($fwhostsettings{'type'} eq 'mac' )
380 if ($fwhostsettings{'IP'}!~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/ )
382 $errormessage=$Lang::tr
{'fwhost err mac'};
387 if ($fwhostsettings{'type'} eq 'ip'){
389 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
390 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
392 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
393 $fwhostsettings{'error'}='on';
396 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
397 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
398 $fwhostsettings{'error'}='on';
400 #check if net or broadcast
401 my @tmp= split (/\./,$fwhostsettings{'IP'});
402 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
403 $errormessage=$Lang::tr
{'fwhost err hostip'};
409 #only check plausi when no error till now
411 &plausicheck
("edithost");
414 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
415 $fwhostsettings{'actualize'} = '';
416 my $key = &General
::findhasharraykey
(\
%customhost);
417 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
418 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
419 $customhost{$key}[1] = $fwhostsettings{'type'} ;
420 if($customhost{$key}[1] eq 'ip'){
421 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
423 $customhost{$key}[2] = $fwhostsettings{'orgip'};
425 $customhost{$key}[3] = $fwhostsettings{'count'};
426 &General
::writehasharray
("$confighost", \
%customhost);
432 #get count if host was edited
433 if($fwhostsettings{'actualize'} eq 'on'){
434 $count=$fwhostsettings{'count'};
435 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
438 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
439 #check if we need to update groups
440 &General
::readhasharray
("$configgrp", \
%customgrp);
441 foreach my $key (sort keys %customgrp){
442 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
443 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
447 &General
::writehasharray
("$configgrp", \
%customgrp);
448 #check if we need to update firewallrules
449 if ( ! -z
$fwconfigfwd ){
450 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
451 foreach my $line (sort keys %fwfwd){
452 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
453 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
455 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
456 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
459 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
461 if ( ! -z
$fwconfiginp ){
462 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
463 foreach my $line (sort keys %fwinp){
464 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
465 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
468 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
472 my $key = &General
::findhasharraykey
(\
%customhost);
473 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
474 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
475 $customhost{$key}[1] = $fwhostsettings{'type'} ;
476 if ($fwhostsettings{'type'} eq 'ip'){
477 #convert ip when leading '0' in byte
478 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
479 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
480 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
482 $customhost{$key}[2] = $fwhostsettings{'IP'};
484 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
485 $customhost{$key}[3] = $count;
486 &General
::writehasharray
("$confighost", \
%customhost);
488 #$fwhostsettings{'IP'} = $fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'});
490 $fwhostsettings{'HOSTNAME'}='';
491 $fwhostsettings{'IP'}='';
492 $fwhostsettings{'type'}='';
493 #check if we need to update rules while host was edited
494 if($needrules eq 'on'){
507 if ($fwhostsettings{'ACTION'} eq 'savegrp')
510 my $rem=$fwhostsettings{'remark'};
513 my $updcounter='off';
516 &General
::readhasharray
("$configgrp", \
%customgrp);
517 &General
::readhasharray
("$confignet", \
%customnetwork);
518 &General
::readhasharray
("$confighost", \
%customhost);
519 $grp=$fwhostsettings{'grp_name'};
521 if (!&General
::validhostname
($grp)){$errormessage=$errormessage.$Lang::tr
{'fwhost err name'};}
523 ###check standard networks
524 if ($fwhostsettings{'grp2'} eq 'std_net'){
525 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
526 $type='Standard Network';
528 ##check custom networks
529 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
530 @target=$fwhostsettings{'CUST_SRC_NET'};
532 $type='Custom Network';
533 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
534 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
535 $fwhostsettings{'grp_name'}='';
536 $fwhostsettings{'remark'}='';
538 #check custom addresses
539 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
540 @target=$fwhostsettings{'CUST_SRC_HOST'};
543 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
544 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
545 $fwhostsettings{'grp_name'}='';
546 $fwhostsettings{'remark'}='';
548 #get address from ovpn ccd static net
549 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
550 @target=$fwhostsettings{'OVPN_CCD_NET'};
551 $type='OpenVPN static network';
552 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
553 $errormessage=$Lang::tr
{'fwhost err groupempty'};
554 $fwhostsettings{'grp_name'}='';
555 $fwhostsettings{'remark'}='';
557 #get address from ovpn ccd static host
558 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
559 @target=$fwhostsettings{'OVPN_CCD_HOST'};
560 $type='OpenVPN static host';
561 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
562 $errormessage=$Lang::tr
{'fwhost err groupempty'};
564 #get address from ovpn ccd Net-2-Net
565 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
566 @target=$fwhostsettings{'OVPN_N2N'};
567 $type='OpenVPN N-2-N';
568 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
569 $errormessage=$Lang::tr
{'fwhost err groupempty'};
570 $fwhostsettings{'grp_name'}='';
571 $fwhostsettings{'remark'}='';
574 #get address from IPSEC HOST
575 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
576 @target=$fwhostsettings{'IPSEC_HOST'};
578 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
579 $errormessage=$Lang::tr
{'fwhost err groupempty'};
580 $fwhostsettings{'grp_name'}='';
581 $fwhostsettings{'remark'}='';
583 #get address from IPSEC NETWORK
584 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
585 @target=$fwhostsettings{'IPSEC_NET'};
586 $type='IpSec Network';
587 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
588 $errormessage=$Lang::tr
{'fwhost err groupempty'};
589 $fwhostsettings{'grp_name'}='';
590 $fwhostsettings{'remark'}='';
593 #check if host/net exists in grp
594 my $test="$grp,$fwhostsettings{'oldremark'},@target";
595 foreach my $key (keys %customgrp) {
596 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
597 if ($test1 eq $test){
598 $errormessage=$Lang::tr
{'fwhost err isingrp'};
599 $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
611 foreach my $key (keys %customgrp){
612 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq $Lang::tr
{'fwhost empty'}){
613 delete $customgrp{$key};
617 &General
::writehasharray
("$configgrp", \
%customgrp);
618 &General
::readhasharray
("$configgrp", \
%customgrp);
622 #check if remark has also changed
623 if ($fwhostsettings{'remark'} ne $fwhostsettings{'oldremark'} && $fwhostsettings{'update'} eq 'on')
625 foreach my $key (keys %customgrp)
627 if($customgrp{$key}[0] eq $grp && $customgrp{$key}[1] eq $fwhostsettings{'oldremark'})
629 $customgrp{$key}[1]='';
630 $customgrp{$key}[1]=$rem;
635 foreach my $key (keys %customgrp)
637 if($customgrp{$key}[0] eq $grp)
639 $count=$customgrp{$key}[4];
643 if ($count eq '' ){$count='0';}
645 #create array with new lines
646 foreach my $line (@target){
647 push (@newgrp,"$grp,$rem,$line");
650 my $key = &General
::findhasharraykey
(\
%customgrp);
651 foreach my $line (@newgrp){
652 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
653 my ($a,$b,$c,$d) = split (",",$line);
654 $customgrp{$key}[0] = $a;
655 $customgrp{$key}[1] = $b;
656 $customgrp{$key}[2] = $c;
657 $customgrp{$key}[3] = $type;
658 $customgrp{$key}[4] = $count;
660 &General
::writehasharray
("$configgrp", \
%customgrp);
662 #update counter in Host/Net
663 if($updcounter eq 'net'){
664 foreach my $key (keys %customnetwork) {
665 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
666 $customnetwork{$key}[3] = $customnetwork{$key}[3]+1;
670 &General
::writehasharray
("$confignet", \
%customnetwork);
671 }elsif($updcounter eq 'host'){
672 foreach my $key (keys %customhost) {
673 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
674 $customhost{$key}[3]=$customhost{$key}[3]+1;
677 &General
::writehasharray
("$confighost", \
%customhost);
680 $fwhostsettings{'update'}='on';
683 if ($fwhostsettings{'remark'} ne $fwhostsettings{'oldremark'} && $errormessage)
685 foreach my $key (keys %customgrp)
687 if($customgrp{$key}[0] eq $grp && $customgrp{$key}[1] eq $fwhostsettings{'oldremark'})
689 $customgrp{$key}[1]='';
690 $customgrp{$key}[1]=$rem;
693 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
695 $hint=$Lang::tr
{'fwhost changeremark'};
696 $fwhostsettings{'update'}='on';
698 #check if ruleupdate is needed
707 if ($fwhostsettings{'ACTION'} eq 'saveservice')
711 &General
::readhasharray
("$configsrv", \
%customservice );
712 $errormessage=&checkports
(\
%customservice);
714 if ($fwhostsettings{'PROT'} eq 'ICMP'){
715 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
716 foreach my $key (keys %icmptypes){
717 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
718 $ICMP=$icmptypes{$key}[0];
722 if($ICMP eq ''){$ICMP='BLANK';}
725 my $key = &General
::findhasharraykey
(\
%customservice);
726 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
727 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
728 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
729 $customservice{$key}[2] = $fwhostsettings{'PROT'};
730 $customservice{$key}[3] = $ICMP;
731 $customservice{$key}[4] = 0;
732 &General
::writehasharray
("$configsrv", \
%customservice );
734 $fwhostsettings{'SRV_NAME'}='';
735 $fwhostsettings{'SRV_PORT'}='';
736 $fwhostsettings{'PROT'}='';
737 $fwhostsettings{'ICMP_TYPES'}='';
744 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
749 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
750 &General
::readhasharray
("$configsrv", \
%customservice );
752 $errormessage=&checkservicegroup
;
755 #on first save, we have to enter a dummy value
756 if ($fwhostsettings{'CUST_SRV'} eq ''){$fwhostsettings{'CUST_SRV'}=$Lang::tr
{'fwhost empty'};}
758 #on update, we have to delete the dummy entry
759 foreach my $key (keys %customservicegrp){
760 if ($customservicegrp{$key}[2] eq $Lang::tr
{'fwhost empty'}){
761 delete $customservicegrp{$key};
765 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
766 #check if remark has also changed
767 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
769 foreach my $key (keys %customservicegrp)
771 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
773 $customservicegrp{$key}[1]='';
774 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
779 foreach my $key (keys %customservicegrp)
781 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
783 $count=$customservicegrp{$key}[5];
787 if ($count eq '' ){$count='0';}
789 foreach my $key (sort keys %customservice){
790 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
791 $port=$customservice{$key}[1];
792 $prot=$customservice{$key}[2];
793 $customservice{$key}[4]++;
796 &General
::writehasharray
("$configsrv", \
%customservice );
798 my $key = &General
::findhasharraykey
(\
%customservicegrp);
799 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
800 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
801 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
802 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
803 $customservicegrp{$key}[3] = $port;
804 $customservicegrp{$key}[4] = $prot;
805 $customservicegrp{$key}[5] = $count;
806 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
807 $fwhostsettings{'updatesrvgrp'}='on';
809 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $errormessage){
810 foreach my $key (keys %customservicegrp)
812 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
814 $customservicegrp{$key}[1]='';
815 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
818 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
820 $hint=$Lang::tr
{'fwhost changeremark'};
821 $fwhostsettings{'update'}='on';
827 &viewtableservicegrp
;
830 if ($fwhostsettings{'ACTION'} eq 'editnet')
835 if ($fwhostsettings{'ACTION'} eq 'edithost')
840 if ($fwhostsettings{'ACTION'} eq 'editgrp')
842 $fwhostsettings{'update'}='on';
846 if ($fwhostsettings{'ACTION'} eq 'editservice')
848 $fwhostsettings{'updatesrv'}='on';
851 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
853 $fwhostsettings{'updatesrvgrp'} = 'on';
855 &viewtableservicegrp
;
858 if ($fwhostsettings{'ACTION'} eq 'resetnet')
860 $fwhostsettings{'HOSTNAME'} ="";
861 $fwhostsettings{'IP'} ="";
862 $fwhostsettings{'SUBNET'} ="";
865 if ($fwhostsettings{'ACTION'} eq 'resethost')
867 $fwhostsettings{'HOSTNAME'} ="";
868 $fwhostsettings{'IP'} ="";
869 $fwhostsettings{'type'} ="";
873 if ($fwhostsettings{'ACTION'} eq 'delnet')
875 &General
::readhasharray
("$confignet", \
%customnetwork);
876 foreach my $key (keys %customnetwork) {
877 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
878 delete $customnetwork{$key};
879 &General
::writehasharray
("$confignet", \
%customnetwork);
886 if ($fwhostsettings{'ACTION'} eq 'delhost')
888 &General
::readhasharray
("$confighost", \
%customhost);
889 foreach my $key (keys %customhost) {
890 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
891 delete $customhost{$key};
892 &General
::writehasharray
("$confighost", \
%customhost);
900 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
902 &General
::readhasharray
("$configgrp", \
%customgrp);
903 foreach my $key (keys %customgrp){
904 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
905 #decrease count from source host/net
906 if ($customgrp{$key}[3] eq 'Custom Network'){
907 &General
::readhasharray
("$confignet", \
%customnetwork);
908 foreach my $key1 (keys %customnetwork){
909 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
910 $customnetwork{$key1}[3] = $customnetwork{$key1}[3]-1;
914 &General
::writehasharray
("$confignet", \
%customnetwork);
916 if ($customgrp{$key}[3] eq 'Custom Host'){
917 &General
::readhasharray
("$confighost", \
%customhost);
918 foreach my $key1 (keys %customhost){
919 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
920 $customhost{$key1}[3] = $customhost{$key1}[3]-1;
924 &General
::writehasharray
("$confighost", \
%customhost);
926 delete $customgrp{$key};
929 &General
::writehasharray
("$configgrp", \
%customgrp);
934 if ($fwhostsettings{'ACTION'} eq 'delgrp')
936 &General
::readhasharray
("$configgrp", \
%customgrp);
937 &decrease
($fwhostsettings{'grp_name'});
938 foreach my $key (sort keys %customgrp)
940 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
942 delete $customgrp{$key};
945 &General
::writehasharray
("$configgrp", \
%customgrp);
946 $fwhostsettings{'grp_name'}='';
950 if ($fwhostsettings{'ACTION'} eq 'delservice')
952 &General
::readhasharray
("$configsrv", \
%customservice);
953 foreach my $key (keys %customservice) {
954 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
955 #&deletefromgrp($customhost{$key}[0],$configgrp);
956 delete $customservice{$key};
957 &General
::writehasharray
("$configsrv", \
%customservice);
961 $fwhostsettings{'SRV_NAME'}='';
962 $fwhostsettings{'SRV_PORT'}='';
963 $fwhostsettings{'PROT'}='';
966 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
968 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
969 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
970 foreach my $key (sort keys %customservicegrp)
972 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
974 delete $customservicegrp{$key};
977 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
978 $fwhostsettings{'SRVGRP_NAME'}='';
980 &viewtableservicegrp
;
982 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
984 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
985 &General
::readhasharray
("$configsrv", \
%customservice);
986 foreach my $key (keys %customservicegrp){
987 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
989 #decrease count from source service
990 foreach my $key1 (sort keys %customservice){
991 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
992 $customservice{$key1}[4]--;
996 &General
::writehasharray
("$configsrv", \
%customservice);
997 delete $customservicegrp{$key}
1000 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1003 &viewtableservicegrp
;
1006 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1011 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1016 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1021 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1025 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1028 &viewtableservicegrp
;
1031 if($fwhostsettings{'ACTION'} eq '')
1039 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1041 <table border='0' width='100%'><form method='post'>
1042 <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>
1043 <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>
1044 <tr><td colspan='6'><hr></hr></td></tr></table></form>
1047 &Header
::closebox
();
1055 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1056 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1058 <table border='0' width='100%'><form method='post' style='display:inline' >
1059 <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>
1060 <tr><td colspan='6'><hr></hr></td></tr><tr>
1062 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1064 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'}'>";
1066 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'>";
1068 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>";
1069 &Header
::closebox
();
1075 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1076 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1078 <table border='0' width='100%'><form method='post' style='display:inline'>
1079 <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'>
1081 if ($fwhostsettings{'type'} eq 'ip'){print "<option value='ip' selected >IP</option>";}else{print "<option value='ip' >IP</option>";}
1082 if ($fwhostsettings{'type'} eq 'mac'){print "<option value='mac' selected >MAC</option>";}else{print "<option value='mac' >MAC</option>";}
1084 </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>
1085 <tr><td colspan='7'><br><br><b>$Lang::tr{'fwhost attention'}</b><br>$Lang::tr{'fwhost macwarn'}</td></tr>
1086 <tr><td colspan='7'><hr></hr></td></tr>
1089 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1092 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>";
1094 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'>";
1096 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>";
1097 &Header
::closebox
();
1104 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1105 &General
::setup_default_networks
(\
%defaultNetworks);
1107 $checked{'check1'}{'off'} = '';
1108 $checked{'check1'}{'on'} = '';
1109 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1110 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1112 if ($fwhostsettings{'update'} eq ''){
1114 <table width='100%' border='0'><form method='post'>
1115 <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>
1116 <tr><td colspan='5'><hr></td></tr></table>
1120 <table width='100%' border='0'><form method='post'>
1121 <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>
1122 <tr><td colspan='5'><hr></td></tr></table>
1126 if ($fwhostsettings{'update'} eq 'on'){
1130 <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;'>
1133 foreach my $network (sort keys %defaultNetworks)
1135 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1136 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1137 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1138 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1139 print ">$network</option>";
1143 </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;'>
1145 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1146 foreach my $key (sort { uc($ccdnet{$a}[0]) cmp uc($ccdnet{$b}[0]) } keys %ccdnet)
1148 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1153 <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;'>
1155 &General
::readhasharray
("$confignet", \
%customnetwork);
1156 foreach my $key (sort { uc($customnetwork{$a}[0]) cmp uc($customnetwork{$b}[0]) } keys %customnetwork) {
1157 print"<option>$customnetwork{$key}[0]</option>";
1161 </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;'>
1163 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1164 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1166 if ($ccdhost{$key}[33] ne ''){
1167 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1173 <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;'>
1175 &General
::readhasharray
("$confighost", \
%customhost);
1176 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0]) } keys %customhost) {
1177 print"<option>$customhost{$key}[0]</option>";
1180 </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;'>
1182 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1183 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1184 if($ccdhost{$key}[3] eq 'net'){
1185 print"<option>$ccdhost{$key}[1]</option>";
1190 <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;'>
1192 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1193 foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1194 if ($ipsecconf{$key}[3] eq 'net'){
1195 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1199 </select></td></tr></table>
1201 # <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;'>
1203 # &General::readhasharray("$configipsec", \%ipsecconf);
1204 # foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1205 # if ($ipsecconf{$key}[3] eq 'host'){
1206 # print"<option>$ipsecconf{$key}[1]</option>";
1210 # </select></td></tr>
1214 <b>$Lang::tr{'fwhost attention'}:</b><br>
1215 $Lang::tr{'fwhost macwarn'}<br><hr>
1219 <table border='0' width='100%'>
1220 <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>
1224 &Header
::closebox
();
1230 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservice'});
1231 if ($fwhostsettings{'updatesrv'} eq 'on')
1233 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1234 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1235 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1238 <table width='100%' border='0'><form method='post'>
1239 <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'>
1241 foreach ("TCP","UDP","ICMP")
1243 if ($_ eq $fwhostsettings{'PROT'})
1245 print"<option selected>$_</option>";
1247 print"<option>$_</option>";
1251 </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>
1252 <tr><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='4'><select name='ICMP_TYPES'>
1254 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1255 print"<option>All ICMP-Types</option>";
1256 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1257 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1262 <tr><td colspan='6'><hr></td></tr>
1263 <tr><td colspan='6' align='right'>
1265 if ($fwhostsettings{'updatesrv'} eq 'on')
1268 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1269 <input type='hidden' name='ACTION' value='updateservice'>
1270 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1271 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1272 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1276 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1279 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1284 &Header
::closebox
();
1292 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservicegrp'});
1293 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1295 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1297 <table width='100%' border='0'><form method='post'>
1298 <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>
1299 <tr><td colspan='4'><hr></td></td></tr>
1304 <table width='100%' border='0'><form method='post'>
1305 <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>
1306 <tr><td colspan='4'><hr></td></td></tr>
1310 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1312 <table border='0' width='100%'>
1313 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1315 &General
::readhasharray
("$configsrv", \
%customservice);
1316 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice)
1318 print "<option>$customservice{$key}[0]</option>";
1322 <tr><td colspan='4'><br><br><br></td></tr>
1323 <tr><td colspan='4'><hr></td></tr>
1328 <table width='100%' border='0'>
1329 <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>
1333 &Header
::closebox
();
1338 if(! -z
$confignet){
1339 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1340 &General
::readhasharray
("$confignet", \
%customnetwork);
1341 if (!keys %customnetwork)
1343 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1346 <table border='0' width='100%'>
1347 <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>
1351 foreach my $key (sort { uc($customnetwork{$a}[0]) cmp uc($customnetwork{$b}[0]) } keys %customnetwork) {
1352 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1353 print" <tr bgcolor='${Header::colouryellow}'>";
1356 print" <tr bgcolor='$color{'color22'}'>";
1359 print" <tr bgcolor='$color{'color20'}'>";
1362 <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>
1363 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1364 <input type='hidden' name='ACTION' value='editnet'>
1365 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1366 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1367 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1370 if($customnetwork{$key}[3] == '0')
1372 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>";
1374 print"<td></td></form></tr>";
1379 &Header
::closebox
();
1385 if (! -z
$confighost){
1386 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1387 &General
::readhasharray
("$confighost", \
%customhost);
1388 if (!keys %customhost)
1390 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1393 <table border='0' width='100%'>
1394 <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>
1398 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0]) } keys %customhost) {
1399 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1400 print" <tr bgcolor='${Header::colouryellow}'>";
1401 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1402 else{ print" <tr bgcolor='$color{'color20'}'>";}
1403 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1405 <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>
1406 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1407 <input type='hidden' name='ACTION' value='edithost' />
1408 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1409 <input type='hidden' name='IP' value='$ip' />
1410 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1413 if($customhost{$key}[3] == '0')
1415 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>";
1417 print"<td width='1%'></td></tr>";
1422 &Header
::closebox
();
1427 if(! -z
"$configgrp"){
1428 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1429 &General
::readhasharray
("$configgrp", \
%customgrp);
1430 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1431 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1432 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1433 &General
::readhasharray
("$confighost", \
%customhost);
1434 &General
::readhasharray
("$confignet", \
%customnetwork);
1440 my $number=keys %customgrp;
1441 if (!keys %customgrp)
1443 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1445 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){
1448 if ($helper ne $customgrp{$key}[0]){
1449 $grpname=$customgrp{$key}[0];
1450 $remark=$customgrp{$key}[1];
1451 if($count >=2){print"</table>";}
1452 print "<br><b><u>$grpname</u></b>    ";
1453 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1454 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4] x";
1455 if($customgrp{$key}[4] == '0')
1457 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>";
1459 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>";
1460 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>";
1462 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1463 print" <tr bgcolor='${Header::colouryellow}'>";
1464 }elsif ($count %2 == 0){print"<tr bgcolor='$color{'color22'}'>";}else{print"<tr bgcolor='$color{'color20'}'>";}
1465 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1466 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1469 print "<td width='39%'>";
1470 if($customgrp{$key}[3] eq 'Standard Network'){
1471 print &get_name
($customgrp{$key}[2])."</td>";
1473 print "$customgrp{$key}[2]</td>";
1475 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost empty'}){
1476 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1478 print"<td>$ip</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1480 if ($number gt '1' && $ip ne ''){
1481 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1483 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>";
1485 $helper=$customgrp{$key}[0];
1490 &Header
::closebox
();
1494 sub viewtableservice
1497 if(! -z
"$configsrv")
1499 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1500 &General
::readhasharray
("$configsrv", \
%customservice);
1502 <table width='100%' border='0'>
1503 <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>
1505 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice)
1508 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1509 print" <tr bgcolor='${Header::colouryellow}'>";
1510 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1512 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1514 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1517 </td><td align='center'>$customservice{$key}[4]x</td>
1518 <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' />
1519 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1520 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1521 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1523 if ($customservice{$key}[4] eq '0')
1525 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>";
1527 print"<td></td></tr>";
1531 &Header
::closebox
();
1534 sub viewtableservicegrp
1540 if (! -z
$configsrvgrp){
1542 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1543 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1544 my $number= keys %customservicegrp;
1545 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1547 if ($helper ne $customservicegrp{$key}[0]){
1548 $grpname=$customservicegrp{$key}[0];
1549 $remark=$customservicegrp{$key}[1];
1550 if($count >=2){print"</table>";}
1551 print "<br><b><u>$grpname</u></b>     ";
1552 print "<b>$Lang::tr{'remark'}:</b>  $remark " if ($remark ne '');
1553 print "  <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[5] x";
1554 if($customservicegrp{$key}[5] == '0')
1556 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>";
1558 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>";
1559 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>";
1561 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1562 print" <tr bgcolor='${Header::colouryellow}'>";
1563 }elsif ($count %2 == 0){print"<tr bgcolor='$color{'color22'}'>";}else{print"<tr bgcolor='$color{'color20'}'>";}
1564 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1565 print"<td align='center'>$customservicegrp{$key}[3]</td><td align='center'>$customservicegrp{$key}[4]</td><td width='1%'><form method='post'>";
1566 if ($number gt '1'){
1567 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1569 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>";
1570 $helper=$customservicegrp{$key}[0];
1573 &Header
::closebox
();
1579 my %hash=%{(shift)};
1580 foreach my $key (keys %hash) {
1581 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1591 my %hash=%{(shift)};
1593 foreach my $key (keys %hash) {
1594 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1603 my %hash=%{(shift)};
1604 &General
::readhasharray
("$confignet", \
%hash);
1605 foreach my $key (keys %hash) {
1606 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1613 sub checkservicegroup
1615 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1619 if ( ! &General
::validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1621 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1622 return $errormessage;
1625 if ( ($fwhostsettings{'SRVGRP_REMARK'} ne '') && (! &validhostname
($fwhostsettings{'SRVGRP_REMARK'})))
1627 $errormessage.=$Lang::tr
{'fwhost err remark'}."<br>";
1629 #check empty selectbox
1630 if (keys %customservice lt 1)
1632 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1635 #check if name already exists
1636 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1637 foreach my $key (keys %customservicegrp) {
1638 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1639 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1644 #check if service already exists in group
1645 foreach my $key (keys %customservicegrp) {
1646 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1647 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1654 return $errormessage;
1658 if ($errormessage) {
1659 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1660 print "<class name='base'>$errormessage\n";
1661 print " </class>\n";
1662 &Header
::closebox
();
1668 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1669 print "<class name='base'>$hint\n";
1670 print " </class>\n";
1671 &Header
::closebox
();
1677 &General
::setup_default_networks
(\
%defaultNetworks);
1678 foreach my $network (sort keys %defaultNetworks)
1680 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1688 &General
::readhasharray
("$config",\
%hash);
1689 foreach my $key (keys %hash) {
1690 $errormessage.="lese $hash{$key}[2] und $target<br>";
1691 if($hash{$key}[2] eq $target){
1694 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1697 &General
::writehasharray
("$config",\
%hash);
1705 if (!&General
::validhostname
($fwhostsettings{'HOSTNAME'}))
1707 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1708 $fwhostsettings{'BLK_IP'}='readonly';
1709 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1710 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1712 #check if name collides with CCD Netname
1714 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1715 foreach my $key (keys %ccdnet) {
1716 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1717 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1718 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1719 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1724 #check if IP collides with CCD NetIP
1725 if ($fwhostsettings{'type'} ne 'mac'){
1726 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1727 foreach my $key (keys %ccdnet) {
1728 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1729 if($ccdnet{$key}[1] eq $test){
1730 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1731 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1732 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1733 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1741 #check if name collides with CCD Hostname
1742 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1743 foreach my $key (keys %ccdhost) {
1744 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1745 if($ip eq $fwhostsettings{'IP'}){
1746 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1747 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1751 #check if IP collides with CCD HostIP (only hosts)
1752 if ($edit eq 'edithost')
1754 foreach my $key (keys %ccdhost) {
1755 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1756 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1757 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1758 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1763 #check if network with this name already exists
1764 &General
::readhasharray
("$confignet", \
%customnetwork);
1765 if (!&checkname
(\
%customnetwork))
1767 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1768 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1769 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1771 #check if network ip already exists
1772 if (!&checkip
(\
%customnetwork,1))
1774 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1775 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1777 #check if host with this name already exists
1778 &General
::readhasharray
("$confighost", \
%customhost);
1779 if (!&checkname
(\
%customhost))
1781 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err hostexist'};
1782 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1783 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1785 #check if host with this ip already exists
1786 if (!&checkip
(\
%customhost,2))
1788 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1801 #get address from IPSEC NETWORK
1802 if ($type eq 'IpSec Network'){
1803 foreach my $key (keys %ipsecconf) {
1804 if ($ipsecconf{$key}[1] eq $name){
1805 return $ipsecconf{$key}[11];
1808 &deletefromgrp
($name,$configgrp);
1811 #get address from IPSEC HOST
1812 if ($type eq 'IpSec Host'){
1813 foreach my $key (keys %ipsecconf) {
1814 if ($ipsecconf{$key}[1] eq $name){
1815 return $ipsecconf{$key}[10];
1818 &deletefromgrp
($name,$configgrp);
1821 #get address from ovpn ccd Net-2-Net
1822 if ($type eq 'OpenVPN N-2-N'){
1823 foreach my $key (keys %ccdhost) {
1824 if($ccdhost{$key}[1] eq $name){
1825 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1826 $b=&General
::iporsubtodec
($b);
1830 &deletefromgrp
($name,$configgrp);
1833 #get address from ovpn ccd static host
1834 if ($type eq 'OpenVPN static host'){
1835 foreach my $key (keys %ccdhost) {
1836 if($ccdhost{$key}[1] eq $name){
1837 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1838 $b=&General
::iporsubtodec
($b);
1842 &deletefromgrp
($name,$configgrp);
1845 #get address from ovpn ccd static net
1846 if ($type eq 'OpenVPN static network'){
1847 foreach my $key (keys %ccdnet) {
1848 if ($ccdnet{$key}[0] eq $name){
1849 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1850 $b=&General
::iporsubtodec
($b);
1856 #check custom addresses
1857 if ($type eq 'Custom Host'){
1858 foreach my $key (keys %customhost) {
1859 if ($customhost{$key}[0] eq $name){
1860 return $customhost{$key}[2];
1865 ##check custom networks
1866 if ($type eq 'Custom Network'){
1867 foreach my $key (keys %customnetwork) {
1868 if($customnetwork{$key}[0] eq $name){
1869 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
1874 #check standard networks
1875 if ($type eq 'Standard Network'){
1876 if ($name =~ /OpenVPN/i){
1878 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
1879 return $ovpn{'DOVPN_SUBNET'};
1881 if ($name eq 'GREEN'){
1883 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1884 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
1886 if ($name eq 'BLUE'){
1888 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1889 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
1891 if ($name eq 'ORANGE'){
1893 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1894 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
1896 if ($name eq 'ALL'){
1897 return "0.0.0.0/0.0.0.0";
1899 if ($name =~ /IPsec/i){
1901 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
1902 return $hash{'RW_NET'};
1908 system ("/usr/local/bin/forwardfwctrl");
1909 system("rm ${General::swroot}/forward/reread");
1914 &General
::readhasharray
("$confignet", \
%customnetwork);
1915 &General
::readhasharray
("$confighost", \
%customhost);
1916 foreach my $key (sort keys %customgrp ){
1917 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
1918 foreach my $key1 (sort keys %customnetwork){
1919 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
1920 $customnetwork{$key1}[3]=$customnetwork{$key1}[3]-1;
1926 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
1927 foreach my $key2 (sort keys %customhost){
1928 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
1929 $customhost{$key2}[3]=$customhost{$key2}[3]-1;
1936 &General
::writehasharray
("$confignet", \
%customnetwork);
1937 &General
::writehasharray
("$confighost", \
%customhost);
1942 &General
::readhasharray
("$configsrv", \
%customservice);
1943 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1945 foreach my $key (sort keys %customservicegrp){
1946 if ($customservicegrp{$key}[0] eq $grp ){
1947 foreach my $key2 (sort keys %customservice){
1948 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
1949 $customservice{$key2}[4]--;
1954 &General
::writehasharray
("$configsrv", \
%customservice);
1960 my %hash=%{(shift)};
1962 if ($fwhostsettings{'SRV_NAME'} eq '' ){
1963 $errormessage=$Lang::tr
{'fwhost err name1'};
1965 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
1966 $errormessage=$Lang::tr
{'fwhost err port'};
1969 if (! &General
::validhostname
($fwhostsettings{'SRV_NAME'})){
1970 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
1972 #change dashes with :
1973 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
1975 if ($fwhostsettings{'SRV_PORT'} eq "*") {
1976 $fwhostsettings{'SRV_PORT'} = "1:65535";
1978 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
1979 $fwhostsettings{'SRV_PORT'} = "1:$2";
1981 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
1982 $fwhostsettings{'SRV_PORT'} = "$1:65535";
1984 if($fwhostsettings{'PROT'} ne 'ICMP'){
1985 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
1987 # a new service has to have a different name
1988 foreach my $key (keys %hash){
1989 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
1990 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
1994 return $errormessage;
1998 # Checks a hostname against RFC1035
1999 my $hostname = $_[0];
2001 # Each part should be at least two characters in length
2002 # but no more than 63 characters
2003 if (length ($hostname) < 1 || length ($hostname) > 63) {
2005 # Only valid characters are a-z, A-Z, 0-9 and -
2006 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-\s]*$/) {
2008 # First character can only be a letter or a digit
2009 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2011 # Last character can only be a letter or a digit
2012 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2017 &Header
::closebigbox
();
2018 &Header
::closepage
();