]>
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=();
56 my $confignet = "${General::swroot}/fwhosts/customnetworks";
57 my $confighost = "${General::swroot}/fwhosts/customhosts";
58 my $configgrp = "${General::swroot}/fwhosts/customgroups";
59 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
60 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
61 my $configipsec = "${General::swroot}/vpn/config";
62 my $configsrv = "${General::swroot}/fwhosts/customservices";
63 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
64 my $fwconfigfwd = "${General::swroot}/firewall/config";
65 my $fwconfiginp = "${General::swroot}/firewall/input";
66 my $fwconfigout = "${General::swroot}/firewall/outgoing";
67 my $configovpn = "${General::swroot}/ovpn/settings";
69 my $configipsecrw = "${General::swroot}/vpn/settings";
71 unless (-e
$confignet) { system("touch $confignet"); }
72 unless (-e
$confighost) { system("touch $confighost"); }
73 unless (-e
$configgrp) { system("touch $configgrp"); }
74 unless (-e
$configsrv) { system("touch $configsrv"); }
75 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
77 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
78 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
79 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
80 &General
::readhash
("$configovpn", \
%ovpnsettings);
81 &General
::readhasharray
("$configipsec", \
%ipsecconf);
82 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
84 &Header
::getcgihash
(\
%fwhostsettings);
86 &Header
::showhttpheaders
();
87 &Header
::openpage
($Lang::tr
{'fwhost hosts'}, 1, '');
88 &Header
::openbigbox
('100%', 'center');
93 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
94 var update_protocol = function() {
95 var protocol = \$("#protocol").val();
97 if (protocol === undefined)
100 // Check if we are dealing with a protocol, that knows ports.
101 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
103 \$("#PROTOKOLL").hide();
106 \$("#PROTOKOLL").show();
110 \$(document).ready(function() {
111 var protocol = \$("#protocol").val();
112 \$("#protocol").change(update_protocol);
120 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
122 &General
::readhasharray
("$confignet", \
%customnetwork);
123 foreach my $key (keys %customnetwork)
125 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
127 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
128 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
129 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
130 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
131 $fwhostsettings{'count'} = $customnetwork{$key}[4];
132 delete $customnetwork{$key};
136 &General
::writehasharray
("$confignet", \
%customnetwork);
137 $fwhostsettings{'actualize'} = 'on';
138 $fwhostsettings{'ACTION'} = 'savenet';
140 if ($fwhostsettings{'ACTION'} eq 'updatehost')
143 &General
::readhasharray
("$confighost", \
%customhost);
144 foreach my $key (keys %customhost)
146 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
148 if ($customhost{$key}[1] eq 'ip'){
149 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
151 $ip = $customhost{$key}[2];
153 $fwhostsettings{'orgip'} = $ip;
154 $fwhostsettings{'count'} = $customhost{$key}[4];
155 delete $customhost{$key};
156 &General
::writehasharray
("$confighost", \
%customhost);
159 $fwhostsettings{'actualize'} = 'on';
160 if($fwhostsettings{'orgip'}){
161 $fwhostsettings{'ACTION'} = 'savehost';
163 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
166 if ($fwhostsettings{'ACTION'} eq 'updateservice')
170 $errormessage=&checkports
(\
%customservice);
171 if ($fwhostsettings{'oldsrvname'} ne $fwhostsettings{'SRV_NAME'} && !&checkgroup
($fwhostsettings{'SRV_NAME'})){
172 $errormessage=$Lang::tr
{'fwhost err grpexist'};
175 &General
::readhasharray
("$configsrv", \
%customservice);
176 foreach my $key (keys %customservice)
178 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
180 delete $customservice{$key};
181 &General
::writehasharray
("$configsrv", \
%customservice);
185 if ($fwhostsettings{'PROT'} ne 'ICMP'){
186 $fwhostsettings{'ICMP_TYPES'}='BLANK';
188 my $key1 = &General
::findhasharraykey
(\
%customservice);
189 #find out short ICMP-TYPE
190 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
191 foreach my $key (keys %icmptypes){
192 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
193 $fwhostsettings{'ICMP_TYPES'}=$icmptypes{$key}[0];
196 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
197 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
198 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
199 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
200 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
201 &General
::writehasharray
("$configsrv", \
%customservice);
202 #check if we need to update firewallrules
203 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
204 if ( ! -z
$fwconfigfwd ){
205 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
206 foreach my $key (sort keys %fwfwd){
207 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
208 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
211 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
213 if ( ! -z
$fwconfiginp ){
214 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
215 foreach my $line (sort keys %fwinp){
216 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
217 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
220 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
222 if ( ! -z
$fwconfigout ){
223 &General
::readhasharray
("$fwconfigout", \
%fwout);
224 foreach my $line (sort keys %fwout){
225 if ($fwout{$line}[15] eq $fwhostsettings{'oldsrvname'}){
226 $fwout{$line}[15] = $fwhostsettings{'SRV_NAME'};
229 &General
::writehasharray
("$fwconfigout", \
%fwout);
231 #check if we need to update groups
232 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
233 foreach my $key (sort keys %customservicegrp){
234 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
235 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
238 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
241 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
244 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
247 if($count gt 0 && $fwhostsettings{'oldsrvicmp'} ne $fwhostsettings{'ICMP'} ){
250 $fwhostsettings{'SRV_NAME'} = '';
251 $fwhostsettings{'SRV_PORT'} = '';
252 $fwhostsettings{'PROT'} = '';
253 $fwhostsettings{'ICMP'} = '';
254 $fwhostsettings{'oldsrvicmp'} = '';
255 $fwhostsettings{'updatesrv'} = '';
257 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
258 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
259 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
260 $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
261 $fwhostsettings{'updatesrv'}= 'on';
263 if($needrules eq 'on'){
264 &General
::firewall_config_changed
();
269 if ($fwhostsettings{'ACTION'} eq 'savenet' )
273 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
274 #check if all fields are set
275 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
277 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
282 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
284 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
285 $fwhostsettings{'BLK_HOST'} ='readonly';
286 $fwhostsettings{'NOCHECK'} ='false';
287 $fwhostsettings{'error'} ='on';
290 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
291 $errormessage=$Lang::tr
{'fwhost err remark'};
292 $fwhostsettings{'error'} ='on';
294 #check if subnet is sigle host
295 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
297 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
299 if($fwhostsettings{'error'} ne 'on'){
300 #check if we use one of ipfire's networks (green,orange,blue)
301 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
303 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
304 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
305 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
307 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
309 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
310 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
311 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
313 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
315 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
316 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
317 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
319 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
321 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
322 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
323 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
326 #only check plausi when no error till now
328 &plausicheck
("editnet");
330 #check if network ip is part of an already used one
331 if(&checksubnet
(\
%customnetwork))
333 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
334 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
336 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
338 $fwhostsettings{'actualize'} = '';
339 my $key = &General
::findhasharraykey
(\
%customnetwork);
340 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
341 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
342 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
343 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
344 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
345 $customnetwork{$key}[4] = $fwhostsettings{'count'};
346 &General
::writehasharray
("$confignet", \
%customnetwork);
347 undef %customnetwork;
351 &General
::readhasharray
("$confignet", \
%customnetwork);
352 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
353 if ($fwhostsettings{'update'} == '0'){
354 foreach my $key (keys %customnetwork) {
355 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
356 $count=$customnetwork{$key}[4];
357 delete $customnetwork{$key};
363 #get count if actualize is 'on'
364 if($fwhostsettings{'actualize'} eq 'on'){
365 $fwhostsettings{'actualize'} = '';
366 $count=$fwhostsettings{'count'};
367 #check if we need to reload rules
368 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
371 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
372 #check if we need to update groups
373 &General
::readhasharray
("$configgrp", \
%customgrp);
374 foreach my $key (sort keys %customgrp){
375 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
376 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
380 &General
::writehasharray
("$configgrp", \
%customgrp);
381 #check if we need to update firewallrules
382 if ( ! -z
$fwconfigfwd ){
383 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
384 foreach my $line (sort keys %fwfwd){
385 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
386 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
388 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
389 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
392 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
394 if ( ! -z
$fwconfiginp ){
395 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
396 foreach my $line (sort keys %fwinp){
397 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
398 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
401 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
405 my $key = &General
::findhasharraykey
(\
%customnetwork);
406 foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";}
407 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
408 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
409 #convert ip when leading '0' in byte
410 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
411 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
412 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
413 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
414 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
415 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
416 $customnetwork{$key}[4] = $count;
417 &General
::writehasharray
("$confignet", \
%customnetwork);
418 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
419 undef %customnetwork;
420 $fwhostsettings{'HOSTNAME'}='';
421 $fwhostsettings{'IP'}='';
422 $fwhostsettings{'SUBNET'}='';
423 $fwhostsettings{'NETREMARK'}='';
424 #check if an edited net affected groups and need to reload rules
425 if ($needrules eq 'on'){
426 &General
::firewall_config_changed
();
436 if ($fwhostsettings{'ACTION'} eq 'savehost')
440 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
441 $fwhostsettings{'SUBNET'}='32';
442 #check if all fields are set
443 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
445 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
446 $fwhostsettings{'ACTION'} = 'edithost';
448 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
449 $fwhostsettings{'type'} = 'mac';
450 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
451 $fwhostsettings{'type'} = 'ip';
453 $fwhostsettings{'type'} = '';
454 $errormessage=$Lang::tr
{'fwhost err ipmac'};
457 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
458 $errormessage=$Lang::tr
{'fwhost err remark'};
461 if ($fwhostsettings{'type'} eq 'ip'){
463 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
464 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
466 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
467 $fwhostsettings{'error'}='on';
469 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
470 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
471 $fwhostsettings{'error'}='on';
473 #check if net or broadcast
474 my @tmp= split (/\./,$fwhostsettings{'IP'});
475 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
476 $errormessage=$Lang::tr
{'fwhost err hostip'};
479 #only check plausi when no error till now
481 &plausicheck
("edithost");
483 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
484 $fwhostsettings{'actualize'} = '';
485 my $key = &General
::findhasharraykey
(\
%customhost);
486 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
487 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
488 $customhost{$key}[1] = $fwhostsettings{'type'} ;
489 if($customhost{$key}[1] eq 'ip'){
490 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
492 $customhost{$key}[2] = $fwhostsettings{'orgip'};
494 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
495 $customhost{$key}[4] = $fwhostsettings{'count'};
496 &General
::writehasharray
("$confighost", \
%customhost);
500 #get count if host was edited
501 if($fwhostsettings{'actualize'} eq 'on'){
502 $count=$fwhostsettings{'count'};
503 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
506 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
507 #check if we need to update groups
508 &General
::readhasharray
("$configgrp", \
%customgrp);
509 foreach my $key (sort keys %customgrp){
510 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
511 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
514 &General
::writehasharray
("$configgrp", \
%customgrp);
515 #check if we need to update firewallrules
516 if ( ! -z
$fwconfigfwd ){
517 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
518 foreach my $line (sort keys %fwfwd){
519 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
520 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
522 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
523 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
526 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
528 if ( ! -z
$fwconfiginp ){
529 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
530 foreach my $line (sort keys %fwinp){
531 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
532 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
535 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
539 my $key = &General
::findhasharraykey
(\
%customhost);
540 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
541 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
542 $customhost{$key}[1] = $fwhostsettings{'type'} ;
543 if ($fwhostsettings{'type'} eq 'ip'){
544 #convert ip when leading '0' in byte
545 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
546 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
547 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
549 $customhost{$key}[2] = $fwhostsettings{'IP'};
551 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
552 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
553 $customhost{$key}[4] =$count;
554 &General
::writehasharray
("$confighost", \
%customhost);
556 $fwhostsettings{'HOSTNAME'}='';
557 $fwhostsettings{'IP'}='';
558 $fwhostsettings{'type'}='';
559 $fwhostsettings{'HOSTREMARK'}='';
560 #check if we need to update rules while host was edited
561 if($needrules eq 'on'){
562 &General
::firewall_config_changed
();
572 if ($fwhostsettings{'ACTION'} eq 'savegrp')
574 my $grp=$fwhostsettings{'grp_name'};;
575 my $rem=$fwhostsettings{'remark'};
578 my $updcounter='off';
581 &General
::readhasharray
("$configgrp", \
%customgrp);
582 &General
::readhasharray
("$confignet", \
%customnetwork);
583 &General
::readhasharray
("$confighost", \
%customhost);
585 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
587 if (!&checkgroup
($grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
589 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
590 $errormessage.=$Lang::tr
{'fwhost err remark'};
592 if ($fwhostsettings{'update'} eq 'on'){
593 #check standard networks
594 if ($fwhostsettings{'grp2'} eq 'std_net'){
595 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
596 $type='Standard Network';
598 #check custom networks
599 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
600 @target=$fwhostsettings{'CUST_SRC_NET'};
602 $type='Custom Network';
603 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
604 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
605 $fwhostsettings{'grp_name'}='';
606 $fwhostsettings{'remark'}='';
608 #check custom addresses
609 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
610 @target=$fwhostsettings{'CUST_SRC_HOST'};
613 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
614 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
615 $fwhostsettings{'grp_name'}='';
616 $fwhostsettings{'remark'}='';
618 #get address from ovpn ccd static net
619 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
620 @target=$fwhostsettings{'OVPN_CCD_NET'};
621 $type='OpenVPN static network';
622 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
623 $errormessage=$Lang::tr
{'fwhost err groupempty'};
624 $fwhostsettings{'grp_name'}='';
625 $fwhostsettings{'remark'}='';
627 #get address from ovpn ccd static host
628 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
629 @target=$fwhostsettings{'OVPN_CCD_HOST'};
630 $type='OpenVPN static host';
631 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
632 $errormessage=$Lang::tr
{'fwhost err groupempty'};
634 #get address from ovpn ccd Net-2-Net
635 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
636 @target=$fwhostsettings{'OVPN_N2N'};
637 $type='OpenVPN N-2-N';
638 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
639 $errormessage=$Lang::tr
{'fwhost err groupempty'};
640 $fwhostsettings{'grp_name'}='';
641 $fwhostsettings{'remark'}='';
643 #get address from IPSEC HOST
644 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
645 @target=$fwhostsettings{'IPSEC_HOST'};
647 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
648 $errormessage=$Lang::tr
{'fwhost err groupempty'};
649 $fwhostsettings{'grp_name'}='';
650 $fwhostsettings{'remark'}='';
652 #get address from IPSEC NETWORK
653 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
654 @target=$fwhostsettings{'IPSEC_NET'};
655 $type='IpSec Network';
656 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
657 $errormessage=$Lang::tr
{'fwhost err groupempty'};
658 $fwhostsettings{'grp_name'}='';
659 $fwhostsettings{'remark'}='';
661 #check if host/net exists in grp
663 my $test="$grp,$fwhostsettings{'oldremark'},@target";
664 foreach my $key (keys %customgrp) {
665 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
666 if ($test1 eq $test){
667 $errormessage=$Lang::tr
{'fwhost err isingrp'};
668 $fwhostsettings{'update'} = 'on';
674 #on first save, we have an empty @target, so fill it with nothing
675 my $targetvalues=@target;
676 if ($targetvalues == '0'){
679 #on update, we have to delete the dummy entry
680 foreach my $key (keys %customgrp){
681 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
682 delete $customgrp{$key};
686 &General
::writehasharray
("$configgrp", \
%customgrp);
687 &General
::readhasharray
("$configgrp", \
%customgrp);
689 foreach my $key (keys %customgrp)
691 if($customgrp{$key}[0] eq $grp)
693 $count=$customgrp{$key}[4];
697 if ($count eq '' ){$count='0';}
699 #create array with new lines
700 foreach my $line (@target){
701 push (@newgrp,"$grp,$rem,$line");
704 my $key = &General
::findhasharraykey
(\
%customgrp);
705 foreach my $line (@newgrp){
706 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
707 my ($a,$b,$c,$d) = split (",",$line);
708 $customgrp{$key}[0] = $a;
709 $customgrp{$key}[1] = $b;
710 $customgrp{$key}[2] = $c;
711 $customgrp{$key}[3] = $type;
712 $customgrp{$key}[4] = $count;
714 &General
::writehasharray
("$configgrp", \
%customgrp);
715 #update counter in Host/Net
716 if($updcounter eq 'net'){
717 foreach my $key (keys %customnetwork) {
718 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
719 $customnetwork{$key}[4] = $customnetwork{$key}[4]+1;
723 &General
::writehasharray
("$confignet", \
%customnetwork);
724 }elsif($updcounter eq 'host'){
725 foreach my $key (keys %customhost) {
726 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
727 $customhost{$key}[4]=$customhost{$key}[4]+1;
730 &General
::writehasharray
("$confighost", \
%customhost);
732 $fwhostsettings{'update'}='on';
734 #check if ruleupdate is needed
737 &General
::firewall_config_changed
();
742 if ($fwhostsettings{'ACTION'} eq 'saveservice')
745 &General
::readhasharray
("$configsrv", \
%customservice );
746 &General
::readhasharray
("$configgrp", \
%customgrp);
747 $errormessage=&checkports
(\
%customservice);
748 if ($fwhostsettings{'PROT'} eq 'ICMP'){
749 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
750 foreach my $key (keys %icmptypes){
751 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
752 $ICMP=$icmptypes{$key}[0];
756 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
757 if ($fwhostsettings{'PROT'} ne 'ICMP'){$ICMP='BLANK';}
758 #Check if a group with the same name already exists
759 if (!&checkgroup
($fwhostsettings{'SRV_NAME'})){
760 $errormessage = $Lang::tr
{'fwhost err grpexist'};
763 my $key = &General
::findhasharraykey
(\
%customservice);
764 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
765 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
766 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
767 $customservice{$key}[2] = $fwhostsettings{'PROT'};
768 $customservice{$key}[3] = $ICMP;
769 &General
::writehasharray
("$configsrv", \
%customservice );
771 $fwhostsettings{'SRV_NAME'}='';
772 $fwhostsettings{'SRV_PORT'}='';
773 $fwhostsettings{'PROT'}='';
774 $fwhostsettings{'ICMP_TYPES'}='';
778 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
785 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
786 &General
::readhasharray
("$configsrv", \
%customservice );
787 $errormessage=&checkservicegroup
;
788 #Check if we have more than 15 services from one Protocol in the group
789 #iptables can only handle 15 ports/portranges via multiport
790 foreach my $key (keys %customservicegrp){
791 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
792 foreach my $key1 (keys %customservice){
793 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
794 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
795 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
796 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
800 if ($tcpcounter > 15){
801 $errormessage=$Lang::tr
{'fwhost err maxservicetcp'};
803 if ($udpcounter > 15){
804 $errormessage=$Lang::tr
{'fwhost err maxserviceudp'};
809 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
810 $errormessage .= $Lang::tr
{'fwhost err remark'};
812 #Check if there is already a service with the same name
813 if(!&checkservice
($fwhostsettings{'SRVGRP_NAME'})){
814 $errormessage .= $Lang::tr
{'fwhost err srv exists'};
817 #on first save, we have to enter a dummy value
818 if ($fwhostsettings{'CUST_SRV'} eq ''){
819 $fwhostsettings{'CUST_SRV'}='none';
821 #on update, we have to delete the dummy entry
822 foreach my $key (keys %customservicegrp){
823 if ($customservicegrp{$key}[2] eq 'none'){
824 delete $customservicegrp{$key};
828 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
829 #check if remark has also changed
830 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
832 foreach my $key (keys %customservicegrp)
834 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
836 $customservicegrp{$key}[1]='';
837 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
841 my $key = &General
::findhasharraykey
(\
%customservicegrp);
842 foreach my $i (0 .. 2) { $customservice{$key}[$i] = "";}
843 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
844 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
845 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
846 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
847 $fwhostsettings{'updatesrvgrp'}='on';
850 &General
::firewall_config_changed
();
853 &viewtableservicegrp
;
856 if ($fwhostsettings{'ACTION'} eq 'editnet')
861 if ($fwhostsettings{'ACTION'} eq 'edithost')
866 if ($fwhostsettings{'ACTION'} eq 'editgrp')
868 $fwhostsettings{'update'}='on';
872 if ($fwhostsettings{'ACTION'} eq 'editservice')
874 $fwhostsettings{'updatesrv'}='on';
877 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
879 $fwhostsettings{'updatesrvgrp'} = 'on';
881 &viewtableservicegrp
;
884 if ($fwhostsettings{'ACTION'} eq 'resetnet')
886 $fwhostsettings{'HOSTNAME'} ="";
887 $fwhostsettings{'IP'} ="";
888 $fwhostsettings{'SUBNET'} ="";
891 if ($fwhostsettings{'ACTION'} eq 'resethost')
893 $fwhostsettings{'HOSTNAME'} ="";
894 $fwhostsettings{'IP'} ="";
895 $fwhostsettings{'type'} ="";
898 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
900 $fwhostsettings{'grp_name'} ="";
901 $fwhostsettings{'remark'} ="";
905 if ($fwhostsettings{'ACTION'} eq 'delnet')
907 &General
::readhasharray
("$confignet", \
%customnetwork);
908 foreach my $key (keys %customnetwork) {
909 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
910 delete $customnetwork{$key};
911 &General
::writehasharray
("$confignet", \
%customnetwork);
918 if ($fwhostsettings{'ACTION'} eq 'delhost')
920 &General
::readhasharray
("$confighost", \
%customhost);
921 foreach my $key (keys %customhost) {
922 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
923 delete $customhost{$key};
924 &General
::writehasharray
("$confighost", \
%customhost);
931 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
935 &General
::readhasharray
("$configgrp", \
%customgrp);
936 foreach my $key (keys %customgrp){
937 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
938 #decrease count from source host/net
939 if ($customgrp{$key}[3] eq 'Custom Network'){
940 &General
::readhasharray
("$confignet", \
%customnetwork);
941 foreach my $key1 (keys %customnetwork){
942 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
943 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
947 &General
::writehasharray
("$confignet", \
%customnetwork);
949 if ($customgrp{$key}[3] eq 'Custom Host'){
950 &General
::readhasharray
("$confighost", \
%customhost);
951 foreach my $key1 (keys %customhost){
952 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
953 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
957 &General
::writehasharray
("$confighost", \
%customhost);
959 $grpname=$customgrp{$key}[0];
960 $grpremark=$customgrp{$key}[1];
961 delete $customgrp{$key};
964 &General
::writehasharray
("$configgrp", \
%customgrp);
965 if ($fwhostsettings{'grpcnt'} > 0){
966 &General
::firewall_config_changed
();
968 if ($fwhostsettings{'update'} eq 'on'){
969 $fwhostsettings{'remark'}= $grpremark;
970 $fwhostsettings{'grp_name'}=$grpname;
975 if ($fwhostsettings{'ACTION'} eq 'delgrp')
977 &General
::readhasharray
("$configgrp", \
%customgrp);
978 &decrease
($fwhostsettings{'grp_name'});
979 foreach my $key (sort keys %customgrp)
981 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
983 delete $customgrp{$key};
986 &General
::writehasharray
("$configgrp", \
%customgrp);
987 $fwhostsettings{'grp_name'}='';
991 if ($fwhostsettings{'ACTION'} eq 'delservice')
993 &General
::readhasharray
("$configsrv", \
%customservice);
994 foreach my $key (keys %customservice) {
995 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
996 delete $customservice{$key};
997 &General
::writehasharray
("$configsrv", \
%customservice);
1001 $fwhostsettings{'SRV_NAME'}='';
1002 $fwhostsettings{'SRV_PORT'}='';
1003 $fwhostsettings{'PROT'}='';
1006 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
1008 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1009 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
1010 foreach my $key (sort keys %customservicegrp)
1012 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
1014 delete $customservicegrp{$key};
1017 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1018 $fwhostsettings{'SRVGRP_NAME'}='';
1020 &viewtableservicegrp
;
1022 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
1026 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1027 &General
::readhasharray
("$configsrv", \
%customservice);
1028 foreach my $key (keys %customservicegrp){
1029 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'})
1031 #decrease count from source service
1032 foreach my $key1 (sort keys %customservice){
1033 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1034 $customservice{$key1}[4]--;
1038 $grpname=$customservicegrp{$key}[0];
1039 $grpremark=$customservicegrp{$key}[1];
1040 delete $customservicegrp{$key};
1043 &General
::writehasharray
("$configsrv", \
%customservice);
1044 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1045 &General
::firewall_config_changed
();
1046 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1047 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1048 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1051 &viewtableservicegrp
;
1054 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1059 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1064 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1069 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1073 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1076 &viewtableservicegrp
;
1078 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1080 &General
::readhasharray
("$configgrp", \
%customgrp);
1081 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1082 foreach my $key (sort keys %customgrp)
1084 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1086 $customgrp{$key}[1]='';
1087 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1090 &General
::writehasharray
("$configgrp", \
%customgrp);
1091 $fwhostsettings{'update'}='on';
1092 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1094 $errormessage=$Lang::tr
{'fwhost err remark'};
1095 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1096 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1097 $fwhostsettings{'update'} = 'on';
1099 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1103 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1105 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1106 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1107 foreach my $key (sort keys %customservicegrp)
1109 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1111 $customservicegrp{$key}[1]='';
1112 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1115 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1116 $fwhostsettings{'updatesrvgrp'}='on';
1117 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1118 }elsif($fwhostsettings{'oldsrvrem'} eq $fwhostsettings{'newsrvrem'}){
1120 &viewtableservicegrp
;
1122 $errormessage=$Lang::tr
{'fwhost err remark'};
1123 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1124 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1125 $fwhostsettings{'updatesrvgrp'} = 'on';
1127 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1129 &viewtableservicegrp
;
1132 if($fwhostsettings{'ACTION'} eq '')
1138 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1139 print "$Lang::tr{'fwhost welcome'}";
1141 <br><br><table border='0' width='100%'>
1142 <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>
1143 <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>
1144 <tr><td colspan='6'><hr></td></tr></table>
1146 &Header
::closebox
();
1154 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1155 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1156 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1158 <table border='0' width='100%'>
1159 <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>
1160 <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>
1161 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1162 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1163 <tr><td colspan='6'><br><hr></td></tr><tr>
1165 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1167 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>";
1169 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'>";
1171 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>";
1172 &Header
::closebox
();
1178 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1179 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1180 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1182 <table border='0' width='100%'>
1183 <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>
1184 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1185 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1186 <tr><td colspan='5'><hr></td></tr><tr>
1189 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1192 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>";
1194 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'>";
1196 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>";
1197 &Header
::closebox
();
1204 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1205 &General
::setup_default_networks
(\
%defaultNetworks);
1206 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1207 &General
::readhasharray
("$confignet", \
%customnetwork);
1208 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1209 &General
::readhasharray
("$confighost", \
%customhost);
1210 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1214 $checked{'check1'}{'off'} = '';
1215 $checked{'check1'}{'on'} = '';
1216 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1217 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1218 my $grp=$fwhostsettings{'grp_name'};
1219 my $rem=$fwhostsettings{'remark'};
1220 if ($fwhostsettings{'update'} eq ''){
1222 <table width='100%' border='0'>
1223 <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>
1224 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1225 <tr><td colspan='2'><br><hr></td></tr></table>
1229 <table width='100%' border='0'><form method='post' style='display:inline'>
1230 <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>
1231 <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>
1235 if ($fwhostsettings{'update'} eq 'on'){
1237 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1238 <table width='100%' border='0'>
1239 <tr><td width=50% valign='top'>
1240 <table width='100%' border='0'>
1241 <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;'>
1243 foreach my $network (sort keys %defaultNetworks)
1245 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1246 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1247 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1248 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1249 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1250 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1251 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1252 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1253 if ($ownnet{$defnet}){
1254 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1256 print ">$network</option>";
1259 print"</select></td></tr>";
1260 if (! -z
$confignet){
1261 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;'>";
1262 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1263 print"<option>$customnetwork{$key}[0]</option>";
1265 print"</select></td></tr>";
1267 if (! -z
$confighost){
1268 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;'>";
1269 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1270 print"<option>$customhost{$key}[0]</option>";
1272 print"</select></td></tr>";
1276 print"</td><td valign='top'><table width='100%' border='0'>";
1278 if (! -z
$configccdnet){
1279 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;'>";
1280 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1282 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1284 print"</select></td></tr>";
1287 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1289 if ($ccdhost{$key}[33] ne ''){
1290 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 '');
1292 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1295 if ($show eq '1'){$show='';print"</select></td></tr>";}
1297 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1298 if($ccdhost{$key}[3] eq 'net'){
1299 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 '');
1301 print"<option>$ccdhost{$key}[1]</option>";
1304 if ($show eq '1'){$show='';print"</select></td></tr>";}
1306 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1307 if ($ipsecconf{$key}[3] eq 'net'){
1308 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 '');
1310 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1313 if ($show eq '1'){$show='';print"</select></td></tr>";}
1315 print"</td></tr></table>";
1316 print"<br><br><hr>";
1318 print"<table border='0' width='100%'>";
1319 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>";
1320 &Header
::closebox
();
1326 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1327 if ($fwhostsettings{'updatesrv'} eq 'on')
1329 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1330 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1331 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1332 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1335 <table width='100%' border='0'><form method='post'>
1336 <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>
1337 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1339 foreach ("TCP","UDP","ICMP")
1341 if ($_ eq $fwhostsettings{'PROT'})
1343 print"<option selected>$_</option>";
1345 print"<option>$_</option>";
1349 </select></td></tr></table>
1350 <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'>
1352 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1353 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1354 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1355 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1356 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1358 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1362 </select></td></tr></table></div>
1363 <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>
1364 <table width='100%' border='0'><tr><td colspan='6'><br><hr></td></tr>
1365 <tr><td colspan='6' align='right'>
1367 if ($fwhostsettings{'updatesrv'} eq 'on')
1370 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1371 <input type='hidden' name='ACTION' value='updateservice'>
1372 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1373 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1374 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1375 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1379 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1382 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1385 &Header
::closebox
();
1393 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1394 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1395 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1397 <table width='100%' border='0'><form method='post'>
1398 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1399 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1400 <tr><td colspan='2'><br><hr></tr>
1405 <table width='100%' border='0'><form method='post' style='display:inline'>
1406 <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>
1407 <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>
1408 <tr><td colspan='3'><br><hr></td></td></tr>
1412 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1414 <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%'>
1415 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'add'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1417 &General
::readhasharray
("$configsrv", \
%customservice);
1418 #Protocols for use in servicegroups
1419 print "<optgroup label='$Lang::tr{'fwhost cust service'}'>";
1420 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1422 print "<option>$customservice{$key}[0]</option>";
1424 print "</optgroup>";
1425 print "<optgroup label='$Lang::tr{'protocol'}'>";
1426 print "<option>GRE</option>";
1427 print "<option>AH</option>";
1428 print "<option>ESP</option>";
1429 print "<option>IGMP</option>";
1430 print "<option>IPIP</option>";
1431 print "<option value='IPV6'>IPv6 encap</option>";
1432 print "</optgroup>";
1435 <tr><td colspan='4'><br><br></td></tr>
1436 <tr><td colspan='4'><hr></td></tr>
1441 <table width='100%' border='0'>
1442 <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>
1445 &Header
::closebox
();
1450 if(! -z
$confignet){
1451 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1452 &General
::readhasharray
("$confignet", \
%customnetwork);
1453 if (!keys %customnetwork)
1455 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1458 <table border='0' width='100%' cellspacing='0'>
1459 <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>
1463 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1464 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1465 print" <tr bgcolor='${Header::colouryellow}'>";
1468 print" <tr bgcolor='$color{'color22'}'>";
1471 print" <tr bgcolor='$color{'color20'}'>";
1473 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1474 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>";
1476 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1477 <input type='hidden' name='ACTION' value='editnet'>
1478 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1479 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1480 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1481 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1484 if($customnetwork{$key}[4] == '0')
1486 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>";
1488 print"<td></td></tr>";
1493 &Header
::closebox
();
1500 #Check if IP is part of OpenVPN N2N subnet
1501 foreach my $key (sort keys %ccdhost){
1502 if ($ccdhost{$key}[3] eq 'net'){
1503 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1504 if (&General
::IpInSubnet
($c,$a,$b)){
1505 $tdcolor="style='color:$Header::colourovpn ;'";
1510 #Check if IP is part of OpenVPN dynamic subnet
1511 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1512 if (&General
::IpInSubnet
($c,$a,$b)){
1513 $tdcolor="style='color: $Header::colourovpn;'";
1516 #Check if IP is part of OpenVPN static subnet
1517 foreach my $key (sort keys %ccdnet){
1518 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1519 $b =&General
::iporsubtodec
($b);
1520 if (&General
::IpInSubnet
($c,$a,$b)){
1521 $tdcolor="style='color: $Header::colourovpn;'";
1525 #Check if IP is part of IPsec RW network
1526 if ($ipsecsettings{'RW_NET'} ne ''){
1527 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1528 $b=&General
::iporsubtodec
($b);
1529 if (&General
::IpInSubnet
($c,$a,$b)){
1530 $tdcolor="style='color: $Header::colourvpn;'";
1534 #Check if IP is part of a IPsec N2N network
1535 foreach my $key (sort keys %ipsecconf){
1536 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1537 if (&General
::IpInSubnet
($c,$a,$b)){
1538 $tdcolor="style='color: $Header::colourvpn;'";
1547 if (! -z
$confighost){
1548 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1549 &General
::readhasharray
("$confighost", \
%customhost);
1550 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1551 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1552 if (!keys %customhost)
1554 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1557 <table border='0' width='100%' cellspacing='0'>
1558 <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>
1562 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1563 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1564 print" <tr bgcolor='${Header::colouryellow}'>";
1565 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1566 else{ print" <tr bgcolor='$color{'color20'}'>";}
1567 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1568 $customhost{$key}[4]=~s/\s+//g;
1569 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>";
1571 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1572 <input type='hidden' name='ACTION' value='edithost' />
1573 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1574 <input type='hidden' name='IP' value='$ip' />
1575 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1576 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1579 if($customhost{$key}[4] == '0')
1581 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>";
1583 print"<td width='1%'></td></tr>";
1588 &Header
::closebox
();
1593 if(! -z
"$configgrp"){
1594 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1595 &General
::readhasharray
("$configgrp", \
%customgrp);
1596 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1597 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1598 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1599 &General
::readhasharray
("$confighost", \
%customhost);
1600 &General
::readhasharray
("$confignet", \
%customnetwork);
1608 if (!keys %customgrp)
1610 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1612 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1614 if ($helper ne $customgrp{$key}[0]){
1616 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1617 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1626 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
1627 $grpname=$customgrp{$key}[0];
1628 $remark="$customgrp{$key}[1]";
1629 if($count gt 1){ print"</table>";}
1630 print "<br><b><u>$grpname</u></b> ";
1631 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1632 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1633 if($customgrp{$key}[4] == '0')
1635 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>";
1637 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>";
1638 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>";
1641 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1642 print" <tr bgcolor='${Header::colouryellow}'>";
1643 }elsif ($count %2 == 0){
1644 print"<tr bgcolor='$color{'color22'}'>";
1646 print"<tr bgcolor='$color{'color20'}'>";
1648 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1649 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1650 print "<td width='39%' align='left'>";
1651 if($customgrp{$key}[3] eq 'Standard Network'){
1652 print &get_name
($customgrp{$key}[2])."</td>";
1654 print "$customgrp{$key}[2]</td>";
1656 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
1657 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1659 my ($colip,$colsub) = split("/",$ip);
1660 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1661 print"<td align='center' ".&getcolor
($colip).">".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1663 if ($delflag > '1' && $ip ne ''){
1664 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1666 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>";
1668 $helper=$customgrp{$key}[0];
1673 &Header
::closebox
();
1677 sub viewtableservice
1681 if(! -z
"$configsrv")
1683 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1684 &General
::readhasharray
("$configsrv", \
%customservice);
1685 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1686 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1687 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1688 &General
::readhasharray
("$fwconfigout", \
%fwout);
1690 <table width='100%' border='0' cellspacing='0'>
1691 <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>
1693 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1696 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1697 print" <tr bgcolor='${Header::colouryellow}'>";
1698 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1700 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1703 $srvcount=&getsrvcount
($customservice{$key}[0]);
1704 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
1705 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1707 </td><td align='center'>$srvcount 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 ($srvcount 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
1735 if (! -z
$configsrvgrp){
1736 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1737 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1738 &General
::readhasharray
("$configsrv", \
%customservice);
1739 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1740 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1741 &General
::readhasharray
("$fwconfigout", \
%fwout);
1742 my $number= keys %customservicegrp;
1743 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
1745 if ($helper ne $customservicegrp{$key}[0]){
1746 #Get used groupcounter
1747 $grpcount=&getsrvcount
($customservicegrp{$key}[0]);
1749 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1750 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1758 $grpname=$customservicegrp{$key}[0];
1759 if ($customservicegrp{$key}[2] eq "none"){
1760 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1764 $remark="$customservicegrp{$key}[1]";
1765 if($count >=2){print"</table>";}
1766 print "<br><b><u>$grpname</u></b> ";
1767 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1768 print " <b>$Lang::tr{'used'}:</b> $grpcount x";
1769 if($grpcount == '0')
1771 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>";
1773 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>";
1774 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>";
1776 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1777 print" <tr bgcolor='${Header::colouryellow}'>";
1778 }elsif ($count %2 == 0){
1779 print"<tr bgcolor='$color{'color22'}'>";
1781 print"<tr bgcolor='$color{'color20'}'>";
1783 #Set fields if we use protocols in servicegroups
1784 if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
1787 if ($customservicegrp{$key}[2] eq 'GRE'){$protocol='GRE';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} GRE";}
1788 if ($customservicegrp{$key}[2] eq 'ESP'){$protocol='ESP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} ESP";}
1789 if ($customservicegrp{$key}[2] eq 'AH'){$protocol='AH';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} AH";}
1790 if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
1791 if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
1792 if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
1793 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1794 foreach my $srv (sort keys %customservice){
1795 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1796 $protocol=$customservice{$srv}[2];
1797 $port=$customservice{$srv}[1];
1801 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1802 if ($delflag gt '1'){
1803 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1805 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
1806 if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
1807 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2]'></form></td></tr>";
1809 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$protocol'></form></td></tr>";
1811 $helper=$customservicegrp{$key}[0];
1814 &Header
::closebox
();
1820 my %hash=%{(shift)};
1821 foreach my $key (keys %hash) {
1822 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1831 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1833 foreach my $key (keys %customservicegrp) {
1834 if($customservicegrp{$key}[0] eq $name){
1842 &General
::readhasharray
("$configsrv", \
%customservice );
1844 foreach my $key (keys %customservice) {
1845 if($customservice{$key}[0] eq $name){
1854 my %hash=%{(shift)};
1856 foreach my $key (keys %hash) {
1857 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1865 my %hash=%{(shift)};
1866 &General
::readhasharray
("$confignet", \
%hash);
1867 foreach my $key (keys %hash) {
1868 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1875 sub checkservicegroup
1877 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1879 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1881 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1882 return $errormessage;
1884 #check empty selectbox
1885 if (keys %customservice lt 1)
1887 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1889 #check if name already exists
1890 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1891 foreach my $key (keys %customservicegrp) {
1892 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1893 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1898 #check if service already exists in group
1899 foreach my $key (keys %customservicegrp) {
1900 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1901 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1904 return $errormessage;
1908 if ($errormessage) {
1909 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1910 print "<class name='base'>$errormessage\n";
1911 print " </class>\n";
1912 &Header
::closebox
();
1918 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1919 print "<class name='base'>$hint\n";
1920 print " </class>\n";
1921 &Header
::closebox
();
1927 &General
::setup_default_networks
(\
%defaultNetworks);
1928 foreach my $network (sort keys %defaultNetworks)
1930 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1935 my $searchstring=shift;
1937 #Count services used in servicegroups
1938 foreach my $key (keys %customservicegrp) {
1939 if($customservicegrp{$key}[2] eq $searchstring){
1943 #Count services used in firewall - config
1944 foreach my $key1 (keys %fwfwd) {
1945 if($fwfwd{$key1}[15] eq $searchstring){
1949 #Count services used in firewall - input
1950 foreach my $key2 (keys %fwinp) {
1951 if($fwinp{$key2}[15] eq $searchstring){
1955 #Count services used in firewall - outgoing
1956 foreach my $key3 (keys %fwout) {
1957 if($fwout{$key3}[15] eq $searchstring){
1968 &General
::readhasharray
("$config",\
%hash);
1969 foreach my $key (keys %hash) {
1970 if($hash{$key}[2] eq $target){
1974 &General
::writehasharray
("$config",\
%hash);
1981 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
1983 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1984 $fwhostsettings{'BLK_IP'}='readonly';
1985 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1986 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1988 #check if name collides with CCD Netname
1989 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1990 foreach my $key (keys %ccdnet) {
1991 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1992 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1993 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1994 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1998 #check if IP collides with CCD NetIP
1999 if ($fwhostsettings{'type'} ne 'mac'){
2000 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2001 foreach my $key (keys %ccdnet) {
2002 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
2003 if($ccdnet{$key}[1] eq $test){
2004 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
2005 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
2006 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
2007 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2012 #check if name collides with CCD Hostname
2013 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2014 foreach my $key (keys %ccdhost) {
2015 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
2016 if($ip eq $fwhostsettings{'IP'}){
2017 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
2018 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2022 #check if IP collides with CCD HostIP (only hosts)
2023 if ($edit eq 'edithost')
2025 foreach my $key (keys %ccdhost) {
2026 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
2027 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
2028 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
2029 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2034 #check if network with this name already exists
2035 &General
::readhasharray
("$confignet", \
%customnetwork);
2036 if (!&checkname
(\
%customnetwork))
2038 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
2039 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2040 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2042 #check if network ip already exists
2043 if (!&checkip
(\
%customnetwork,1))
2045 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
2046 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2048 #check if host with this name already exists
2049 &General
::readhasharray
("$confighost", \
%customhost);
2050 if (!&checkname
(\
%customhost))
2052 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
2053 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2054 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2056 #check if host with this ip already exists
2057 if (!&checkip
(\
%customhost,2))
2059 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
2069 #get address from IPSEC NETWORK
2070 if ($type eq 'IpSec Network'){
2071 foreach my $key (keys %ipsecconf) {
2072 if ($ipsecconf{$key}[1] eq $name){
2073 return $ipsecconf{$key}[11];
2076 &deletefromgrp
($name,$configgrp);
2079 #get address from IPSEC HOST
2080 if ($type eq 'IpSec Host'){
2081 foreach my $key (keys %ipsecconf) {
2082 if ($ipsecconf{$key}[1] eq $name){
2083 return $ipsecconf{$key}[10];
2086 &deletefromgrp
($name,$configgrp);
2089 #get address from ovpn ccd Net-2-Net
2090 if ($type eq 'OpenVPN N-2-N'){
2091 foreach my $key (keys %ccdhost) {
2092 if($ccdhost{$key}[1] eq $name){
2093 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2094 $b=&General
::iporsubtodec
($b);
2098 &deletefromgrp
($name,$configgrp);
2101 #get address from ovpn ccd static host
2102 if ($type eq 'OpenVPN static host'){
2103 foreach my $key (keys %ccdhost) {
2104 if($ccdhost{$key}[1] eq $name){
2105 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2106 $b=&General
::iporsubtodec
($b);
2110 &deletefromgrp
($name,$configgrp);
2113 #get address from ovpn ccd static net
2114 if ($type eq 'OpenVPN static network'){
2115 foreach my $key (keys %ccdnet) {
2116 if ($ccdnet{$key}[0] eq $name){
2117 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2118 $b=&General
::iporsubtodec
($b);
2124 #check custom addresses
2125 if ($type eq 'Custom Host'){
2126 foreach my $key (keys %customhost) {
2127 if ($customhost{$key}[0] eq $name){
2128 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2134 ##check custom networks
2135 if ($type eq 'Custom Network'){
2136 foreach my $key (keys %customnetwork) {
2137 if($customnetwork{$key}[0] eq $name){
2138 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2143 #check standard networks
2144 if ($type eq 'Standard Network'){
2145 if ($name =~ /OpenVPN/i){
2147 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2148 return $ovpn{'DOVPN_SUBNET'};
2150 if ($name eq 'GREEN'){
2152 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2153 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2155 if ($name eq 'BLUE'){
2157 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2158 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2160 if ($name eq 'ORANGE'){
2162 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2163 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2165 if ($name eq 'ALL'){
2166 return "0.0.0.0/0.0.0.0";
2168 if ($name =~ /IPsec/i){
2170 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2171 return $hash{'RW_NET'};
2178 &General
::readhasharray
("$confignet", \
%customnetwork);
2179 &General
::readhasharray
("$confighost", \
%customhost);
2180 foreach my $key (sort keys %customgrp ){
2181 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2182 foreach my $key1 (sort keys %customnetwork){
2183 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2184 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2190 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2191 foreach my $key2 (sort keys %customhost){
2192 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2193 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2200 &General
::writehasharray
("$confignet", \
%customnetwork);
2201 &General
::writehasharray
("$confighost", \
%customhost);
2206 &General
::readhasharray
("$configsrv", \
%customservice);
2207 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2209 foreach my $key (sort keys %customservicegrp){
2210 if ($customservicegrp{$key}[0] eq $grp ){
2211 foreach my $key2 (sort keys %customservice){
2212 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2213 $customservice{$key2}[4]--;
2218 &General
::writehasharray
("$configsrv", \
%customservice);
2224 my %hash=%{(shift)};
2226 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2227 $errormessage=$Lang::tr
{'fwhost err name1'};
2229 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2230 $errormessage=$Lang::tr
{'fwhost err port'};
2233 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2234 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2236 #change dashes with :
2237 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2239 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2240 $fwhostsettings{'SRV_PORT'} = "1:65535";
2242 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2243 $fwhostsettings{'SRV_PORT'} = "1:$2";
2245 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2246 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2248 if($fwhostsettings{'PROT'} ne 'ICMP'){
2249 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2251 # a new service has to have a different name
2252 foreach my $key (keys %hash){
2253 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2254 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2258 return $errormessage;
2262 # Checks a hostname against RFC1035
2263 my $hostname = $_[0];
2265 # Each part should be at least two characters in length
2266 # but no more than 63 characters
2267 if (length ($hostname) < 1 || length ($hostname) > 63) {
2269 # Only valid characters are a-z, A-Z, 0-9 and -
2270 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2272 # First character can only be a letter or a digit
2273 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2275 # Last character can only be a letter or a digit
2276 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2282 # Checks a hostname against RFC1035
2284 # Each part should be at least two characters in length
2285 # but no more than 63 characters
2286 if (length ($remark) < 1 || length ($remark) > 255) {
2288 # Only valid characters are a-z, A-Z, 0-9 and -
2289 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2291 # First character can only be a letter or a digit
2292 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2294 # Last character can only be a letter or a digit
2295 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2299 &Header
::closebigbox
();
2300 &Header
::closepage
();