]>
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) 2013 Alexander Marx <amarx@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 ###############################################################################
23 # enable only the following on debugging purpose
26 use CGI
::Carp
'fatalsToBrowser';
27 no warnings
'uninitialized';
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
32 my %fwhostsettings=();
37 my %customservicegrp=();
43 my %defaultNetworks=();
55 my $confignet = "${General::swroot}/fwhosts/customnetworks";
56 my $confighost = "${General::swroot}/fwhosts/customhosts";
57 my $configgrp = "${General::swroot}/fwhosts/customgroups";
58 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
59 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
60 my $configipsec = "${General::swroot}/vpn/config";
61 my $configsrv = "${General::swroot}/fwhosts/customservices";
62 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
63 my $fwconfigfwd = "${General::swroot}/firewall/config";
64 my $fwconfiginp = "${General::swroot}/firewall/input";
65 my $configovpn = "${General::swroot}/ovpn/settings";
67 my $configipsecrw = "${General::swroot}/vpn/settings";
69 unless (-e
$confignet) { system("touch $confignet"); }
70 unless (-e
$confighost) { system("touch $confighost"); }
71 unless (-e
$configgrp) { system("touch $configgrp"); }
72 unless (-e
$configsrv) { system("touch $configsrv"); }
73 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
75 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
76 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
77 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
78 &General
::readhash
("$configovpn", \
%ovpnsettings);
79 &General
::readhasharray
("$configipsec", \
%ipsecconf);
80 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
82 &Header
::getcgihash
(\
%fwhostsettings);
84 &Header
::showhttpheaders
();
85 &Header
::openpage
($Lang::tr
{'fwhost hosts'}, 1, '');
86 &Header
::openbigbox
('100%', 'center');
91 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
92 var update_protocol = function() {
93 var protocol = \$("#protocol").val();
95 if (protocol === undefined)
98 // Check if we are dealing with a protocol, that knows ports.
99 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
101 \$("#PROTOKOLL").hide();
104 \$("#PROTOKOLL").show();
108 \$(document).ready(function() {
109 var protocol = \$("#protocol").val();
110 \$("#protocol").change(update_protocol);
118 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
120 &General
::readhasharray
("$confignet", \
%customnetwork);
121 foreach my $key (keys %customnetwork)
123 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
125 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
126 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
127 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
128 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
129 $fwhostsettings{'count'} = $customnetwork{$key}[4];
130 delete $customnetwork{$key};
134 &General
::writehasharray
("$confignet", \
%customnetwork);
135 $fwhostsettings{'actualize'} = 'on';
136 $fwhostsettings{'ACTION'} = 'savenet';
138 if ($fwhostsettings{'ACTION'} eq 'updatehost')
141 &General
::readhasharray
("$confighost", \
%customhost);
142 foreach my $key (keys %customhost)
144 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
146 if ($customhost{$key}[1] eq 'ip'){
147 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
149 $ip = $customhost{$key}[2];
151 $fwhostsettings{'orgip'} = $ip;
152 $fwhostsettings{'count'} = $customhost{$key}[4];
153 delete $customhost{$key};
154 &General
::writehasharray
("$confighost", \
%customhost);
157 $fwhostsettings{'actualize'} = 'on';
158 if($fwhostsettings{'orgip'}){
159 $fwhostsettings{'ACTION'} = 'savehost';
161 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
164 if ($fwhostsettings{'ACTION'} eq 'updateservice')
168 $errormessage=&checkports
(\
%customservice);
170 &General
::readhasharray
("$configsrv", \
%customservice);
171 foreach my $key (keys %customservice)
173 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
175 $count=$customservice{$key}[4];
176 delete $customservice{$key};
177 &General
::writehasharray
("$configsrv", \
%customservice);
181 if ($fwhostsettings{'PROT'} ne 'ICMP'){
182 $fwhostsettings{'ICMP_TYPES'}='BLANK';
184 my $key1 = &General
::findhasharraykey
(\
%customservice);
185 #find out short ICMP-TYPE
186 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
187 foreach my $key (keys %icmptypes){
188 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
189 $fwhostsettings{'ICMP_TYPES'}=$icmptypes{$key}[0];
192 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
193 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
194 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
195 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
196 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
197 $customservice{$key1}[4] = $count;
198 &General
::writehasharray
("$configsrv", \
%customservice);
199 #check if we need to update firewallrules
200 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
201 if ( ! -z
$fwconfigfwd ){
202 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
203 foreach my $key (sort keys %fwfwd){
204 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
205 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
208 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
210 if ( ! -z
$fwconfiginp ){
211 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
212 foreach my $line (sort keys %fwinp){
213 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
214 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
217 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
219 #check if we need to update groups
220 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
221 foreach my $key (sort keys %customservicegrp){
222 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
223 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
226 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
229 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
232 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
235 if($count gt 0 && $fwhostsettings{'oldsrvicmp'} ne $fwhostsettings{'ICMP'} ){
238 $fwhostsettings{'SRV_NAME'} = '';
239 $fwhostsettings{'SRV_PORT'} = '';
240 $fwhostsettings{'PROT'} = '';
241 $fwhostsettings{'ICMP'} = '';
242 $fwhostsettings{'oldsrvicmp'} = '';
244 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
245 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
246 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
247 $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
248 $fwhostsettings{'updatesrv'}= 'on';
250 $fwhostsettings{'updatesrv'} = '';
251 if($needrules eq 'on'){
252 &General
::firewall_config_changed
();
257 if ($fwhostsettings{'ACTION'} eq 'savenet' )
261 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
262 #check if all fields are set
263 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
265 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
270 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
272 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
273 $fwhostsettings{'BLK_HOST'} ='readonly';
274 $fwhostsettings{'NOCHECK'} ='false';
275 $fwhostsettings{'error'} ='on';
278 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
279 $errormessage=$Lang::tr
{'fwhost err remark'};
280 $fwhostsettings{'error'} ='on';
282 #check if subnet is sigle host
283 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
285 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
287 if($fwhostsettings{'error'} ne 'on'){
288 #check if we use one of ipfire's networks (green,orange,blue)
289 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
291 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
292 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
293 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
295 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
297 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
298 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
299 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
301 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
303 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
304 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
305 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
307 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
309 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
310 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
311 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
314 #only check plausi when no error till now
316 &plausicheck
("editnet");
318 #check if network ip is part of an already used one
319 if(&checksubnet
(\
%customnetwork))
321 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
322 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
324 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
326 $fwhostsettings{'actualize'} = '';
327 my $key = &General
::findhasharraykey
(\
%customnetwork);
328 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
329 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
330 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
331 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
332 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
333 $customnetwork{$key}[4] = $fwhostsettings{'count'};
334 &General
::writehasharray
("$confignet", \
%customnetwork);
335 undef %customnetwork;
339 &General
::readhasharray
("$confignet", \
%customnetwork);
340 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
341 if ($fwhostsettings{'update'} == '0'){
342 foreach my $key (keys %customnetwork) {
343 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
344 $count=$customnetwork{$key}[4];
345 delete $customnetwork{$key};
351 #get count if actualize is 'on'
352 if($fwhostsettings{'actualize'} eq 'on'){
353 $fwhostsettings{'actualize'} = '';
354 $count=$fwhostsettings{'count'};
355 #check if we need to reload rules
356 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
359 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
360 #check if we need to update groups
361 &General
::readhasharray
("$configgrp", \
%customgrp);
362 foreach my $key (sort keys %customgrp){
363 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
364 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
368 &General
::writehasharray
("$configgrp", \
%customgrp);
369 #check if we need to update firewallrules
370 if ( ! -z
$fwconfigfwd ){
371 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
372 foreach my $line (sort keys %fwfwd){
373 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
374 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
376 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
377 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
380 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
382 if ( ! -z
$fwconfiginp ){
383 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
384 foreach my $line (sort keys %fwinp){
385 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
386 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
389 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
393 my $key = &General
::findhasharraykey
(\
%customnetwork);
394 foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";}
395 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
396 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
397 #convert ip when leading '0' in byte
398 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
399 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
400 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
401 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
402 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
403 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
404 $customnetwork{$key}[4] = $count;
405 &General
::writehasharray
("$confignet", \
%customnetwork);
406 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
407 undef %customnetwork;
408 $fwhostsettings{'HOSTNAME'}='';
409 $fwhostsettings{'IP'}='';
410 $fwhostsettings{'SUBNET'}='';
411 $fwhostsettings{'NETREMARK'}='';
412 #check if an edited net affected groups and need to reload rules
413 if ($needrules eq 'on'){
414 &General
::firewall_config_changed
();
424 if ($fwhostsettings{'ACTION'} eq 'savehost')
428 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
429 $fwhostsettings{'SUBNET'}='32';
430 #check if all fields are set
431 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
433 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
434 $fwhostsettings{'ACTION'} = 'edithost';
436 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
437 $fwhostsettings{'type'} = 'mac';
438 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
439 $fwhostsettings{'type'} = 'ip';
441 $fwhostsettings{'type'} = '';
442 $errormessage=$Lang::tr
{'fwhost err ipmac'};
445 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
446 $errormessage=$Lang::tr
{'fwhost err remark'};
449 if ($fwhostsettings{'type'} eq 'ip'){
451 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
452 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
454 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
455 $fwhostsettings{'error'}='on';
457 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
458 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
459 $fwhostsettings{'error'}='on';
461 #check if net or broadcast
462 my @tmp= split (/\./,$fwhostsettings{'IP'});
463 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
464 $errormessage=$Lang::tr
{'fwhost err hostip'};
467 #only check plausi when no error till now
469 &plausicheck
("edithost");
471 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
472 $fwhostsettings{'actualize'} = '';
473 my $key = &General
::findhasharraykey
(\
%customhost);
474 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
475 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
476 $customhost{$key}[1] = $fwhostsettings{'type'} ;
477 if($customhost{$key}[1] eq 'ip'){
478 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
480 $customhost{$key}[2] = $fwhostsettings{'orgip'};
482 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
483 $customhost{$key}[4] = $fwhostsettings{'count'};
484 &General
::writehasharray
("$confighost", \
%customhost);
488 #get count if host was edited
489 if($fwhostsettings{'actualize'} eq 'on'){
490 $count=$fwhostsettings{'count'};
491 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
494 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
495 #check if we need to update groups
496 &General
::readhasharray
("$configgrp", \
%customgrp);
497 foreach my $key (sort keys %customgrp){
498 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
499 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
502 &General
::writehasharray
("$configgrp", \
%customgrp);
503 #check if we need to update firewallrules
504 if ( ! -z
$fwconfigfwd ){
505 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
506 foreach my $line (sort keys %fwfwd){
507 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
508 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
510 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
511 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
514 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
516 if ( ! -z
$fwconfiginp ){
517 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
518 foreach my $line (sort keys %fwinp){
519 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
520 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
523 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
527 my $key = &General
::findhasharraykey
(\
%customhost);
528 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
529 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
530 $customhost{$key}[1] = $fwhostsettings{'type'} ;
531 if ($fwhostsettings{'type'} eq 'ip'){
532 #convert ip when leading '0' in byte
533 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
534 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
535 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
537 $customhost{$key}[2] = $fwhostsettings{'IP'};
539 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
540 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
541 $customhost{$key}[4] =$count;
542 &General
::writehasharray
("$confighost", \
%customhost);
544 $fwhostsettings{'HOSTNAME'}='';
545 $fwhostsettings{'IP'}='';
546 $fwhostsettings{'type'}='';
547 $fwhostsettings{'HOSTREMARK'}='';
548 #check if we need to update rules while host was edited
549 if($needrules eq 'on'){
550 &General
::firewall_config_changed
();
560 if ($fwhostsettings{'ACTION'} eq 'savegrp')
562 my $grp=$fwhostsettings{'grp_name'};;
563 my $rem=$fwhostsettings{'remark'};
566 my $updcounter='off';
569 &General
::readhasharray
("$configgrp", \
%customgrp);
570 &General
::readhasharray
("$confignet", \
%customnetwork);
571 &General
::readhasharray
("$confighost", \
%customhost);
573 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
575 if (!checkgroup
(\
%customgrp,$grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
577 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
578 $errormessage.=$Lang::tr
{'fwhost err remark'};
580 if ($fwhostsettings{'update'} eq 'on'){
581 #check standard networks
582 if ($fwhostsettings{'grp2'} eq 'std_net'){
583 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
584 $type='Standard Network';
586 #check custom networks
587 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
588 @target=$fwhostsettings{'CUST_SRC_NET'};
590 $type='Custom Network';
591 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
592 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
593 $fwhostsettings{'grp_name'}='';
594 $fwhostsettings{'remark'}='';
596 #check custom addresses
597 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
598 @target=$fwhostsettings{'CUST_SRC_HOST'};
601 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
602 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
603 $fwhostsettings{'grp_name'}='';
604 $fwhostsettings{'remark'}='';
606 #get address from ovpn ccd static net
607 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
608 @target=$fwhostsettings{'OVPN_CCD_NET'};
609 $type='OpenVPN static network';
610 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
611 $errormessage=$Lang::tr
{'fwhost err groupempty'};
612 $fwhostsettings{'grp_name'}='';
613 $fwhostsettings{'remark'}='';
615 #get address from ovpn ccd static host
616 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
617 @target=$fwhostsettings{'OVPN_CCD_HOST'};
618 $type='OpenVPN static host';
619 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
620 $errormessage=$Lang::tr
{'fwhost err groupempty'};
622 #get address from ovpn ccd Net-2-Net
623 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
624 @target=$fwhostsettings{'OVPN_N2N'};
625 $type='OpenVPN N-2-N';
626 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
627 $errormessage=$Lang::tr
{'fwhost err groupempty'};
628 $fwhostsettings{'grp_name'}='';
629 $fwhostsettings{'remark'}='';
631 #get address from IPSEC HOST
632 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
633 @target=$fwhostsettings{'IPSEC_HOST'};
635 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
636 $errormessage=$Lang::tr
{'fwhost err groupempty'};
637 $fwhostsettings{'grp_name'}='';
638 $fwhostsettings{'remark'}='';
640 #get address from IPSEC NETWORK
641 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
642 @target=$fwhostsettings{'IPSEC_NET'};
643 $type='IpSec Network';
644 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
645 $errormessage=$Lang::tr
{'fwhost err groupempty'};
646 $fwhostsettings{'grp_name'}='';
647 $fwhostsettings{'remark'}='';
649 #check if host/net exists in grp
651 my $test="$grp,$fwhostsettings{'oldremark'},@target";
652 foreach my $key (keys %customgrp) {
653 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
654 if ($test1 eq $test){
655 $errormessage=$Lang::tr
{'fwhost err isingrp'};
656 $fwhostsettings{'update'} = 'on';
662 #on first save, we have an empty @target, so fill it with nothing
663 my $targetvalues=@target;
664 if ($targetvalues == '0'){
667 #on update, we have to delete the dummy entry
668 foreach my $key (keys %customgrp){
669 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
670 delete $customgrp{$key};
674 &General
::writehasharray
("$configgrp", \
%customgrp);
675 &General
::readhasharray
("$configgrp", \
%customgrp);
677 foreach my $key (keys %customgrp)
679 if($customgrp{$key}[0] eq $grp)
681 $count=$customgrp{$key}[4];
685 if ($count eq '' ){$count='0';}
687 #create array with new lines
688 foreach my $line (@target){
689 push (@newgrp,"$grp,$rem,$line");
692 my $key = &General
::findhasharraykey
(\
%customgrp);
693 foreach my $line (@newgrp){
694 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
695 my ($a,$b,$c,$d) = split (",",$line);
696 $customgrp{$key}[0] = $a;
697 $customgrp{$key}[1] = $b;
698 $customgrp{$key}[2] = $c;
699 $customgrp{$key}[3] = $type;
700 $customgrp{$key}[4] = $count;
702 &General
::writehasharray
("$configgrp", \
%customgrp);
703 #update counter in Host/Net
704 if($updcounter eq 'net'){
705 foreach my $key (keys %customnetwork) {
706 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
707 $customnetwork{$key}[4] = $customnetwork{$key}[4]+1;
711 &General
::writehasharray
("$confignet", \
%customnetwork);
712 }elsif($updcounter eq 'host'){
713 foreach my $key (keys %customhost) {
714 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
715 $customhost{$key}[4]=$customhost{$key}[4]+1;
718 &General
::writehasharray
("$confighost", \
%customhost);
720 $fwhostsettings{'update'}='on';
722 #check if ruleupdate is needed
725 &General
::firewall_config_changed
();
730 if ($fwhostsettings{'ACTION'} eq 'saveservice')
733 &General
::readhasharray
("$configsrv", \
%customservice );
734 $errormessage=&checkports
(\
%customservice);
735 if ($fwhostsettings{'PROT'} eq 'ICMP'){
736 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
737 foreach my $key (keys %icmptypes){
738 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
739 $ICMP=$icmptypes{$key}[0];
743 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
744 if ($fwhostsettings{'PROT'} ne 'ICMP'){$ICMP='';}
746 my $key = &General
::findhasharraykey
(\
%customservice);
747 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
748 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
749 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
750 $customservice{$key}[2] = $fwhostsettings{'PROT'};
751 $customservice{$key}[3] = $ICMP;
752 $customservice{$key}[4] = 0;
753 &General
::writehasharray
("$configsrv", \
%customservice );
755 $fwhostsettings{'SRV_NAME'}='';
756 $fwhostsettings{'SRV_PORT'}='';
757 $fwhostsettings{'PROT'}='';
758 $fwhostsettings{'ICMP_TYPES'}='';
762 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
769 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
770 &General
::readhasharray
("$configsrv", \
%customservice );
771 $errormessage=&checkservicegroup
;
772 #Check if we have more than 13 services from one Protocol in the group
773 #iptables can only handle 13 ports/portranges via multiport
774 foreach my $key (keys %customservicegrp){
775 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
776 foreach my $key1 (keys %customservice){
777 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
778 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
782 if ($tcpcounter > 13){
783 $errormessage=$Lang::tr
{'fwhost err maxservicetcp'};
785 if ($udpcounter > 13){
786 $errormessage=$Lang::tr
{'fwhost err maxserviceudp'};
791 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
792 $errormessage .= $Lang::tr
{'fwhost err remark'};
795 #on first save, we have to enter a dummy value
796 if ($fwhostsettings{'CUST_SRV'} eq ''){
797 $fwhostsettings{'CUST_SRV'}='none';
799 #on update, we have to delete the dummy entry
800 foreach my $key (keys %customservicegrp){
801 if ($customservicegrp{$key}[2] eq 'none'){
802 delete $customservicegrp{$key};
806 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
807 #check if remark has also changed
808 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
810 foreach my $key (keys %customservicegrp)
812 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
814 $customservicegrp{$key}[1]='';
815 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
820 foreach my $key (keys %customservicegrp)
822 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
824 $count=$customservicegrp{$key}[3];
828 if ($count eq '' ){$count='0';}
830 foreach my $key (sort keys %customservice){
831 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
832 $port=$customservice{$key}[1];
833 $prot=$customservice{$key}[2];
834 $customservice{$key}[4]++;
837 &General
::writehasharray
("$configsrv", \
%customservice );
838 my $key = &General
::findhasharraykey
(\
%customservicegrp);
839 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
840 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
841 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
842 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
843 $customservicegrp{$key}[3] = $count;
844 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
845 $fwhostsettings{'updatesrvgrp'}='on';
848 &General
::firewall_config_changed
();
851 &viewtableservicegrp
;
854 if ($fwhostsettings{'ACTION'} eq 'editnet')
859 if ($fwhostsettings{'ACTION'} eq 'edithost')
864 if ($fwhostsettings{'ACTION'} eq 'editgrp')
866 $fwhostsettings{'update'}='on';
870 if ($fwhostsettings{'ACTION'} eq 'editservice')
872 $fwhostsettings{'updatesrv'}='on';
875 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
877 $fwhostsettings{'updatesrvgrp'} = 'on';
879 &viewtableservicegrp
;
882 if ($fwhostsettings{'ACTION'} eq 'resetnet')
884 $fwhostsettings{'HOSTNAME'} ="";
885 $fwhostsettings{'IP'} ="";
886 $fwhostsettings{'SUBNET'} ="";
889 if ($fwhostsettings{'ACTION'} eq 'resethost')
891 $fwhostsettings{'HOSTNAME'} ="";
892 $fwhostsettings{'IP'} ="";
893 $fwhostsettings{'type'} ="";
896 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
898 $fwhostsettings{'grp_name'} ="";
899 $fwhostsettings{'remark'} ="";
903 if ($fwhostsettings{'ACTION'} eq 'delnet')
905 &General
::readhasharray
("$confignet", \
%customnetwork);
906 foreach my $key (keys %customnetwork) {
907 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
908 delete $customnetwork{$key};
909 &General
::writehasharray
("$confignet", \
%customnetwork);
916 if ($fwhostsettings{'ACTION'} eq 'delhost')
918 &General
::readhasharray
("$confighost", \
%customhost);
919 foreach my $key (keys %customhost) {
920 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
921 delete $customhost{$key};
922 &General
::writehasharray
("$confighost", \
%customhost);
929 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
933 &General
::readhasharray
("$configgrp", \
%customgrp);
934 foreach my $key (keys %customgrp){
935 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
936 #decrease count from source host/net
937 if ($customgrp{$key}[3] eq 'Custom Network'){
938 &General
::readhasharray
("$confignet", \
%customnetwork);
939 foreach my $key1 (keys %customnetwork){
940 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
941 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
945 &General
::writehasharray
("$confignet", \
%customnetwork);
947 if ($customgrp{$key}[3] eq 'Custom Host'){
948 &General
::readhasharray
("$confighost", \
%customhost);
949 foreach my $key1 (keys %customhost){
950 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
951 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
955 &General
::writehasharray
("$confighost", \
%customhost);
957 $grpname=$customgrp{$key}[0];
958 $grpremark=$customgrp{$key}[1];
959 delete $customgrp{$key};
962 &General
::writehasharray
("$configgrp", \
%customgrp);
963 if ($fwhostsettings{'grpcnt'} > 0){
964 &General
::firewall_config_changed
();
966 if ($fwhostsettings{'update'} eq 'on'){
967 $fwhostsettings{'remark'}= $grpremark;
968 $fwhostsettings{'grp_name'}=$grpname;
973 if ($fwhostsettings{'ACTION'} eq 'delgrp')
975 &General
::readhasharray
("$configgrp", \
%customgrp);
976 &decrease
($fwhostsettings{'grp_name'});
977 foreach my $key (sort keys %customgrp)
979 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
981 delete $customgrp{$key};
984 &General
::writehasharray
("$configgrp", \
%customgrp);
985 $fwhostsettings{'grp_name'}='';
989 if ($fwhostsettings{'ACTION'} eq 'delservice')
991 &General
::readhasharray
("$configsrv", \
%customservice);
992 foreach my $key (keys %customservice) {
993 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
994 #&deletefromgrp($customhost{$key}[0],$configgrp);
995 delete $customservice{$key};
996 &General
::writehasharray
("$configsrv", \
%customservice);
1000 $fwhostsettings{'SRV_NAME'}='';
1001 $fwhostsettings{'SRV_PORT'}='';
1002 $fwhostsettings{'PROT'}='';
1005 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
1007 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1008 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
1009 foreach my $key (sort keys %customservicegrp)
1011 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
1013 delete $customservicegrp{$key};
1016 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1017 $fwhostsettings{'SRVGRP_NAME'}='';
1019 &viewtableservicegrp
;
1021 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
1025 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1026 &General
::readhasharray
("$configsrv", \
%customservice);
1027 foreach my $key (keys %customservicegrp){
1028 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
1030 #decrease count from source service
1031 foreach my $key1 (sort keys %customservice){
1032 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1033 $customservice{$key1}[4]--;
1037 &General
::writehasharray
("$configsrv", \
%customservice);
1038 $grpname=$customservicegrp{$key}[0];
1039 $grpremark=$customservicegrp{$key}[1];
1040 delete $customservicegrp{$key};
1043 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1044 &General
::firewall_config_changed
();
1045 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1046 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1047 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1050 &viewtableservicegrp
;
1053 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1058 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1063 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1068 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1072 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1075 &viewtableservicegrp
;
1077 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1079 &General
::readhasharray
("$configgrp", \
%customgrp);
1080 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1081 foreach my $key (sort keys %customgrp)
1083 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1085 $customgrp{$key}[1]='';
1086 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1089 &General
::writehasharray
("$configgrp", \
%customgrp);
1090 $fwhostsettings{'update'}='on';
1091 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1093 $errormessage=$Lang::tr
{'fwhost err remark'};
1094 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1095 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1096 $fwhostsettings{'update'} = 'on';
1098 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1102 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1104 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1105 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1106 foreach my $key (sort keys %customservicegrp)
1108 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1110 $customservicegrp{$key}[1]='';
1111 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1114 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1115 $fwhostsettings{'updatesrvgrp'}='on';
1116 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1118 $errormessage=$Lang::tr
{'fwhost err remark'};
1119 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1120 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1121 $fwhostsettings{'updatesrvgrp'} = 'on';
1123 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1125 &viewtableservicegrp
;
1128 if($fwhostsettings{'ACTION'} eq '')
1134 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1135 print "$Lang::tr{'fwhost welcome'}";
1137 <br><br><table border='0' width='100%'>
1138 <tr><td><form method='post'><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'}' ></form></td>
1139 <td align='right'><form method='post'><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservice'}' ><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservicegrp'}' ></form></td></tr>
1140 <tr><td colspan='6'><hr></td></tr></table>
1142 &Header
::closebox
();
1150 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1151 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1152 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1154 <table border='0' width='100%'>
1155 <tr><td width='15%'>$Lang::tr{'name'}:</td><td><form method='post'><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} size='20'><script>document.getElementById('textbox1').focus()</script></td></tr>
1156 <tr><td>$Lang::tr{'fwhost netaddress'}:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1157 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1158 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1159 <tr><td colspan='6'><br><hr></td></tr><tr>
1161 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1163 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'}'></td>";
1165 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'>";
1167 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'></form></td></tr></table>";
1168 &Header
::closebox
();
1174 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1175 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1176 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1178 <table border='0' width='100%'>
1179 <tr><td>$Lang::tr{'name'}:</td><td><form method='post' style='display:inline;'><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} size='20'><script>document.getElementById('textbox1').focus()</script></td></tr>
1180 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1181 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1182 <tr><td colspan='5'><hr></td></tr><tr>
1185 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1188 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>";
1190 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'>";
1192 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'></form></td></tr></table>";
1193 &Header
::closebox
();
1200 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1201 &General
::setup_default_networks
(\
%defaultNetworks);
1202 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1203 &General
::readhasharray
("$confignet", \
%customnetwork);
1204 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1205 &General
::readhasharray
("$confighost", \
%customhost);
1206 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1210 $checked{'check1'}{'off'} = '';
1211 $checked{'check1'}{'on'} = '';
1212 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1213 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1214 my $grp=$fwhostsettings{'grp_name'};
1215 my $rem=$fwhostsettings{'remark'};
1216 if ($fwhostsettings{'update'} eq ''){
1218 <table width='100%' border='0'>
1219 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='20'></td></tr>
1220 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1221 <tr><td colspan='2'><br><hr></td></tr></table>
1225 <table width='100%' border='0'><form method='post' style='display:inline'>
1226 <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>
1227 <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>
1231 if ($fwhostsettings{'update'} eq 'on'){
1233 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1234 <table width='100%' border='0'>
1235 <tr><td width=50% valign='top'>
1236 <table width='100%' border='0'>
1237 <tr><td width='1%'><input type='radio' name='grp2' value='std_net' id='DEFAULT_SRC_ADR' checked></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost stdnet'}</td><td><select name='DEFAULT_SRC_ADR' style='min-width:185px;'>
1239 foreach my $network (sort keys %defaultNetworks)
1241 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1242 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1243 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1244 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1245 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1246 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1247 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1248 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1249 if ($ownnet{$defnet}){
1250 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1252 print ">$network</option>";
1255 print"</select></td></tr>";
1256 if (! -z
$confignet){
1257 print"<tr><td><input type='radio' name='grp2' id='CUST_SRC_NET' 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;'>";
1258 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1259 print"<option>$customnetwork{$key}[0]</option>";
1261 print"</select></td></tr>";
1263 if (! -z
$confighost){
1264 print"<tr><td valign='top'><input type='radio' name='grp2' id='CUST_SRC_HOST' 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;'>";
1265 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1266 print"<option>$customhost{$key}[0]</option>";
1268 print"</select></td></tr>";
1272 print"</td><td valign='top'><table width='100%' border='0'>";
1274 if (! -z
$configccdnet){
1275 print"<td width='1%'><input type='radio' name='grp2' id='OVPN_CCD_NET' 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;'>";
1276 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1278 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1280 print"</select></td></tr>";
1283 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1285 if ($ccdhost{$key}[33] ne ''){
1286 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 '');
1288 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1291 if ($show eq '1'){$show='';print"</select></td></tr>";}
1293 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1294 if($ccdhost{$key}[3] eq 'net'){
1295 print"<td width='1%'><input type='radio' name='grp2' id='OVPN_N2N' 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 '');
1297 print"<option>$ccdhost{$key}[1]</option>";
1300 if ($show eq '1'){$show='';print"</select></td></tr>";}
1302 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1303 if ($ipsecconf{$key}[3] eq 'net'){
1304 print"<td valign='top'><input type='radio' name='grp2' id='IPSEC_NET' 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 '');
1306 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1309 if ($show eq '1'){$show='';print"</select></td></tr>";}
1311 print"</td></tr></table>";
1312 print"<br><br><hr>";
1314 print"<table border='0' width='100%'>";
1315 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='resetgrp'></form></td></table>";
1316 &Header
::closebox
();
1322 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1323 if ($fwhostsettings{'updatesrv'} eq 'on')
1325 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1326 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1327 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1328 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1331 <table width='100%' border='0'><form method='post'>
1332 <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='24'><script>document.getElementById('textbox1').focus()</script></td></tr>
1333 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1335 foreach ("TCP","UDP","ICMP")
1337 if ($_ eq $fwhostsettings{'PROT'})
1339 print"<option selected>$_</option>";
1341 print"<option>$_</option>";
1345 </select></td></tr></table>
1346 <div id='PROTOKOLL' class='noscript'><table width=100%' border='0'><tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td><select name='ICMP_TYPES'>
1348 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1349 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1350 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1351 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1352 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1354 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1358 </select></td></tr></table></div>
1359 <div id='PORT' class='noscript'><table width='100%' border='0'><tr><td width='10%'>$Lang::tr{'fwhost port'}:</td><td><input type='text' name='SRV_PORT' value='$fwhostsettings{'SRV_PORT'}' maxlength='11' size='24'></td></tr></table></div>
1360 <table width='100%' border='0'><tr><td colspan='6'><br><hr></td></tr>
1361 <tr><td colspan='6' align='right'>
1363 if ($fwhostsettings{'updatesrv'} eq 'on')
1366 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1367 <input type='hidden' name='ACTION' value='updateservice'>
1368 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1369 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1370 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1371 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1375 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1378 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1381 &Header
::closebox
();
1389 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1390 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1391 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1393 <table width='100%' border='0'><form method='post'>
1394 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1395 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1396 <tr><td colspan='2'><br><hr></tr>
1401 <table width='100%' border='0'><form method='post' style='display:inline'>
1402 <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>
1403 <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>
1404 <tr><td colspan='3'><br><hr></td></td></tr>
1408 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1410 <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%'>
1411 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1413 &General
::readhasharray
("$configsrv", \
%customservice);
1414 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1416 print "<option>$customservice{$key}[0]</option>";
1420 <tr><td colspan='4'><br><br></td></tr>
1421 <tr><td colspan='4'><hr></td></tr>
1426 <table width='100%' border='0'>
1427 <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>
1430 &Header
::closebox
();
1435 if(! -z
$confignet){
1436 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1437 &General
::readhasharray
("$confignet", \
%customnetwork);
1438 if (!keys %customnetwork)
1440 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1443 <table border='0' width='100%' cellspacing='0'>
1444 <tr><td align='center'><b>$Lang::tr{'name'}</b></td><td align='center'><b>$Lang::tr{'fwhost netaddress'}</b></td><td align='center'><b>$Lang::tr{'remark'}</b></td><td align='center'><b>$Lang::tr{'used'}</b></td><td></td><td width='3%'></td></tr>
1448 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1449 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1450 print" <tr bgcolor='${Header::colouryellow}'>";
1453 print" <tr bgcolor='$color{'color22'}'>";
1456 print" <tr bgcolor='$color{'color20'}'>";
1458 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1459 print"<td width='20%'><form method='post'>$customnetwork{$key}[0]</td><td width='15%' align='center'>".&Header
::colorize
($colnet)."</td><td width='40%'>$customnetwork{$key}[3]</td><td align='center'>$customnetwork{$key}[4]x</td>";
1461 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1462 <input type='hidden' name='ACTION' value='editnet'>
1463 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1464 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1465 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1466 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1469 if($customnetwork{$key}[4] == '0')
1471 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>";
1473 print"<td></td></tr>";
1478 &Header
::closebox
();
1485 #Check if IP is part of OpenVPN N2N subnet
1486 foreach my $key (sort keys %ccdhost){
1487 if ($ccdhost{$key}[3] eq 'net'){
1488 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1489 if (&General
::IpInSubnet
($c,$a,$b)){
1490 $tdcolor="style='color:$Header::colourovpn ;'";
1495 #Check if IP is part of OpenVPN dynamic subnet
1496 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1497 if (&General
::IpInSubnet
($c,$a,$b)){
1498 $tdcolor="style='color: $Header::colourovpn;'";
1501 #Check if IP is part of OpenVPN static subnet
1502 foreach my $key (sort keys %ccdnet){
1503 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1504 $b =&General
::iporsubtodec
($b);
1505 if (&General
::IpInSubnet
($c,$a,$b)){
1506 $tdcolor="style='color: $Header::colourovpn;'";
1510 #Check if IP is part of IPsec RW network
1511 if ($ipsecsettings{'RW_NET'} ne ''){
1512 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1513 $b=&General
::iporsubtodec
($b);
1514 if (&General
::IpInSubnet
($c,$a,$b)){
1515 $tdcolor="style='color: $Header::colourvpn;'";
1519 #Check if IP is part of a IPsec N2N network
1520 foreach my $key (sort keys %ipsecconf){
1521 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1522 if (&General
::IpInSubnet
($c,$a,$b)){
1523 $tdcolor="style='color: $Header::colourvpn;'";
1532 if (! -z
$confighost){
1533 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1534 &General
::readhasharray
("$confighost", \
%customhost);
1535 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1536 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1537 if (!keys %customhost)
1539 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1542 <table border='0' width='100%' cellspacing='0'>
1543 <tr><td align='center'><b>$Lang::tr{'name'}</b></td><td align='center'><b>$Lang::tr{'fwhost ip_mac'}</b></td><td align='center'><b>$Lang::tr{'remark'}</b></td><td align='center'><b>$Lang::tr{'used'}</b></td><td></td><td width='3%'></td></tr>
1547 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1548 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1549 print" <tr bgcolor='${Header::colouryellow}'>";
1550 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1551 else{ print" <tr bgcolor='$color{'color20'}'>";}
1552 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1553 $customhost{$key}[4]=~s/\s+//g;
1554 print"<td width='20%'>$customhost{$key}[0]</td><td width='20%' align='center' ".&getcolor
($ip).">".&Header
::colorize
($ip)."</td><td width='50%' align='left'>$customhost{$key}[3]</td><td align='center'>$customhost{$key}[4]x</td>";
1556 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1557 <input type='hidden' name='ACTION' value='edithost' />
1558 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1559 <input type='hidden' name='IP' value='$ip' />
1560 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1561 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1564 if($customhost{$key}[4] == '0')
1566 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>";
1568 print"<td width='1%'></td></tr>";
1573 &Header
::closebox
();
1578 if(! -z
"$configgrp"){
1579 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1580 &General
::readhasharray
("$configgrp", \
%customgrp);
1581 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1582 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1583 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1584 &General
::readhasharray
("$confighost", \
%customhost);
1585 &General
::readhasharray
("$confignet", \
%customnetwork);
1593 if (!keys %customgrp)
1595 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1597 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1599 if ($helper ne $customgrp{$key}[0]){
1601 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1602 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1611 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
1612 $grpname=$customgrp{$key}[0];
1613 $remark="$customgrp{$key}[1]";
1614 if($count gt 1){ print"</table>";}
1615 print "<br><b><u>$grpname</u></b> ";
1616 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1617 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1618 if($customgrp{$key}[4] == '0')
1620 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>";
1622 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>";
1623 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>";
1626 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1627 print" <tr bgcolor='${Header::colouryellow}'>";
1628 }elsif ($count %2 == 0){
1629 print"<tr bgcolor='$color{'color22'}'>";
1631 print"<tr bgcolor='$color{'color20'}'>";
1633 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1634 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1635 print "<td width='39%' align='left'>";
1636 if($customgrp{$key}[3] eq 'Standard Network'){
1637 print &get_name
($customgrp{$key}[2])."</td>";
1639 print "$customgrp{$key}[2]</td>";
1641 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
1642 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1644 my ($colip,$colsub) = split("/",$ip);
1645 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1646 print"<td align='center' ".&getcolor
($colip).">".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1648 if ($delflag > '1' && $ip ne ''){
1649 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1651 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>";
1653 $helper=$customgrp{$key}[0];
1658 &Header
::closebox
();
1662 sub viewtableservice
1665 if(! -z
"$configsrv")
1667 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1668 &General
::readhasharray
("$configsrv", \
%customservice);
1670 <table width='100%' border='0' cellspacing='0'>
1671 <tr><td align='center'><b>$Lang::tr{'fwhost srv_name'}</b></td><td align='center'><b>$Lang::tr{'fwhost prot'}</b></td><td align='center'><b>$Lang::tr{'fwhost port'}</b></td><td align='center'><b>ICMP</b></td><td align='center'><b>$Lang::tr{'fwhost used'}</b></td><td></td><td width='3%'></td></tr>
1673 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1676 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1677 print" <tr bgcolor='${Header::colouryellow}'>";
1678 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1680 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1682 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
1683 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1685 </td><td align='center'>$customservice{$key}[4]x</td>
1686 <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' />
1687 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1688 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1689 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
1690 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
1692 if ($customservice{$key}[4] eq '0')
1694 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>";
1696 print"<td></td></tr>";
1700 &Header
::closebox
();
1703 sub viewtableservicegrp
1712 if (! -z
$configsrvgrp){
1713 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1714 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1715 &General
::readhasharray
("$configsrv", \
%customservice);
1716 my $number= keys %customservicegrp;
1717 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1719 if ($helper ne $customservicegrp{$key}[0]){
1721 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1722 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1730 $grpname=$customservicegrp{$key}[0];
1731 if ($customservicegrp{$key}[2] eq "none"){
1732 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1736 $remark="$customservicegrp{$key}[1]";
1737 if($count >=2){print"</table>";}
1738 print "<br><b><u>$grpname</u></b> ";
1739 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1740 print " <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1741 if($customservicegrp{$key}[3] == '0')
1743 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>";
1745 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>";
1746 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>";
1748 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1749 print" <tr bgcolor='${Header::colouryellow}'>";
1750 }elsif ($count %2 == 0){
1751 print"<tr bgcolor='$color{'color22'}'>";
1753 print"<tr bgcolor='$color{'color20'}'>";
1755 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1756 foreach my $srv (sort keys %customservice){
1757 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1758 $protocol=$customservice{$srv}[2];
1759 $port=$customservice{$srv}[1];
1763 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1764 if ($delflag gt '1'){
1765 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1767 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>";
1768 $helper=$customservicegrp{$key}[0];
1771 &Header
::closebox
();
1777 my %hash=%{(shift)};
1778 foreach my $key (keys %hash) {
1779 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1788 my %hash=%{(shift)};
1790 foreach my $key (keys %hash) {
1791 if($hash{$key}[0] eq $name){
1800 my %hash=%{(shift)};
1802 foreach my $key (keys %hash) {
1803 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1811 my %hash=%{(shift)};
1812 &General
::readhasharray
("$confignet", \
%hash);
1813 foreach my $key (keys %hash) {
1814 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1821 sub checkservicegroup
1823 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1827 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1829 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1830 return $errormessage;
1832 #check empty selectbox
1833 if (keys %customservice lt 1)
1835 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1837 #check if name already exists
1838 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1839 foreach my $key (keys %customservicegrp) {
1840 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1841 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1846 #check if service already exists in group
1847 foreach my $key (keys %customservicegrp) {
1848 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1849 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1852 return $errormessage;
1856 if ($errormessage) {
1857 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1858 print "<class name='base'>$errormessage\n";
1859 print " </class>\n";
1860 &Header
::closebox
();
1866 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1867 print "<class name='base'>$hint\n";
1868 print " </class>\n";
1869 &Header
::closebox
();
1875 &General
::setup_default_networks
(\
%defaultNetworks);
1876 foreach my $network (sort keys %defaultNetworks)
1878 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1887 &General
::readhasharray
("$config",\
%hash);
1888 foreach my $key (keys %hash) {
1889 $errormessage.="lese $hash{$key}[2] und $target<br>";
1890 if($hash{$key}[2] eq $target){
1893 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1896 &General
::writehasharray
("$config",\
%hash);
1903 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
1905 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1906 $fwhostsettings{'BLK_IP'}='readonly';
1907 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1908 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1910 #check if name collides with CCD Netname
1911 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1912 foreach my $key (keys %ccdnet) {
1913 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1914 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1915 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1916 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1920 #check if IP collides with CCD NetIP
1921 if ($fwhostsettings{'type'} ne 'mac'){
1922 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1923 foreach my $key (keys %ccdnet) {
1924 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1925 if($ccdnet{$key}[1] eq $test){
1926 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1927 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1928 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1929 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1934 #check if name collides with CCD Hostname
1935 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1936 foreach my $key (keys %ccdhost) {
1937 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1938 if($ip eq $fwhostsettings{'IP'}){
1939 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1940 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1944 #check if IP collides with CCD HostIP (only hosts)
1945 if ($edit eq 'edithost')
1947 foreach my $key (keys %ccdhost) {
1948 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1949 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1950 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1951 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1956 #check if network with this name already exists
1957 &General
::readhasharray
("$confignet", \
%customnetwork);
1958 if (!&checkname
(\
%customnetwork))
1960 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1961 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1962 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1964 #check if network ip already exists
1965 if (!&checkip
(\
%customnetwork,1))
1967 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1968 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1970 #check if host with this name already exists
1971 &General
::readhasharray
("$confighost", \
%customhost);
1972 if (!&checkname
(\
%customhost))
1974 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1975 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1976 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1978 #check if host with this ip already exists
1979 if (!&checkip
(\
%customhost,2))
1981 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1991 #get address from IPSEC NETWORK
1992 if ($type eq 'IpSec Network'){
1993 foreach my $key (keys %ipsecconf) {
1994 if ($ipsecconf{$key}[1] eq $name){
1995 return $ipsecconf{$key}[11];
1998 &deletefromgrp
($name,$configgrp);
2001 #get address from IPSEC HOST
2002 if ($type eq 'IpSec Host'){
2003 foreach my $key (keys %ipsecconf) {
2004 if ($ipsecconf{$key}[1] eq $name){
2005 return $ipsecconf{$key}[10];
2008 &deletefromgrp
($name,$configgrp);
2011 #get address from ovpn ccd Net-2-Net
2012 if ($type eq 'OpenVPN N-2-N'){
2013 foreach my $key (keys %ccdhost) {
2014 if($ccdhost{$key}[1] eq $name){
2015 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2016 $b=&General
::iporsubtodec
($b);
2020 &deletefromgrp
($name,$configgrp);
2023 #get address from ovpn ccd static host
2024 if ($type eq 'OpenVPN static host'){
2025 foreach my $key (keys %ccdhost) {
2026 if($ccdhost{$key}[1] eq $name){
2027 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2028 $b=&General
::iporsubtodec
($b);
2032 &deletefromgrp
($name,$configgrp);
2035 #get address from ovpn ccd static net
2036 if ($type eq 'OpenVPN static network'){
2037 foreach my $key (keys %ccdnet) {
2038 if ($ccdnet{$key}[0] eq $name){
2039 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2040 $b=&General
::iporsubtodec
($b);
2046 #check custom addresses
2047 if ($type eq 'Custom Host'){
2048 foreach my $key (keys %customhost) {
2049 if ($customhost{$key}[0] eq $name){
2050 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2056 ##check custom networks
2057 if ($type eq 'Custom Network'){
2058 foreach my $key (keys %customnetwork) {
2059 if($customnetwork{$key}[0] eq $name){
2060 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2065 #check standard networks
2066 if ($type eq 'Standard Network'){
2067 if ($name =~ /OpenVPN/i){
2069 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2070 return $ovpn{'DOVPN_SUBNET'};
2072 if ($name eq 'GREEN'){
2074 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2075 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2077 if ($name eq 'BLUE'){
2079 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2080 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2082 if ($name eq 'ORANGE'){
2084 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2085 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2087 if ($name eq 'ALL'){
2088 return "0.0.0.0/0.0.0.0";
2090 if ($name =~ /IPsec/i){
2092 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2093 return $hash{'RW_NET'};
2100 &General
::readhasharray
("$confignet", \
%customnetwork);
2101 &General
::readhasharray
("$confighost", \
%customhost);
2102 foreach my $key (sort keys %customgrp ){
2103 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2104 foreach my $key1 (sort keys %customnetwork){
2105 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2106 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2112 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2113 foreach my $key2 (sort keys %customhost){
2114 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2115 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2122 &General
::writehasharray
("$confignet", \
%customnetwork);
2123 &General
::writehasharray
("$confighost", \
%customhost);
2128 &General
::readhasharray
("$configsrv", \
%customservice);
2129 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2131 foreach my $key (sort keys %customservicegrp){
2132 if ($customservicegrp{$key}[0] eq $grp ){
2133 foreach my $key2 (sort keys %customservice){
2134 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2135 $customservice{$key2}[4]--;
2140 &General
::writehasharray
("$configsrv", \
%customservice);
2146 my %hash=%{(shift)};
2148 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2149 $errormessage=$Lang::tr
{'fwhost err name1'};
2151 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2152 $errormessage=$Lang::tr
{'fwhost err port'};
2155 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2156 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2158 #change dashes with :
2159 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2161 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2162 $fwhostsettings{'SRV_PORT'} = "1:65535";
2164 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2165 $fwhostsettings{'SRV_PORT'} = "1:$2";
2167 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2168 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2170 if($fwhostsettings{'PROT'} ne 'ICMP'){
2171 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2173 # a new service has to have a different name
2174 foreach my $key (keys %hash){
2175 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2176 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2180 return $errormessage;
2184 # Checks a hostname against RFC1035
2185 my $hostname = $_[0];
2187 # Each part should be at least two characters in length
2188 # but no more than 63 characters
2189 if (length ($hostname) < 1 || length ($hostname) > 63) {
2191 # Only valid characters are a-z, A-Z, 0-9 and -
2192 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2194 # First character can only be a letter or a digit
2195 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2197 # Last character can only be a letter or a digit
2198 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2204 # Checks a hostname against RFC1035
2206 # Each part should be at least two characters in length
2207 # but no more than 63 characters
2208 if (length ($remark) < 1 || length ($remark) > 255) {
2210 # Only valid characters are a-z, A-Z, 0-9 and -
2211 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2213 # First character can only be a letter or a digit
2214 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2216 # Last character can only be a letter or a digit
2217 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2221 &Header
::closebigbox
();
2222 &Header
::closepage
();