]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/fwhosts.cgi
e7ae946efa980708a36fcedbcb5838606eb43667
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);
107 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
113 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
115 &General
::readhasharray
("$confignet", \
%customnetwork);
116 foreach my $key (keys %customnetwork)
118 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
120 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
121 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
122 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
123 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
124 $fwhostsettings{'count'} = $customnetwork{$key}[4];
125 delete $customnetwork{$key};
129 &General
::writehasharray
("$confignet", \
%customnetwork);
130 $fwhostsettings{'actualize'} = 'on';
131 $fwhostsettings{'ACTION'} = 'savenet';
133 if ($fwhostsettings{'ACTION'} eq 'updatehost')
136 &General
::readhasharray
("$confighost", \
%customhost);
137 foreach my $key (keys %customhost)
139 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
141 if ($customhost{$key}[1] eq 'ip'){
142 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
144 $ip = $customhost{$key}[2];
146 $fwhostsettings{'orgip'} = $ip;
147 $fwhostsettings{'count'} = $customhost{$key}[4];
148 delete $customhost{$key};
149 &General
::writehasharray
("$confighost", \
%customhost);
152 $fwhostsettings{'actualize'} = 'on';
153 if($fwhostsettings{'orgip'}){
154 $fwhostsettings{'ACTION'} = 'savehost';
156 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
159 if ($fwhostsettings{'ACTION'} eq 'updateservice')
163 $errormessage=&checkports
(\
%customservice);
165 &General
::readhasharray
("$configsrv", \
%customservice);
166 foreach my $key (keys %customservice)
168 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
170 $count=$customservice{$key}[4];
171 delete $customservice{$key};
172 &General
::writehasharray
("$configsrv", \
%customservice);
176 if ($fwhostsettings{'PROT'} ne 'ICMP'){
177 $fwhostsettings{'ICMP_TYPES'}='BLANK';
179 my $key1 = &General
::findhasharraykey
(\
%customservice);
180 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
181 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
182 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
183 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
184 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
185 $customservice{$key1}[4] = $count;
186 &General
::writehasharray
("$configsrv", \
%customservice);
187 #check if we need to update firewallrules
188 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
189 if ( ! -z
$fwconfigfwd ){
190 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
191 foreach my $key (sort keys %fwfwd){
192 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
193 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
196 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
198 if ( ! -z
$fwconfiginp ){
199 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
200 foreach my $line (sort keys %fwinp){
201 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
202 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
205 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
207 #check if we need to update groups
208 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
209 foreach my $key (sort keys %customservicegrp){
210 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
211 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
214 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
217 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
220 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
223 $fwhostsettings{'SRV_NAME'} = '';
224 $fwhostsettings{'SRV_PORT'} = '';
225 $fwhostsettings{'PROT'} = '';
227 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
228 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
229 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
230 $fwhostsettings{'updatesrv'}= 'on';
232 if($needrules eq 'on'){
238 if ($fwhostsettings{'ACTION'} eq 'savenet' )
242 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
243 #check if all fields are set
244 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
246 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
251 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
253 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
254 $fwhostsettings{'BLK_HOST'} ='readonly';
255 $fwhostsettings{'NOCHECK'} ='false';
256 $fwhostsettings{'error'} ='on';
259 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
260 $errormessage=$Lang::tr
{'fwhost err remark'};
261 $fwhostsettings{'error'} ='on';
263 #check if subnet is sigle host
264 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
266 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
268 if($fwhostsettings{'error'} ne 'on'){
269 #check if we use one of ipfire's networks (green,orange,blue)
270 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
272 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
273 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
274 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
276 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
278 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
279 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
280 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
282 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
284 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
285 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
286 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
288 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
290 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
291 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
292 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
295 #only check plausi when no error till now
297 &plausicheck
("editnet");
299 #check if network ip is part of an already used one
300 if(&checksubnet
(\
%customnetwork))
302 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
303 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
305 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
307 $fwhostsettings{'actualize'} = '';
308 my $key = &General
::findhasharraykey
(\
%customnetwork);
309 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
310 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
311 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
312 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
313 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
314 $customnetwork{$key}[4] = $fwhostsettings{'count'};
315 &General
::writehasharray
("$confignet", \
%customnetwork);
316 undef %customnetwork;
320 &General
::readhasharray
("$confignet", \
%customnetwork);
321 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
322 if ($fwhostsettings{'update'} == '0'){
323 foreach my $key (keys %customnetwork) {
324 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
325 $count=$customnetwork{$key}[4];
326 delete $customnetwork{$key};
332 #get count if actualize is 'on'
333 if($fwhostsettings{'actualize'} eq 'on'){
334 $fwhostsettings{'actualize'} = '';
335 $count=$fwhostsettings{'count'};
336 #check if we need to reload rules
337 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
340 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
341 #check if we need to update groups
342 &General
::readhasharray
("$configgrp", \
%customgrp);
343 foreach my $key (sort keys %customgrp){
344 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
345 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
349 &General
::writehasharray
("$configgrp", \
%customgrp);
350 #check if we need to update firewallrules
351 if ( ! -z
$fwconfigfwd ){
352 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
353 foreach my $line (sort keys %fwfwd){
354 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
355 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
357 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
358 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
361 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
363 if ( ! -z
$fwconfiginp ){
364 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
365 foreach my $line (sort keys %fwinp){
366 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
367 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
370 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
374 my $key = &General
::findhasharraykey
(\
%customnetwork);
375 foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";}
376 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
377 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
378 #convert ip when leading '0' in byte
379 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
380 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
381 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
382 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
383 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
384 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
385 $customnetwork{$key}[4] = $count;
386 &General
::writehasharray
("$confignet", \
%customnetwork);
387 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
388 undef %customnetwork;
389 $fwhostsettings{'HOSTNAME'}='';
390 $fwhostsettings{'IP'}='';
391 $fwhostsettings{'SUBNET'}='';
392 $fwhostsettings{'NETREMARK'}='';
393 #check if an edited net affected groups and need to reload rules
394 if ($needrules eq 'on'){
405 if ($fwhostsettings{'ACTION'} eq 'savehost')
409 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
410 $fwhostsettings{'SUBNET'}='32';
411 #check if all fields are set
412 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
414 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
415 $fwhostsettings{'ACTION'} = 'edithost';
417 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
418 $fwhostsettings{'type'} = 'mac';
419 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
420 $fwhostsettings{'type'} = 'ip';
422 $fwhostsettings{'type'} = '';
423 $errormessage=$Lang::tr
{'fwhost err ipmac'};
426 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
427 $errormessage=$Lang::tr
{'fwhost err remark'};
430 if ($fwhostsettings{'type'} eq 'ip'){
432 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
433 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
435 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
436 $fwhostsettings{'error'}='on';
438 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
439 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
440 $fwhostsettings{'error'}='on';
442 #check if net or broadcast
443 my @tmp= split (/\./,$fwhostsettings{'IP'});
444 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
445 $errormessage=$Lang::tr
{'fwhost err hostip'};
448 #only check plausi when no error till now
450 &plausicheck
("edithost");
452 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
453 $fwhostsettings{'actualize'} = '';
454 my $key = &General
::findhasharraykey
(\
%customhost);
455 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
456 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
457 $customhost{$key}[1] = $fwhostsettings{'type'} ;
458 if($customhost{$key}[1] eq 'ip'){
459 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
461 $customhost{$key}[2] = $fwhostsettings{'orgip'};
463 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
464 $customhost{$key}[4] = $fwhostsettings{'count'};
465 &General
::writehasharray
("$confighost", \
%customhost);
469 #get count if host was edited
470 if($fwhostsettings{'actualize'} eq 'on'){
471 $count=$fwhostsettings{'count'};
472 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
475 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
476 #check if we need to update groups
477 &General
::readhasharray
("$configgrp", \
%customgrp);
478 foreach my $key (sort keys %customgrp){
479 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
480 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
483 &General
::writehasharray
("$configgrp", \
%customgrp);
484 #check if we need to update firewallrules
485 if ( ! -z
$fwconfigfwd ){
486 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
487 foreach my $line (sort keys %fwfwd){
488 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
489 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
491 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
492 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
495 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
497 if ( ! -z
$fwconfiginp ){
498 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
499 foreach my $line (sort keys %fwinp){
500 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
501 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
504 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
508 my $key = &General
::findhasharraykey
(\
%customhost);
509 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
510 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
511 $customhost{$key}[1] = $fwhostsettings{'type'} ;
512 if ($fwhostsettings{'type'} eq 'ip'){
513 #convert ip when leading '0' in byte
514 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
515 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
516 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
518 $customhost{$key}[2] = $fwhostsettings{'IP'};
520 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
521 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
522 $customhost{$key}[4] =$count;
523 &General
::writehasharray
("$confighost", \
%customhost);
525 $fwhostsettings{'HOSTNAME'}='';
526 $fwhostsettings{'IP'}='';
527 $fwhostsettings{'type'}='';
528 $fwhostsettings{'HOSTREMARK'}='';
529 #check if we need to update rules while host was edited
530 if($needrules eq 'on'){
541 if ($fwhostsettings{'ACTION'} eq 'savegrp')
543 my $grp=$fwhostsettings{'grp_name'};;
544 my $rem=$fwhostsettings{'remark'};
547 my $updcounter='off';
550 &General
::readhasharray
("$configgrp", \
%customgrp);
551 &General
::readhasharray
("$confignet", \
%customnetwork);
552 &General
::readhasharray
("$confighost", \
%customhost);
554 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
556 if (!checkgroup
(\
%customgrp,$grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
558 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
559 $errormessage.=$Lang::tr
{'fwhost err remark'};
561 if ($fwhostsettings{'update'} eq 'on'){
562 #check standard networks
563 if ($fwhostsettings{'grp2'} eq 'std_net'){
564 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
565 $type='Standard Network';
567 #check custom networks
568 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
569 @target=$fwhostsettings{'CUST_SRC_NET'};
571 $type='Custom Network';
572 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
573 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
574 $fwhostsettings{'grp_name'}='';
575 $fwhostsettings{'remark'}='';
577 #check custom addresses
578 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
579 @target=$fwhostsettings{'CUST_SRC_HOST'};
582 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
583 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
584 $fwhostsettings{'grp_name'}='';
585 $fwhostsettings{'remark'}='';
587 #get address from ovpn ccd static net
588 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
589 @target=$fwhostsettings{'OVPN_CCD_NET'};
590 $type='OpenVPN static network';
591 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
592 $errormessage=$Lang::tr
{'fwhost err groupempty'};
593 $fwhostsettings{'grp_name'}='';
594 $fwhostsettings{'remark'}='';
596 #get address from ovpn ccd static host
597 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
598 @target=$fwhostsettings{'OVPN_CCD_HOST'};
599 $type='OpenVPN static host';
600 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
601 $errormessage=$Lang::tr
{'fwhost err groupempty'};
603 #get address from ovpn ccd Net-2-Net
604 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
605 @target=$fwhostsettings{'OVPN_N2N'};
606 $type='OpenVPN N-2-N';
607 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
608 $errormessage=$Lang::tr
{'fwhost err groupempty'};
609 $fwhostsettings{'grp_name'}='';
610 $fwhostsettings{'remark'}='';
612 #get address from IPSEC HOST
613 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
614 @target=$fwhostsettings{'IPSEC_HOST'};
616 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
617 $errormessage=$Lang::tr
{'fwhost err groupempty'};
618 $fwhostsettings{'grp_name'}='';
619 $fwhostsettings{'remark'}='';
621 #get address from IPSEC NETWORK
622 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
623 @target=$fwhostsettings{'IPSEC_NET'};
624 $type='IpSec Network';
625 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
626 $errormessage=$Lang::tr
{'fwhost err groupempty'};
627 $fwhostsettings{'grp_name'}='';
628 $fwhostsettings{'remark'}='';
630 #check if host/net exists in grp
632 my $test="$grp,$fwhostsettings{'oldremark'},@target";
633 foreach my $key (keys %customgrp) {
634 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
635 if ($test1 eq $test){
636 $errormessage=$Lang::tr
{'fwhost err isingrp'};
637 $fwhostsettings{'update'} = 'on';
643 #on first save, we have an empty @target, so fill it with nothing
644 my $targetvalues=@target;
645 if ($targetvalues == '0'){
648 #on update, we have to delete the dummy entry
649 foreach my $key (keys %customgrp){
650 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
651 delete $customgrp{$key};
655 &General
::writehasharray
("$configgrp", \
%customgrp);
656 &General
::readhasharray
("$configgrp", \
%customgrp);
658 foreach my $key (keys %customgrp)
660 if($customgrp{$key}[0] eq $grp)
662 $count=$customgrp{$key}[4];
666 if ($count eq '' ){$count='0';}
668 #create array with new lines
669 foreach my $line (@target){
670 push (@newgrp,"$grp,$rem,$line");
673 my $key = &General
::findhasharraykey
(\
%customgrp);
674 foreach my $line (@newgrp){
675 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
676 my ($a,$b,$c,$d) = split (",",$line);
677 $customgrp{$key}[0] = $a;
678 $customgrp{$key}[1] = $b;
679 $customgrp{$key}[2] = $c;
680 $customgrp{$key}[3] = $type;
681 $customgrp{$key}[4] = $count;
683 &General
::writehasharray
("$configgrp", \
%customgrp);
684 #update counter in Host/Net
685 if($updcounter eq 'net'){
686 foreach my $key (keys %customnetwork) {
687 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
688 $customnetwork{$key}[4] = $customnetwork{$key}[4]+1;
692 &General
::writehasharray
("$confignet", \
%customnetwork);
693 }elsif($updcounter eq 'host'){
694 foreach my $key (keys %customhost) {
695 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
696 $customhost{$key}[4]=$customhost{$key}[4]+1;
699 &General
::writehasharray
("$confighost", \
%customhost);
701 $fwhostsettings{'update'}='on';
703 #check if ruleupdate is needed
711 if ($fwhostsettings{'ACTION'} eq 'saveservice')
714 &General
::readhasharray
("$configsrv", \
%customservice );
715 $errormessage=&checkports
(\
%customservice);
716 if ($fwhostsettings{'PROT'} eq 'ICMP'){
717 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
718 foreach my $key (keys %icmptypes){
719 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
720 $ICMP=$icmptypes{$key}[0];
724 if($ICMP eq ''){$ICMP='BLANK';}
726 my $key = &General
::findhasharraykey
(\
%customservice);
727 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
728 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
729 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
730 $customservice{$key}[2] = $fwhostsettings{'PROT'};
731 $customservice{$key}[3] = $ICMP;
732 $customservice{$key}[4] = 0;
733 &General
::writehasharray
("$configsrv", \
%customservice );
735 $fwhostsettings{'SRV_NAME'}='';
736 $fwhostsettings{'SRV_PORT'}='';
737 $fwhostsettings{'PROT'}='';
738 $fwhostsettings{'ICMP_TYPES'}='';
742 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
747 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
748 &General
::readhasharray
("$configsrv", \
%customservice );
749 $errormessage=&checkservicegroup
;
751 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
752 $errormessage=$Lang::tr
{'fwhost err remark'};
755 #on first save, we have to enter a dummy value
756 if ($fwhostsettings{'CUST_SRV'} eq ''){
757 $fwhostsettings{'CUST_SRV'}='none';
759 #on update, we have to delete the dummy entry
760 foreach my $key (keys %customservicegrp){
761 if ($customservicegrp{$key}[2] eq 'none'){
762 delete $customservicegrp{$key};
766 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
767 #check if remark has also changed
768 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
770 foreach my $key (keys %customservicegrp)
772 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
774 $customservicegrp{$key}[1]='';
775 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
780 foreach my $key (keys %customservicegrp)
782 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
784 $count=$customservicegrp{$key}[3];
788 if ($count eq '' ){$count='0';}
790 foreach my $key (sort keys %customservice){
791 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
792 $port=$customservice{$key}[1];
793 $prot=$customservice{$key}[2];
794 $customservice{$key}[4]++;
797 &General
::writehasharray
("$configsrv", \
%customservice );
798 my $key = &General
::findhasharraykey
(\
%customservicegrp);
799 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
800 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
801 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
802 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
803 $customservicegrp{$key}[3] = $count;
804 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
805 $fwhostsettings{'updatesrvgrp'}='on';
811 &viewtableservicegrp
;
814 if ($fwhostsettings{'ACTION'} eq 'editnet')
819 if ($fwhostsettings{'ACTION'} eq 'edithost')
824 if ($fwhostsettings{'ACTION'} eq 'editgrp')
826 $fwhostsettings{'update'}='on';
830 if ($fwhostsettings{'ACTION'} eq 'editservice')
832 $fwhostsettings{'updatesrv'}='on';
835 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
837 $fwhostsettings{'updatesrvgrp'} = 'on';
839 &viewtableservicegrp
;
842 if ($fwhostsettings{'ACTION'} eq 'resetnet')
844 $fwhostsettings{'HOSTNAME'} ="";
845 $fwhostsettings{'IP'} ="";
846 $fwhostsettings{'SUBNET'} ="";
849 if ($fwhostsettings{'ACTION'} eq 'resethost')
851 $fwhostsettings{'HOSTNAME'} ="";
852 $fwhostsettings{'IP'} ="";
853 $fwhostsettings{'type'} ="";
856 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
858 $fwhostsettings{'grp_name'} ="";
859 $fwhostsettings{'remark'} ="";
863 if ($fwhostsettings{'ACTION'} eq 'delnet')
865 &General
::readhasharray
("$confignet", \
%customnetwork);
866 foreach my $key (keys %customnetwork) {
867 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
868 delete $customnetwork{$key};
869 &General
::writehasharray
("$confignet", \
%customnetwork);
876 if ($fwhostsettings{'ACTION'} eq 'delhost')
878 &General
::readhasharray
("$confighost", \
%customhost);
879 foreach my $key (keys %customhost) {
880 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
881 delete $customhost{$key};
882 &General
::writehasharray
("$confighost", \
%customhost);
889 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
893 &General
::readhasharray
("$configgrp", \
%customgrp);
894 foreach my $key (keys %customgrp){
895 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
896 #decrease count from source host/net
897 if ($customgrp{$key}[3] eq 'Custom Network'){
898 &General
::readhasharray
("$confignet", \
%customnetwork);
899 foreach my $key1 (keys %customnetwork){
900 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
901 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
905 &General
::writehasharray
("$confignet", \
%customnetwork);
907 if ($customgrp{$key}[3] eq 'Custom Host'){
908 &General
::readhasharray
("$confighost", \
%customhost);
909 foreach my $key1 (keys %customhost){
910 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
911 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
915 &General
::writehasharray
("$confighost", \
%customhost);
917 $grpname=$customgrp{$key}[0];
918 $grpremark=$customgrp{$key}[1];
919 delete $customgrp{$key};
922 &General
::writehasharray
("$configgrp", \
%customgrp);
923 if ($fwhostsettings{'grpcnt'} > 0){&rules
;}
924 if ($fwhostsettings{'update'} eq 'on'){
925 $fwhostsettings{'remark'}= $grpremark;
926 $fwhostsettings{'grp_name'}=$grpname;
931 if ($fwhostsettings{'ACTION'} eq 'delgrp')
933 &General
::readhasharray
("$configgrp", \
%customgrp);
934 &decrease
($fwhostsettings{'grp_name'});
935 foreach my $key (sort keys %customgrp)
937 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
939 delete $customgrp{$key};
942 &General
::writehasharray
("$configgrp", \
%customgrp);
943 $fwhostsettings{'grp_name'}='';
947 if ($fwhostsettings{'ACTION'} eq 'delservice')
949 &General
::readhasharray
("$configsrv", \
%customservice);
950 foreach my $key (keys %customservice) {
951 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
952 #&deletefromgrp($customhost{$key}[0],$configgrp);
953 delete $customservice{$key};
954 &General
::writehasharray
("$configsrv", \
%customservice);
958 $fwhostsettings{'SRV_NAME'}='';
959 $fwhostsettings{'SRV_PORT'}='';
960 $fwhostsettings{'PROT'}='';
963 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
965 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
966 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
967 foreach my $key (sort keys %customservicegrp)
969 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
971 delete $customservicegrp{$key};
974 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
975 $fwhostsettings{'SRVGRP_NAME'}='';
977 &viewtableservicegrp
;
979 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
983 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
984 &General
::readhasharray
("$configsrv", \
%customservice);
985 foreach my $key (keys %customservicegrp){
986 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
988 #decrease count from source service
989 foreach my $key1 (sort keys %customservice){
990 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
991 $customservice{$key1}[4]--;
995 &General
::writehasharray
("$configsrv", \
%customservice);
996 $grpname=$customservicegrp{$key}[0];
997 $grpremark=$customservicegrp{$key}[1];
998 delete $customservicegrp{$key};
1001 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1003 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1004 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1005 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1008 &viewtableservicegrp
;
1011 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1016 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1021 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1026 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1030 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1033 &viewtableservicegrp
;
1035 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1037 &General
::readhasharray
("$configgrp", \
%customgrp);
1038 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1039 foreach my $key (sort keys %customgrp)
1041 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1043 $customgrp{$key}[1]='';
1044 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1047 &General
::writehasharray
("$configgrp", \
%customgrp);
1048 $fwhostsettings{'update'}='on';
1049 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1051 $errormessage=$Lang::tr
{'fwhost err remark'};
1052 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1053 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1054 $fwhostsettings{'update'} = 'on';
1056 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1060 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1062 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1063 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1064 foreach my $key (sort keys %customservicegrp)
1066 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1068 $customservicegrp{$key}[1]='';
1069 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1072 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1073 $fwhostsettings{'updatesrvgrp'}='on';
1074 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1076 $errormessage=$Lang::tr
{'fwhost err remark'};
1077 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1078 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1079 $fwhostsettings{'updatesrvgrp'} = 'on';
1081 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1083 &viewtableservicegrp
;
1086 if($fwhostsettings{'ACTION'} eq '')
1093 if (-f
"${General::swroot}/forward/reread"){
1094 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>";
1096 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1097 print "$Lang::tr{'fwhost welcome'}";
1099 <br><br><table border='0' width='100%'>
1100 <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>
1101 <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>
1102 <tr><td colspan='6'><hr></td></tr></table>
1104 &Header
::closebox
();
1112 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1113 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1114 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1116 <table border='0' width='100%'>
1117 <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>
1118 <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>
1119 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1120 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1121 <tr><td colspan='6'><br><hr></td></tr><tr>
1123 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1125 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>";
1127 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'>";
1129 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>";
1130 &Header
::closebox
();
1136 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1137 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1138 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1140 <table border='0' width='100%'>
1141 <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>
1142 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1143 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1144 <tr><td colspan='5'><hr></td></tr><tr>
1147 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1150 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>";
1152 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'>";
1154 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>";
1155 &Header
::closebox
();
1162 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1163 &General
::setup_default_networks
(\
%defaultNetworks);
1164 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1165 &General
::readhasharray
("$confignet", \
%customnetwork);
1166 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1167 &General
::readhasharray
("$confighost", \
%customhost);
1168 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1172 $checked{'check1'}{'off'} = '';
1173 $checked{'check1'}{'on'} = '';
1174 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1175 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1176 my $grp=$fwhostsettings{'grp_name'};
1177 my $rem=$fwhostsettings{'remark'};
1178 if ($fwhostsettings{'update'} eq ''){
1180 <table width='100%' border='0'>
1181 <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>
1182 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1183 <tr><td colspan='2'><br><hr></td></tr></table>
1187 <table width='100%' border='0'><form method='post' style='display:inline'>
1188 <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>
1189 <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>
1193 if ($fwhostsettings{'update'} eq 'on'){
1195 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1196 <table width='100%' border='0'>
1197 <tr><td width=50% valign='top'>
1198 <table width='100%' border='0'>
1199 <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;'>
1201 foreach my $network (sort keys %defaultNetworks)
1203 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1204 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1205 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1206 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1207 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1208 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1209 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1210 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1211 if ($ownnet{$defnet}){
1212 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1214 print ">$network</option>";
1217 print"</select></td></tr>";
1218 if (! -z
$confignet){
1219 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;'>";
1220 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1221 print"<option>$customnetwork{$key}[0]</option>";
1223 print"</select></td></tr>";
1225 if (! -z
$confighost){
1226 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;'>";
1227 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1228 print"<option>$customhost{$key}[0]</option>";
1230 print"</select></td></tr>";
1234 print"</td><td valign='top'><table width='100%' border='0'>";
1236 if (! -z
$configccdnet){
1237 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;'>";
1238 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1240 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1242 print"</select></td></tr>";
1245 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1247 if ($ccdhost{$key}[33] ne ''){
1248 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 '');
1250 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1253 if ($show eq '1'){$show='';print"</select></td></tr>";}
1255 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1256 if($ccdhost{$key}[3] eq 'net'){
1257 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 '');
1259 print"<option>$ccdhost{$key}[1]</option>";
1262 if ($show eq '1'){$show='';print"</select></td></tr>";}
1264 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1265 if ($ipsecconf{$key}[3] eq 'net'){
1266 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 '');
1268 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1271 if ($show eq '1'){$show='';print"</select></td></tr>";}
1273 print"</td></tr></table>";
1274 print"<br><br><hr>";
1276 print"<table border='0' width='100%'>";
1277 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>";
1278 &Header
::closebox
();
1284 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1285 if ($fwhostsettings{'updatesrv'} eq 'on')
1287 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1288 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1289 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1292 <table width='100%' border='0'><form method='post'>
1293 <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>
1294 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT'>
1296 foreach ("TCP","UDP","ICMP")
1298 if ($_ eq $fwhostsettings{'PROT'})
1300 print"<option selected>$_</option>";
1302 print"<option>$_</option>";
1307 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td><select name='ICMP_TYPES'>
1309 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1310 print"<option>All ICMP-Types</option>";
1311 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1312 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1317 <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>
1318 <tr><td colspan='6'><br><hr></td></tr>
1319 <tr><td colspan='6' align='right'>
1321 if ($fwhostsettings{'updatesrv'} eq 'on')
1324 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1325 <input type='hidden' name='ACTION' value='updateservice'>
1326 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1327 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1328 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1332 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1335 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1340 &Header
::closebox
();
1348 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1349 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1350 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1352 <table width='100%' border='0'><form method='post'>
1353 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1354 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1355 <tr><td colspan='2'><br><hr></tr>
1360 <table width='100%' border='0'><form method='post' style='display:inline'>
1361 <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>
1362 <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>
1363 <tr><td colspan='3'><br><hr></td></td></tr>
1367 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1369 <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%'>
1370 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1372 &General
::readhasharray
("$configsrv", \
%customservice);
1373 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1375 print "<option>$customservice{$key}[0]</option>";
1379 <tr><td colspan='4'><br><br></td></tr>
1380 <tr><td colspan='4'><hr></td></tr>
1385 <table width='100%' border='0'>
1386 <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>
1389 &Header
::closebox
();
1394 if(! -z
$confignet){
1395 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1396 &General
::readhasharray
("$confignet", \
%customnetwork);
1397 if (!keys %customnetwork)
1399 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1402 <table border='0' width='100%' cellspacing='0'>
1403 <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>
1407 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1408 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1409 print" <tr bgcolor='${Header::colouryellow}'>";
1412 print" <tr bgcolor='$color{'color22'}'>";
1415 print" <tr bgcolor='$color{'color20'}'>";
1417 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1418 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>";
1420 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1421 <input type='hidden' name='ACTION' value='editnet'>
1422 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1423 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1424 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1425 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1428 if($customnetwork{$key}[4] == '0')
1430 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>";
1432 print"<td></td></tr>";
1437 &Header
::closebox
();
1444 #Check if IP is part of OpenVPN N2N subnet
1445 foreach my $key (sort keys %ccdhost){
1446 if ($ccdhost{$key}[3] eq 'net'){
1447 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1448 if (&General
::IpInSubnet
($c,$a,$b)){
1449 $tdcolor="style='color:$Header::colourovpn ;'";
1454 #Check if IP is part of OpenVPN dynamic subnet
1455 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1456 if (&General
::IpInSubnet
($c,$a,$b)){
1457 $tdcolor="style='color: $Header::colourovpn;'";
1460 #Check if IP is part of OpenVPN static subnet
1461 foreach my $key (sort keys %ccdnet){
1462 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1463 $b =&General
::iporsubtodec
($b);
1464 if (&General
::IpInSubnet
($c,$a,$b)){
1465 $tdcolor="style='color: $Header::colourovpn;'";
1469 #Check if IP is part of IPsec RW network
1470 if ($ipsecsettings{'RW_NET'} ne ''){
1471 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1472 $b=&General
::iporsubtodec
($b);
1473 if (&General
::IpInSubnet
($c,$a,$b)){
1474 $tdcolor="style='color: $Header::colourvpn;'";
1478 #Check if IP is part of a IPsec N2N network
1479 foreach my $key (sort keys %ipsecconf){
1480 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1481 if (&General
::IpInSubnet
($c,$a,$b)){
1482 $tdcolor="style='color: $Header::colourvpn;'";
1491 if (! -z
$confighost){
1492 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1493 &General
::readhasharray
("$confighost", \
%customhost);
1494 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1495 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1496 if (!keys %customhost)
1498 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1501 <table border='0' width='100%' cellspacing='0'>
1502 <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>
1506 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1507 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1508 print" <tr bgcolor='${Header::colouryellow}'>";
1509 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1510 else{ print" <tr bgcolor='$color{'color20'}'>";}
1511 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1512 $customhost{$key}[4]=~s/\s+//g;
1513 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>";
1515 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1516 <input type='hidden' name='ACTION' value='edithost' />
1517 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1518 <input type='hidden' name='IP' value='$ip' />
1519 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1520 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1523 if($customhost{$key}[4] == '0')
1525 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>";
1527 print"<td width='1%'></td></tr>";
1532 &Header
::closebox
();
1537 if(! -z
"$configgrp"){
1538 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1539 &General
::readhasharray
("$configgrp", \
%customgrp);
1540 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1541 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1542 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1543 &General
::readhasharray
("$confighost", \
%customhost);
1544 &General
::readhasharray
("$confignet", \
%customnetwork);
1552 if (!keys %customgrp)
1554 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1556 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1558 if ($helper ne $customgrp{$key}[0]){
1560 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1561 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1570 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
1571 $grpname=$customgrp{$key}[0];
1572 $remark="$customgrp{$key}[1]";
1573 if($count gt 1){ print"</table>";}
1574 print "<br><b><u>$grpname</u></b> ";
1575 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1576 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1577 if($customgrp{$key}[4] == '0')
1579 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>";
1581 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>";
1582 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>";
1585 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1586 print" <tr bgcolor='${Header::colouryellow}'>";
1587 }elsif ($count %2 == 0){
1588 print"<tr bgcolor='$color{'color22'}'>";
1590 print"<tr bgcolor='$color{'color20'}'>";
1592 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1593 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1594 print "<td width='39%' align='left'>";
1595 if($customgrp{$key}[3] eq 'Standard Network'){
1596 print &get_name
($customgrp{$key}[2])."</td>";
1598 print "$customgrp{$key}[2]</td>";
1600 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
1601 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1603 my ($colip,$colsub) = split("/",$ip);
1604 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1605 print"<td align='center' ".&getcolor
($colip).">".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1607 if ($delflag > '1' && $ip ne ''){
1608 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1610 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>";
1612 $helper=$customgrp{$key}[0];
1617 &Header
::closebox
();
1621 sub viewtableservice
1624 if(! -z
"$configsrv")
1626 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1627 &General
::readhasharray
("$configsrv", \
%customservice);
1629 <table width='100%' border='0' cellspacing='0'>
1630 <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>
1632 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1635 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1636 print" <tr bgcolor='${Header::colouryellow}'>";
1637 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1639 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1641 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1644 </td><td align='center'>$customservice{$key}[4]x</td>
1645 <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' />
1646 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1647 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1648 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1650 if ($customservice{$key}[4] eq '0')
1652 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>";
1654 print"<td></td></tr>";
1658 &Header
::closebox
();
1661 sub viewtableservicegrp
1670 if (! -z
$configsrvgrp){
1671 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1672 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1673 &General
::readhasharray
("$configsrv", \
%customservice);
1674 my $number= keys %customservicegrp;
1675 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1677 if ($helper ne $customservicegrp{$key}[0]){
1679 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1680 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1688 $grpname=$customservicegrp{$key}[0];
1689 if ($customservicegrp{$key}[2] eq "none"){
1690 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1694 $remark="$customservicegrp{$key}[1]";
1695 if($count >=2){print"</table>";}
1696 print "<br><b><u>$grpname</u></b> ";
1697 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1698 print " <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1699 if($customservicegrp{$key}[3] == '0')
1701 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>";
1703 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>";
1704 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>";
1706 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1707 print" <tr bgcolor='${Header::colouryellow}'>";
1708 }elsif ($count %2 == 0){
1709 print"<tr bgcolor='$color{'color22'}'>";
1711 print"<tr bgcolor='$color{'color20'}'>";
1713 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1714 foreach my $srv (sort keys %customservice){
1715 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1716 $protocol=$customservice{$srv}[2];
1717 $port=$customservice{$srv}[1];
1721 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1722 if ($number gt '1'){
1723 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1725 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>";
1726 $helper=$customservicegrp{$key}[0];
1729 &Header
::closebox
();
1735 my %hash=%{(shift)};
1736 foreach my $key (keys %hash) {
1737 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1746 my %hash=%{(shift)};
1748 foreach my $key (keys %hash) {
1749 if($hash{$key}[0] eq $name){
1758 my %hash=%{(shift)};
1760 foreach my $key (keys %hash) {
1761 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1769 my %hash=%{(shift)};
1770 &General
::readhasharray
("$confignet", \
%hash);
1771 foreach my $key (keys %hash) {
1772 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1779 sub checkservicegroup
1781 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1785 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1787 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1788 return $errormessage;
1790 #check empty selectbox
1791 if (keys %customservice lt 1)
1793 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1795 #check if name already exists
1796 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1797 foreach my $key (keys %customservicegrp) {
1798 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1799 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1804 #check if service already exists in group
1805 foreach my $key (keys %customservicegrp) {
1806 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1807 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1810 return $errormessage;
1814 if ($errormessage) {
1815 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1816 print "<class name='base'>$errormessage\n";
1817 print " </class>\n";
1818 &Header
::closebox
();
1824 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1825 print "<class name='base'>$hint\n";
1826 print " </class>\n";
1827 &Header
::closebox
();
1833 &General
::setup_default_networks
(\
%defaultNetworks);
1834 foreach my $network (sort keys %defaultNetworks)
1836 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1845 &General
::readhasharray
("$config",\
%hash);
1846 foreach my $key (keys %hash) {
1847 $errormessage.="lese $hash{$key}[2] und $target<br>";
1848 if($hash{$key}[2] eq $target){
1851 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1854 &General
::writehasharray
("$config",\
%hash);
1861 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
1863 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1864 $fwhostsettings{'BLK_IP'}='readonly';
1865 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1866 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1868 #check if name collides with CCD Netname
1869 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1870 foreach my $key (keys %ccdnet) {
1871 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1872 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1873 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1874 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1878 #check if IP collides with CCD NetIP
1879 if ($fwhostsettings{'type'} ne 'mac'){
1880 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1881 foreach my $key (keys %ccdnet) {
1882 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1883 if($ccdnet{$key}[1] eq $test){
1884 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1885 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1886 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1887 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1892 #check if name collides with CCD Hostname
1893 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1894 foreach my $key (keys %ccdhost) {
1895 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1896 if($ip eq $fwhostsettings{'IP'}){
1897 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1898 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1902 #check if IP collides with CCD HostIP (only hosts)
1903 if ($edit eq 'edithost')
1905 foreach my $key (keys %ccdhost) {
1906 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1907 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1908 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1909 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1914 #check if network with this name already exists
1915 &General
::readhasharray
("$confignet", \
%customnetwork);
1916 if (!&checkname
(\
%customnetwork))
1918 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1919 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1920 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1922 #check if network ip already exists
1923 if (!&checkip
(\
%customnetwork,1))
1925 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1926 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1928 #check if host with this name already exists
1929 &General
::readhasharray
("$confighost", \
%customhost);
1930 if (!&checkname
(\
%customhost))
1932 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1933 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1934 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1936 #check if host with this ip already exists
1937 if (!&checkip
(\
%customhost,2))
1939 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1949 #get address from IPSEC NETWORK
1950 if ($type eq 'IpSec Network'){
1951 foreach my $key (keys %ipsecconf) {
1952 if ($ipsecconf{$key}[1] eq $name){
1953 return $ipsecconf{$key}[11];
1956 &deletefromgrp
($name,$configgrp);
1959 #get address from IPSEC HOST
1960 if ($type eq 'IpSec Host'){
1961 foreach my $key (keys %ipsecconf) {
1962 if ($ipsecconf{$key}[1] eq $name){
1963 return $ipsecconf{$key}[10];
1966 &deletefromgrp
($name,$configgrp);
1969 #get address from ovpn ccd Net-2-Net
1970 if ($type eq 'OpenVPN N-2-N'){
1971 foreach my $key (keys %ccdhost) {
1972 if($ccdhost{$key}[1] eq $name){
1973 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1974 $b=&General
::iporsubtodec
($b);
1978 &deletefromgrp
($name,$configgrp);
1981 #get address from ovpn ccd static host
1982 if ($type eq 'OpenVPN static host'){
1983 foreach my $key (keys %ccdhost) {
1984 if($ccdhost{$key}[1] eq $name){
1985 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1986 $b=&General
::iporsubtodec
($b);
1990 &deletefromgrp
($name,$configgrp);
1993 #get address from ovpn ccd static net
1994 if ($type eq 'OpenVPN static network'){
1995 foreach my $key (keys %ccdnet) {
1996 if ($ccdnet{$key}[0] eq $name){
1997 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1998 $b=&General
::iporsubtodec
($b);
2004 #check custom addresses
2005 if ($type eq 'Custom Host'){
2006 foreach my $key (keys %customhost) {
2007 if ($customhost{$key}[0] eq $name){
2008 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2014 ##check custom networks
2015 if ($type eq 'Custom Network'){
2016 foreach my $key (keys %customnetwork) {
2017 if($customnetwork{$key}[0] eq $name){
2018 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2023 #check standard networks
2024 if ($type eq 'Standard Network'){
2025 if ($name =~ /OpenVPN/i){
2027 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2028 return $ovpn{'DOVPN_SUBNET'};
2030 if ($name eq 'GREEN'){
2032 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2033 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2035 if ($name eq 'BLUE'){
2037 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2038 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2040 if ($name eq 'ORANGE'){
2042 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2043 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2045 if ($name eq 'ALL'){
2046 return "0.0.0.0/0.0.0.0";
2048 if ($name =~ /IPsec/i){
2050 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2051 return $hash{'RW_NET'};
2057 if (!-f
"${General::swroot}/fwhosts/reread"){
2058 system("touch ${General::swroot}/fwhosts/reread");
2059 system("touch ${General::swroot}/forward/reread");
2064 system ("/usr/local/bin/forwardfwctrl");
2065 if ( -f
"${General::swroot}/fwhosts/reread"){
2066 system("rm ${General::swroot}/fwhosts/reread");
2067 system("rm ${General::swroot}/forward/reread");
2074 &General
::readhasharray
("$confignet", \
%customnetwork);
2075 &General
::readhasharray
("$confighost", \
%customhost);
2076 foreach my $key (sort keys %customgrp ){
2077 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2078 foreach my $key1 (sort keys %customnetwork){
2079 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2080 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2086 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2087 foreach my $key2 (sort keys %customhost){
2088 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2089 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2096 &General
::writehasharray
("$confignet", \
%customnetwork);
2097 &General
::writehasharray
("$confighost", \
%customhost);
2102 &General
::readhasharray
("$configsrv", \
%customservice);
2103 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2105 foreach my $key (sort keys %customservicegrp){
2106 if ($customservicegrp{$key}[0] eq $grp ){
2107 foreach my $key2 (sort keys %customservice){
2108 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2109 $customservice{$key2}[4]--;
2114 &General
::writehasharray
("$configsrv", \
%customservice);
2120 my %hash=%{(shift)};
2122 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2123 $errormessage=$Lang::tr
{'fwhost err name1'};
2125 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2126 $errormessage=$Lang::tr
{'fwhost err port'};
2129 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2130 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2132 #change dashes with :
2133 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2135 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2136 $fwhostsettings{'SRV_PORT'} = "1:65535";
2138 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2139 $fwhostsettings{'SRV_PORT'} = "1:$2";
2141 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2142 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2144 if($fwhostsettings{'PROT'} ne 'ICMP'){
2145 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2147 # a new service has to have a different name
2148 foreach my $key (keys %hash){
2149 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2150 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2154 return $errormessage;
2158 # Checks a hostname against RFC1035
2159 my $hostname = $_[0];
2161 # Each part should be at least two characters in length
2162 # but no more than 63 characters
2163 if (length ($hostname) < 1 || length ($hostname) > 63) {
2165 # Only valid characters are a-z, A-Z, 0-9 and -
2166 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2168 # First character can only be a letter or a digit
2169 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2171 # Last character can only be a letter or a digit
2172 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2178 # Checks a hostname against RFC1035
2180 # Each part should be at least two characters in length
2181 # but no more than 63 characters
2182 if (length ($remark) < 1 || length ($remark) > 255) {
2184 # Only valid characters are a-z, A-Z, 0-9 and -
2185 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2187 # First character can only be a letter or a digit
2188 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2190 # Last character can only be a letter or a digit
2191 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2195 &Header
::closebigbox
();
2196 &Header
::closepage
();