]>
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 \$(document).ready(function() {
92 // Automatically select radio buttons when corresponding
93 // dropdown menu changes.
94 \$("select").change(function() {
95 var id = \$(this).attr("name");
96 //When using SNAT or DNAT, check "USE NAT" Checkbox
97 if ( id === 'snat' || id === 'dnat') {
98 \$('#USE_NAT').prop('checked', true);
100 \$('#' + id).prop("checked", true);
102 // When protokol is not ICMP hide icmp-types
103 if ( \$("#PROT").val() === 'ICMP') {
104 \$('PROTOKOLL').hide();
106 // When protocol dropdown is changed, check if we selected icmp - then show icmp-types
107 \$("#prt").change(function(){
108 if ( \$("#PROT").val() === 'ICMP' ){
109 \$('PROTOKOLL').show();
112 \$('PROTOKOLL').hide();
116 function hide_elements(){
117 var elementNames = hide_elements.arguments;
118 for (var i=0; i<elementNames.length; i++)
120 var elementName = elementNames[i];
121 document.getElementById(elementName).style.display='none';
124 function getdropdown(){
125 d = document.getElementById("PROT").value;
128 document.getElementById('PROTOKOLL').style.display='block';
132 document.getElementById('PROTOKOLL').style.display='none';
134 if(document.getElementById('PROTOKOLL').style.display== "block" )
136 document.getElementById('PORT').style.display='none';
138 if(document.getElementById('PROTOKOLL').style.display== "none" )
140 document.getElementById('PORT').style.display='block';
147 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
153 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
155 &General
::readhasharray
("$confignet", \
%customnetwork);
156 foreach my $key (keys %customnetwork)
158 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
160 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
161 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
162 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
163 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
164 $fwhostsettings{'count'} = $customnetwork{$key}[4];
165 delete $customnetwork{$key};
169 &General
::writehasharray
("$confignet", \
%customnetwork);
170 $fwhostsettings{'actualize'} = 'on';
171 $fwhostsettings{'ACTION'} = 'savenet';
173 if ($fwhostsettings{'ACTION'} eq 'updatehost')
176 &General
::readhasharray
("$confighost", \
%customhost);
177 foreach my $key (keys %customhost)
179 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
181 if ($customhost{$key}[1] eq 'ip'){
182 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
184 $ip = $customhost{$key}[2];
186 $fwhostsettings{'orgip'} = $ip;
187 $fwhostsettings{'count'} = $customhost{$key}[4];
188 delete $customhost{$key};
189 &General
::writehasharray
("$confighost", \
%customhost);
192 $fwhostsettings{'actualize'} = 'on';
193 if($fwhostsettings{'orgip'}){
194 $fwhostsettings{'ACTION'} = 'savehost';
196 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
199 if ($fwhostsettings{'ACTION'} eq 'updateservice')
203 $errormessage=&checkports
(\
%customservice);
205 &General
::readhasharray
("$configsrv", \
%customservice);
206 foreach my $key (keys %customservice)
208 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
210 $count=$customservice{$key}[4];
211 delete $customservice{$key};
212 &General
::writehasharray
("$configsrv", \
%customservice);
216 if ($fwhostsettings{'PROT'} ne 'ICMP'){
217 $fwhostsettings{'ICMP_TYPES'}='BLANK';
219 my $key1 = &General
::findhasharraykey
(\
%customservice);
220 #find out short ICMP-TYPE
221 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
222 foreach my $key (keys %icmptypes){
223 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
224 $fwhostsettings{'ICMP_TYPES'}=$icmptypes{$key}[0];
227 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
228 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
229 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
230 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
231 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
232 $customservice{$key1}[4] = $count;
233 &General
::writehasharray
("$configsrv", \
%customservice);
234 #check if we need to update firewallrules
235 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
236 if ( ! -z
$fwconfigfwd ){
237 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
238 foreach my $key (sort keys %fwfwd){
239 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
240 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
243 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
245 if ( ! -z
$fwconfiginp ){
246 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
247 foreach my $line (sort keys %fwinp){
248 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
249 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
252 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
254 #check if we need to update groups
255 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
256 foreach my $key (sort keys %customservicegrp){
257 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
258 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
261 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
264 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
267 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
270 if($count gt 0 && $fwhostsettings{'oldsrvicmp'} ne $fwhostsettings{'ICMP'} ){
273 $fwhostsettings{'SRV_NAME'} = '';
274 $fwhostsettings{'SRV_PORT'} = '';
275 $fwhostsettings{'PROT'} = '';
276 $fwhostsettings{'ICMP'} = '';
277 $fwhostsettings{'oldsrvicmp'} = '';
279 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
280 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
281 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
282 $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
283 $fwhostsettings{'updatesrv'}= 'on';
285 $fwhostsettings{'updatesrv'} = '';
286 if($needrules eq 'on'){
292 if ($fwhostsettings{'ACTION'} eq 'savenet' )
296 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
297 #check if all fields are set
298 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
300 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
305 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
307 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
308 $fwhostsettings{'BLK_HOST'} ='readonly';
309 $fwhostsettings{'NOCHECK'} ='false';
310 $fwhostsettings{'error'} ='on';
313 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
314 $errormessage=$Lang::tr
{'fwhost err remark'};
315 $fwhostsettings{'error'} ='on';
317 #check if subnet is sigle host
318 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
320 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
322 if($fwhostsettings{'error'} ne 'on'){
323 #check if we use one of ipfire's networks (green,orange,blue)
324 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
326 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
327 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
328 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
330 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
332 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
333 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
334 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
336 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
338 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
339 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
340 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
342 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
344 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
345 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
346 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
349 #only check plausi when no error till now
351 &plausicheck
("editnet");
353 #check if network ip is part of an already used one
354 if(&checksubnet
(\
%customnetwork))
356 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
357 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
359 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
361 $fwhostsettings{'actualize'} = '';
362 my $key = &General
::findhasharraykey
(\
%customnetwork);
363 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
364 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
365 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
366 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
367 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
368 $customnetwork{$key}[4] = $fwhostsettings{'count'};
369 &General
::writehasharray
("$confignet", \
%customnetwork);
370 undef %customnetwork;
374 &General
::readhasharray
("$confignet", \
%customnetwork);
375 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
376 if ($fwhostsettings{'update'} == '0'){
377 foreach my $key (keys %customnetwork) {
378 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
379 $count=$customnetwork{$key}[4];
380 delete $customnetwork{$key};
386 #get count if actualize is 'on'
387 if($fwhostsettings{'actualize'} eq 'on'){
388 $fwhostsettings{'actualize'} = '';
389 $count=$fwhostsettings{'count'};
390 #check if we need to reload rules
391 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
394 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
395 #check if we need to update groups
396 &General
::readhasharray
("$configgrp", \
%customgrp);
397 foreach my $key (sort keys %customgrp){
398 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
399 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
403 &General
::writehasharray
("$configgrp", \
%customgrp);
404 #check if we need to update firewallrules
405 if ( ! -z
$fwconfigfwd ){
406 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
407 foreach my $line (sort keys %fwfwd){
408 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
409 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
411 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
412 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
415 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
417 if ( ! -z
$fwconfiginp ){
418 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
419 foreach my $line (sort keys %fwinp){
420 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
421 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
424 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
428 my $key = &General
::findhasharraykey
(\
%customnetwork);
429 foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";}
430 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
431 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
432 #convert ip when leading '0' in byte
433 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
434 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
435 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
436 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
437 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
438 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
439 $customnetwork{$key}[4] = $count;
440 &General
::writehasharray
("$confignet", \
%customnetwork);
441 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
442 undef %customnetwork;
443 $fwhostsettings{'HOSTNAME'}='';
444 $fwhostsettings{'IP'}='';
445 $fwhostsettings{'SUBNET'}='';
446 $fwhostsettings{'NETREMARK'}='';
447 #check if an edited net affected groups and need to reload rules
448 if ($needrules eq 'on'){
459 if ($fwhostsettings{'ACTION'} eq 'savehost')
463 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
464 $fwhostsettings{'SUBNET'}='32';
465 #check if all fields are set
466 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
468 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
469 $fwhostsettings{'ACTION'} = 'edithost';
471 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
472 $fwhostsettings{'type'} = 'mac';
473 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
474 $fwhostsettings{'type'} = 'ip';
476 $fwhostsettings{'type'} = '';
477 $errormessage=$Lang::tr
{'fwhost err ipmac'};
480 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
481 $errormessage=$Lang::tr
{'fwhost err remark'};
484 if ($fwhostsettings{'type'} eq 'ip'){
486 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
487 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
489 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
490 $fwhostsettings{'error'}='on';
492 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
493 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
494 $fwhostsettings{'error'}='on';
496 #check if net or broadcast
497 my @tmp= split (/\./,$fwhostsettings{'IP'});
498 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
499 $errormessage=$Lang::tr
{'fwhost err hostip'};
502 #only check plausi when no error till now
504 &plausicheck
("edithost");
506 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
507 $fwhostsettings{'actualize'} = '';
508 my $key = &General
::findhasharraykey
(\
%customhost);
509 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
510 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
511 $customhost{$key}[1] = $fwhostsettings{'type'} ;
512 if($customhost{$key}[1] eq 'ip'){
513 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
515 $customhost{$key}[2] = $fwhostsettings{'orgip'};
517 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
518 $customhost{$key}[4] = $fwhostsettings{'count'};
519 &General
::writehasharray
("$confighost", \
%customhost);
523 #get count if host was edited
524 if($fwhostsettings{'actualize'} eq 'on'){
525 $count=$fwhostsettings{'count'};
526 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
529 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
530 #check if we need to update groups
531 &General
::readhasharray
("$configgrp", \
%customgrp);
532 foreach my $key (sort keys %customgrp){
533 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
534 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
537 &General
::writehasharray
("$configgrp", \
%customgrp);
538 #check if we need to update firewallrules
539 if ( ! -z
$fwconfigfwd ){
540 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
541 foreach my $line (sort keys %fwfwd){
542 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
543 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
545 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
546 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
549 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
551 if ( ! -z
$fwconfiginp ){
552 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
553 foreach my $line (sort keys %fwinp){
554 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
555 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
558 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
562 my $key = &General
::findhasharraykey
(\
%customhost);
563 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
564 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
565 $customhost{$key}[1] = $fwhostsettings{'type'} ;
566 if ($fwhostsettings{'type'} eq 'ip'){
567 #convert ip when leading '0' in byte
568 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
569 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
570 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
572 $customhost{$key}[2] = $fwhostsettings{'IP'};
574 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
575 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
576 $customhost{$key}[4] =$count;
577 &General
::writehasharray
("$confighost", \
%customhost);
579 $fwhostsettings{'HOSTNAME'}='';
580 $fwhostsettings{'IP'}='';
581 $fwhostsettings{'type'}='';
582 $fwhostsettings{'HOSTREMARK'}='';
583 #check if we need to update rules while host was edited
584 if($needrules eq 'on'){
595 if ($fwhostsettings{'ACTION'} eq 'savegrp')
597 my $grp=$fwhostsettings{'grp_name'};;
598 my $rem=$fwhostsettings{'remark'};
601 my $updcounter='off';
604 &General
::readhasharray
("$configgrp", \
%customgrp);
605 &General
::readhasharray
("$confignet", \
%customnetwork);
606 &General
::readhasharray
("$confighost", \
%customhost);
608 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
610 if (!checkgroup
(\
%customgrp,$grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
612 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
613 $errormessage.=$Lang::tr
{'fwhost err remark'};
615 if ($fwhostsettings{'update'} eq 'on'){
616 #check standard networks
617 if ($fwhostsettings{'grp2'} eq 'std_net'){
618 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
619 $type='Standard Network';
621 #check custom networks
622 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
623 @target=$fwhostsettings{'CUST_SRC_NET'};
625 $type='Custom Network';
626 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
627 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
628 $fwhostsettings{'grp_name'}='';
629 $fwhostsettings{'remark'}='';
631 #check custom addresses
632 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
633 @target=$fwhostsettings{'CUST_SRC_HOST'};
636 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
637 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
638 $fwhostsettings{'grp_name'}='';
639 $fwhostsettings{'remark'}='';
641 #get address from ovpn ccd static net
642 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
643 @target=$fwhostsettings{'OVPN_CCD_NET'};
644 $type='OpenVPN static network';
645 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
646 $errormessage=$Lang::tr
{'fwhost err groupempty'};
647 $fwhostsettings{'grp_name'}='';
648 $fwhostsettings{'remark'}='';
650 #get address from ovpn ccd static host
651 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
652 @target=$fwhostsettings{'OVPN_CCD_HOST'};
653 $type='OpenVPN static host';
654 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
655 $errormessage=$Lang::tr
{'fwhost err groupempty'};
657 #get address from ovpn ccd Net-2-Net
658 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
659 @target=$fwhostsettings{'OVPN_N2N'};
660 $type='OpenVPN N-2-N';
661 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
662 $errormessage=$Lang::tr
{'fwhost err groupempty'};
663 $fwhostsettings{'grp_name'}='';
664 $fwhostsettings{'remark'}='';
666 #get address from IPSEC HOST
667 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
668 @target=$fwhostsettings{'IPSEC_HOST'};
670 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
671 $errormessage=$Lang::tr
{'fwhost err groupempty'};
672 $fwhostsettings{'grp_name'}='';
673 $fwhostsettings{'remark'}='';
675 #get address from IPSEC NETWORK
676 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
677 @target=$fwhostsettings{'IPSEC_NET'};
678 $type='IpSec Network';
679 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
680 $errormessage=$Lang::tr
{'fwhost err groupempty'};
681 $fwhostsettings{'grp_name'}='';
682 $fwhostsettings{'remark'}='';
684 #check if host/net exists in grp
686 my $test="$grp,$fwhostsettings{'oldremark'},@target";
687 foreach my $key (keys %customgrp) {
688 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
689 if ($test1 eq $test){
690 $errormessage=$Lang::tr
{'fwhost err isingrp'};
691 $fwhostsettings{'update'} = 'on';
697 #on first save, we have an empty @target, so fill it with nothing
698 my $targetvalues=@target;
699 if ($targetvalues == '0'){
702 #on update, we have to delete the dummy entry
703 foreach my $key (keys %customgrp){
704 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
705 delete $customgrp{$key};
709 &General
::writehasharray
("$configgrp", \
%customgrp);
710 &General
::readhasharray
("$configgrp", \
%customgrp);
712 foreach my $key (keys %customgrp)
714 if($customgrp{$key}[0] eq $grp)
716 $count=$customgrp{$key}[4];
720 if ($count eq '' ){$count='0';}
722 #create array with new lines
723 foreach my $line (@target){
724 push (@newgrp,"$grp,$rem,$line");
727 my $key = &General
::findhasharraykey
(\
%customgrp);
728 foreach my $line (@newgrp){
729 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
730 my ($a,$b,$c,$d) = split (",",$line);
731 $customgrp{$key}[0] = $a;
732 $customgrp{$key}[1] = $b;
733 $customgrp{$key}[2] = $c;
734 $customgrp{$key}[3] = $type;
735 $customgrp{$key}[4] = $count;
737 &General
::writehasharray
("$configgrp", \
%customgrp);
738 #update counter in Host/Net
739 if($updcounter eq 'net'){
740 foreach my $key (keys %customnetwork) {
741 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
742 $customnetwork{$key}[4] = $customnetwork{$key}[4]+1;
746 &General
::writehasharray
("$confignet", \
%customnetwork);
747 }elsif($updcounter eq 'host'){
748 foreach my $key (keys %customhost) {
749 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
750 $customhost{$key}[4]=$customhost{$key}[4]+1;
753 &General
::writehasharray
("$confighost", \
%customhost);
755 $fwhostsettings{'update'}='on';
757 #check if ruleupdate is needed
765 if ($fwhostsettings{'ACTION'} eq 'saveservice')
768 &General
::readhasharray
("$configsrv", \
%customservice );
769 $errormessage=&checkports
(\
%customservice);
770 if ($fwhostsettings{'PROT'} eq 'ICMP'){
771 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
772 foreach my $key (keys %icmptypes){
773 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
774 $ICMP=$icmptypes{$key}[0];
778 if($ICMP eq ''){$ICMP='BLANK';}
780 my $key = &General
::findhasharraykey
(\
%customservice);
781 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
782 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
783 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
784 $customservice{$key}[2] = $fwhostsettings{'PROT'};
785 $customservice{$key}[3] = $ICMP;
786 $customservice{$key}[4] = 0;
787 &General
::writehasharray
("$configsrv", \
%customservice );
789 $fwhostsettings{'SRV_NAME'}='';
790 $fwhostsettings{'SRV_PORT'}='';
791 $fwhostsettings{'PROT'}='';
792 $fwhostsettings{'ICMP_TYPES'}='';
796 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
801 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
802 &General
::readhasharray
("$configsrv", \
%customservice );
803 $errormessage=&checkservicegroup
;
805 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
806 $errormessage=$Lang::tr
{'fwhost err remark'};
809 #on first save, we have to enter a dummy value
810 if ($fwhostsettings{'CUST_SRV'} eq ''){
811 $fwhostsettings{'CUST_SRV'}='none';
813 #on update, we have to delete the dummy entry
814 foreach my $key (keys %customservicegrp){
815 if ($customservicegrp{$key}[2] eq 'none'){
816 delete $customservicegrp{$key};
820 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
821 #check if remark has also changed
822 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
824 foreach my $key (keys %customservicegrp)
826 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
828 $customservicegrp{$key}[1]='';
829 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
834 foreach my $key (keys %customservicegrp)
836 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
838 $count=$customservicegrp{$key}[3];
842 if ($count eq '' ){$count='0';}
844 foreach my $key (sort keys %customservice){
845 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
846 $port=$customservice{$key}[1];
847 $prot=$customservice{$key}[2];
848 $customservice{$key}[4]++;
851 &General
::writehasharray
("$configsrv", \
%customservice );
852 my $key = &General
::findhasharraykey
(\
%customservicegrp);
853 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
854 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
855 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
856 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
857 $customservicegrp{$key}[3] = $count;
858 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
859 $fwhostsettings{'updatesrvgrp'}='on';
865 &viewtableservicegrp
;
868 if ($fwhostsettings{'ACTION'} eq 'editnet')
873 if ($fwhostsettings{'ACTION'} eq 'edithost')
878 if ($fwhostsettings{'ACTION'} eq 'editgrp')
880 $fwhostsettings{'update'}='on';
884 if ($fwhostsettings{'ACTION'} eq 'editservice')
886 $fwhostsettings{'updatesrv'}='on';
889 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
891 $fwhostsettings{'updatesrvgrp'} = 'on';
893 &viewtableservicegrp
;
896 if ($fwhostsettings{'ACTION'} eq 'resetnet')
898 $fwhostsettings{'HOSTNAME'} ="";
899 $fwhostsettings{'IP'} ="";
900 $fwhostsettings{'SUBNET'} ="";
903 if ($fwhostsettings{'ACTION'} eq 'resethost')
905 $fwhostsettings{'HOSTNAME'} ="";
906 $fwhostsettings{'IP'} ="";
907 $fwhostsettings{'type'} ="";
910 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
912 $fwhostsettings{'grp_name'} ="";
913 $fwhostsettings{'remark'} ="";
917 if ($fwhostsettings{'ACTION'} eq 'delnet')
919 &General
::readhasharray
("$confignet", \
%customnetwork);
920 foreach my $key (keys %customnetwork) {
921 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
922 delete $customnetwork{$key};
923 &General
::writehasharray
("$confignet", \
%customnetwork);
930 if ($fwhostsettings{'ACTION'} eq 'delhost')
932 &General
::readhasharray
("$confighost", \
%customhost);
933 foreach my $key (keys %customhost) {
934 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
935 delete $customhost{$key};
936 &General
::writehasharray
("$confighost", \
%customhost);
943 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
947 &General
::readhasharray
("$configgrp", \
%customgrp);
948 foreach my $key (keys %customgrp){
949 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
950 #decrease count from source host/net
951 if ($customgrp{$key}[3] eq 'Custom Network'){
952 &General
::readhasharray
("$confignet", \
%customnetwork);
953 foreach my $key1 (keys %customnetwork){
954 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
955 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
959 &General
::writehasharray
("$confignet", \
%customnetwork);
961 if ($customgrp{$key}[3] eq 'Custom Host'){
962 &General
::readhasharray
("$confighost", \
%customhost);
963 foreach my $key1 (keys %customhost){
964 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
965 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
969 &General
::writehasharray
("$confighost", \
%customhost);
971 $grpname=$customgrp{$key}[0];
972 $grpremark=$customgrp{$key}[1];
973 delete $customgrp{$key};
976 &General
::writehasharray
("$configgrp", \
%customgrp);
977 if ($fwhostsettings{'grpcnt'} > 0){&rules
;}
978 if ($fwhostsettings{'update'} eq 'on'){
979 $fwhostsettings{'remark'}= $grpremark;
980 $fwhostsettings{'grp_name'}=$grpname;
985 if ($fwhostsettings{'ACTION'} eq 'delgrp')
987 &General
::readhasharray
("$configgrp", \
%customgrp);
988 &decrease
($fwhostsettings{'grp_name'});
989 foreach my $key (sort keys %customgrp)
991 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
993 delete $customgrp{$key};
996 &General
::writehasharray
("$configgrp", \
%customgrp);
997 $fwhostsettings{'grp_name'}='';
1001 if ($fwhostsettings{'ACTION'} eq 'delservice')
1003 &General
::readhasharray
("$configsrv", \
%customservice);
1004 foreach my $key (keys %customservice) {
1005 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
1006 #&deletefromgrp($customhost{$key}[0],$configgrp);
1007 delete $customservice{$key};
1008 &General
::writehasharray
("$configsrv", \
%customservice);
1012 $fwhostsettings{'SRV_NAME'}='';
1013 $fwhostsettings{'SRV_PORT'}='';
1014 $fwhostsettings{'PROT'}='';
1017 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
1019 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1020 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
1021 foreach my $key (sort keys %customservicegrp)
1023 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
1025 delete $customservicegrp{$key};
1028 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1029 $fwhostsettings{'SRVGRP_NAME'}='';
1031 &viewtableservicegrp
;
1033 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
1037 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1038 &General
::readhasharray
("$configsrv", \
%customservice);
1039 foreach my $key (keys %customservicegrp){
1040 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
1042 #decrease count from source service
1043 foreach my $key1 (sort keys %customservice){
1044 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1045 $customservice{$key1}[4]--;
1049 &General
::writehasharray
("$configsrv", \
%customservice);
1050 $grpname=$customservicegrp{$key}[0];
1051 $grpremark=$customservicegrp{$key}[1];
1052 delete $customservicegrp{$key};
1055 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1057 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1058 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1059 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1062 &viewtableservicegrp
;
1065 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1070 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1075 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1080 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1084 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1087 &viewtableservicegrp
;
1089 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1091 &General
::readhasharray
("$configgrp", \
%customgrp);
1092 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1093 foreach my $key (sort keys %customgrp)
1095 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1097 $customgrp{$key}[1]='';
1098 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1101 &General
::writehasharray
("$configgrp", \
%customgrp);
1102 $fwhostsettings{'update'}='on';
1103 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1105 $errormessage=$Lang::tr
{'fwhost err remark'};
1106 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1107 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1108 $fwhostsettings{'update'} = 'on';
1110 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1114 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1116 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1117 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1118 foreach my $key (sort keys %customservicegrp)
1120 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1122 $customservicegrp{$key}[1]='';
1123 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1126 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1127 $fwhostsettings{'updatesrvgrp'}='on';
1128 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1130 $errormessage=$Lang::tr
{'fwhost err remark'};
1131 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1132 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1133 $fwhostsettings{'updatesrvgrp'} = 'on';
1135 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1137 &viewtableservicegrp
;
1140 if($fwhostsettings{'ACTION'} eq '')
1147 if (-f
"${General::swroot}/forward/reread"){
1148 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>";
1150 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1151 print "$Lang::tr{'fwhost welcome'}";
1153 <br><br><table border='0' width='100%'>
1154 <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>
1155 <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>
1156 <tr><td colspan='6'><hr></td></tr></table>
1158 &Header
::closebox
();
1166 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1167 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1168 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1170 <table border='0' width='100%'>
1171 <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>
1172 <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>
1173 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1174 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1175 <tr><td colspan='6'><br><hr></td></tr><tr>
1177 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1179 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>";
1181 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'>";
1183 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>";
1184 &Header
::closebox
();
1190 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1191 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1192 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1194 <table border='0' width='100%'>
1195 <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>
1196 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1197 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1198 <tr><td colspan='5'><hr></td></tr><tr>
1201 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1204 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>";
1206 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'>";
1208 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>";
1209 &Header
::closebox
();
1216 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1217 &General
::setup_default_networks
(\
%defaultNetworks);
1218 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1219 &General
::readhasharray
("$confignet", \
%customnetwork);
1220 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1221 &General
::readhasharray
("$confighost", \
%customhost);
1222 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1226 $checked{'check1'}{'off'} = '';
1227 $checked{'check1'}{'on'} = '';
1228 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1229 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1230 my $grp=$fwhostsettings{'grp_name'};
1231 my $rem=$fwhostsettings{'remark'};
1232 if ($fwhostsettings{'update'} eq ''){
1234 <table width='100%' border='0'>
1235 <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>
1236 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1237 <tr><td colspan='2'><br><hr></td></tr></table>
1241 <table width='100%' border='0'><form method='post' style='display:inline'>
1242 <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>
1243 <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>
1247 if ($fwhostsettings{'update'} eq 'on'){
1249 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1250 <table width='100%' border='0'>
1251 <tr><td width=50% valign='top'>
1252 <table width='100%' border='0'>
1253 <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;'>
1255 foreach my $network (sort keys %defaultNetworks)
1257 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1258 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1259 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1260 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1261 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1262 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1263 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1264 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1265 if ($ownnet{$defnet}){
1266 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1268 print ">$network</option>";
1271 print"</select></td></tr>";
1272 if (! -z
$confignet){
1273 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;'>";
1274 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1275 print"<option>$customnetwork{$key}[0]</option>";
1277 print"</select></td></tr>";
1279 if (! -z
$confighost){
1280 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;'>";
1281 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1282 print"<option>$customhost{$key}[0]</option>";
1284 print"</select></td></tr>";
1288 print"</td><td valign='top'><table width='100%' border='0'>";
1290 if (! -z
$configccdnet){
1291 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;'>";
1292 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1294 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1296 print"</select></td></tr>";
1299 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1301 if ($ccdhost{$key}[33] ne ''){
1302 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 '');
1304 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1307 if ($show eq '1'){$show='';print"</select></td></tr>";}
1309 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1310 if($ccdhost{$key}[3] eq 'net'){
1311 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 '');
1313 print"<option>$ccdhost{$key}[1]</option>";
1316 if ($show eq '1'){$show='';print"</select></td></tr>";}
1318 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1319 if ($ipsecconf{$key}[3] eq 'net'){
1320 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 '');
1322 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1325 if ($show eq '1'){$show='';print"</select></td></tr>";}
1327 print"</td></tr></table>";
1328 print"<br><br><hr>";
1330 print"<table border='0' width='100%'>";
1331 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>";
1332 &Header
::closebox
();
1338 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1339 if ($fwhostsettings{'updatesrv'} eq 'on')
1341 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1342 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1343 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1344 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1347 <div id='prt'><table width='100%' border='0'><form method='post'>
1348 <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>
1349 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='PROT' >
1351 foreach ("TCP","UDP","ICMP")
1353 if ($_ eq $fwhostsettings{'PROT'})
1355 print"<option selected>$_</option>";
1357 print"<option>$_</option>";
1361 </select></td></tr></table></div>
1362 <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'>
1364 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1365 print"<option>All ICMP-Types</option>";
1366 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1367 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1368 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1370 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1374 </select></td></tr></table></div>
1375 <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>
1376 <table width='100%' border='0'><tr><td colspan='6'><br><hr></td></tr>
1377 <tr><td colspan='6' align='right'>
1379 if ($fwhostsettings{'updatesrv'} eq 'on')
1382 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1383 <input type='hidden' name='ACTION' value='updateservice'>
1384 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1385 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1386 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1387 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1392 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1395 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1400 #if ($fwhostsettings{'PROT'} ne 'ICMP'){
1401 #print"<script language='JavaScript'>hide_elements('PROTOKOLL');</script>";
1403 &Header
::closebox
();
1411 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1412 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1413 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1415 <table width='100%' border='0'><form method='post'>
1416 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1417 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1418 <tr><td colspan='2'><br><hr></tr>
1423 <table width='100%' border='0'><form method='post' style='display:inline'>
1424 <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>
1425 <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>
1426 <tr><td colspan='3'><br><hr></td></td></tr>
1430 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1432 <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%'>
1433 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1435 &General
::readhasharray
("$configsrv", \
%customservice);
1436 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1438 print "<option>$customservice{$key}[0]</option>";
1442 <tr><td colspan='4'><br><br></td></tr>
1443 <tr><td colspan='4'><hr></td></tr>
1448 <table width='100%' border='0'>
1449 <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>
1452 &Header
::closebox
();
1457 if(! -z
$confignet){
1458 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1459 &General
::readhasharray
("$confignet", \
%customnetwork);
1460 if (!keys %customnetwork)
1462 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1465 <table border='0' width='100%' cellspacing='0'>
1466 <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>
1470 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1471 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1472 print" <tr bgcolor='${Header::colouryellow}'>";
1475 print" <tr bgcolor='$color{'color22'}'>";
1478 print" <tr bgcolor='$color{'color20'}'>";
1480 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1481 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>";
1483 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1484 <input type='hidden' name='ACTION' value='editnet'>
1485 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1486 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1487 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1488 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1491 if($customnetwork{$key}[4] == '0')
1493 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>";
1495 print"<td></td></tr>";
1500 &Header
::closebox
();
1507 #Check if IP is part of OpenVPN N2N subnet
1508 foreach my $key (sort keys %ccdhost){
1509 if ($ccdhost{$key}[3] eq 'net'){
1510 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1511 if (&General
::IpInSubnet
($c,$a,$b)){
1512 $tdcolor="style='color:$Header::colourovpn ;'";
1517 #Check if IP is part of OpenVPN dynamic subnet
1518 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1519 if (&General
::IpInSubnet
($c,$a,$b)){
1520 $tdcolor="style='color: $Header::colourovpn;'";
1523 #Check if IP is part of OpenVPN static subnet
1524 foreach my $key (sort keys %ccdnet){
1525 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1526 $b =&General
::iporsubtodec
($b);
1527 if (&General
::IpInSubnet
($c,$a,$b)){
1528 $tdcolor="style='color: $Header::colourovpn;'";
1532 #Check if IP is part of IPsec RW network
1533 if ($ipsecsettings{'RW_NET'} ne ''){
1534 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1535 $b=&General
::iporsubtodec
($b);
1536 if (&General
::IpInSubnet
($c,$a,$b)){
1537 $tdcolor="style='color: $Header::colourvpn;'";
1541 #Check if IP is part of a IPsec N2N network
1542 foreach my $key (sort keys %ipsecconf){
1543 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1544 if (&General
::IpInSubnet
($c,$a,$b)){
1545 $tdcolor="style='color: $Header::colourvpn;'";
1554 if (! -z
$confighost){
1555 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1556 &General
::readhasharray
("$confighost", \
%customhost);
1557 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1558 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1559 if (!keys %customhost)
1561 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1564 <table border='0' width='100%' cellspacing='0'>
1565 <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>
1569 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1570 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1571 print" <tr bgcolor='${Header::colouryellow}'>";
1572 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1573 else{ print" <tr bgcolor='$color{'color20'}'>";}
1574 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1575 $customhost{$key}[4]=~s/\s+//g;
1576 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>";
1578 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1579 <input type='hidden' name='ACTION' value='edithost' />
1580 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1581 <input type='hidden' name='IP' value='$ip' />
1582 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1583 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1586 if($customhost{$key}[4] == '0')
1588 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>";
1590 print"<td width='1%'></td></tr>";
1595 &Header
::closebox
();
1600 if(! -z
"$configgrp"){
1601 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1602 &General
::readhasharray
("$configgrp", \
%customgrp);
1603 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1604 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1605 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1606 &General
::readhasharray
("$confighost", \
%customhost);
1607 &General
::readhasharray
("$confignet", \
%customnetwork);
1615 if (!keys %customgrp)
1617 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1619 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1621 if ($helper ne $customgrp{$key}[0]){
1623 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1624 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1633 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
1634 $grpname=$customgrp{$key}[0];
1635 $remark="$customgrp{$key}[1]";
1636 if($count gt 1){ print"</table>";}
1637 print "<br><b><u>$grpname</u></b> ";
1638 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1639 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1640 if($customgrp{$key}[4] == '0')
1642 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>";
1644 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>";
1645 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>";
1648 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1649 print" <tr bgcolor='${Header::colouryellow}'>";
1650 }elsif ($count %2 == 0){
1651 print"<tr bgcolor='$color{'color22'}'>";
1653 print"<tr bgcolor='$color{'color20'}'>";
1655 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1656 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1657 print "<td width='39%' align='left'>";
1658 if($customgrp{$key}[3] eq 'Standard Network'){
1659 print &get_name
($customgrp{$key}[2])."</td>";
1661 print "$customgrp{$key}[2]</td>";
1663 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
1664 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1666 my ($colip,$colsub) = split("/",$ip);
1667 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1668 print"<td align='center' ".&getcolor
($colip).">".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1670 if ($delflag > '1' && $ip ne ''){
1671 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1673 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>";
1675 $helper=$customgrp{$key}[0];
1680 &Header
::closebox
();
1684 sub viewtableservice
1687 if(! -z
"$configsrv")
1689 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1690 &General
::readhasharray
("$configsrv", \
%customservice);
1692 <table width='100%' border='0' cellspacing='0'>
1693 <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>
1695 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1698 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1699 print" <tr bgcolor='${Header::colouryellow}'>";
1700 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1702 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1704 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1707 </td><td align='center'>$customservice{$key}[4]x</td>
1708 <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' />
1709 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1710 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1711 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
1712 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
1714 if ($customservice{$key}[4] eq '0')
1716 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>";
1718 print"<td></td></tr>";
1722 &Header
::closebox
();
1725 sub viewtableservicegrp
1734 if (! -z
$configsrvgrp){
1735 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1736 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1737 &General
::readhasharray
("$configsrv", \
%customservice);
1738 my $number= keys %customservicegrp;
1739 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1741 if ($helper ne $customservicegrp{$key}[0]){
1743 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1744 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1752 $grpname=$customservicegrp{$key}[0];
1753 if ($customservicegrp{$key}[2] eq "none"){
1754 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1758 $remark="$customservicegrp{$key}[1]";
1759 if($count >=2){print"</table>";}
1760 print "<br><b><u>$grpname</u></b> ";
1761 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1762 print " <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1763 if($customservicegrp{$key}[3] == '0')
1765 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>";
1767 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>";
1768 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>";
1770 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1771 print" <tr bgcolor='${Header::colouryellow}'>";
1772 }elsif ($count %2 == 0){
1773 print"<tr bgcolor='$color{'color22'}'>";
1775 print"<tr bgcolor='$color{'color20'}'>";
1777 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1778 foreach my $srv (sort keys %customservice){
1779 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1780 $protocol=$customservice{$srv}[2];
1781 $port=$customservice{$srv}[1];
1785 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1786 if ($delflag gt '1'){
1787 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1789 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>";
1790 $helper=$customservicegrp{$key}[0];
1793 &Header
::closebox
();
1799 my %hash=%{(shift)};
1800 foreach my $key (keys %hash) {
1801 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1810 my %hash=%{(shift)};
1812 foreach my $key (keys %hash) {
1813 if($hash{$key}[0] eq $name){
1822 my %hash=%{(shift)};
1824 foreach my $key (keys %hash) {
1825 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1833 my %hash=%{(shift)};
1834 &General
::readhasharray
("$confignet", \
%hash);
1835 foreach my $key (keys %hash) {
1836 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1843 sub checkservicegroup
1845 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1849 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1851 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1852 return $errormessage;
1854 #check empty selectbox
1855 if (keys %customservice lt 1)
1857 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1859 #check if name already exists
1860 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1861 foreach my $key (keys %customservicegrp) {
1862 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1863 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1868 #check if service already exists in group
1869 foreach my $key (keys %customservicegrp) {
1870 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1871 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1874 return $errormessage;
1878 if ($errormessage) {
1879 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1880 print "<class name='base'>$errormessage\n";
1881 print " </class>\n";
1882 &Header
::closebox
();
1888 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1889 print "<class name='base'>$hint\n";
1890 print " </class>\n";
1891 &Header
::closebox
();
1897 &General
::setup_default_networks
(\
%defaultNetworks);
1898 foreach my $network (sort keys %defaultNetworks)
1900 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1909 &General
::readhasharray
("$config",\
%hash);
1910 foreach my $key (keys %hash) {
1911 $errormessage.="lese $hash{$key}[2] und $target<br>";
1912 if($hash{$key}[2] eq $target){
1915 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1918 &General
::writehasharray
("$config",\
%hash);
1925 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
1927 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1928 $fwhostsettings{'BLK_IP'}='readonly';
1929 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1930 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1932 #check if name collides with CCD Netname
1933 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1934 foreach my $key (keys %ccdnet) {
1935 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1936 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1937 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1938 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1942 #check if IP collides with CCD NetIP
1943 if ($fwhostsettings{'type'} ne 'mac'){
1944 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1945 foreach my $key (keys %ccdnet) {
1946 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1947 if($ccdnet{$key}[1] eq $test){
1948 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1949 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1950 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1951 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1956 #check if name collides with CCD Hostname
1957 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1958 foreach my $key (keys %ccdhost) {
1959 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1960 if($ip eq $fwhostsettings{'IP'}){
1961 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1962 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1966 #check if IP collides with CCD HostIP (only hosts)
1967 if ($edit eq 'edithost')
1969 foreach my $key (keys %ccdhost) {
1970 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1971 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1972 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1973 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1978 #check if network with this name already exists
1979 &General
::readhasharray
("$confignet", \
%customnetwork);
1980 if (!&checkname
(\
%customnetwork))
1982 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1983 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1984 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1986 #check if network ip already exists
1987 if (!&checkip
(\
%customnetwork,1))
1989 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1990 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1992 #check if host with this name already exists
1993 &General
::readhasharray
("$confighost", \
%customhost);
1994 if (!&checkname
(\
%customhost))
1996 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1997 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1998 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2000 #check if host with this ip already exists
2001 if (!&checkip
(\
%customhost,2))
2003 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
2013 #get address from IPSEC NETWORK
2014 if ($type eq 'IpSec Network'){
2015 foreach my $key (keys %ipsecconf) {
2016 if ($ipsecconf{$key}[1] eq $name){
2017 return $ipsecconf{$key}[11];
2020 &deletefromgrp
($name,$configgrp);
2023 #get address from IPSEC HOST
2024 if ($type eq 'IpSec Host'){
2025 foreach my $key (keys %ipsecconf) {
2026 if ($ipsecconf{$key}[1] eq $name){
2027 return $ipsecconf{$key}[10];
2030 &deletefromgrp
($name,$configgrp);
2033 #get address from ovpn ccd Net-2-Net
2034 if ($type eq 'OpenVPN N-2-N'){
2035 foreach my $key (keys %ccdhost) {
2036 if($ccdhost{$key}[1] eq $name){
2037 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2038 $b=&General
::iporsubtodec
($b);
2042 &deletefromgrp
($name,$configgrp);
2045 #get address from ovpn ccd static host
2046 if ($type eq 'OpenVPN static host'){
2047 foreach my $key (keys %ccdhost) {
2048 if($ccdhost{$key}[1] eq $name){
2049 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2050 $b=&General
::iporsubtodec
($b);
2054 &deletefromgrp
($name,$configgrp);
2057 #get address from ovpn ccd static net
2058 if ($type eq 'OpenVPN static network'){
2059 foreach my $key (keys %ccdnet) {
2060 if ($ccdnet{$key}[0] eq $name){
2061 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2062 $b=&General
::iporsubtodec
($b);
2068 #check custom addresses
2069 if ($type eq 'Custom Host'){
2070 foreach my $key (keys %customhost) {
2071 if ($customhost{$key}[0] eq $name){
2072 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2078 ##check custom networks
2079 if ($type eq 'Custom Network'){
2080 foreach my $key (keys %customnetwork) {
2081 if($customnetwork{$key}[0] eq $name){
2082 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2087 #check standard networks
2088 if ($type eq 'Standard Network'){
2089 if ($name =~ /OpenVPN/i){
2091 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2092 return $ovpn{'DOVPN_SUBNET'};
2094 if ($name eq 'GREEN'){
2096 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2097 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2099 if ($name eq 'BLUE'){
2101 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2102 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2104 if ($name eq 'ORANGE'){
2106 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2107 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2109 if ($name eq 'ALL'){
2110 return "0.0.0.0/0.0.0.0";
2112 if ($name =~ /IPsec/i){
2114 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2115 return $hash{'RW_NET'};
2121 if (!-f
"${General::swroot}/fwhosts/reread"){
2122 system("touch ${General::swroot}/fwhosts/reread");
2123 system("touch ${General::swroot}/forward/reread");
2128 system ("/usr/local/bin/forwardfwctrl");
2129 if ( -f
"${General::swroot}/fwhosts/reread"){
2130 system("rm ${General::swroot}/fwhosts/reread");
2131 system("rm ${General::swroot}/forward/reread");
2138 &General
::readhasharray
("$confignet", \
%customnetwork);
2139 &General
::readhasharray
("$confighost", \
%customhost);
2140 foreach my $key (sort keys %customgrp ){
2141 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2142 foreach my $key1 (sort keys %customnetwork){
2143 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2144 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2150 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2151 foreach my $key2 (sort keys %customhost){
2152 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2153 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2160 &General
::writehasharray
("$confignet", \
%customnetwork);
2161 &General
::writehasharray
("$confighost", \
%customhost);
2166 &General
::readhasharray
("$configsrv", \
%customservice);
2167 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2169 foreach my $key (sort keys %customservicegrp){
2170 if ($customservicegrp{$key}[0] eq $grp ){
2171 foreach my $key2 (sort keys %customservice){
2172 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2173 $customservice{$key2}[4]--;
2178 &General
::writehasharray
("$configsrv", \
%customservice);
2184 my %hash=%{(shift)};
2186 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2187 $errormessage=$Lang::tr
{'fwhost err name1'};
2189 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2190 $errormessage=$Lang::tr
{'fwhost err port'};
2193 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2194 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2196 #change dashes with :
2197 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2199 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2200 $fwhostsettings{'SRV_PORT'} = "1:65535";
2202 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2203 $fwhostsettings{'SRV_PORT'} = "1:$2";
2205 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2206 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2208 if($fwhostsettings{'PROT'} ne 'ICMP'){
2209 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2211 # a new service has to have a different name
2212 foreach my $key (keys %hash){
2213 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2214 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2218 return $errormessage;
2222 # Checks a hostname against RFC1035
2223 my $hostname = $_[0];
2225 # Each part should be at least two characters in length
2226 # but no more than 63 characters
2227 if (length ($hostname) < 1 || length ($hostname) > 63) {
2229 # Only valid characters are a-z, A-Z, 0-9 and -
2230 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2232 # First character can only be a letter or a digit
2233 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2235 # Last character can only be a letter or a digit
2236 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2242 # Checks a hostname against RFC1035
2244 # Each part should be at least two characters in length
2245 # but no more than 63 characters
2246 if (length ($remark) < 1 || length ($remark) > 255) {
2248 # Only valid characters are a-z, A-Z, 0-9 and -
2249 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2251 # First character can only be a letter or a digit
2252 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2254 # Last character can only be a letter or a digit
2255 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2259 &Header
::closebigbox
();
2260 &Header
::closepage
();