]>
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}/forward/config";
64 my $fwconfiginp = "${General::swroot}/forward/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);
117 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
123 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
125 &General
::readhasharray
("$confignet", \
%customnetwork);
126 foreach my $key (keys %customnetwork)
128 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
130 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
131 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
132 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
133 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
134 $fwhostsettings{'count'} = $customnetwork{$key}[4];
135 delete $customnetwork{$key};
139 &General
::writehasharray
("$confignet", \
%customnetwork);
140 $fwhostsettings{'actualize'} = 'on';
141 $fwhostsettings{'ACTION'} = 'savenet';
143 if ($fwhostsettings{'ACTION'} eq 'updatehost')
146 &General
::readhasharray
("$confighost", \
%customhost);
147 foreach my $key (keys %customhost)
149 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
151 if ($customhost{$key}[1] eq 'ip'){
152 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
154 $ip = $customhost{$key}[2];
156 $fwhostsettings{'orgip'} = $ip;
157 $fwhostsettings{'count'} = $customhost{$key}[4];
158 delete $customhost{$key};
159 &General
::writehasharray
("$confighost", \
%customhost);
162 $fwhostsettings{'actualize'} = 'on';
163 if($fwhostsettings{'orgip'}){
164 $fwhostsettings{'ACTION'} = 'savehost';
166 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
169 if ($fwhostsettings{'ACTION'} eq 'updateservice')
173 $errormessage=&checkports
(\
%customservice);
175 &General
::readhasharray
("$configsrv", \
%customservice);
176 foreach my $key (keys %customservice)
178 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
180 $count=$customservice{$key}[4];
181 delete $customservice{$key};
182 &General
::writehasharray
("$configsrv", \
%customservice);
186 if ($fwhostsettings{'PROT'} ne 'ICMP'){
187 $fwhostsettings{'ICMP_TYPES'}='BLANK';
189 my $key1 = &General
::findhasharraykey
(\
%customservice);
190 #find out short ICMP-TYPE
191 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
192 foreach my $key (keys %icmptypes){
193 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
194 $fwhostsettings{'ICMP_TYPES'}=$icmptypes{$key}[0];
197 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
198 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
199 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
200 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
201 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
202 $customservice{$key1}[4] = $count;
203 &General
::writehasharray
("$configsrv", \
%customservice);
204 #check if we need to update firewallrules
205 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
206 if ( ! -z
$fwconfigfwd ){
207 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
208 foreach my $key (sort keys %fwfwd){
209 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
210 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
213 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
215 if ( ! -z
$fwconfiginp ){
216 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
217 foreach my $line (sort keys %fwinp){
218 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
219 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
222 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
224 #check if we need to update groups
225 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
226 foreach my $key (sort keys %customservicegrp){
227 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
228 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
231 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
234 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
237 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
240 if($count gt 0 && $fwhostsettings{'oldsrvicmp'} ne $fwhostsettings{'ICMP'} ){
243 $fwhostsettings{'SRV_NAME'} = '';
244 $fwhostsettings{'SRV_PORT'} = '';
245 $fwhostsettings{'PROT'} = '';
246 $fwhostsettings{'ICMP'} = '';
247 $fwhostsettings{'oldsrvicmp'} = '';
249 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
250 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
251 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
252 $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
253 $fwhostsettings{'updatesrv'}= 'on';
255 $fwhostsettings{'updatesrv'} = '';
256 if($needrules eq 'on'){
262 if ($fwhostsettings{'ACTION'} eq 'savenet' )
266 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
267 #check if all fields are set
268 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
270 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
275 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
277 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
278 $fwhostsettings{'BLK_HOST'} ='readonly';
279 $fwhostsettings{'NOCHECK'} ='false';
280 $fwhostsettings{'error'} ='on';
283 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
284 $errormessage=$Lang::tr
{'fwhost err remark'};
285 $fwhostsettings{'error'} ='on';
287 #check if subnet is sigle host
288 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
290 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
292 if($fwhostsettings{'error'} ne 'on'){
293 #check if we use one of ipfire's networks (green,orange,blue)
294 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
296 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
297 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
298 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
300 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
302 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
303 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
304 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
306 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
308 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
309 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
310 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
312 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
314 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
315 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
316 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
319 #only check plausi when no error till now
321 &plausicheck
("editnet");
323 #check if network ip is part of an already used one
324 if(&checksubnet
(\
%customnetwork))
326 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
327 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
329 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
331 $fwhostsettings{'actualize'} = '';
332 my $key = &General
::findhasharraykey
(\
%customnetwork);
333 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
334 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
335 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
336 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
337 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
338 $customnetwork{$key}[4] = $fwhostsettings{'count'};
339 &General
::writehasharray
("$confignet", \
%customnetwork);
340 undef %customnetwork;
344 &General
::readhasharray
("$confignet", \
%customnetwork);
345 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
346 if ($fwhostsettings{'update'} == '0'){
347 foreach my $key (keys %customnetwork) {
348 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
349 $count=$customnetwork{$key}[4];
350 delete $customnetwork{$key};
356 #get count if actualize is 'on'
357 if($fwhostsettings{'actualize'} eq 'on'){
358 $fwhostsettings{'actualize'} = '';
359 $count=$fwhostsettings{'count'};
360 #check if we need to reload rules
361 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
364 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
365 #check if we need to update groups
366 &General
::readhasharray
("$configgrp", \
%customgrp);
367 foreach my $key (sort keys %customgrp){
368 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
369 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
373 &General
::writehasharray
("$configgrp", \
%customgrp);
374 #check if we need to update firewallrules
375 if ( ! -z
$fwconfigfwd ){
376 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
377 foreach my $line (sort keys %fwfwd){
378 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
379 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
381 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
382 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
385 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
387 if ( ! -z
$fwconfiginp ){
388 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
389 foreach my $line (sort keys %fwinp){
390 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
391 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
394 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
398 my $key = &General
::findhasharraykey
(\
%customnetwork);
399 foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";}
400 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
401 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
402 #convert ip when leading '0' in byte
403 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
404 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
405 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
406 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
407 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
408 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
409 $customnetwork{$key}[4] = $count;
410 &General
::writehasharray
("$confignet", \
%customnetwork);
411 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
412 undef %customnetwork;
413 $fwhostsettings{'HOSTNAME'}='';
414 $fwhostsettings{'IP'}='';
415 $fwhostsettings{'SUBNET'}='';
416 $fwhostsettings{'NETREMARK'}='';
417 #check if an edited net affected groups and need to reload rules
418 if ($needrules eq 'on'){
429 if ($fwhostsettings{'ACTION'} eq 'savehost')
433 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
434 $fwhostsettings{'SUBNET'}='32';
435 #check if all fields are set
436 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
438 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
439 $fwhostsettings{'ACTION'} = 'edithost';
441 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
442 $fwhostsettings{'type'} = 'mac';
443 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
444 $fwhostsettings{'type'} = 'ip';
446 $fwhostsettings{'type'} = '';
447 $errormessage=$Lang::tr
{'fwhost err ipmac'};
450 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
451 $errormessage=$Lang::tr
{'fwhost err remark'};
454 if ($fwhostsettings{'type'} eq 'ip'){
456 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
457 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
459 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
460 $fwhostsettings{'error'}='on';
462 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
463 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
464 $fwhostsettings{'error'}='on';
466 #check if net or broadcast
467 my @tmp= split (/\./,$fwhostsettings{'IP'});
468 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
469 $errormessage=$Lang::tr
{'fwhost err hostip'};
472 #only check plausi when no error till now
474 &plausicheck
("edithost");
476 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
477 $fwhostsettings{'actualize'} = '';
478 my $key = &General
::findhasharraykey
(\
%customhost);
479 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
480 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
481 $customhost{$key}[1] = $fwhostsettings{'type'} ;
482 if($customhost{$key}[1] eq 'ip'){
483 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
485 $customhost{$key}[2] = $fwhostsettings{'orgip'};
487 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
488 $customhost{$key}[4] = $fwhostsettings{'count'};
489 &General
::writehasharray
("$confighost", \
%customhost);
493 #get count if host was edited
494 if($fwhostsettings{'actualize'} eq 'on'){
495 $count=$fwhostsettings{'count'};
496 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
499 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
500 #check if we need to update groups
501 &General
::readhasharray
("$configgrp", \
%customgrp);
502 foreach my $key (sort keys %customgrp){
503 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
504 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
507 &General
::writehasharray
("$configgrp", \
%customgrp);
508 #check if we need to update firewallrules
509 if ( ! -z
$fwconfigfwd ){
510 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
511 foreach my $line (sort keys %fwfwd){
512 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
513 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
515 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
516 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
519 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
521 if ( ! -z
$fwconfiginp ){
522 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
523 foreach my $line (sort keys %fwinp){
524 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
525 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
528 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
532 my $key = &General
::findhasharraykey
(\
%customhost);
533 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
534 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
535 $customhost{$key}[1] = $fwhostsettings{'type'} ;
536 if ($fwhostsettings{'type'} eq 'ip'){
537 #convert ip when leading '0' in byte
538 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
539 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
540 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
542 $customhost{$key}[2] = $fwhostsettings{'IP'};
544 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
545 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
546 $customhost{$key}[4] =$count;
547 &General
::writehasharray
("$confighost", \
%customhost);
549 $fwhostsettings{'HOSTNAME'}='';
550 $fwhostsettings{'IP'}='';
551 $fwhostsettings{'type'}='';
552 $fwhostsettings{'HOSTREMARK'}='';
553 #check if we need to update rules while host was edited
554 if($needrules eq 'on'){
565 if ($fwhostsettings{'ACTION'} eq 'savegrp')
567 my $grp=$fwhostsettings{'grp_name'};;
568 my $rem=$fwhostsettings{'remark'};
571 my $updcounter='off';
574 &General
::readhasharray
("$configgrp", \
%customgrp);
575 &General
::readhasharray
("$confignet", \
%customnetwork);
576 &General
::readhasharray
("$confighost", \
%customhost);
578 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
580 if (!checkgroup
(\
%customgrp,$grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
582 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
583 $errormessage.=$Lang::tr
{'fwhost err remark'};
585 if ($fwhostsettings{'update'} eq 'on'){
586 #check standard networks
587 if ($fwhostsettings{'grp2'} eq 'std_net'){
588 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
589 $type='Standard Network';
591 #check custom networks
592 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
593 @target=$fwhostsettings{'CUST_SRC_NET'};
595 $type='Custom Network';
596 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
597 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
598 $fwhostsettings{'grp_name'}='';
599 $fwhostsettings{'remark'}='';
601 #check custom addresses
602 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
603 @target=$fwhostsettings{'CUST_SRC_HOST'};
606 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
607 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
608 $fwhostsettings{'grp_name'}='';
609 $fwhostsettings{'remark'}='';
611 #get address from ovpn ccd static net
612 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
613 @target=$fwhostsettings{'OVPN_CCD_NET'};
614 $type='OpenVPN static network';
615 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
616 $errormessage=$Lang::tr
{'fwhost err groupempty'};
617 $fwhostsettings{'grp_name'}='';
618 $fwhostsettings{'remark'}='';
620 #get address from ovpn ccd static host
621 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
622 @target=$fwhostsettings{'OVPN_CCD_HOST'};
623 $type='OpenVPN static host';
624 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
625 $errormessage=$Lang::tr
{'fwhost err groupempty'};
627 #get address from ovpn ccd Net-2-Net
628 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
629 @target=$fwhostsettings{'OVPN_N2N'};
630 $type='OpenVPN N-2-N';
631 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
632 $errormessage=$Lang::tr
{'fwhost err groupempty'};
633 $fwhostsettings{'grp_name'}='';
634 $fwhostsettings{'remark'}='';
636 #get address from IPSEC HOST
637 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
638 @target=$fwhostsettings{'IPSEC_HOST'};
640 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
641 $errormessage=$Lang::tr
{'fwhost err groupempty'};
642 $fwhostsettings{'grp_name'}='';
643 $fwhostsettings{'remark'}='';
645 #get address from IPSEC NETWORK
646 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
647 @target=$fwhostsettings{'IPSEC_NET'};
648 $type='IpSec Network';
649 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
650 $errormessage=$Lang::tr
{'fwhost err groupempty'};
651 $fwhostsettings{'grp_name'}='';
652 $fwhostsettings{'remark'}='';
654 #check if host/net exists in grp
656 my $test="$grp,$fwhostsettings{'oldremark'},@target";
657 foreach my $key (keys %customgrp) {
658 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
659 if ($test1 eq $test){
660 $errormessage=$Lang::tr
{'fwhost err isingrp'};
661 $fwhostsettings{'update'} = 'on';
667 #on first save, we have an empty @target, so fill it with nothing
668 my $targetvalues=@target;
669 if ($targetvalues == '0'){
672 #on update, we have to delete the dummy entry
673 foreach my $key (keys %customgrp){
674 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
675 delete $customgrp{$key};
679 &General
::writehasharray
("$configgrp", \
%customgrp);
680 &General
::readhasharray
("$configgrp", \
%customgrp);
682 foreach my $key (keys %customgrp)
684 if($customgrp{$key}[0] eq $grp)
686 $count=$customgrp{$key}[4];
690 if ($count eq '' ){$count='0';}
692 #create array with new lines
693 foreach my $line (@target){
694 push (@newgrp,"$grp,$rem,$line");
697 my $key = &General
::findhasharraykey
(\
%customgrp);
698 foreach my $line (@newgrp){
699 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
700 my ($a,$b,$c,$d) = split (",",$line);
701 $customgrp{$key}[0] = $a;
702 $customgrp{$key}[1] = $b;
703 $customgrp{$key}[2] = $c;
704 $customgrp{$key}[3] = $type;
705 $customgrp{$key}[4] = $count;
707 &General
::writehasharray
("$configgrp", \
%customgrp);
708 #update counter in Host/Net
709 if($updcounter eq 'net'){
710 foreach my $key (keys %customnetwork) {
711 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
712 $customnetwork{$key}[4] = $customnetwork{$key}[4]+1;
716 &General
::writehasharray
("$confignet", \
%customnetwork);
717 }elsif($updcounter eq 'host'){
718 foreach my $key (keys %customhost) {
719 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
720 $customhost{$key}[4]=$customhost{$key}[4]+1;
723 &General
::writehasharray
("$confighost", \
%customhost);
725 $fwhostsettings{'update'}='on';
727 #check if ruleupdate is needed
735 if ($fwhostsettings{'ACTION'} eq 'saveservice')
738 &General
::readhasharray
("$configsrv", \
%customservice );
739 $errormessage=&checkports
(\
%customservice);
740 if ($fwhostsettings{'PROT'} eq 'ICMP'){
741 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
742 foreach my $key (keys %icmptypes){
743 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
744 $ICMP=$icmptypes{$key}[0];
748 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
750 my $key = &General
::findhasharraykey
(\
%customservice);
751 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
752 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
753 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
754 $customservice{$key}[2] = $fwhostsettings{'PROT'};
755 $customservice{$key}[3] = $ICMP;
756 $customservice{$key}[4] = 0;
757 &General
::writehasharray
("$configsrv", \
%customservice );
759 $fwhostsettings{'SRV_NAME'}='';
760 $fwhostsettings{'SRV_PORT'}='';
761 $fwhostsettings{'PROT'}='';
762 $fwhostsettings{'ICMP_TYPES'}='';
766 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
771 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
772 &General
::readhasharray
("$configsrv", \
%customservice );
773 $errormessage=&checkservicegroup
;
775 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
776 $errormessage=$Lang::tr
{'fwhost err remark'};
779 #on first save, we have to enter a dummy value
780 if ($fwhostsettings{'CUST_SRV'} eq ''){
781 $fwhostsettings{'CUST_SRV'}='none';
783 #on update, we have to delete the dummy entry
784 foreach my $key (keys %customservicegrp){
785 if ($customservicegrp{$key}[2] eq 'none'){
786 delete $customservicegrp{$key};
790 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
791 #check if remark has also changed
792 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
794 foreach my $key (keys %customservicegrp)
796 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
798 $customservicegrp{$key}[1]='';
799 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
804 foreach my $key (keys %customservicegrp)
806 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
808 $count=$customservicegrp{$key}[3];
812 if ($count eq '' ){$count='0';}
814 foreach my $key (sort keys %customservice){
815 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
816 $port=$customservice{$key}[1];
817 $prot=$customservice{$key}[2];
818 $customservice{$key}[4]++;
821 &General
::writehasharray
("$configsrv", \
%customservice );
822 my $key = &General
::findhasharraykey
(\
%customservicegrp);
823 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
824 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
825 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
826 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
827 $customservicegrp{$key}[3] = $count;
828 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
829 $fwhostsettings{'updatesrvgrp'}='on';
835 &viewtableservicegrp
;
838 if ($fwhostsettings{'ACTION'} eq 'editnet')
843 if ($fwhostsettings{'ACTION'} eq 'edithost')
848 if ($fwhostsettings{'ACTION'} eq 'editgrp')
850 $fwhostsettings{'update'}='on';
854 if ($fwhostsettings{'ACTION'} eq 'editservice')
856 $fwhostsettings{'updatesrv'}='on';
859 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
861 $fwhostsettings{'updatesrvgrp'} = 'on';
863 &viewtableservicegrp
;
866 if ($fwhostsettings{'ACTION'} eq 'resetnet')
868 $fwhostsettings{'HOSTNAME'} ="";
869 $fwhostsettings{'IP'} ="";
870 $fwhostsettings{'SUBNET'} ="";
873 if ($fwhostsettings{'ACTION'} eq 'resethost')
875 $fwhostsettings{'HOSTNAME'} ="";
876 $fwhostsettings{'IP'} ="";
877 $fwhostsettings{'type'} ="";
880 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
882 $fwhostsettings{'grp_name'} ="";
883 $fwhostsettings{'remark'} ="";
887 if ($fwhostsettings{'ACTION'} eq 'delnet')
889 &General
::readhasharray
("$confignet", \
%customnetwork);
890 foreach my $key (keys %customnetwork) {
891 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
892 delete $customnetwork{$key};
893 &General
::writehasharray
("$confignet", \
%customnetwork);
900 if ($fwhostsettings{'ACTION'} eq 'delhost')
902 &General
::readhasharray
("$confighost", \
%customhost);
903 foreach my $key (keys %customhost) {
904 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
905 delete $customhost{$key};
906 &General
::writehasharray
("$confighost", \
%customhost);
913 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
917 &General
::readhasharray
("$configgrp", \
%customgrp);
918 foreach my $key (keys %customgrp){
919 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
920 #decrease count from source host/net
921 if ($customgrp{$key}[3] eq 'Custom Network'){
922 &General
::readhasharray
("$confignet", \
%customnetwork);
923 foreach my $key1 (keys %customnetwork){
924 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
925 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
929 &General
::writehasharray
("$confignet", \
%customnetwork);
931 if ($customgrp{$key}[3] eq 'Custom Host'){
932 &General
::readhasharray
("$confighost", \
%customhost);
933 foreach my $key1 (keys %customhost){
934 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
935 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
939 &General
::writehasharray
("$confighost", \
%customhost);
941 $grpname=$customgrp{$key}[0];
942 $grpremark=$customgrp{$key}[1];
943 delete $customgrp{$key};
946 &General
::writehasharray
("$configgrp", \
%customgrp);
947 if ($fwhostsettings{'grpcnt'} > 0){&rules
;}
948 if ($fwhostsettings{'update'} eq 'on'){
949 $fwhostsettings{'remark'}= $grpremark;
950 $fwhostsettings{'grp_name'}=$grpname;
955 if ($fwhostsettings{'ACTION'} eq 'delgrp')
957 &General
::readhasharray
("$configgrp", \
%customgrp);
958 &decrease
($fwhostsettings{'grp_name'});
959 foreach my $key (sort keys %customgrp)
961 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
963 delete $customgrp{$key};
966 &General
::writehasharray
("$configgrp", \
%customgrp);
967 $fwhostsettings{'grp_name'}='';
971 if ($fwhostsettings{'ACTION'} eq 'delservice')
973 &General
::readhasharray
("$configsrv", \
%customservice);
974 foreach my $key (keys %customservice) {
975 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
976 #&deletefromgrp($customhost{$key}[0],$configgrp);
977 delete $customservice{$key};
978 &General
::writehasharray
("$configsrv", \
%customservice);
982 $fwhostsettings{'SRV_NAME'}='';
983 $fwhostsettings{'SRV_PORT'}='';
984 $fwhostsettings{'PROT'}='';
987 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
989 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
990 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
991 foreach my $key (sort keys %customservicegrp)
993 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
995 delete $customservicegrp{$key};
998 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
999 $fwhostsettings{'SRVGRP_NAME'}='';
1001 &viewtableservicegrp
;
1003 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
1007 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1008 &General
::readhasharray
("$configsrv", \
%customservice);
1009 foreach my $key (keys %customservicegrp){
1010 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
1012 #decrease count from source service
1013 foreach my $key1 (sort keys %customservice){
1014 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1015 $customservice{$key1}[4]--;
1019 &General
::writehasharray
("$configsrv", \
%customservice);
1020 $grpname=$customservicegrp{$key}[0];
1021 $grpremark=$customservicegrp{$key}[1];
1022 delete $customservicegrp{$key};
1025 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1027 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1028 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1029 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1032 &viewtableservicegrp
;
1035 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1040 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1045 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1050 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1054 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1057 &viewtableservicegrp
;
1059 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1061 &General
::readhasharray
("$configgrp", \
%customgrp);
1062 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1063 foreach my $key (sort keys %customgrp)
1065 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1067 $customgrp{$key}[1]='';
1068 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1071 &General
::writehasharray
("$configgrp", \
%customgrp);
1072 $fwhostsettings{'update'}='on';
1073 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1075 $errormessage=$Lang::tr
{'fwhost err remark'};
1076 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1077 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1078 $fwhostsettings{'update'} = 'on';
1080 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1084 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1086 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1087 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1088 foreach my $key (sort keys %customservicegrp)
1090 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1092 $customservicegrp{$key}[1]='';
1093 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1096 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1097 $fwhostsettings{'updatesrvgrp'}='on';
1098 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1100 $errormessage=$Lang::tr
{'fwhost err remark'};
1101 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1102 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1103 $fwhostsettings{'updatesrvgrp'} = 'on';
1105 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1107 &viewtableservicegrp
;
1110 if($fwhostsettings{'ACTION'} eq '')
1117 if (-f
"${General::swroot}/forward/reread"){
1118 print "<table border='1' rules='groups' bgcolor='lightgreen' width='100%'><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: green; font-weight: bold; font-size: 14pt;'>    $Lang::tr{'fwhost reread'}</td></tr></table></form><br>";
1120 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1121 print "$Lang::tr{'fwhost welcome'}";
1123 <br><br><table border='0' width='100%'>
1124 <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>
1125 <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>
1126 <tr><td colspan='6'><hr></td></tr></table>
1128 &Header
::closebox
();
1136 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1137 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1138 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1140 <table border='0' width='100%'>
1141 <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>
1142 <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>
1143 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1144 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1145 <tr><td colspan='6'><br><hr></td></tr><tr>
1147 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1149 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>";
1151 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'>";
1153 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>";
1154 &Header
::closebox
();
1160 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1161 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1162 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1164 <table border='0' width='100%'>
1165 <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>
1166 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1167 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1168 <tr><td colspan='5'><hr></td></tr><tr>
1171 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1174 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>";
1176 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'>";
1178 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>";
1179 &Header
::closebox
();
1186 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1187 &General
::setup_default_networks
(\
%defaultNetworks);
1188 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1189 &General
::readhasharray
("$confignet", \
%customnetwork);
1190 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1191 &General
::readhasharray
("$confighost", \
%customhost);
1192 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1196 $checked{'check1'}{'off'} = '';
1197 $checked{'check1'}{'on'} = '';
1198 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1199 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1200 my $grp=$fwhostsettings{'grp_name'};
1201 my $rem=$fwhostsettings{'remark'};
1202 if ($fwhostsettings{'update'} eq ''){
1204 <table width='100%' border='0'>
1205 <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>
1206 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1207 <tr><td colspan='2'><br><hr></td></tr></table>
1211 <table width='100%' border='0'><form method='post' style='display:inline'>
1212 <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>
1213 <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>
1217 if ($fwhostsettings{'update'} eq 'on'){
1219 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1220 <table width='100%' border='0'>
1221 <tr><td width=50% valign='top'>
1222 <table width='100%' border='0'>
1223 <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;'>
1225 foreach my $network (sort keys %defaultNetworks)
1227 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1228 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1229 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1230 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1231 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1232 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1233 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1234 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1235 if ($ownnet{$defnet}){
1236 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1238 print ">$network</option>";
1241 print"</select></td></tr>";
1242 if (! -z
$confignet){
1243 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;'>";
1244 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1245 print"<option>$customnetwork{$key}[0]</option>";
1247 print"</select></td></tr>";
1249 if (! -z
$confighost){
1250 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;'>";
1251 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1252 print"<option>$customhost{$key}[0]</option>";
1254 print"</select></td></tr>";
1258 print"</td><td valign='top'><table width='100%' border='0'>";
1260 if (! -z
$configccdnet){
1261 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;'>";
1262 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1264 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1266 print"</select></td></tr>";
1269 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1271 if ($ccdhost{$key}[33] ne ''){
1272 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 '');
1274 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1277 if ($show eq '1'){$show='';print"</select></td></tr>";}
1279 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1280 if($ccdhost{$key}[3] eq 'net'){
1281 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 '');
1283 print"<option>$ccdhost{$key}[1]</option>";
1286 if ($show eq '1'){$show='';print"</select></td></tr>";}
1288 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1289 if ($ipsecconf{$key}[3] eq 'net'){
1290 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 '');
1292 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1295 if ($show eq '1'){$show='';print"</select></td></tr>";}
1297 print"</td></tr></table>";
1298 print"<br><br><hr>";
1300 print"<table border='0' width='100%'>";
1301 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>";
1302 &Header
::closebox
();
1308 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1309 if ($fwhostsettings{'updatesrv'} eq 'on')
1311 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1312 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1313 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1314 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1317 <table width='100%' border='0'><form method='post'>
1318 <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>
1319 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1321 foreach ("TCP","UDP","ICMP")
1323 if ($_ eq $fwhostsettings{'PROT'})
1325 print"<option selected>$_</option>";
1327 print"<option>$_</option>";
1331 </select></td></tr></table>
1332 <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'>
1334 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1335 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1336 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1337 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1338 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1340 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1344 </select></td></tr></table></div>
1345 <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>
1346 <table width='100%' border='0'><tr><td colspan='6'><br><hr></td></tr>
1347 <tr><td colspan='6' align='right'>
1349 if ($fwhostsettings{'updatesrv'} eq 'on')
1352 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1353 <input type='hidden' name='ACTION' value='updateservice'>
1354 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1355 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1356 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1357 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1361 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1364 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1367 &Header
::closebox
();
1375 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1376 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1377 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1379 <table width='100%' border='0'><form method='post'>
1380 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1381 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1382 <tr><td colspan='2'><br><hr></tr>
1387 <table width='100%' border='0'><form method='post' style='display:inline'>
1388 <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>
1389 <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>
1390 <tr><td colspan='3'><br><hr></td></td></tr>
1394 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1396 <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%'>
1397 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1399 &General
::readhasharray
("$configsrv", \
%customservice);
1400 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1402 print "<option>$customservice{$key}[0]</option>";
1406 <tr><td colspan='4'><br><br></td></tr>
1407 <tr><td colspan='4'><hr></td></tr>
1412 <table width='100%' border='0'>
1413 <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>
1416 &Header
::closebox
();
1421 if(! -z
$confignet){
1422 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1423 &General
::readhasharray
("$confignet", \
%customnetwork);
1424 if (!keys %customnetwork)
1426 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1429 <table border='0' width='100%' cellspacing='0'>
1430 <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>
1434 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1435 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1436 print" <tr bgcolor='${Header::colouryellow}'>";
1439 print" <tr bgcolor='$color{'color22'}'>";
1442 print" <tr bgcolor='$color{'color20'}'>";
1444 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1445 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>";
1447 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1448 <input type='hidden' name='ACTION' value='editnet'>
1449 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1450 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1451 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1452 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1455 if($customnetwork{$key}[4] == '0')
1457 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>";
1459 print"<td></td></tr>";
1464 &Header
::closebox
();
1471 #Check if IP is part of OpenVPN N2N subnet
1472 foreach my $key (sort keys %ccdhost){
1473 if ($ccdhost{$key}[3] eq 'net'){
1474 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1475 if (&General
::IpInSubnet
($c,$a,$b)){
1476 $tdcolor="style='color:$Header::colourovpn ;'";
1481 #Check if IP is part of OpenVPN dynamic subnet
1482 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1483 if (&General
::IpInSubnet
($c,$a,$b)){
1484 $tdcolor="style='color: $Header::colourovpn;'";
1487 #Check if IP is part of OpenVPN static subnet
1488 foreach my $key (sort keys %ccdnet){
1489 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1490 $b =&General
::iporsubtodec
($b);
1491 if (&General
::IpInSubnet
($c,$a,$b)){
1492 $tdcolor="style='color: $Header::colourovpn;'";
1496 #Check if IP is part of IPsec RW network
1497 if ($ipsecsettings{'RW_NET'} ne ''){
1498 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1499 $b=&General
::iporsubtodec
($b);
1500 if (&General
::IpInSubnet
($c,$a,$b)){
1501 $tdcolor="style='color: $Header::colourvpn;'";
1505 #Check if IP is part of a IPsec N2N network
1506 foreach my $key (sort keys %ipsecconf){
1507 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1508 if (&General
::IpInSubnet
($c,$a,$b)){
1509 $tdcolor="style='color: $Header::colourvpn;'";
1518 if (! -z
$confighost){
1519 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1520 &General
::readhasharray
("$confighost", \
%customhost);
1521 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1522 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1523 if (!keys %customhost)
1525 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1528 <table border='0' width='100%' cellspacing='0'>
1529 <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>
1533 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1534 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1535 print" <tr bgcolor='${Header::colouryellow}'>";
1536 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1537 else{ print" <tr bgcolor='$color{'color20'}'>";}
1538 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1539 $customhost{$key}[4]=~s/\s+//g;
1540 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>";
1542 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1543 <input type='hidden' name='ACTION' value='edithost' />
1544 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1545 <input type='hidden' name='IP' value='$ip' />
1546 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1547 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1550 if($customhost{$key}[4] == '0')
1552 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>";
1554 print"<td width='1%'></td></tr>";
1559 &Header
::closebox
();
1564 if(! -z
"$configgrp"){
1565 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1566 &General
::readhasharray
("$configgrp", \
%customgrp);
1567 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1568 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1569 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1570 &General
::readhasharray
("$confighost", \
%customhost);
1571 &General
::readhasharray
("$confignet", \
%customnetwork);
1579 if (!keys %customgrp)
1581 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1583 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1585 if ($helper ne $customgrp{$key}[0]){
1587 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1588 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1597 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
1598 $grpname=$customgrp{$key}[0];
1599 $remark="$customgrp{$key}[1]";
1600 if($count gt 1){ print"</table>";}
1601 print "<br><b><u>$grpname</u></b> ";
1602 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1603 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1604 if($customgrp{$key}[4] == '0')
1606 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>";
1608 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>";
1609 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>";
1612 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1613 print" <tr bgcolor='${Header::colouryellow}'>";
1614 }elsif ($count %2 == 0){
1615 print"<tr bgcolor='$color{'color22'}'>";
1617 print"<tr bgcolor='$color{'color20'}'>";
1619 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1620 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1621 print "<td width='39%' align='left'>";
1622 if($customgrp{$key}[3] eq 'Standard Network'){
1623 print &get_name
($customgrp{$key}[2])."</td>";
1625 print "$customgrp{$key}[2]</td>";
1627 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
1628 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1630 my ($colip,$colsub) = split("/",$ip);
1631 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1632 print"<td align='center' ".&getcolor
($colip).">".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1634 if ($delflag > '1' && $ip ne ''){
1635 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1637 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>";
1639 $helper=$customgrp{$key}[0];
1644 &Header
::closebox
();
1648 sub viewtableservice
1651 if(! -z
"$configsrv")
1653 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1654 &General
::readhasharray
("$configsrv", \
%customservice);
1656 <table width='100%' border='0' cellspacing='0'>
1657 <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>
1659 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1662 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1663 print" <tr bgcolor='${Header::colouryellow}'>";
1664 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1666 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1668 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
1669 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1671 </td><td align='center'>$customservice{$key}[4]x</td>
1672 <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' />
1673 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1674 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1675 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
1676 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
1678 if ($customservice{$key}[4] eq '0')
1680 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>";
1682 print"<td></td></tr>";
1686 &Header
::closebox
();
1689 sub viewtableservicegrp
1698 if (! -z
$configsrvgrp){
1699 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1700 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1701 &General
::readhasharray
("$configsrv", \
%customservice);
1702 my $number= keys %customservicegrp;
1703 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1705 if ($helper ne $customservicegrp{$key}[0]){
1707 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1708 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1716 $grpname=$customservicegrp{$key}[0];
1717 if ($customservicegrp{$key}[2] eq "none"){
1718 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1722 $remark="$customservicegrp{$key}[1]";
1723 if($count >=2){print"</table>";}
1724 print "<br><b><u>$grpname</u></b> ";
1725 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1726 print " <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1727 if($customservicegrp{$key}[3] == '0')
1729 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>";
1731 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>";
1732 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>";
1734 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1735 print" <tr bgcolor='${Header::colouryellow}'>";
1736 }elsif ($count %2 == 0){
1737 print"<tr bgcolor='$color{'color22'}'>";
1739 print"<tr bgcolor='$color{'color20'}'>";
1741 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1742 foreach my $srv (sort keys %customservice){
1743 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1744 $protocol=$customservice{$srv}[2];
1745 $port=$customservice{$srv}[1];
1749 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1750 if ($delflag gt '1'){
1751 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1753 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>";
1754 $helper=$customservicegrp{$key}[0];
1757 &Header
::closebox
();
1763 my %hash=%{(shift)};
1764 foreach my $key (keys %hash) {
1765 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1774 my %hash=%{(shift)};
1776 foreach my $key (keys %hash) {
1777 if($hash{$key}[0] eq $name){
1786 my %hash=%{(shift)};
1788 foreach my $key (keys %hash) {
1789 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1797 my %hash=%{(shift)};
1798 &General
::readhasharray
("$confignet", \
%hash);
1799 foreach my $key (keys %hash) {
1800 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1807 sub checkservicegroup
1809 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1813 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1815 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1816 return $errormessage;
1818 #check empty selectbox
1819 if (keys %customservice lt 1)
1821 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1823 #check if name already exists
1824 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1825 foreach my $key (keys %customservicegrp) {
1826 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1827 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1832 #check if service already exists in group
1833 foreach my $key (keys %customservicegrp) {
1834 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1835 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1838 return $errormessage;
1842 if ($errormessage) {
1843 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1844 print "<class name='base'>$errormessage\n";
1845 print " </class>\n";
1846 &Header
::closebox
();
1852 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1853 print "<class name='base'>$hint\n";
1854 print " </class>\n";
1855 &Header
::closebox
();
1861 &General
::setup_default_networks
(\
%defaultNetworks);
1862 foreach my $network (sort keys %defaultNetworks)
1864 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1873 &General
::readhasharray
("$config",\
%hash);
1874 foreach my $key (keys %hash) {
1875 $errormessage.="lese $hash{$key}[2] und $target<br>";
1876 if($hash{$key}[2] eq $target){
1879 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1882 &General
::writehasharray
("$config",\
%hash);
1889 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
1891 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1892 $fwhostsettings{'BLK_IP'}='readonly';
1893 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1894 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1896 #check if name collides with CCD Netname
1897 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1898 foreach my $key (keys %ccdnet) {
1899 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1900 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1901 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1902 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1906 #check if IP collides with CCD NetIP
1907 if ($fwhostsettings{'type'} ne 'mac'){
1908 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1909 foreach my $key (keys %ccdnet) {
1910 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1911 if($ccdnet{$key}[1] eq $test){
1912 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1913 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1914 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1915 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1920 #check if name collides with CCD Hostname
1921 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1922 foreach my $key (keys %ccdhost) {
1923 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1924 if($ip eq $fwhostsettings{'IP'}){
1925 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1926 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1930 #check if IP collides with CCD HostIP (only hosts)
1931 if ($edit eq 'edithost')
1933 foreach my $key (keys %ccdhost) {
1934 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1935 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1936 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1937 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1942 #check if network with this name already exists
1943 &General
::readhasharray
("$confignet", \
%customnetwork);
1944 if (!&checkname
(\
%customnetwork))
1946 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1947 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1948 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1950 #check if network ip already exists
1951 if (!&checkip
(\
%customnetwork,1))
1953 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1954 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1956 #check if host with this name already exists
1957 &General
::readhasharray
("$confighost", \
%customhost);
1958 if (!&checkname
(\
%customhost))
1960 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1961 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1962 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1964 #check if host with this ip already exists
1965 if (!&checkip
(\
%customhost,2))
1967 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1977 #get address from IPSEC NETWORK
1978 if ($type eq 'IpSec Network'){
1979 foreach my $key (keys %ipsecconf) {
1980 if ($ipsecconf{$key}[1] eq $name){
1981 return $ipsecconf{$key}[11];
1984 &deletefromgrp
($name,$configgrp);
1987 #get address from IPSEC HOST
1988 if ($type eq 'IpSec Host'){
1989 foreach my $key (keys %ipsecconf) {
1990 if ($ipsecconf{$key}[1] eq $name){
1991 return $ipsecconf{$key}[10];
1994 &deletefromgrp
($name,$configgrp);
1997 #get address from ovpn ccd Net-2-Net
1998 if ($type eq 'OpenVPN N-2-N'){
1999 foreach my $key (keys %ccdhost) {
2000 if($ccdhost{$key}[1] eq $name){
2001 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2002 $b=&General
::iporsubtodec
($b);
2006 &deletefromgrp
($name,$configgrp);
2009 #get address from ovpn ccd static host
2010 if ($type eq 'OpenVPN static host'){
2011 foreach my $key (keys %ccdhost) {
2012 if($ccdhost{$key}[1] eq $name){
2013 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2014 $b=&General
::iporsubtodec
($b);
2018 &deletefromgrp
($name,$configgrp);
2021 #get address from ovpn ccd static net
2022 if ($type eq 'OpenVPN static network'){
2023 foreach my $key (keys %ccdnet) {
2024 if ($ccdnet{$key}[0] eq $name){
2025 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2026 $b=&General
::iporsubtodec
($b);
2032 #check custom addresses
2033 if ($type eq 'Custom Host'){
2034 foreach my $key (keys %customhost) {
2035 if ($customhost{$key}[0] eq $name){
2036 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2042 ##check custom networks
2043 if ($type eq 'Custom Network'){
2044 foreach my $key (keys %customnetwork) {
2045 if($customnetwork{$key}[0] eq $name){
2046 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2051 #check standard networks
2052 if ($type eq 'Standard Network'){
2053 if ($name =~ /OpenVPN/i){
2055 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2056 return $ovpn{'DOVPN_SUBNET'};
2058 if ($name eq 'GREEN'){
2060 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2061 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2063 if ($name eq 'BLUE'){
2065 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2066 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2068 if ($name eq 'ORANGE'){
2070 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2071 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2073 if ($name eq 'ALL'){
2074 return "0.0.0.0/0.0.0.0";
2076 if ($name =~ /IPsec/i){
2078 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2079 return $hash{'RW_NET'};
2085 if (!-f
"${General::swroot}/fwhosts/reread"){
2086 system("touch ${General::swroot}/fwhosts/reread");
2087 system("touch ${General::swroot}/forward/reread");
2092 system ("/usr/local/bin/forwardfwctrl");
2093 if ( -f
"${General::swroot}/fwhosts/reread"){
2094 system("rm ${General::swroot}/fwhosts/reread");
2095 system("rm ${General::swroot}/forward/reread");
2102 &General
::readhasharray
("$confignet", \
%customnetwork);
2103 &General
::readhasharray
("$confighost", \
%customhost);
2104 foreach my $key (sort keys %customgrp ){
2105 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2106 foreach my $key1 (sort keys %customnetwork){
2107 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2108 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2114 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2115 foreach my $key2 (sort keys %customhost){
2116 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2117 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2124 &General
::writehasharray
("$confignet", \
%customnetwork);
2125 &General
::writehasharray
("$confighost", \
%customhost);
2130 &General
::readhasharray
("$configsrv", \
%customservice);
2131 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2133 foreach my $key (sort keys %customservicegrp){
2134 if ($customservicegrp{$key}[0] eq $grp ){
2135 foreach my $key2 (sort keys %customservice){
2136 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2137 $customservice{$key2}[4]--;
2142 &General
::writehasharray
("$configsrv", \
%customservice);
2148 my %hash=%{(shift)};
2150 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2151 $errormessage=$Lang::tr
{'fwhost err name1'};
2153 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2154 $errormessage=$Lang::tr
{'fwhost err port'};
2157 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2158 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2160 #change dashes with :
2161 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2163 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2164 $fwhostsettings{'SRV_PORT'} = "1:65535";
2166 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2167 $fwhostsettings{'SRV_PORT'} = "1:$2";
2169 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2170 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2172 if($fwhostsettings{'PROT'} ne 'ICMP'){
2173 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2175 # a new service has to have a different name
2176 foreach my $key (keys %hash){
2177 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2178 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2182 return $errormessage;
2186 # Checks a hostname against RFC1035
2187 my $hostname = $_[0];
2189 # Each part should be at least two characters in length
2190 # but no more than 63 characters
2191 if (length ($hostname) < 1 || length ($hostname) > 63) {
2193 # Only valid characters are a-z, A-Z, 0-9 and -
2194 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2196 # First character can only be a letter or a digit
2197 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2199 # Last character can only be a letter or a digit
2200 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2206 # Checks a hostname against RFC1035
2208 # Each part should be at least two characters in length
2209 # but no more than 63 characters
2210 if (length ($remark) < 1 || length ($remark) > 255) {
2212 # Only valid characters are a-z, A-Z, 0-9 and -
2213 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2215 # First character can only be a letter or a digit
2216 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2218 # Last character can only be a letter or a digit
2219 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2223 &Header
::closebigbox
();
2224 &Header
::closepage
();