]>
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
30 use CGI
::Carp
'fatalsToBrowser';
31 no warnings
'uninitialized';
32 require '/var/ipfire/general-functions.pl';
33 require "${General::swroot}/lang.pl";
34 require "${General::swroot}/header.pl";
36 my %fwhostsettings=();
41 my %customservicegrp=();
47 my %defaultNetworks=();
57 my $confignet = "${General::swroot}/fwhosts/customnetworks";
58 my $confighost = "${General::swroot}/fwhosts/customhosts";
59 my $configgrp = "${General::swroot}/fwhosts/customgroups";
60 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
61 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
62 my $configipsec = "${General::swroot}/vpn/config";
63 my $configsrv = "${General::swroot}/fwhosts/customservices";
64 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
65 my $fwconfigfwd = "${General::swroot}/forward/config";
66 my $fwconfiginp = "${General::swroot}/forward/input";
68 unless (-e
$confignet) { system("touch $confignet"); }
69 unless (-e
$confighost) { system("touch $confighost"); }
70 unless (-e
$configgrp) { system("touch $configgrp"); }
71 unless (-e
$configsrv) { system("touch $configsrv"); }
72 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
74 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
75 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
76 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
77 &Header
::getcgihash
(\
%fwhostsettings);
79 &Header
::showhttpheaders
();
80 &Header
::openpage
($Lang::tr
{'fwhost hosts'}, 1, '');
81 &Header
::openbigbox
('100%', 'center');
84 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
90 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
92 &General
::readhasharray
("$confignet", \
%customnetwork);
93 foreach my $key (keys %customnetwork)
95 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
97 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
98 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
99 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
100 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
101 $fwhostsettings{'count'} = $customnetwork{$key}[4];
102 delete $customnetwork{$key};
106 &General
::writehasharray
("$confignet", \
%customnetwork);
107 $fwhostsettings{'actualize'} = 'on';
108 $fwhostsettings{'ACTION'} = 'savenet';
110 if ($fwhostsettings{'ACTION'} eq 'updatehost')
113 &General
::readhasharray
("$confighost", \
%customhost);
114 foreach my $key (keys %customhost)
116 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
118 if ($customhost{$key}[1] eq 'ip'){
119 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
121 $ip = $customhost{$key}[2];
123 $fwhostsettings{'orgip'} = $ip;
124 $fwhostsettings{'count'} = $customhost{$key}[4];
125 delete $customhost{$key};
126 &General
::writehasharray
("$confighost", \
%customhost);
129 $fwhostsettings{'actualize'} = 'on';
130 if($fwhostsettings{'orgip'}){
131 $fwhostsettings{'ACTION'} = 'savehost';
133 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
136 if ($fwhostsettings{'ACTION'} eq 'updateservice')
140 $errormessage=&checkports
(\
%customservice);
142 &General
::readhasharray
("$configsrv", \
%customservice);
143 foreach my $key (keys %customservice)
145 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
147 $count=$customservice{$key}[4];
148 delete $customservice{$key};
149 &General
::writehasharray
("$configsrv", \
%customservice);
153 if ($fwhostsettings{'PROT'} ne 'ICMP'){
154 $fwhostsettings{'ICMP_TYPES'}='BLANK';
156 my $key1 = &General
::findhasharraykey
(\
%customservice);
157 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
158 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
159 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
160 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
161 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
162 $customservice{$key1}[4] = $count;
163 &General
::writehasharray
("$configsrv", \
%customservice);
164 #check if we need to update firewallrules
165 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
166 if ( ! -z
$fwconfigfwd ){
167 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
168 foreach my $key (sort keys %fwfwd){
169 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
170 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
173 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
175 if ( ! -z
$fwconfiginp ){
176 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
177 foreach my $line (sort keys %fwinp){
178 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
179 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
182 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
184 #check if we need to update groups
185 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
186 foreach my $key (sort keys %customservicegrp){
187 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
188 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
191 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
194 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
197 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
200 $fwhostsettings{'SRV_NAME'} = '';
201 $fwhostsettings{'SRV_PORT'} = '';
202 $fwhostsettings{'PROT'} = '';
204 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
205 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
206 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
207 $fwhostsettings{'updatesrv'}= 'on';
209 if($needrules eq 'on'){
215 if ($fwhostsettings{'ACTION'} eq 'savenet' )
219 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
220 #check if all fields are set
221 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
223 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
228 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
230 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
231 $fwhostsettings{'BLK_HOST'} ='readonly';
232 $fwhostsettings{'NOCHECK'} ='false';
233 $fwhostsettings{'error'} ='on';
236 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
237 $errormessage=$Lang::tr
{'fwhost err remark'};
238 $fwhostsettings{'error'} ='on';
240 #check if subnet is sigle host
241 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
243 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
245 if($fwhostsettings{'error'} ne 'on'){
246 #check if we use one of ipfire's networks (green,orange,blue)
247 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
249 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
250 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
251 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
253 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
255 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
256 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
257 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
259 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
261 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
262 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
263 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
265 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
267 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
268 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
269 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
272 #only check plausi when no error till now
274 &plausicheck
("editnet");
276 #check if network ip is part of an already used one
277 if(&checksubnet
(\
%customnetwork))
279 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
280 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
282 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
284 $fwhostsettings{'actualize'} = '';
285 my $key = &General
::findhasharraykey
(\
%customnetwork);
286 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
287 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
288 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
289 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
290 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
291 $customnetwork{$key}[4] = $fwhostsettings{'count'};
292 &General
::writehasharray
("$confignet", \
%customnetwork);
293 undef %customnetwork;
297 &General
::readhasharray
("$confignet", \
%customnetwork);
298 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
299 if ($fwhostsettings{'update'} == '0'){
300 foreach my $key (keys %customnetwork) {
301 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
302 $count=$customnetwork{$key}[4];
303 delete $customnetwork{$key};
309 #get count if actualize is 'on'
310 if($fwhostsettings{'actualize'} eq 'on'){
311 $fwhostsettings{'actualize'} = '';
312 $count=$fwhostsettings{'count'};
313 #check if we need to reload rules
314 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
317 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
318 #check if we need to update groups
319 &General
::readhasharray
("$configgrp", \
%customgrp);
320 foreach my $key (sort keys %customgrp){
321 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
322 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
326 &General
::writehasharray
("$configgrp", \
%customgrp);
327 #check if we need to update firewallrules
328 if ( ! -z
$fwconfigfwd ){
329 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
330 foreach my $line (sort keys %fwfwd){
331 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
332 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
334 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
335 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
338 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
340 if ( ! -z
$fwconfiginp ){
341 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
342 foreach my $line (sort keys %fwinp){
343 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
344 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
347 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
351 my $key = &General
::findhasharraykey
(\
%customnetwork);
352 foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";}
353 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
354 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
355 #convert ip when leading '0' in byte
356 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
357 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
358 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
359 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
360 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
361 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
362 $customnetwork{$key}[4] = $count;
363 &General
::writehasharray
("$confignet", \
%customnetwork);
364 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
365 undef %customnetwork;
366 $fwhostsettings{'HOSTNAME'}='';
367 $fwhostsettings{'IP'}='';
368 $fwhostsettings{'SUBNET'}='';
369 $fwhostsettings{'NETREMARK'}='';
370 #check if an edited net affected groups and need to reload rules
371 if ($needrules eq 'on'){
383 if ($fwhostsettings{'ACTION'} eq 'savehost')
387 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
388 $fwhostsettings{'SUBNET'}='32';
389 #check if all fields are set
390 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
392 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
393 $fwhostsettings{'ACTION'} = 'edithost';
395 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
396 $fwhostsettings{'type'} = 'mac';
397 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
398 $fwhostsettings{'type'} = 'ip';
400 $fwhostsettings{'type'} = '';
401 $errormessage=$Lang::tr
{'fwhost err ipmac'};
404 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
405 $errormessage=$Lang::tr
{'fwhost err remark'};
408 if ($fwhostsettings{'type'} eq 'ip'){
410 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
411 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
413 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
414 $fwhostsettings{'error'}='on';
416 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
417 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
418 $fwhostsettings{'error'}='on';
420 #check if net or broadcast
421 my @tmp= split (/\./,$fwhostsettings{'IP'});
422 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
423 $errormessage=$Lang::tr
{'fwhost err hostip'};
426 #only check plausi when no error till now
428 &plausicheck
("edithost");
430 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
431 $fwhostsettings{'actualize'} = '';
432 my $key = &General
::findhasharraykey
(\
%customhost);
433 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
434 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
435 $customhost{$key}[1] = $fwhostsettings{'type'} ;
436 if($customhost{$key}[1] eq 'ip'){
437 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
439 $customhost{$key}[2] = $fwhostsettings{'orgip'};
441 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
442 $customhost{$key}[4] = $fwhostsettings{'count'};
443 &General
::writehasharray
("$confighost", \
%customhost);
447 #get count if host was edited
448 if($fwhostsettings{'actualize'} eq 'on'){
449 $count=$fwhostsettings{'count'};
450 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
453 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
454 #check if we need to update groups
455 &General
::readhasharray
("$configgrp", \
%customgrp);
456 foreach my $key (sort keys %customgrp){
457 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
458 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
461 &General
::writehasharray
("$configgrp", \
%customgrp);
462 #check if we need to update firewallrules
463 if ( ! -z
$fwconfigfwd ){
464 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
465 foreach my $line (sort keys %fwfwd){
466 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
467 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
469 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
470 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
473 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
475 if ( ! -z
$fwconfiginp ){
476 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
477 foreach my $line (sort keys %fwinp){
478 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
479 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
482 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
486 my $key = &General
::findhasharraykey
(\
%customhost);
487 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
488 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
489 $customhost{$key}[1] = $fwhostsettings{'type'} ;
490 if ($fwhostsettings{'type'} eq 'ip'){
491 #convert ip when leading '0' in byte
492 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
493 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
494 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
496 $customhost{$key}[2] = $fwhostsettings{'IP'};
498 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
499 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
500 $customhost{$key}[4] =$count;
501 &General
::writehasharray
("$confighost", \
%customhost);
503 $fwhostsettings{'HOSTNAME'}='';
504 $fwhostsettings{'IP'}='';
505 $fwhostsettings{'type'}='';
506 $fwhostsettings{'HOSTREMARK'}='';
507 #check if we need to update rules while host was edited
508 if($needrules eq 'on'){
519 if ($fwhostsettings{'ACTION'} eq 'savegrp')
521 my $grp=$fwhostsettings{'grp_name'};;
522 my $rem=$fwhostsettings{'remark'};
525 my $updcounter='off';
528 &General
::readhasharray
("$configgrp", \
%customgrp);
529 &General
::readhasharray
("$confignet", \
%customnetwork);
530 &General
::readhasharray
("$confighost", \
%customhost);
532 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
534 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
535 $errormessage.=$Lang::tr
{'fwhost err remark'};
537 if ($fwhostsettings{'update'} eq 'on'){
538 #check standard networks
539 if ($fwhostsettings{'grp2'} eq 'std_net'){
540 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
541 $type='Standard Network';
543 #check custom networks
544 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
545 @target=$fwhostsettings{'CUST_SRC_NET'};
547 $type='Custom Network';
548 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
549 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
550 $fwhostsettings{'grp_name'}='';
551 $fwhostsettings{'remark'}='';
553 #check custom addresses
554 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
555 @target=$fwhostsettings{'CUST_SRC_HOST'};
558 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
559 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
560 $fwhostsettings{'grp_name'}='';
561 $fwhostsettings{'remark'}='';
563 #get address from ovpn ccd static net
564 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
565 @target=$fwhostsettings{'OVPN_CCD_NET'};
566 $type='OpenVPN static network';
567 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
568 $errormessage=$Lang::tr
{'fwhost err groupempty'};
569 $fwhostsettings{'grp_name'}='';
570 $fwhostsettings{'remark'}='';
572 #get address from ovpn ccd static host
573 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
574 @target=$fwhostsettings{'OVPN_CCD_HOST'};
575 $type='OpenVPN static host';
576 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
577 $errormessage=$Lang::tr
{'fwhost err groupempty'};
579 #get address from ovpn ccd Net-2-Net
580 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
581 @target=$fwhostsettings{'OVPN_N2N'};
582 $type='OpenVPN N-2-N';
583 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
584 $errormessage=$Lang::tr
{'fwhost err groupempty'};
585 $fwhostsettings{'grp_name'}='';
586 $fwhostsettings{'remark'}='';
588 #get address from IPSEC HOST
589 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
590 @target=$fwhostsettings{'IPSEC_HOST'};
592 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
593 $errormessage=$Lang::tr
{'fwhost err groupempty'};
594 $fwhostsettings{'grp_name'}='';
595 $fwhostsettings{'remark'}='';
597 #get address from IPSEC NETWORK
598 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
599 @target=$fwhostsettings{'IPSEC_NET'};
600 $type='IpSec Network';
601 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
602 $errormessage=$Lang::tr
{'fwhost err groupempty'};
603 $fwhostsettings{'grp_name'}='';
604 $fwhostsettings{'remark'}='';
606 #check if host/net exists in grp
608 my $test="$grp,$fwhostsettings{'oldremark'},@target";
609 foreach my $key (keys %customgrp) {
610 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
611 if ($test1 eq $test){
612 $errormessage=$Lang::tr
{'fwhost err isingrp'};
613 $fwhostsettings{'update'} = 'on';
619 #on first save, we have an empty @target, so fill it with nothing
620 my $targetvalues=@target;
621 if ($targetvalues == '0'){
624 #on update, we have to delete the dummy entry
625 foreach my $key (keys %customgrp){
626 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
627 delete $customgrp{$key};
631 &General
::writehasharray
("$configgrp", \
%customgrp);
632 &General
::readhasharray
("$configgrp", \
%customgrp);
634 foreach my $key (keys %customgrp)
636 if($customgrp{$key}[0] eq $grp)
638 $count=$customgrp{$key}[4];
642 if ($count eq '' ){$count='0';}
644 #create array with new lines
645 foreach my $line (@target){
646 push (@newgrp,"$grp,$rem,$line");
649 my $key = &General
::findhasharraykey
(\
%customgrp);
650 foreach my $line (@newgrp){
651 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
652 my ($a,$b,$c,$d) = split (",",$line);
653 $customgrp{$key}[0] = $a;
654 $customgrp{$key}[1] = $b;
655 $customgrp{$key}[2] = $c;
656 $customgrp{$key}[3] = $type;
657 $customgrp{$key}[4] = $count;
659 &General
::writehasharray
("$configgrp", \
%customgrp);
660 #update counter in Host/Net
661 if($updcounter eq 'net'){
662 foreach my $key (keys %customnetwork) {
663 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
664 $customnetwork{$key}[4] = $customnetwork{$key}[4]+1;
668 &General
::writehasharray
("$confignet", \
%customnetwork);
669 }elsif($updcounter eq 'host'){
670 foreach my $key (keys %customhost) {
671 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
672 $customhost{$key}[4]=$customhost{$key}[3]+1;
675 &General
::writehasharray
("$confighost", \
%customhost);
677 $fwhostsettings{'update'}='on';
679 #check if ruleupdate is needed
687 if ($fwhostsettings{'ACTION'} eq 'saveservice')
690 &General
::readhasharray
("$configsrv", \
%customservice );
691 $errormessage=&checkports
(\
%customservice);
692 if ($fwhostsettings{'PROT'} eq 'ICMP'){
693 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
694 foreach my $key (keys %icmptypes){
695 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
696 $ICMP=$icmptypes{$key}[0];
700 if($ICMP eq ''){$ICMP='BLANK';}
702 my $key = &General
::findhasharraykey
(\
%customservice);
703 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
704 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
705 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
706 $customservice{$key}[2] = $fwhostsettings{'PROT'};
707 $customservice{$key}[3] = $ICMP;
708 $customservice{$key}[4] = 0;
709 &General
::writehasharray
("$configsrv", \
%customservice );
711 $fwhostsettings{'SRV_NAME'}='';
712 $fwhostsettings{'SRV_PORT'}='';
713 $fwhostsettings{'PROT'}='';
714 $fwhostsettings{'ICMP_TYPES'}='';
718 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
723 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
724 &General
::readhasharray
("$configsrv", \
%customservice );
725 $errormessage=&checkservicegroup
;
727 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
728 $errormessage=$Lang::tr
{'fwhost err remark'};
731 #on first save, we have to enter a dummy value
732 if ($fwhostsettings{'CUST_SRV'} eq ''){
733 $fwhostsettings{'CUST_SRV'}='none';
735 #on update, we have to delete the dummy entry
736 foreach my $key (keys %customservicegrp){
737 if ($customservicegrp{$key}[2] eq 'none'){
738 delete $customservicegrp{$key};
742 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
743 #check if remark has also changed
744 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
746 foreach my $key (keys %customservicegrp)
748 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
750 $customservicegrp{$key}[1]='';
751 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
756 foreach my $key (keys %customservicegrp)
758 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
760 $count=$customservicegrp{$key}[3];
764 if ($count eq '' ){$count='0';}
766 foreach my $key (sort keys %customservice){
767 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
768 $port=$customservice{$key}[1];
769 $prot=$customservice{$key}[2];
770 $customservice{$key}[4]++;
773 &General
::writehasharray
("$configsrv", \
%customservice );
774 my $key = &General
::findhasharraykey
(\
%customservicegrp);
775 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
776 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
777 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
778 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
779 $customservicegrp{$key}[3] = $count;
780 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
781 $fwhostsettings{'updatesrvgrp'}='on';
787 &viewtableservicegrp
;
790 if ($fwhostsettings{'ACTION'} eq 'editnet')
795 if ($fwhostsettings{'ACTION'} eq 'edithost')
800 if ($fwhostsettings{'ACTION'} eq 'editgrp')
802 $fwhostsettings{'update'}='on';
806 if ($fwhostsettings{'ACTION'} eq 'editservice')
808 $fwhostsettings{'updatesrv'}='on';
811 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
813 $fwhostsettings{'updatesrvgrp'} = 'on';
815 &viewtableservicegrp
;
818 if ($fwhostsettings{'ACTION'} eq 'resetnet')
820 $fwhostsettings{'HOSTNAME'} ="";
821 $fwhostsettings{'IP'} ="";
822 $fwhostsettings{'SUBNET'} ="";
825 if ($fwhostsettings{'ACTION'} eq 'resethost')
827 $fwhostsettings{'HOSTNAME'} ="";
828 $fwhostsettings{'IP'} ="";
829 $fwhostsettings{'type'} ="";
833 if ($fwhostsettings{'ACTION'} eq 'delnet')
835 &General
::readhasharray
("$confignet", \
%customnetwork);
836 foreach my $key (keys %customnetwork) {
837 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
838 delete $customnetwork{$key};
839 &General
::writehasharray
("$confignet", \
%customnetwork);
846 if ($fwhostsettings{'ACTION'} eq 'delhost')
848 &General
::readhasharray
("$confighost", \
%customhost);
849 foreach my $key (keys %customhost) {
850 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
851 delete $customhost{$key};
852 &General
::writehasharray
("$confighost", \
%customhost);
859 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
863 &General
::readhasharray
("$configgrp", \
%customgrp);
864 foreach my $key (keys %customgrp){
865 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
866 #decrease count from source host/net
867 if ($customgrp{$key}[3] eq 'Custom Network'){
868 &General
::readhasharray
("$confignet", \
%customnetwork);
869 foreach my $key1 (keys %customnetwork){
870 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
871 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
875 &General
::writehasharray
("$confignet", \
%customnetwork);
877 if ($customgrp{$key}[3] eq 'Custom Host'){
878 &General
::readhasharray
("$confighost", \
%customhost);
879 foreach my $key1 (keys %customhost){
880 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
881 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
885 &General
::writehasharray
("$confighost", \
%customhost);
887 $grpname=$customgrp{$key}[0];
888 $grpremark=$customgrp{$key}[1];
889 delete $customgrp{$key};
892 &General
::writehasharray
("$configgrp", \
%customgrp);
893 if ($fwhostsettings{'grpcnt'} > 0){&rules
;}
894 if ($fwhostsettings{'update'} eq 'on'){
895 $fwhostsettings{'remark'}= $grpremark;
896 $fwhostsettings{'grp_name'}=$grpname;
901 if ($fwhostsettings{'ACTION'} eq 'delgrp')
903 &General
::readhasharray
("$configgrp", \
%customgrp);
904 &decrease
($fwhostsettings{'grp_name'});
905 foreach my $key (sort keys %customgrp)
907 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
909 delete $customgrp{$key};
912 &General
::writehasharray
("$configgrp", \
%customgrp);
913 $fwhostsettings{'grp_name'}='';
917 if ($fwhostsettings{'ACTION'} eq 'delservice')
919 &General
::readhasharray
("$configsrv", \
%customservice);
920 foreach my $key (keys %customservice) {
921 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
922 #&deletefromgrp($customhost{$key}[0],$configgrp);
923 delete $customservice{$key};
924 &General
::writehasharray
("$configsrv", \
%customservice);
928 $fwhostsettings{'SRV_NAME'}='';
929 $fwhostsettings{'SRV_PORT'}='';
930 $fwhostsettings{'PROT'}='';
933 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
935 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
936 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
937 foreach my $key (sort keys %customservicegrp)
939 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
941 delete $customservicegrp{$key};
944 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
945 $fwhostsettings{'SRVGRP_NAME'}='';
947 &viewtableservicegrp
;
949 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
953 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
954 &General
::readhasharray
("$configsrv", \
%customservice);
955 foreach my $key (keys %customservicegrp){
956 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
958 #decrease count from source service
959 foreach my $key1 (sort keys %customservice){
960 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
961 $customservice{$key1}[4]--;
965 &General
::writehasharray
("$configsrv", \
%customservice);
966 $grpname=$customservicegrp{$key}[0];
967 $grpremark=$customservicegrp{$key}[1];
968 delete $customservicegrp{$key};
971 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
973 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
974 #$fwhostsettings{'updatesrvgrp'}='on';
975 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
976 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
979 &viewtableservicegrp
;
982 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
987 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
992 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
997 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1001 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1004 &viewtableservicegrp
;
1006 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1008 &General
::readhasharray
("$configgrp", \
%customgrp);
1009 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1010 foreach my $key (sort keys %customgrp)
1012 #$customgrp{$key}[1]=~ s/\|/,/g;
1013 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1015 #$fwhostsettings{'newrem'}=~ s/,/\|/g;
1016 $customgrp{$key}[1]='';
1017 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1020 &General
::writehasharray
("$configgrp", \
%customgrp);
1021 $fwhostsettings{'update'}='on';
1022 #$fwhostsettings{'newrem'}=~ s/\|/,/g;
1023 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1025 $errormessage=$Lang::tr
{'fwhost err remark'};
1026 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1027 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1028 $fwhostsettings{'update'} = 'on';
1030 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1034 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1036 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1037 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1038 foreach my $key (sort keys %customservicegrp)
1040 #$customservicegrp{$key}[1]=~ s/\|/,/g;
1041 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1043 #$fwhostsettings{'newsrvrem'}=~ s/,/|/g;
1044 $customservicegrp{$key}[1]='';
1045 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1048 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1049 $fwhostsettings{'updatesrvgrp'}='on';
1050 #$fwhostsettings{'newsrvrem'}=~ s/\|/,/g;
1051 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1053 $errormessage=$Lang::tr
{'fwhost err remark'};
1054 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1055 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1056 $fwhostsettings{'updatesrvgrp'} = 'on';
1058 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1060 &viewtableservicegrp
;
1063 if($fwhostsettings{'ACTION'} eq '')
1070 if (-f
"${General::swroot}/forward/reread"){
1071 print "<table border='0'><form method='post'><td><div style='font-size:11pt; font-weight: bold;vertical-align: middle; '><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: red; font-weight: bold; font-size: 14pt;'>$Lang::tr{'fwhost reread'}</td></tr></table></form><hr><br>";
1073 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1075 <table border='0' width='100%'><form method='post'>
1076 <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>
1077 <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>
1078 <tr><td colspan='6'><hr></hr></td></tr></table></form>
1080 &Header
::closebox
();
1088 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1089 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1090 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1092 <table border='0' width='100%'><form method='post' style='display:inline' >
1093 <tr><td width='15%'>$Lang::tr{'name'}:</td><td><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} size='14'><script>document.getElementById('textbox1').focus()</script></td></tr>
1094 <tr><td>$Lang::tr{'fwhost netaddress'}:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='14' maxlength='15'></td></tr>
1095 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='14' maxlength='15'></td></tr>
1096 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1097 <tr><td colspan='6'><br><hr></hr></td></tr><tr>
1099 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1101 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='orgnetremark' value='$fwhostsettings{'orgnetremark'}' ><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newnet' value='$fwhostsettings{'newnet'}'>";
1103 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'>";
1105 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>";
1106 &Header
::closebox
();
1112 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1113 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1114 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1116 <table border='0' width='100%'><form method='post' style='display:inline'>
1117 <tr><td>$Lang::tr{'name'}:</td><td><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} size='14'><script>document.getElementById('textbox1').focus()</script></td></tr>
1118 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='14' maxlength='17'></td></tr>
1119 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1120 <tr><td colspan='5'><br><br><b>$Lang::tr{'fwhost attention'}</b><br>$Lang::tr{'fwhost macwarn'}</td></tr>
1121 <tr><td colspan='5'><hr></hr></td></tr>
1124 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1127 print " <td colspan='4' align='right'><input type='submit' value='$Lang::tr{'update'}' style='min-width:100px;'/><input type='hidden' name='ACTION' value='updatehost'><input type='hidden' name='orgremark' value='$fwhostsettings{'orgremark'}' ><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newhost' value='$fwhostsettings{'newhost'}'></form>";
1129 print " <td colspan='4' 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'>";
1131 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>";
1132 &Header
::closebox
();
1139 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1140 &General
::setup_default_networks
(\
%defaultNetworks);
1141 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1142 &General
::readhasharray
("$confignet", \
%customnetwork);
1143 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1144 &General
::readhasharray
("$confighost", \
%customhost);
1145 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1149 $checked{'check1'}{'off'} = '';
1150 $checked{'check1'}{'on'} = '';
1151 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1152 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1153 my $grp=$fwhostsettings{'grp_name'};
1154 my $rem=$fwhostsettings{'remark'};
1155 if ($fwhostsettings{'update'} eq ''){
1157 <table width='100%' border='0'><form method='post'>
1158 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='14'></td></tr>
1159 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1160 <tr><td colspan='2'><br><hr></td></tr></table>
1164 <table width='100%' border='0'><form method='post' style='display:inline'>
1165 <tr><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' readonly ></td><td></td></tr>
1166 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='newrem' size='45' value='$fwhostsettings{'remark'}' style='width:98%'></td><td align='right'><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldrem' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='ACTION' value='changegrpremark' ></td></tr></table></form>
1170 if ($fwhostsettings{'update'} eq 'on'){
1172 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1173 <table width='100%' border='0'>
1174 <tr><td width=50% valign='top'>
1175 <table width='100%' border='0'>
1176 <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;'>
1178 foreach my $network (sort keys %defaultNetworks)
1180 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1181 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1182 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1183 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1184 print ">$network</option>";
1186 print"</select></td></tr>";
1187 if (! -z
$confignet){
1188 print"<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;'>";
1189 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1190 print"<option>$customnetwork{$key}[0]</option>";
1192 print"</select></td></tr>";
1194 if (! -z
$confighost){
1195 print"<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;'>";
1196 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1197 print"<option>$customhost{$key}[0]</option>";
1199 print"</select></td></tr>";
1203 print"</td><td valign='top'><table width='100%' border='0'>";
1205 if (! -z
$configccdnet){
1206 print"<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;'>";
1207 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1209 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1211 print"</select></td></tr>";
1214 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1216 if ($ccdhost{$key}[33] ne ''){
1217 print"<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;'>" if ($show eq '');
1219 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1222 if ($show eq '1'){$show='';print"</select></td></tr>";}
1224 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1225 if($ccdhost{$key}[3] eq 'net'){
1226 print"<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;'>" if ($show eq '');
1228 print"<option>$ccdhost{$key}[1]</option>";
1231 if ($show eq '1'){$show='';print"</select></td></tr>";}
1233 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1234 if ($ipsecconf{$key}[3] eq 'net'){
1235 print"<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;'>" if ($show eq '');
1237 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1240 if ($show eq '1'){$show='';print"</select></td></tr>";}
1242 print"</td></tr></table>";
1243 print"<br><br><b>$Lang::tr{'fwhost attention'}:</b><br> $Lang::tr{'fwhost macwarn'}<br><hr>";
1245 print"<table border='0' width='100%'>";
1246 print"<tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /><input type='hidden' name='oldremark' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='update' value=$fwhostsettings{'update'} ><input type='hidden' name='ACTION' value='savegrp' ></form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value'reset'></td></td></table></form>";
1247 &Header
::closebox
();
1253 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservice'});
1254 if ($fwhostsettings{'updatesrv'} eq 'on')
1256 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1257 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1258 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1261 <table width='100%' border='0'><form method='post'>
1262 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost srv_name'}:</td><td><input type='text' name='SRV_NAME' id='textbox1' value='$fwhostsettings{'SRV_NAME'}' size='14'><script>document.getElementById('textbox1').focus()</script></td></tr>
1263 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT'>
1265 foreach ("TCP","UDP","ICMP")
1267 if ($_ eq $fwhostsettings{'PROT'})
1269 print"<option selected>$_</option>";
1271 print"<option>$_</option>";
1276 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td><select name='ICMP_TYPES'>
1278 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1279 print"<option>All ICMP-Types</option>";
1280 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1281 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1286 <tr><td width='10%'>$Lang::tr{'fwhost port'}:</td><td><input type='text' name='SRV_PORT' value='$fwhostsettings{'SRV_PORT'}' maxlength='11' size='14'></td></tr>
1287 <tr><td colspan='6'><br><hr></td></tr>
1288 <tr><td colspan='6' align='right'>
1290 if ($fwhostsettings{'updatesrv'} eq 'on')
1293 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1294 <input type='hidden' name='ACTION' value='updateservice'>
1295 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1296 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1297 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1301 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1304 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1309 &Header
::closebox
();
1317 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservicegrp'});
1318 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1319 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1321 <table width='100%' border='0'><form method='post'>
1322 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='14'></td></tr>
1323 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1324 <tr><td colspan='2'><br><hr></tr>
1329 <table width='100%' border='0'><form method='post' style='display:inline'>
1330 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}' readonly size='14'></td><td width='3%'></td></tr>
1331 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='newsrvrem' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width:98%;'></td><td align='right'><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldsrvrem' value='$fwhostsettings{'oldsrvgrpremark'}'><input type='hidden' name='ACTION' value='changesrvgrpremark' ></td></tr>
1332 <tr><td colspan='3'><br><hr></td></td></tr>
1336 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1338 <form method='post'><input type='hidden' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}'><input type='hidden' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}'><table border='0' width='100%'>
1339 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1341 &General
::readhasharray
("$configsrv", \
%customservice);
1342 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1344 print "<option>$customservice{$key}[0]</option>";
1348 <tr><td colspan='4'><br><br></td></tr>
1349 <tr><td colspan='4'><hr></td></tr>
1354 <table width='100%' border='0'>
1355 <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>
1358 &Header
::closebox
();
1363 if(! -z
$confignet){
1364 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1365 &General
::readhasharray
("$confignet", \
%customnetwork);
1366 if (!keys %customnetwork)
1368 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1371 <table border='0' width='100%' cellspacing='0'>
1372 <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{'remark'}</td><td align='center'><b>$Lang::tr{'used'}</td><td></td><td width='3%'></td></tr>
1376 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1377 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1378 print" <tr bgcolor='${Header::colouryellow}'>";
1381 print" <tr bgcolor='$color{'color22'}'>";
1384 print" <tr bgcolor='$color{'color20'}'>";
1387 <td width='20%'><form method='post'>$customnetwork{$key}[0]</td><td width=15%' align='center'>$customnetwork{$key}[1]</td><td width='15%' align='center'>$customnetwork{$key}[2]</td><td width='40%'>$customnetwork{$key}[3]</td><td align='center'>$customnetwork{$key}[4]x</td>
1388 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1389 <input type='hidden' name='ACTION' value='editnet'>
1390 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1391 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1392 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1393 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1396 if($customnetwork{$key}[4] == '0')
1398 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>";
1400 print"<td></td></form></tr>";
1405 &Header
::closebox
();
1411 if (! -z
$confighost){
1412 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1413 &General
::readhasharray
("$confighost", \
%customhost);
1414 if (!keys %customhost)
1416 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1419 <table border='0' width='100%' cellspacing='0'>
1420 <tr><td align='center'><b>$Lang::tr{'name'}</td><td align='center'><b>$Lang::tr{'fwhost ip_mac'}</td><td align='center'><b>$Lang::tr{'remark'}</td><td align='center'><b>$Lang::tr{'used'}</td><td></td><td width='3%'></td></tr>
1424 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1425 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1426 print" <tr bgcolor='${Header::colouryellow}'>";
1427 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1428 else{ print" <tr bgcolor='$color{'color20'}'>";}
1429 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1430 $customhost{$key}[4]=~s/\s+//g;
1432 <td width='20%'><form method='post'>$customhost{$key}[0]</td><td width='20%' align='center'>$ip</td><td width='50%' align='left'>$customhost{$key}[3]</td><td align='center'>$customhost{$key}[4]x</td>
1433 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1434 <input type='hidden' name='ACTION' value='edithost' />
1435 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1436 <input type='hidden' name='IP' value='$ip' />
1437 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1438 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1441 if($customhost{$key}[4] == '0')
1443 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>";
1445 print"<td width='1%'></td></tr>";
1450 &Header
::closebox
();
1455 if(! -z
"$configgrp"){
1456 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1457 &General
::readhasharray
("$configgrp", \
%customgrp);
1458 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1459 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1460 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1461 &General
::readhasharray
("$confighost", \
%customhost);
1462 &General
::readhasharray
("$confignet", \
%customnetwork);
1470 if (!keys %customgrp)
1472 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1474 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1476 if ($helper ne $customgrp{$key}[0]){
1478 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1479 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1488 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost empty'};}
1489 $grpname=$customgrp{$key}[0];
1490 $remark="$customgrp{$key}[1]";
1491 if($count >=2){print"</table>";}
1492 print "<br><b><u>$grpname</u></b>    ";
1493 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1494 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1495 if($customgrp{$key}[4] == '0')
1497 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>";
1499 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>";
1500 print"<table width='100%' style='border: 1px solid #CCCCCC;' rules='none' cellspacing='0'><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><td></td></tr>";
1503 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1504 print" <tr bgcolor='${Header::colouryellow}'>";
1505 }elsif ($count %2 == 0){
1506 print"<tr bgcolor='$color{'color22'}'>";
1508 print"<tr bgcolor='$color{'color20'}'>";
1510 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1511 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1512 print "<td width='39%' align='left'>";
1513 if($customgrp{$key}[3] eq 'Standard Network'){
1514 print &get_name
($customgrp{$key}[2])."</td>";
1516 print "$customgrp{$key}[2]</td>";
1518 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost empty'}){
1519 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1521 print"<td align='center'>$ip</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1523 if ($delflag > '1' && $ip ne ''){
1524 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1526 print"<input type='hidden' name='ACTION' value='deletegrphost'><input type='hidden' name='grpcnt' value='$customgrp{$key}[4]'><input type='hidden' name='update' value='$fwhostsettings{'update'}'><input type='hidden' name='delhost' value='$grpname,$remark,$customgrp{$key}[2],$customgrp{$key}[3]'></form></td></tr>";
1528 $helper=$customgrp{$key}[0];
1534 &Header
::closebox
();
1538 sub viewtableservice
1541 if(! -z
"$configsrv")
1543 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1544 &General
::readhasharray
("$configsrv", \
%customservice);
1546 <table width='100%' border='0' cellspacing='0'>
1547 <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>
1549 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1552 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1553 print" <tr bgcolor='${Header::colouryellow}'>";
1554 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1556 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1558 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1561 </td><td align='center'>$customservice{$key}[4]x</td>
1562 <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' />
1563 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1564 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1565 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1567 if ($customservice{$key}[4] eq '0')
1569 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>";
1571 print"<td></td></tr>";
1575 &Header
::closebox
();
1578 sub viewtableservicegrp
1587 if (! -z
$configsrvgrp){
1588 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1589 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1590 &General
::readhasharray
("$configsrv", \
%customservice);
1591 my $number= keys %customservicegrp;
1592 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1594 if ($helper ne $customservicegrp{$key}[0]){
1596 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1597 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1605 $grpname=$customservicegrp{$key}[0];
1606 if ($customservicegrp{$key}[2] eq "none"){
1607 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1611 $remark="$customservicegrp{$key}[1]";
1612 if($count >=2){print"</table>";}
1613 print "<br><b><u>$grpname</u></b>     ";
1614 print "<b>$Lang::tr{'remark'}:</b>  $remark " if ($remark ne '');
1615 print "  <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1616 if($customservicegrp{$key}[3] == '0')
1618 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>";
1620 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>";
1621 print"<table width='100%' style='border: 1px solid #CCCCCC;' rules='none' cellspacing='0'><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><td></td></tr>";
1623 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1624 print" <tr bgcolor='${Header::colouryellow}'>";
1625 }elsif ($count %2 == 0){
1626 print"<tr bgcolor='$color{'color22'}'>";
1628 print"<tr bgcolor='$color{'color20'}'>";
1630 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1631 foreach my $srv (sort keys %customservice){
1632 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1633 $protocol=$customservice{$srv}[2];
1634 $port=$customservice{$srv}[1];
1638 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1639 if ($number gt '1'){
1640 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1642 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'><input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2],$customservicegrp{$key}[3]'></form></td></tr>";
1643 $helper=$customservicegrp{$key}[0];
1646 &Header
::closebox
();
1652 my %hash=%{(shift)};
1653 foreach my $key (keys %hash) {
1654 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1664 my %hash=%{(shift)};
1666 foreach my $key (keys %hash) {
1667 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1676 my %hash=%{(shift)};
1677 &General
::readhasharray
("$confignet", \
%hash);
1678 foreach my $key (keys %hash) {
1679 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1686 sub checkservicegroup
1688 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1692 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1694 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1695 return $errormessage;
1697 #check empty selectbox
1698 if (keys %customservice lt 1)
1700 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1702 #check if name already exists
1703 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1704 foreach my $key (keys %customservicegrp) {
1705 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1706 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1711 #check if service already exists in group
1712 foreach my $key (keys %customservicegrp) {
1713 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1714 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1717 return $errormessage;
1721 if ($errormessage) {
1722 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1723 print "<class name='base'>$errormessage\n";
1724 print " </class>\n";
1725 &Header
::closebox
();
1731 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1732 print "<class name='base'>$hint\n";
1733 print " </class>\n";
1734 &Header
::closebox
();
1740 &General
::setup_default_networks
(\
%defaultNetworks);
1741 foreach my $network (sort keys %defaultNetworks)
1743 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1751 &General
::readhasharray
("$config",\
%hash);
1752 foreach my $key (keys %hash) {
1753 $errormessage.="lese $hash{$key}[2] und $target<br>";
1754 if($hash{$key}[2] eq $target){
1757 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1760 &General
::writehasharray
("$config",\
%hash);
1767 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
1769 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1770 $fwhostsettings{'BLK_IP'}='readonly';
1771 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1772 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1774 #check if name collides with CCD Netname
1775 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1776 foreach my $key (keys %ccdnet) {
1777 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1778 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1779 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1780 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1784 #check if IP collides with CCD NetIP
1785 if ($fwhostsettings{'type'} ne 'mac'){
1786 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1787 foreach my $key (keys %ccdnet) {
1788 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1789 if($ccdnet{$key}[1] eq $test){
1790 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1791 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1792 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1793 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1798 #check if name collides with CCD Hostname
1799 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1800 foreach my $key (keys %ccdhost) {
1801 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1802 if($ip eq $fwhostsettings{'IP'}){
1803 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1804 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1808 #check if IP collides with CCD HostIP (only hosts)
1809 if ($edit eq 'edithost')
1811 foreach my $key (keys %ccdhost) {
1812 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1813 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1814 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1815 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1820 #check if network with this name already exists
1821 &General
::readhasharray
("$confignet", \
%customnetwork);
1822 if (!&checkname
(\
%customnetwork))
1824 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1825 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1826 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1828 #check if network ip already exists
1829 if (!&checkip
(\
%customnetwork,1))
1831 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1832 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1834 #check if host with this name already exists
1835 &General
::readhasharray
("$confighost", \
%customhost);
1836 if (!&checkname
(\
%customhost))
1838 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1839 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1840 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1842 #check if host with this ip already exists
1843 if (!&checkip
(\
%customhost,2))
1845 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1855 #get address from IPSEC NETWORK
1856 if ($type eq 'IpSec Network'){
1857 foreach my $key (keys %ipsecconf) {
1858 if ($ipsecconf{$key}[1] eq $name){
1859 return $ipsecconf{$key}[11];
1862 &deletefromgrp
($name,$configgrp);
1865 #get address from IPSEC HOST
1866 if ($type eq 'IpSec Host'){
1867 foreach my $key (keys %ipsecconf) {
1868 if ($ipsecconf{$key}[1] eq $name){
1869 return $ipsecconf{$key}[10];
1872 &deletefromgrp
($name,$configgrp);
1875 #get address from ovpn ccd Net-2-Net
1876 if ($type eq 'OpenVPN N-2-N'){
1877 foreach my $key (keys %ccdhost) {
1878 if($ccdhost{$key}[1] eq $name){
1879 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1880 $b=&General
::iporsubtodec
($b);
1884 &deletefromgrp
($name,$configgrp);
1887 #get address from ovpn ccd static host
1888 if ($type eq 'OpenVPN static host'){
1889 foreach my $key (keys %ccdhost) {
1890 if($ccdhost{$key}[1] eq $name){
1891 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1892 $b=&General
::iporsubtodec
($b);
1896 &deletefromgrp
($name,$configgrp);
1899 #get address from ovpn ccd static net
1900 if ($type eq 'OpenVPN static network'){
1901 foreach my $key (keys %ccdnet) {
1902 if ($ccdnet{$key}[0] eq $name){
1903 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1904 $b=&General
::iporsubtodec
($b);
1910 #check custom addresses
1911 if ($type eq 'Custom Host'){
1912 foreach my $key (keys %customhost) {
1913 if ($customhost{$key}[0] eq $name){
1914 return $customhost{$key}[2];
1919 ##check custom networks
1920 if ($type eq 'Custom Network'){
1921 foreach my $key (keys %customnetwork) {
1922 if($customnetwork{$key}[0] eq $name){
1923 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
1928 #check standard networks
1929 if ($type eq 'Standard Network'){
1930 if ($name =~ /OpenVPN/i){
1932 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
1933 return $ovpn{'DOVPN_SUBNET'};
1935 if ($name eq 'GREEN'){
1937 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1938 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
1940 if ($name eq 'BLUE'){
1942 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1943 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
1945 if ($name eq 'ORANGE'){
1947 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1948 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
1950 if ($name eq 'ALL'){
1951 return "0.0.0.0/0.0.0.0";
1953 if ($name =~ /IPsec/i){
1955 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
1956 return $hash{'RW_NET'};
1962 if (!-f
"${General::swroot}/fwhosts/reread"){
1963 system("touch ${General::swroot}/fwhosts/reread");
1964 system("touch ${General::swroot}/forward/reread");
1969 system ("/usr/local/bin/forwardfwctrl");
1970 if ( -f
"${General::swroot}/fwhosts/reread"){
1971 system("rm ${General::swroot}/fwhosts/reread");
1972 system("rm ${General::swroot}/forward/reread");
1979 &General
::readhasharray
("$confignet", \
%customnetwork);
1980 &General
::readhasharray
("$confighost", \
%customhost);
1981 foreach my $key (sort keys %customgrp ){
1982 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
1983 foreach my $key1 (sort keys %customnetwork){
1984 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
1985 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
1991 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
1992 foreach my $key2 (sort keys %customhost){
1993 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
1994 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2001 &General
::writehasharray
("$confignet", \
%customnetwork);
2002 &General
::writehasharray
("$confighost", \
%customhost);
2007 &General
::readhasharray
("$configsrv", \
%customservice);
2008 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2010 foreach my $key (sort keys %customservicegrp){
2011 if ($customservicegrp{$key}[0] eq $grp ){
2012 foreach my $key2 (sort keys %customservice){
2013 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2014 $customservice{$key2}[4]--;
2019 &General
::writehasharray
("$configsrv", \
%customservice);
2025 my %hash=%{(shift)};
2027 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2028 $errormessage=$Lang::tr
{'fwhost err name1'};
2030 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2031 $errormessage=$Lang::tr
{'fwhost err port'};
2034 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2035 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2037 #change dashes with :
2038 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2040 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2041 $fwhostsettings{'SRV_PORT'} = "1:65535";
2043 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2044 $fwhostsettings{'SRV_PORT'} = "1:$2";
2046 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2047 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2049 if($fwhostsettings{'PROT'} ne 'ICMP'){
2050 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2052 # a new service has to have a different name
2053 foreach my $key (keys %hash){
2054 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2055 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2059 return $errormessage;
2063 # Checks a hostname against RFC1035
2064 my $hostname = $_[0];
2066 # Each part should be at least two characters in length
2067 # but no more than 63 characters
2068 if (length ($hostname) < 1 || length ($hostname) > 63) {
2070 # Only valid characters are a-z, A-Z, 0-9 and -
2071 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2073 # First character can only be a letter or a digit
2074 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2076 # Last character can only be a letter or a digit
2077 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2083 # Checks a hostname against RFC1035
2085 # Each part should be at least two characters in length
2086 # but no more than 63 characters
2087 if (length ($remark) < 1 || length ($remark) > 255) {
2089 # Only valid characters are a-z, A-Z, 0-9 and -
2090 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2092 # First character can only be a letter or a digit
2093 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2095 # Last character can only be a letter or a digit
2096 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2100 &Header
::closebigbox
();
2101 &Header
::closepage
();