]>
git.ipfire.org Git - people/pmueller/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);
187 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
190 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
193 $fwhostsettings{'SRV_NAME'} = '';
194 $fwhostsettings{'SRV_PORT'} = '';
195 $fwhostsettings{'PROT'} = '';
197 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
198 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
199 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
200 $fwhostsettings{'updatesrv'}= 'on';
202 if($needrules eq 'on'){
208 if ($fwhostsettings{'ACTION'} eq 'savenet' )
212 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
213 #check if all fields are set
214 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
216 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
221 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
223 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
224 $fwhostsettings{'BLK_HOST'} ='readonly';
225 $fwhostsettings{'NOCHECK'} ='false';
226 $fwhostsettings{'error'} ='on';
228 #check if subnet is sigle host
229 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
231 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
233 if($fwhostsettings{'error'} ne 'on'){
234 #check if we use one of ipfire's networks (green,orange,blue)
235 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
237 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
238 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
239 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
241 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
243 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
244 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
245 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
247 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
249 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
250 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
251 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
253 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
255 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
256 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
257 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
260 #only check plausi when no error till now
262 &plausicheck
("editnet");
264 #check if network ip is part of an already used one
265 if(&checksubnet
(\
%customnetwork))
267 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
268 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
270 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
272 $fwhostsettings{'actualize'} = '';
273 my $key = &General
::findhasharraykey
(\
%customnetwork);
274 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
275 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
276 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
277 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
278 $customnetwork{$key}[3] = $fwhostsettings{'count'};
279 &General
::writehasharray
("$confignet", \
%customnetwork);
280 undef %customnetwork;
283 &General
::readhasharray
("$confignet", \
%customnetwork);
284 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
285 if ($fwhostsettings{'update'} == '0'){
286 foreach my $key (keys %customnetwork) {
287 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
288 $count=$customnetwork{$key}[3];
289 delete $customnetwork{$key};
295 #get count if actualize is 'on'
296 if($fwhostsettings{'actualize'} eq 'on'){
297 $fwhostsettings{'actualize'} = '';
298 $count=$fwhostsettings{'count'};
299 #check if we need to reload rules
300 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
303 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
304 #check if we need to update groups
305 &General
::readhasharray
("$configgrp", \
%customgrp);
306 foreach my $key (sort keys %customgrp){
307 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
308 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
312 &General
::writehasharray
("$configgrp", \
%customgrp);
313 #check if we need to update firewallrules
314 if ( ! -z
$fwconfigfwd ){
315 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
316 foreach my $line (sort keys %fwfwd){
317 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
318 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
320 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
321 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
324 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
326 if ( ! -z
$fwconfiginp ){
327 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
328 foreach my $line (sort keys %fwinp){
329 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
330 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
333 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
337 my $key = &General
::findhasharraykey
(\
%customnetwork);
338 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
339 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
340 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
341 #convert ip when leading '0' in byte
342 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
343 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
344 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
345 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
346 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
347 $customnetwork{$key}[3] = $count;
348 &General
::writehasharray
("$confignet", \
%customnetwork);
349 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
350 undef %customnetwork;
351 $fwhostsettings{'HOSTNAME'}='';
352 $fwhostsettings{'IP'}='';
353 $fwhostsettings{'SUBNET'}='';
354 #check if an edited net affected groups and need to reload rules
355 if ($needrules eq 'on'){
367 if ($fwhostsettings{'ACTION'} eq 'savehost')
371 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
372 $fwhostsettings{'SUBNET'}='32';
373 #check if all fields are set
374 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
376 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
377 $fwhostsettings{'ACTION'} = 'edithost';
379 if($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
380 $fwhostsettings{'type'} = 'mac';
381 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
382 $fwhostsettings{'type'} = 'ip';
383 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
384 $fwhostsettings{'type'} = 'mac';
385 }elsif($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
386 $fwhostsettings{'type'} = 'ip';
388 $fwhostsettings{'type'} = '';
389 $errormessage=$Lang::tr
{'fwhost err ipmac'};
391 if($fwhostsettings{'type'} eq 'mac' )
393 if ($fwhostsettings{'IP'}!~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/ )
395 $errormessage=$Lang::tr
{'fwhost err mac'};
399 if ($fwhostsettings{'type'} eq 'ip'){
401 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
402 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
404 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
405 $fwhostsettings{'error'}='on';
407 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
408 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
409 $fwhostsettings{'error'}='on';
411 #check if net or broadcast
412 my @tmp= split (/\./,$fwhostsettings{'IP'});
413 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
414 $errormessage=$Lang::tr
{'fwhost err hostip'};
417 #only check plausi when no error till now
419 &plausicheck
("edithost");
421 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
422 $fwhostsettings{'actualize'} = '';
423 my $key = &General
::findhasharraykey
(\
%customhost);
424 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
425 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
426 $customhost{$key}[1] = $fwhostsettings{'type'} ;
427 if($customhost{$key}[1] eq 'ip'){
428 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
430 $customhost{$key}[2] = $fwhostsettings{'orgip'};
432 $customhost{$key}[3] = $fwhostsettings{'count'};
433 &General
::writehasharray
("$confighost", \
%customhost);
437 #get count if host was edited
438 if($fwhostsettings{'actualize'} eq 'on'){
439 $count=$fwhostsettings{'count'};
440 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
443 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
444 #check if we need to update groups
445 &General
::readhasharray
("$configgrp", \
%customgrp);
446 foreach my $key (sort keys %customgrp){
447 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
448 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
452 &General
::writehasharray
("$configgrp", \
%customgrp);
453 #check if we need to update firewallrules
454 if ( ! -z
$fwconfigfwd ){
455 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
456 foreach my $line (sort keys %fwfwd){
457 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
458 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
460 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
461 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
464 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
466 if ( ! -z
$fwconfiginp ){
467 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
468 foreach my $line (sort keys %fwinp){
469 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
470 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
473 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
477 my $key = &General
::findhasharraykey
(\
%customhost);
478 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
479 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
480 $customhost{$key}[1] = $fwhostsettings{'type'} ;
481 if ($fwhostsettings{'type'} eq 'ip'){
482 #convert ip when leading '0' in byte
483 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
484 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
485 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
487 $customhost{$key}[2] = $fwhostsettings{'IP'};
489 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
490 $customhost{$key}[3] = $count;
491 &General
::writehasharray
("$confighost", \
%customhost);
493 $fwhostsettings{'HOSTNAME'}='';
494 $fwhostsettings{'IP'}='';
495 $fwhostsettings{'type'}='';
496 #check if we need to update rules while host was edited
497 if($needrules eq 'on'){
508 if ($fwhostsettings{'ACTION'} eq 'savegrp')
511 my $rem=$fwhostsettings{'remark'};
514 my $updcounter='off';
517 &General
::readhasharray
("$configgrp", \
%customgrp);
518 &General
::readhasharray
("$confignet", \
%customnetwork);
519 &General
::readhasharray
("$confighost", \
%customhost);
520 $grp=$fwhostsettings{'grp_name'};
521 if (!&validhostname
($grp)){$errormessage=$errormessage.$Lang::tr
{'fwhost err name'};}
522 ###check standard networks
523 if ($fwhostsettings{'grp2'} eq 'std_net'){
524 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
525 $type='Standard Network';
527 ##check custom networks
528 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
529 @target=$fwhostsettings{'CUST_SRC_NET'};
531 $type='Custom Network';
532 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
533 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
534 $fwhostsettings{'grp_name'}='';
535 $fwhostsettings{'remark'}='';
537 #check custom addresses
538 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
539 @target=$fwhostsettings{'CUST_SRC_HOST'};
542 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
543 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
544 $fwhostsettings{'grp_name'}='';
545 $fwhostsettings{'remark'}='';
547 #get address from ovpn ccd static net
548 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
549 @target=$fwhostsettings{'OVPN_CCD_NET'};
550 $type='OpenVPN static network';
551 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
552 $errormessage=$Lang::tr
{'fwhost err groupempty'};
553 $fwhostsettings{'grp_name'}='';
554 $fwhostsettings{'remark'}='';
556 #get address from ovpn ccd static host
557 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
558 @target=$fwhostsettings{'OVPN_CCD_HOST'};
559 $type='OpenVPN static host';
560 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
561 $errormessage=$Lang::tr
{'fwhost err groupempty'};
563 #get address from ovpn ccd Net-2-Net
564 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
565 @target=$fwhostsettings{'OVPN_N2N'};
566 $type='OpenVPN N-2-N';
567 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
568 $errormessage=$Lang::tr
{'fwhost err groupempty'};
569 $fwhostsettings{'grp_name'}='';
570 $fwhostsettings{'remark'}='';
572 #get address from IPSEC HOST
573 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
574 @target=$fwhostsettings{'IPSEC_HOST'};
576 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
577 $errormessage=$Lang::tr
{'fwhost err groupempty'};
578 $fwhostsettings{'grp_name'}='';
579 $fwhostsettings{'remark'}='';
581 #get address from IPSEC NETWORK
582 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
583 @target=$fwhostsettings{'IPSEC_NET'};
584 $type='IpSec Network';
585 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
586 $errormessage=$Lang::tr
{'fwhost err groupempty'};
587 $fwhostsettings{'grp_name'}='';
588 $fwhostsettings{'remark'}='';
590 #check if host/net exists in grp
591 my $test="$grp,$fwhostsettings{'oldremark'},@target";
592 foreach my $key (keys %customgrp) {
593 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
594 if ($test1 eq $test){
595 $errormessage=$Lang::tr
{'fwhost err isingrp'};
596 $fwhostsettings{'update'} = 'on';
600 #on first save, we have an empty @target, so fill it with nothing
601 my $targetvalues=@target;
602 if ($targetvalues == '0'){
603 @target=$Lang::tr
{'fwhost empty'};
605 #on update, we have to delete the dummy entry
606 foreach my $key (keys %customgrp){
607 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq $Lang::tr
{'fwhost empty'}){
608 delete $customgrp{$key};
612 &General
::writehasharray
("$configgrp", \
%customgrp);
613 &General
::readhasharray
("$configgrp", \
%customgrp);
615 foreach my $key (keys %customgrp)
617 if($customgrp{$key}[0] eq $grp)
619 $count=$customgrp{$key}[4];
623 if ($count eq '' ){$count='0';}
625 #create array with new lines
626 foreach my $line (@target){
627 push (@newgrp,"$grp,$rem,$line");
630 my $key = &General
::findhasharraykey
(\
%customgrp);
631 foreach my $line (@newgrp){
632 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
633 my ($a,$b,$c,$d) = split (",",$line);
634 $customgrp{$key}[0] = $a;
635 $customgrp{$key}[1] = $b;
636 $customgrp{$key}[2] = $c;
637 $customgrp{$key}[3] = $type;
638 $customgrp{$key}[4] = $count;
640 &General
::writehasharray
("$configgrp", \
%customgrp);
641 #update counter in Host/Net
642 if($updcounter eq 'net'){
643 foreach my $key (keys %customnetwork) {
644 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
645 $customnetwork{$key}[3] = $customnetwork{$key}[3]+1;
649 &General
::writehasharray
("$confignet", \
%customnetwork);
650 }elsif($updcounter eq 'host'){
651 foreach my $key (keys %customhost) {
652 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
653 $customhost{$key}[3]=$customhost{$key}[3]+1;
656 &General
::writehasharray
("$confighost", \
%customhost);
658 $fwhostsettings{'update'}='on';
660 if ($fwhostsettings{'remark'} ne $fwhostsettings{'oldremark'} )
662 foreach my $key (sort keys %customgrp)
664 if($customgrp{$key}[0] eq $grp && $customgrp{$key}[1] eq $fwhostsettings{'oldremark'})
666 $customgrp{$key}[1]='';
667 $customgrp{$key}[1]=$rem;
670 &General
::writehasharray
("$configgrp", \
%customgrp);
672 $fwhostsettings{'update'}='on';
674 #check if ruleupdate is needed
682 if ($fwhostsettings{'ACTION'} eq 'saveservice')
685 &General
::readhasharray
("$configsrv", \
%customservice );
686 $errormessage=&checkports
(\
%customservice);
687 if ($fwhostsettings{'PROT'} eq 'ICMP'){
688 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
689 foreach my $key (keys %icmptypes){
690 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
691 $ICMP=$icmptypes{$key}[0];
695 if($ICMP eq ''){$ICMP='BLANK';}
697 my $key = &General
::findhasharraykey
(\
%customservice);
698 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
699 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
700 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
701 $customservice{$key}[2] = $fwhostsettings{'PROT'};
702 $customservice{$key}[3] = $ICMP;
703 $customservice{$key}[4] = 0;
704 &General
::writehasharray
("$configsrv", \
%customservice );
706 $fwhostsettings{'SRV_NAME'}='';
707 $fwhostsettings{'SRV_PORT'}='';
708 $fwhostsettings{'PROT'}='';
709 $fwhostsettings{'ICMP_TYPES'}='';
713 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
718 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
719 &General
::readhasharray
("$configsrv", \
%customservice );
720 $errormessage=&checkservicegroup
;
722 #on first save, we have to enter a dummy value
723 if ($fwhostsettings{'CUST_SRV'} eq ''){$fwhostsettings{'CUST_SRV'}=$Lang::tr
{'fwhost empty'};}
724 #on update, we have to delete the dummy entry
725 foreach my $key (keys %customservicegrp){
726 if ($customservicegrp{$key}[2] eq $Lang::tr
{'fwhost empty'}){
727 delete $customservicegrp{$key};
731 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
732 #check if remark has also changed
733 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
735 foreach my $key (keys %customservicegrp)
737 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
739 $customservicegrp{$key}[1]='';
740 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
745 foreach my $key (keys %customservicegrp)
747 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
749 $count=$customservicegrp{$key}[3];
753 if ($count eq '' ){$count='0';}
755 foreach my $key (sort keys %customservice){
756 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
757 $port=$customservice{$key}[1];
758 $prot=$customservice{$key}[2];
759 $customservice{$key}[4]++;
762 &General
::writehasharray
("$configsrv", \
%customservice );
763 my $key = &General
::findhasharraykey
(\
%customservicegrp);
764 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
765 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
766 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
767 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
768 $customservicegrp{$key}[3] = $count;
769 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
770 $fwhostsettings{'updatesrvgrp'}='on';
772 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $errormessage){
773 foreach my $key (keys %customservicegrp)
775 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
777 $customservicegrp{$key}[1]='';
778 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
781 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
783 $hint=$Lang::tr
{'fwhost changeremark'};
784 $fwhostsettings{'update'}='on';
790 &viewtableservicegrp
;
793 if ($fwhostsettings{'ACTION'} eq 'editnet')
798 if ($fwhostsettings{'ACTION'} eq 'edithost')
803 if ($fwhostsettings{'ACTION'} eq 'editgrp')
805 $fwhostsettings{'update'}='on';
809 if ($fwhostsettings{'ACTION'} eq 'editservice')
811 $fwhostsettings{'updatesrv'}='on';
814 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
816 $fwhostsettings{'updatesrvgrp'} = 'on';
818 &viewtableservicegrp
;
821 if ($fwhostsettings{'ACTION'} eq 'resetnet')
823 $fwhostsettings{'HOSTNAME'} ="";
824 $fwhostsettings{'IP'} ="";
825 $fwhostsettings{'SUBNET'} ="";
828 if ($fwhostsettings{'ACTION'} eq 'resethost')
830 $fwhostsettings{'HOSTNAME'} ="";
831 $fwhostsettings{'IP'} ="";
832 $fwhostsettings{'type'} ="";
836 if ($fwhostsettings{'ACTION'} eq 'delnet')
838 &General
::readhasharray
("$confignet", \
%customnetwork);
839 foreach my $key (keys %customnetwork) {
840 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
841 delete $customnetwork{$key};
842 &General
::writehasharray
("$confignet", \
%customnetwork);
849 if ($fwhostsettings{'ACTION'} eq 'delhost')
851 &General
::readhasharray
("$confighost", \
%customhost);
852 foreach my $key (keys %customhost) {
853 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
854 delete $customhost{$key};
855 &General
::writehasharray
("$confighost", \
%customhost);
862 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
864 &General
::readhasharray
("$configgrp", \
%customgrp);
865 foreach my $key (keys %customgrp){
866 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
867 #decrease count from source host/net
868 if ($customgrp{$key}[3] eq 'Custom Network'){
869 &General
::readhasharray
("$confignet", \
%customnetwork);
870 foreach my $key1 (keys %customnetwork){
871 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
872 $customnetwork{$key1}[3] = $customnetwork{$key1}[3]-1;
876 &General
::writehasharray
("$confignet", \
%customnetwork);
878 if ($customgrp{$key}[3] eq 'Custom Host'){
879 &General
::readhasharray
("$confighost", \
%customhost);
880 foreach my $key1 (keys %customhost){
881 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
882 $customhost{$key1}[3] = $customhost{$key1}[3]-1;
886 &General
::writehasharray
("$confighost", \
%customhost);
888 delete $customgrp{$key};
891 &General
::writehasharray
("$configgrp", \
%customgrp);
896 if ($fwhostsettings{'ACTION'} eq 'delgrp')
898 &General
::readhasharray
("$configgrp", \
%customgrp);
899 &decrease
($fwhostsettings{'grp_name'});
900 foreach my $key (sort keys %customgrp)
902 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
904 delete $customgrp{$key};
907 &General
::writehasharray
("$configgrp", \
%customgrp);
908 $fwhostsettings{'grp_name'}='';
912 if ($fwhostsettings{'ACTION'} eq 'delservice')
914 &General
::readhasharray
("$configsrv", \
%customservice);
915 foreach my $key (keys %customservice) {
916 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
917 #&deletefromgrp($customhost{$key}[0],$configgrp);
918 delete $customservice{$key};
919 &General
::writehasharray
("$configsrv", \
%customservice);
923 $fwhostsettings{'SRV_NAME'}='';
924 $fwhostsettings{'SRV_PORT'}='';
925 $fwhostsettings{'PROT'}='';
928 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
930 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
931 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
932 foreach my $key (sort keys %customservicegrp)
934 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
936 delete $customservicegrp{$key};
939 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
940 $fwhostsettings{'SRVGRP_NAME'}='';
942 &viewtableservicegrp
;
944 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
946 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
947 &General
::readhasharray
("$configsrv", \
%customservice);
948 foreach my $key (keys %customservicegrp){
949 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
951 #decrease count from source service
952 foreach my $key1 (sort keys %customservice){
953 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
954 $customservice{$key1}[4]--;
958 &General
::writehasharray
("$configsrv", \
%customservice);
959 delete $customservicegrp{$key}
962 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
965 &viewtableservicegrp
;
968 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
973 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
978 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
983 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
987 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
990 &viewtableservicegrp
;
993 if($fwhostsettings{'ACTION'} eq '')
1001 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1003 <table border='0' width='100%'><form method='post'>
1004 <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>
1005 <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>
1006 <tr><td colspan='6'><hr></hr></td></tr></table></form>
1009 &Header
::closebox
();
1017 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1018 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1020 <table border='0' width='100%'><form method='post' style='display:inline' >
1021 <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>
1022 <tr><td colspan='6'><hr></hr></td></tr><tr>
1024 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1026 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'}'>";
1028 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'>";
1030 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>";
1031 &Header
::closebox
();
1037 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1038 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1040 <table border='0' width='100%'><form method='post' style='display:inline'>
1041 <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'>
1043 if ($fwhostsettings{'type'} eq 'ip'){print "<option value='ip' selected >IP</option>";}else{print "<option value='ip' >IP</option>";}
1044 if ($fwhostsettings{'type'} eq 'mac'){print "<option value='mac' selected >MAC</option>";}else{print "<option value='mac' >MAC</option>";}
1046 </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>
1047 <tr><td colspan='7'><br><br><b>$Lang::tr{'fwhost attention'}</b><br>$Lang::tr{'fwhost macwarn'}</td></tr>
1048 <tr><td colspan='7'><hr></hr></td></tr>
1051 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1054 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>";
1056 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'>";
1058 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>";
1059 &Header
::closebox
();
1066 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1067 &General
::setup_default_networks
(\
%defaultNetworks);
1069 $checked{'check1'}{'off'} = '';
1070 $checked{'check1'}{'on'} = '';
1071 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1072 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1074 if ($fwhostsettings{'update'} eq ''){
1076 <table width='100%' border='0'><form method='post'>
1077 <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>
1078 <tr><td colspan='5'><hr></td></tr></table>
1082 <table width='100%' border='0'><form method='post'>
1083 <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>
1084 <tr><td colspan='5'><hr></td></tr></table>
1088 if ($fwhostsettings{'update'} eq 'on'){
1092 <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;'>
1095 foreach my $network (sort keys %defaultNetworks)
1097 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1098 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1099 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1100 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1101 print ">$network</option>";
1105 </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;'>
1107 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1108 foreach my $key (sort { uc($ccdnet{$a}[0]) cmp uc($ccdnet{$b}[0]) } keys %ccdnet)
1110 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1115 <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;'>
1117 &General
::readhasharray
("$confignet", \
%customnetwork);
1118 foreach my $key (sort { uc($customnetwork{$a}[0]) cmp uc($customnetwork{$b}[0]) } keys %customnetwork) {
1119 print"<option>$customnetwork{$key}[0]</option>";
1123 </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;'>
1125 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1126 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1128 if ($ccdhost{$key}[33] ne ''){
1129 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1135 <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;'>
1137 &General
::readhasharray
("$confighost", \
%customhost);
1138 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0]) } keys %customhost) {
1139 print"<option>$customhost{$key}[0]</option>";
1142 </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;'>
1144 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1145 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1146 if($ccdhost{$key}[3] eq 'net'){
1147 print"<option>$ccdhost{$key}[1]</option>";
1152 <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;'>
1154 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1155 foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1156 if ($ipsecconf{$key}[3] eq 'net'){
1157 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1161 </select></td></tr></table>
1163 # <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;'>
1165 # &General::readhasharray("$configipsec", \%ipsecconf);
1166 # foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1167 # if ($ipsecconf{$key}[3] eq 'host'){
1168 # print"<option>$ipsecconf{$key}[1]</option>";
1172 # </select></td></tr>
1176 <b>$Lang::tr{'fwhost attention'}:</b><br>
1177 $Lang::tr{'fwhost macwarn'}<br><hr>
1181 <table border='0' width='100%'>
1182 <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>
1186 &Header
::closebox
();
1192 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservice'});
1193 if ($fwhostsettings{'updatesrv'} eq 'on')
1195 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1196 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1197 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1200 <table width='100%' border='0'><form method='post'>
1201 <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'>
1203 foreach ("TCP","UDP","ICMP")
1205 if ($_ eq $fwhostsettings{'PROT'})
1207 print"<option selected>$_</option>";
1209 print"<option>$_</option>";
1213 </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>
1214 <tr><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='4'><select name='ICMP_TYPES'>
1216 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1217 print"<option>All ICMP-Types</option>";
1218 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1219 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1224 <tr><td colspan='6'><hr></td></tr>
1225 <tr><td colspan='6' align='right'>
1227 if ($fwhostsettings{'updatesrv'} eq 'on')
1230 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1231 <input type='hidden' name='ACTION' value='updateservice'>
1232 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1233 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1234 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1238 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1241 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1246 &Header
::closebox
();
1254 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservicegrp'});
1255 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1257 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1259 <table width='100%' border='0'><form method='post'>
1260 <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>
1261 <tr><td colspan='4'><hr></td></td></tr>
1266 <table width='100%' border='0'><form method='post'>
1267 <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>
1268 <tr><td colspan='4'><hr></td></td></tr>
1272 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1274 <table border='0' width='100%'>
1275 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1277 &General
::readhasharray
("$configsrv", \
%customservice);
1278 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
1280 print "<option>$customservice{$key}[0]</option>";
1284 <tr><td colspan='4'><br><br><br></td></tr>
1285 <tr><td colspan='4'><hr></td></tr>
1290 <table width='100%' border='0'>
1291 <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>
1295 &Header
::closebox
();
1300 if(! -z
$confignet){
1301 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1302 &General
::readhasharray
("$confignet", \
%customnetwork);
1303 if (!keys %customnetwork)
1305 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1308 <table border='0' width='100%'>
1309 <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>
1313 foreach my $key (sort {$a <=> $b} keys %customnetwork) {
1314 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1315 print" <tr bgcolor='${Header::colouryellow}'>";
1318 print" <tr bgcolor='$color{'color22'}'>";
1321 print" <tr bgcolor='$color{'color20'}'>";
1324 <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>
1325 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1326 <input type='hidden' name='ACTION' value='editnet'>
1327 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1328 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1329 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1332 if($customnetwork{$key}[3] == '0')
1334 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>";
1336 print"<td></td></form></tr>";
1341 &Header
::closebox
();
1347 if (! -z
$confighost){
1348 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1349 &General
::readhasharray
("$confighost", \
%customhost);
1350 if (!keys %customhost)
1352 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1355 <table border='0' width='100%'>
1356 <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>
1360 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0])|| $a <=> $b } keys %customhost) {
1361 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1362 print" <tr bgcolor='${Header::colouryellow}'>";
1363 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1364 else{ print" <tr bgcolor='$color{'color20'}'>";}
1365 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1366 $customhost{$key}[3]=~s/\s+//g;
1368 <td width='40%'><form method='post'>$customhost{$key}[0]</td><td width='50%'>$ip</td><td align='center'>$customhost{$key}[3]x</td>
1369 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1370 <input type='hidden' name='ACTION' value='edithost' />
1371 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1372 <input type='hidden' name='IP' value='$ip' />
1373 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1376 if($customhost{$key}[3] == '0')
1378 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>";
1380 print"<td width='1%'></td></tr>";
1385 &Header
::closebox
();
1390 if(! -z
"$configgrp"){
1391 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1392 &General
::readhasharray
("$configgrp", \
%customgrp);
1393 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1394 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1395 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1396 &General
::readhasharray
("$confighost", \
%customhost);
1397 &General
::readhasharray
("$confignet", \
%customnetwork);
1404 if (!keys %customgrp)
1406 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1408 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){
1410 if ($helper ne $customgrp{$key}[0]){
1412 $grpname=$customgrp{$key}[0];
1413 $remark=$customgrp{$key}[1];
1414 if($count >=2){print"</table>";}
1415 print "<br><b><u>$grpname</u></b>    ";
1416 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1417 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1418 if($customgrp{$key}[4] == '0')
1420 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>";
1422 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>";
1423 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>";
1425 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1426 print" <tr bgcolor='${Header::colouryellow}'>";
1427 }elsif ($count %2 == 0){print"<tr bgcolor='$color{'color22'}'>";}else{print"<tr bgcolor='$color{'color20'}'>";}
1428 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1429 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1432 print "<td width='39%'>";
1433 if($customgrp{$key}[3] eq 'Standard Network'){
1434 print &get_name
($customgrp{$key}[2])."</td>";
1436 print "$customgrp{$key}[2]</td>";
1438 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost empty'}){
1439 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1441 print"<td>$ip</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1443 if ($number > 1 && $ip ne ''){
1444 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1446 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>";
1448 $helper=$customgrp{$key}[0];
1454 &Header
::closebox
();
1458 sub viewtableservice
1461 if(! -z
"$configsrv")
1463 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1464 &General
::readhasharray
("$configsrv", \
%customservice);
1466 <table width='100%' border='0'>
1467 <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>
1469 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
1472 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1473 print" <tr bgcolor='${Header::colouryellow}'>";
1474 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1476 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1478 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1481 </td><td align='center'>$customservice{$key}[4]x</td>
1482 <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' />
1483 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1484 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1485 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1487 if ($customservice{$key}[4] eq '0')
1489 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>";
1491 print"<td></td></tr>";
1495 &Header
::closebox
();
1498 sub viewtableservicegrp
1506 if (! -z
$configsrvgrp){
1507 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1508 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1509 &General
::readhasharray
("$configsrv", \
%customservice);
1510 my $number= keys %customservicegrp;
1511 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0])|| $a <=> $b } keys %customservicegrp){
1513 if ($helper ne $customservicegrp{$key}[0]){
1514 $grpname=$customservicegrp{$key}[0];
1515 $remark=$customservicegrp{$key}[1];
1516 if($count >=2){print"</table>";}
1517 print "<br><b><u>$grpname</u></b>     ";
1518 print "<b>$Lang::tr{'remark'}:</b>  $remark " if ($remark ne '');
1519 print "  <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1520 if($customservicegrp{$key}[3] == '0')
1522 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>";
1524 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>";
1525 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>";
1527 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1528 print" <tr bgcolor='${Header::colouryellow}'>";
1530 if ($count %2 == 0){
1531 print"<tr bgcolor='$color{'color22'}'>";
1533 print"<tr bgcolor='$color{'color20'}'>";
1535 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1536 foreach my $srv (sort keys %customservice){
1537 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1538 $protocol=$customservice{$srv}[2];
1539 $port=$customservice{$srv}[1];
1543 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1544 if ($number gt '1'){
1545 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1547 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>";
1548 $helper=$customservicegrp{$key}[0];
1551 &Header
::closebox
();
1557 my %hash=%{(shift)};
1558 foreach my $key (keys %hash) {
1559 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1569 my %hash=%{(shift)};
1571 foreach my $key (keys %hash) {
1572 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1581 my %hash=%{(shift)};
1582 &General
::readhasharray
("$confignet", \
%hash);
1583 foreach my $key (keys %hash) {
1584 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1591 sub checkservicegroup
1593 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1597 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1599 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1600 return $errormessage;
1603 if ( ($fwhostsettings{'SRVGRP_REMARK'} ne '') && (! &validhostname
($fwhostsettings{'SRVGRP_REMARK'})))
1605 $errormessage.=$Lang::tr
{'fwhost err remark'}."<br>";
1607 #check empty selectbox
1608 if (keys %customservice lt 1)
1610 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1612 #check if name already exists
1613 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1614 foreach my $key (keys %customservicegrp) {
1615 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1616 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1621 #check if service already exists in group
1622 foreach my $key (keys %customservicegrp) {
1623 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1624 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1627 return $errormessage;
1631 if ($errormessage) {
1632 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1633 print "<class name='base'>$errormessage\n";
1634 print " </class>\n";
1635 &Header
::closebox
();
1641 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1642 print "<class name='base'>$hint\n";
1643 print " </class>\n";
1644 &Header
::closebox
();
1650 &General
::setup_default_networks
(\
%defaultNetworks);
1651 foreach my $network (sort keys %defaultNetworks)
1653 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1661 &General
::readhasharray
("$config",\
%hash);
1662 foreach my $key (keys %hash) {
1663 $errormessage.="lese $hash{$key}[2] und $target<br>";
1664 if($hash{$key}[2] eq $target){
1667 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1670 &General
::writehasharray
("$config",\
%hash);
1678 if (!&General
::validhostname
($fwhostsettings{'HOSTNAME'}))
1680 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1681 $fwhostsettings{'BLK_IP'}='readonly';
1682 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1683 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1685 #check if name collides with CCD Netname
1687 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1688 foreach my $key (keys %ccdnet) {
1689 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1690 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1691 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1692 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1697 #check if IP collides with CCD NetIP
1698 if ($fwhostsettings{'type'} ne 'mac'){
1699 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1700 foreach my $key (keys %ccdnet) {
1701 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1702 if($ccdnet{$key}[1] eq $test){
1703 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1704 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1705 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1706 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1714 #check if name collides with CCD Hostname
1715 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1716 foreach my $key (keys %ccdhost) {
1717 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1718 if($ip eq $fwhostsettings{'IP'}){
1719 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1720 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1724 #check if IP collides with CCD HostIP (only hosts)
1725 if ($edit eq 'edithost')
1727 foreach my $key (keys %ccdhost) {
1728 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1729 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1730 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1731 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1736 #check if network with this name already exists
1737 &General
::readhasharray
("$confignet", \
%customnetwork);
1738 if (!&checkname
(\
%customnetwork))
1740 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1741 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1742 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1744 #check if network ip already exists
1745 if (!&checkip
(\
%customnetwork,1))
1747 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1748 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1750 #check if host with this name already exists
1751 &General
::readhasharray
("$confighost", \
%customhost);
1752 if (!&checkname
(\
%customhost))
1754 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1755 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1756 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1758 #check if host with this ip already exists
1759 if (!&checkip
(\
%customhost,2))
1761 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1773 #get address from IPSEC NETWORK
1774 if ($type eq 'IpSec Network'){
1775 foreach my $key (keys %ipsecconf) {
1776 if ($ipsecconf{$key}[1] eq $name){
1777 return $ipsecconf{$key}[11];
1780 &deletefromgrp
($name,$configgrp);
1783 #get address from IPSEC HOST
1784 if ($type eq 'IpSec Host'){
1785 foreach my $key (keys %ipsecconf) {
1786 if ($ipsecconf{$key}[1] eq $name){
1787 return $ipsecconf{$key}[10];
1790 &deletefromgrp
($name,$configgrp);
1793 #get address from ovpn ccd Net-2-Net
1794 if ($type eq 'OpenVPN N-2-N'){
1795 foreach my $key (keys %ccdhost) {
1796 if($ccdhost{$key}[1] eq $name){
1797 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1798 $b=&General
::iporsubtodec
($b);
1802 &deletefromgrp
($name,$configgrp);
1805 #get address from ovpn ccd static host
1806 if ($type eq 'OpenVPN static host'){
1807 foreach my $key (keys %ccdhost) {
1808 if($ccdhost{$key}[1] eq $name){
1809 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1810 $b=&General
::iporsubtodec
($b);
1814 &deletefromgrp
($name,$configgrp);
1817 #get address from ovpn ccd static net
1818 if ($type eq 'OpenVPN static network'){
1819 foreach my $key (keys %ccdnet) {
1820 if ($ccdnet{$key}[0] eq $name){
1821 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1822 $b=&General
::iporsubtodec
($b);
1828 #check custom addresses
1829 if ($type eq 'Custom Host'){
1830 foreach my $key (keys %customhost) {
1831 if ($customhost{$key}[0] eq $name){
1832 return $customhost{$key}[2];
1837 ##check custom networks
1838 if ($type eq 'Custom Network'){
1839 foreach my $key (keys %customnetwork) {
1840 if($customnetwork{$key}[0] eq $name){
1841 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
1846 #check standard networks
1847 if ($type eq 'Standard Network'){
1848 if ($name =~ /OpenVPN/i){
1850 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
1851 return $ovpn{'DOVPN_SUBNET'};
1853 if ($name eq 'GREEN'){
1855 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1856 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
1858 if ($name eq 'BLUE'){
1860 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1861 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
1863 if ($name eq 'ORANGE'){
1865 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1866 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
1868 if ($name eq 'ALL'){
1869 return "0.0.0.0/0.0.0.0";
1871 if ($name =~ /IPsec/i){
1873 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
1874 return $hash{'RW_NET'};
1880 system ("/usr/local/bin/forwardfwctrl");
1881 system("rm ${General::swroot}/forward/reread");
1886 &General
::readhasharray
("$confignet", \
%customnetwork);
1887 &General
::readhasharray
("$confighost", \
%customhost);
1888 foreach my $key (sort keys %customgrp ){
1889 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
1890 foreach my $key1 (sort keys %customnetwork){
1891 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
1892 $customnetwork{$key1}[3]=$customnetwork{$key1}[3]-1;
1898 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
1899 foreach my $key2 (sort keys %customhost){
1900 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
1901 $customhost{$key2}[3]=$customhost{$key2}[3]-1;
1908 &General
::writehasharray
("$confignet", \
%customnetwork);
1909 &General
::writehasharray
("$confighost", \
%customhost);
1914 &General
::readhasharray
("$configsrv", \
%customservice);
1915 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1917 foreach my $key (sort keys %customservicegrp){
1918 if ($customservicegrp{$key}[0] eq $grp ){
1919 foreach my $key2 (sort keys %customservice){
1920 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
1921 $customservice{$key2}[4]--;
1926 &General
::writehasharray
("$configsrv", \
%customservice);
1932 my %hash=%{(shift)};
1934 if ($fwhostsettings{'SRV_NAME'} eq '' ){
1935 $errormessage=$Lang::tr
{'fwhost err name1'};
1937 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
1938 $errormessage=$Lang::tr
{'fwhost err port'};
1941 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
1942 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
1944 #change dashes with :
1945 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
1947 if ($fwhostsettings{'SRV_PORT'} eq "*") {
1948 $fwhostsettings{'SRV_PORT'} = "1:65535";
1950 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
1951 $fwhostsettings{'SRV_PORT'} = "1:$2";
1953 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
1954 $fwhostsettings{'SRV_PORT'} = "$1:65535";
1956 if($fwhostsettings{'PROT'} ne 'ICMP'){
1957 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
1959 # a new service has to have a different name
1960 foreach my $key (keys %hash){
1961 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
1962 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
1966 return $errormessage;
1970 # Checks a hostname against RFC1035
1971 my $hostname = $_[0];
1973 # Each part should be at least two characters in length
1974 # but no more than 63 characters
1975 if (length ($hostname) < 1 || length ($hostname) > 63) {
1977 # Only valid characters are a-z, A-Z, 0-9 and -
1978 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_()\/\s
]*$/) {
1980 # First character can only be a letter or a digit
1981 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
1983 # Last character can only be a letter or a digit
1984 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
1989 &Header
::closebigbox
();
1990 &Header
::closepage
();