]>
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' )
272 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
273 #check if all fields are set
274 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
276 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
281 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
283 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
284 $fwhostsettings{'BLK_HOST'} ='readonly';
285 $fwhostsettings{'NOCHECK'} ='false';
286 $fwhostsettings{'error'} ='on';
289 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
290 $errormessage=$Lang::tr
{'fwhost err remark'};
291 $fwhostsettings{'error'} ='on';
293 #check if subnet is sigle host
294 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
296 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
298 if($fwhostsettings{'error'} ne 'on'){
299 #check if we use one of ipfire's networks (green,orange,blue)
300 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
302 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
303 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
304 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
306 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
308 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
309 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
310 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
312 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
314 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
315 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
316 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
318 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
320 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
321 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
322 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
325 #only check plausi when no error till now
327 &plausicheck
("editnet");
329 #check if network ip is part of an already used one
330 if(&checksubnet
(\
%customnetwork))
332 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
333 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
335 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
337 $fwhostsettings{'actualize'} = '';
338 my $key = &General
::findhasharraykey
(\
%customnetwork);
339 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
340 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
341 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
342 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
343 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
344 &General
::writehasharray
("$confignet", \
%customnetwork);
345 undef %customnetwork;
349 &General
::readhasharray
("$confignet", \
%customnetwork);
350 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
351 if ($fwhostsettings{'update'} == '0'){
352 foreach my $key (keys %customnetwork) {
353 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
354 delete $customnetwork{$key};
360 #get count if actualize is 'on'
361 if($fwhostsettings{'actualize'} eq 'on'){
362 $fwhostsettings{'actualize'} = '';
363 #check if we need to reload rules
364 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
367 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
368 #check if we need to update groups
369 &General
::readhasharray
("$configgrp", \
%customgrp);
370 foreach my $key (sort keys %customgrp){
371 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
372 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
376 &General
::writehasharray
("$configgrp", \
%customgrp);
377 #check if we need to update firewallrules
378 if ( ! -z
$fwconfigfwd ){
379 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
380 foreach my $line (sort keys %fwfwd){
381 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
382 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
384 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
385 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
388 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
390 if ( ! -z
$fwconfiginp ){
391 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
392 foreach my $line (sort keys %fwinp){
393 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
394 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
397 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
401 my $key = &General
::findhasharraykey
(\
%customnetwork);
402 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
403 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
404 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
405 #convert ip when leading '0' in byte
406 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
407 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
408 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
409 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
410 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
411 &General
::writehasharray
("$confignet", \
%customnetwork);
412 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
413 undef %customnetwork;
414 $fwhostsettings{'HOSTNAME'}='';
415 $fwhostsettings{'IP'}='';
416 $fwhostsettings{'SUBNET'}='';
417 $fwhostsettings{'NETREMARK'}='';
418 #check if an edited net affected groups and need to reload rules
419 if ($needrules eq 'on'){
420 &General
::firewall_config_changed
();
430 if ($fwhostsettings{'ACTION'} eq 'savehost')
433 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
434 $fwhostsettings{'SUBNET'}='32';
435 #check if all fields are set
436 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
438 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
439 $fwhostsettings{'ACTION'} = 'edithost';
441 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
442 $fwhostsettings{'type'} = 'mac';
443 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
444 $fwhostsettings{'type'} = 'ip';
446 $fwhostsettings{'type'} = '';
447 $errormessage=$Lang::tr
{'fwhost err ipmac'};
450 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
451 $errormessage=$Lang::tr
{'fwhost err remark'};
454 if ($fwhostsettings{'type'} eq 'ip'){
456 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
457 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
459 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
460 $fwhostsettings{'error'}='on';
462 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
463 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
464 $fwhostsettings{'error'}='on';
466 #check if net or broadcast
467 my @tmp= split (/\./,$fwhostsettings{'IP'});
468 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
469 $errormessage=$Lang::tr
{'fwhost err hostip'};
472 #only check plausi when no error till now
474 &plausicheck
("edithost");
476 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
477 $fwhostsettings{'actualize'} = '';
478 my $key = &General
::findhasharraykey
(\
%customhost);
479 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
480 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
481 $customhost{$key}[1] = $fwhostsettings{'type'} ;
482 if($customhost{$key}[1] eq 'ip'){
483 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
485 $customhost{$key}[2] = $fwhostsettings{'orgip'};
487 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
488 &General
::writehasharray
("$confighost", \
%customhost);
492 #get count if host was edited
493 if($fwhostsettings{'actualize'} eq 'on'){
494 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
497 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
498 #check if we need to update groups
499 &General
::readhasharray
("$configgrp", \
%customgrp);
500 foreach my $key (sort keys %customgrp){
501 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
502 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
505 &General
::writehasharray
("$configgrp", \
%customgrp);
506 #check if we need to update firewallrules
507 if ( ! -z
$fwconfigfwd ){
508 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
509 foreach my $line (sort keys %fwfwd){
510 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
511 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
513 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
514 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
517 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
519 if ( ! -z
$fwconfiginp ){
520 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
521 foreach my $line (sort keys %fwinp){
522 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
523 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
526 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
530 my $key = &General
::findhasharraykey
(\
%customhost);
531 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
532 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
533 $customhost{$key}[1] = $fwhostsettings{'type'} ;
534 if ($fwhostsettings{'type'} eq 'ip'){
535 #convert ip when leading '0' in byte
536 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
537 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
538 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
540 $customhost{$key}[2] = $fwhostsettings{'IP'};
542 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
543 &General
::writehasharray
("$confighost", \
%customhost);
545 $fwhostsettings{'HOSTNAME'}='';
546 $fwhostsettings{'IP'}='';
547 $fwhostsettings{'type'}='';
548 $fwhostsettings{'HOSTREMARK'}='';
549 #check if we need to update rules while host was edited
550 if($needrules eq 'on'){
551 &General
::firewall_config_changed
();
561 if ($fwhostsettings{'ACTION'} eq 'savegrp')
563 my $grp=$fwhostsettings{'grp_name'};
564 my $rem=$fwhostsettings{'remark'};
567 my $updcounter='off';
570 &General
::readhasharray
("$configgrp", \
%customgrp);
571 &General
::readhasharray
("$confignet", \
%customnetwork);
572 &General
::readhasharray
("$confighost", \
%customhost);
573 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
574 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
575 &General
::readhasharray
("$fwconfigout", \
%fwout);
577 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
579 if (!&checkgroup
($grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
581 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
582 $errormessage.=$Lang::tr
{'fwhost err remark'};
584 if ($fwhostsettings{'update'} eq 'on'){
585 #check standard networks
586 if ($fwhostsettings{'grp2'} eq 'std_net'){
587 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
588 $type='Standard Network';
590 #check custom networks
591 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
592 @target=$fwhostsettings{'CUST_SRC_NET'};
594 $type='Custom Network';
595 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
596 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
597 $fwhostsettings{'grp_name'}='';
598 $fwhostsettings{'remark'}='';
600 #check custom addresses
601 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
602 @target=$fwhostsettings{'CUST_SRC_HOST'};
605 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
606 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
607 $fwhostsettings{'grp_name'}='';
608 $fwhostsettings{'remark'}='';
610 #get address from ovpn ccd static net
611 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
612 @target=$fwhostsettings{'OVPN_CCD_NET'};
613 $type='OpenVPN static network';
614 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
615 $errormessage=$Lang::tr
{'fwhost err groupempty'};
616 $fwhostsettings{'grp_name'}='';
617 $fwhostsettings{'remark'}='';
619 #get address from ovpn ccd static host
620 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
621 @target=$fwhostsettings{'OVPN_CCD_HOST'};
622 $type='OpenVPN static host';
623 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
624 $errormessage=$Lang::tr
{'fwhost err groupempty'};
626 #get address from ovpn ccd Net-2-Net
627 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
628 @target=$fwhostsettings{'OVPN_N2N'};
629 $type='OpenVPN N-2-N';
630 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
631 $errormessage=$Lang::tr
{'fwhost err groupempty'};
632 $fwhostsettings{'grp_name'}='';
633 $fwhostsettings{'remark'}='';
635 #get address from IPSEC HOST
636 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
637 @target=$fwhostsettings{'IPSEC_HOST'};
639 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
640 $errormessage=$Lang::tr
{'fwhost err groupempty'};
641 $fwhostsettings{'grp_name'}='';
642 $fwhostsettings{'remark'}='';
644 #get address from IPSEC NETWORK
645 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
646 @target=$fwhostsettings{'IPSEC_NET'};
647 $type='IpSec Network';
648 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
649 $errormessage=$Lang::tr
{'fwhost err groupempty'};
650 $fwhostsettings{'grp_name'}='';
651 $fwhostsettings{'remark'}='';
653 #check if host/net exists in grp
655 my $test="$grp,$fwhostsettings{'oldremark'},@target";
656 foreach my $key (keys %customgrp) {
657 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
658 if ($test1 eq $test){
659 $errormessage=$Lang::tr
{'fwhost err isingrp'};
660 $fwhostsettings{'update'} = 'on';
666 #on first save, we have an empty @target, so fill it with nothing
667 my $targetvalues=@target;
668 if ($targetvalues == '0'){
671 #on update, we have to delete the dummy entry
672 foreach my $key (keys %customgrp){
673 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
674 delete $customgrp{$key};
678 &General
::writehasharray
("$configgrp", \
%customgrp);
679 &General
::readhasharray
("$configgrp", \
%customgrp);
680 #create array with new lines
681 foreach my $line (@target){
682 push (@newgrp,"$grp,$rem,$line");
685 my $key = &General
::findhasharraykey
(\
%customgrp);
686 foreach my $line (@newgrp){
687 foreach my $i (0 .. 3) { $customgrp{$key}[$i] = "";}
688 my ($a,$b,$c,$d) = split (",",$line);
689 $customgrp{$key}[0] = $a;
690 $customgrp{$key}[1] = $b;
691 $customgrp{$key}[2] = $c;
692 $customgrp{$key}[3] = $type;
694 &General
::writehasharray
("$configgrp", \
%customgrp);
695 #update counter in Host/Net
696 $fwhostsettings{'update'}='on';
698 #check if ruleupdate is needed
700 $netgrpcount=&getnetcount
($grp);
701 if($netgrpcount > 0 )
703 &General
::firewall_config_changed
();
708 if ($fwhostsettings{'ACTION'} eq 'saveservice')
711 &General
::readhasharray
("$configsrv", \
%customservice );
712 &General
::readhasharray
("$configgrp", \
%customgrp);
713 $errormessage=&checkports
(\
%customservice);
714 if ($fwhostsettings{'PROT'} eq 'ICMP'){
715 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
716 foreach my $key (keys %icmptypes){
717 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
718 $ICMP=$icmptypes{$key}[0];
722 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
723 if ($fwhostsettings{'PROT'} ne 'ICMP'){$ICMP='BLANK';}
724 #Check if a group with the same name already exists
725 if (!&checkgroup
($fwhostsettings{'SRV_NAME'})){
726 $errormessage = $Lang::tr
{'fwhost err grpexist'};
729 my $key = &General
::findhasharraykey
(\
%customservice);
730 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
731 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
732 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
733 $customservice{$key}[2] = $fwhostsettings{'PROT'};
734 $customservice{$key}[3] = $ICMP;
735 &General
::writehasharray
("$configsrv", \
%customservice );
737 $fwhostsettings{'SRV_NAME'}='';
738 $fwhostsettings{'SRV_PORT'}='';
739 $fwhostsettings{'PROT'}='';
740 $fwhostsettings{'ICMP_TYPES'}='';
744 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
751 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
752 &General
::readhasharray
("$configsrv", \
%customservice );
753 $errormessage=&checkservicegroup
;
754 #Check if we have more than 15 services from one Protocol in the group
755 #iptables can only handle 15 ports/portranges via multiport
756 foreach my $key (keys %customservicegrp){
757 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
758 foreach my $key1 (keys %customservice){
759 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
760 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
761 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
762 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
766 if ($tcpcounter > 15){
767 $errormessage=$Lang::tr
{'fwhost err maxservicetcp'};
769 if ($udpcounter > 15){
770 $errormessage=$Lang::tr
{'fwhost err maxserviceudp'};
775 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
776 $errormessage .= $Lang::tr
{'fwhost err remark'};
778 #Check if there is already a service with the same name
779 if(!&checkservice
($fwhostsettings{'SRVGRP_NAME'})){
780 $errormessage .= $Lang::tr
{'fwhost err srv exists'};
783 #on first save, we have to enter a dummy value
784 if ($fwhostsettings{'CUST_SRV'} eq ''){
785 $fwhostsettings{'CUST_SRV'}='none';
787 #on update, we have to delete the dummy entry
788 foreach my $key (keys %customservicegrp){
789 if ($customservicegrp{$key}[2] eq 'none'){
790 delete $customservicegrp{$key};
794 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
795 #check if remark has also changed
796 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
798 foreach my $key (keys %customservicegrp)
800 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
802 $customservicegrp{$key}[1]='';
803 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
807 my $key = &General
::findhasharraykey
(\
%customservicegrp);
808 foreach my $i (0 .. 2) { $customservice{$key}[$i] = "";}
809 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
810 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
811 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
812 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
813 $fwhostsettings{'updatesrvgrp'}='on';
816 &General
::firewall_config_changed
();
819 &viewtableservicegrp
;
822 if ($fwhostsettings{'ACTION'} eq 'editnet')
827 if ($fwhostsettings{'ACTION'} eq 'edithost')
832 if ($fwhostsettings{'ACTION'} eq 'editgrp')
834 $fwhostsettings{'update'}='on';
838 if ($fwhostsettings{'ACTION'} eq 'editservice')
840 $fwhostsettings{'updatesrv'}='on';
843 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
845 $fwhostsettings{'updatesrvgrp'} = 'on';
847 &viewtableservicegrp
;
850 if ($fwhostsettings{'ACTION'} eq 'resetnet')
852 $fwhostsettings{'HOSTNAME'} ="";
853 $fwhostsettings{'IP'} ="";
854 $fwhostsettings{'SUBNET'} ="";
857 if ($fwhostsettings{'ACTION'} eq 'resethost')
859 $fwhostsettings{'HOSTNAME'} ="";
860 $fwhostsettings{'IP'} ="";
861 $fwhostsettings{'type'} ="";
864 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
866 $fwhostsettings{'grp_name'} ="";
867 $fwhostsettings{'remark'} ="";
871 if ($fwhostsettings{'ACTION'} eq 'delnet')
873 &General
::readhasharray
("$confignet", \
%customnetwork);
874 foreach my $key (keys %customnetwork) {
875 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
876 delete $customnetwork{$key};
877 &General
::writehasharray
("$confignet", \
%customnetwork);
884 if ($fwhostsettings{'ACTION'} eq 'delhost')
886 &General
::readhasharray
("$confighost", \
%customhost);
887 foreach my $key (keys %customhost) {
888 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
889 delete $customhost{$key};
890 &General
::writehasharray
("$confighost", \
%customhost);
897 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
901 &General
::readhasharray
("$configgrp", \
%customgrp);
902 foreach my $key (keys %customgrp){
903 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
904 #decrease count from source host/net
905 if ($customgrp{$key}[3] eq 'Custom Network'){
906 &General
::readhasharray
("$confignet", \
%customnetwork);
907 foreach my $key1 (keys %customnetwork){
908 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
909 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
913 &General
::writehasharray
("$confignet", \
%customnetwork);
915 if ($customgrp{$key}[3] eq 'Custom Host'){
916 &General
::readhasharray
("$confighost", \
%customhost);
917 foreach my $key1 (keys %customhost){
918 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
919 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
923 &General
::writehasharray
("$confighost", \
%customhost);
925 $grpname=$customgrp{$key}[0];
926 $grpremark=$customgrp{$key}[1];
927 delete $customgrp{$key};
930 &General
::writehasharray
("$configgrp", \
%customgrp);
931 if ($fwhostsettings{'grpcnt'} > 0){
932 &General
::firewall_config_changed
();
934 if ($fwhostsettings{'update'} eq 'on'){
935 $fwhostsettings{'remark'}= $grpremark;
936 $fwhostsettings{'grp_name'}=$grpname;
941 if ($fwhostsettings{'ACTION'} eq 'delgrp')
943 &General
::readhasharray
("$configgrp", \
%customgrp);
944 &decrease
($fwhostsettings{'grp_name'});
945 foreach my $key (sort keys %customgrp)
947 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
949 delete $customgrp{$key};
952 &General
::writehasharray
("$configgrp", \
%customgrp);
953 $fwhostsettings{'grp_name'}='';
957 if ($fwhostsettings{'ACTION'} eq 'delservice')
959 &General
::readhasharray
("$configsrv", \
%customservice);
960 foreach my $key (keys %customservice) {
961 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
962 delete $customservice{$key};
963 &General
::writehasharray
("$configsrv", \
%customservice);
967 $fwhostsettings{'SRV_NAME'}='';
968 $fwhostsettings{'SRV_PORT'}='';
969 $fwhostsettings{'PROT'}='';
972 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
974 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
975 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
976 foreach my $key (sort keys %customservicegrp)
978 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
980 delete $customservicegrp{$key};
983 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
984 $fwhostsettings{'SRVGRP_NAME'}='';
986 &viewtableservicegrp
;
988 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
992 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
993 &General
::readhasharray
("$configsrv", \
%customservice);
994 foreach my $key (keys %customservicegrp){
995 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'})
997 #decrease count from source service
998 foreach my $key1 (sort keys %customservice){
999 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1000 $customservice{$key1}[4]--;
1004 $grpname=$customservicegrp{$key}[0];
1005 $grpremark=$customservicegrp{$key}[1];
1006 delete $customservicegrp{$key};
1009 &General
::writehasharray
("$configsrv", \
%customservice);
1010 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1011 &General
::firewall_config_changed
();
1012 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1013 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1014 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1017 &viewtableservicegrp
;
1020 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1025 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1030 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1035 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1039 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1042 &viewtableservicegrp
;
1044 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1046 &General
::readhasharray
("$configgrp", \
%customgrp);
1047 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1048 foreach my $key (sort keys %customgrp)
1050 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1052 $customgrp{$key}[1]='';
1053 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1056 &General
::writehasharray
("$configgrp", \
%customgrp);
1057 $fwhostsettings{'update'}='on';
1058 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1060 $errormessage=$Lang::tr
{'fwhost err remark'};
1061 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1062 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1063 $fwhostsettings{'update'} = 'on';
1065 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1069 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1071 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1072 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1073 foreach my $key (sort keys %customservicegrp)
1075 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1077 $customservicegrp{$key}[1]='';
1078 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1081 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1082 $fwhostsettings{'updatesrvgrp'}='on';
1083 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1084 }elsif($fwhostsettings{'oldsrvrem'} eq $fwhostsettings{'newsrvrem'}){
1086 &viewtableservicegrp
;
1088 $errormessage=$Lang::tr
{'fwhost err remark'};
1089 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1090 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1091 $fwhostsettings{'updatesrvgrp'} = 'on';
1093 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1095 &viewtableservicegrp
;
1098 if($fwhostsettings{'ACTION'} eq '')
1104 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1105 print "$Lang::tr{'fwhost welcome'}";
1107 <br><br><table border='0' width='100%'>
1108 <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>
1109 <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>
1110 <tr><td colspan='6'><hr></td></tr></table>
1112 &Header
::closebox
();
1120 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1121 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1122 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1124 <table border='0' width='100%'>
1125 <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>
1126 <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>
1127 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1128 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1129 <tr><td colspan='6'><br><hr></td></tr><tr>
1131 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1133 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>";
1135 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'>";
1137 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>";
1138 &Header
::closebox
();
1144 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1145 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1146 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1148 <table border='0' width='100%'>
1149 <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>
1150 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1151 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1152 <tr><td colspan='5'><hr></td></tr><tr>
1155 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1158 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>";
1160 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'>";
1162 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>";
1163 &Header
::closebox
();
1170 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1171 &General
::setup_default_networks
(\
%defaultNetworks);
1172 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1173 &General
::readhasharray
("$confignet", \
%customnetwork);
1174 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1175 &General
::readhasharray
("$confighost", \
%customhost);
1176 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1180 $checked{'check1'}{'off'} = '';
1181 $checked{'check1'}{'on'} = '';
1182 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1183 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1184 my $grp=$fwhostsettings{'grp_name'};
1185 my $rem=$fwhostsettings{'remark'};
1186 if ($fwhostsettings{'update'} eq ''){
1188 <table width='100%' border='0'>
1189 <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>
1190 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1191 <tr><td colspan='2'><br><hr></td></tr></table>
1195 <table width='100%' border='0'><form method='post' style='display:inline'>
1196 <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>
1197 <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>
1201 if ($fwhostsettings{'update'} eq 'on'){
1203 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1204 <table width='100%' border='0'>
1205 <tr><td width=50% valign='top'>
1206 <table width='100%' border='0'>
1207 <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;'>
1209 foreach my $network (sort keys %defaultNetworks)
1211 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1212 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1213 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1214 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1215 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1216 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1217 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1218 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1219 if ($ownnet{$defnet}){
1220 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1222 print ">$network</option>";
1225 print"</select></td></tr>";
1226 if (! -z
$confignet){
1227 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;'>";
1228 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1229 print"<option>$customnetwork{$key}[0]</option>";
1231 print"</select></td></tr>";
1233 if (! -z
$confighost){
1234 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;'>";
1235 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1236 print"<option>$customhost{$key}[0]</option>";
1238 print"</select></td></tr>";
1242 print"</td><td valign='top'><table width='100%' border='0'>";
1244 if (! -z
$configccdnet){
1245 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;'>";
1246 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1248 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1250 print"</select></td></tr>";
1253 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1255 if ($ccdhost{$key}[33] ne ''){
1256 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 '');
1258 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1261 if ($show eq '1'){$show='';print"</select></td></tr>";}
1263 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1264 if($ccdhost{$key}[3] eq 'net'){
1265 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 '');
1267 print"<option>$ccdhost{$key}[1]</option>";
1270 if ($show eq '1'){$show='';print"</select></td></tr>";}
1272 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1273 if ($ipsecconf{$key}[3] eq 'net'){
1274 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 '');
1276 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1279 if ($show eq '1'){$show='';print"</select></td></tr>";}
1281 print"</td></tr></table>";
1282 print"<br><br><hr>";
1284 print"<table border='0' width='100%'>";
1285 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>";
1286 &Header
::closebox
();
1292 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1293 if ($fwhostsettings{'updatesrv'} eq 'on')
1295 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1296 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1297 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1298 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1301 <table width='100%' border='0'><form method='post'>
1302 <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>
1303 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1305 foreach ("TCP","UDP","ICMP")
1307 if ($_ eq $fwhostsettings{'PROT'})
1309 print"<option selected>$_</option>";
1311 print"<option>$_</option>";
1315 </select></td></tr></table>
1316 <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'>
1318 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1319 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1320 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1321 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1322 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1324 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1328 </select></td></tr></table></div>
1329 <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>
1330 <table width='100%' border='0'><tr><td colspan='6'><br><hr></td></tr>
1331 <tr><td colspan='6' align='right'>
1333 if ($fwhostsettings{'updatesrv'} eq 'on')
1336 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1337 <input type='hidden' name='ACTION' value='updateservice'>
1338 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1339 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1340 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1341 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1345 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1348 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1351 &Header
::closebox
();
1359 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1360 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1361 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1363 <table width='100%' border='0'><form method='post'>
1364 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1365 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1366 <tr><td colspan='2'><br><hr></tr>
1371 <table width='100%' border='0'><form method='post' style='display:inline'>
1372 <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>
1373 <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>
1374 <tr><td colspan='3'><br><hr></td></td></tr>
1378 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1380 <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%'>
1381 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'add'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1383 &General
::readhasharray
("$configsrv", \
%customservice);
1384 #Protocols for use in servicegroups
1385 print "<optgroup label='$Lang::tr{'fwhost cust service'}'>";
1386 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1388 print "<option>$customservice{$key}[0]</option>";
1390 print "</optgroup>";
1391 print "<optgroup label='$Lang::tr{'protocol'}'>";
1392 print "<option>GRE</option>";
1393 print "<option>AH</option>";
1394 print "<option>ESP</option>";
1395 print "<option>IGMP</option>";
1396 print "<option>IPIP</option>";
1397 print "<option value='IPV6'>IPv6 encap</option>";
1398 print "</optgroup>";
1401 <tr><td colspan='4'><br><br></td></tr>
1402 <tr><td colspan='4'><hr></td></tr>
1407 <table width='100%' border='0'>
1408 <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>
1411 &Header
::closebox
();
1416 if(! -z
$confignet){
1417 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1418 &General
::readhasharray
("$confignet", \
%customnetwork);
1419 &General
::readhasharray
("$configgrp", \
%customgrp);
1420 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1421 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1422 &General
::readhasharray
("$fwconfigout", \
%fwout);
1423 if (!keys %customnetwork)
1425 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1428 <table border='0' width='100%' cellspacing='0'>
1429 <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>
1433 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1434 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1435 print" <tr bgcolor='${Header::colouryellow}'>";
1438 print" <tr bgcolor='$color{'color22'}'>";
1441 print" <tr bgcolor='$color{'color20'}'>";
1443 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1444 my $netcount=&getnetcount
($customnetwork{$key}[0]);
1445 print"<td width='20%'><form method='post'>$customnetwork{$key}[0]</td><td width='15%' align='center'>".&Header
::colorize
($colnet)."</td><td width='40%'>$customnetwork{$key}[3]</td><td align='center'>$netcount x</td>";
1447 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1448 <input type='hidden' name='ACTION' value='editnet'>
1449 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1450 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1451 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1452 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1455 if($netcount == '0')
1457 print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delnet' /><input type='hidden' name='key' value='$customnetwork{$key}[0]' /></td></form></tr>";
1459 print"<td></td></tr>";
1464 &Header
::closebox
();
1471 #Check if IP is part of OpenVPN N2N subnet
1472 foreach my $key (sort keys %ccdhost){
1473 if ($ccdhost{$key}[3] eq 'net'){
1474 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1475 if (&General
::IpInSubnet
($c,$a,$b)){
1476 $tdcolor="style='color:$Header::colourovpn ;'";
1481 #Check if IP is part of OpenVPN dynamic subnet
1482 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1483 if (&General
::IpInSubnet
($c,$a,$b)){
1484 $tdcolor="style='color: $Header::colourovpn;'";
1487 #Check if IP is part of OpenVPN static subnet
1488 foreach my $key (sort keys %ccdnet){
1489 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1490 $b =&General
::iporsubtodec
($b);
1491 if (&General
::IpInSubnet
($c,$a,$b)){
1492 $tdcolor="style='color: $Header::colourovpn;'";
1496 #Check if IP is part of IPsec RW network
1497 if ($ipsecsettings{'RW_NET'} ne ''){
1498 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1499 $b=&General
::iporsubtodec
($b);
1500 if (&General
::IpInSubnet
($c,$a,$b)){
1501 $tdcolor="style='color: $Header::colourvpn;'";
1505 #Check if IP is part of a IPsec N2N network
1506 foreach my $key (sort keys %ipsecconf){
1507 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1508 if (&General
::IpInSubnet
($c,$a,$b)){
1509 $tdcolor="style='color: $Header::colourvpn;'";
1518 if (! -z
$confighost){
1519 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1520 &General
::readhasharray
("$confighost", \
%customhost);
1521 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1522 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1523 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1524 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1525 &General
::readhasharray
("$fwconfigout", \
%fwout);
1526 &General
::readhasharray
("$configgrp", \
%customgrp);
1527 if (!keys %customhost)
1529 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1532 <table border='0' width='100%' cellspacing='0'>
1533 <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>
1537 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1538 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1539 print" <tr bgcolor='${Header::colouryellow}'>";
1540 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1541 else{ print" <tr bgcolor='$color{'color20'}'>";}
1542 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1543 $customhost{$key}[4]=~s/\s+//g;
1545 $hostcount=&gethostcount
($customhost{$key}[0]);
1546 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'>$hostcount x</td>";
1548 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1549 <input type='hidden' name='ACTION' value='edithost' />
1550 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1551 <input type='hidden' name='IP' value='$ip' />
1552 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1553 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1556 if($hostcount == '0')
1558 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>";
1560 print"<td width='1%'></td></tr>";
1565 &Header
::closebox
();
1570 if(! -z
"$configgrp"){
1571 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1572 &General
::readhasharray
("$configgrp", \
%customgrp);
1573 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1574 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1575 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1576 &General
::readhasharray
("$confighost", \
%customhost);
1577 &General
::readhasharray
("$confignet", \
%customnetwork);
1578 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1579 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1580 &General
::readhasharray
("$fwconfigout", \
%fwout);
1588 if (!keys %customgrp)
1590 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1592 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1594 if ($helper ne $customgrp{$key}[0]){
1596 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1597 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1606 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
1607 $grpname=$customgrp{$key}[0];
1608 $remark="$customgrp{$key}[1]";
1609 if($count gt 1){ print"</table>";}
1610 print "<br><b><u>$grpname</u></b> ";
1611 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1612 my $netgrpcount=&getnetcount
($grpname);
1613 print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
1614 if($netgrpcount == '0')
1616 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>";
1618 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>";
1619 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>";
1622 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1623 print" <tr bgcolor='${Header::colouryellow}'>";
1624 }elsif ($count %2 == 0){
1625 print"<tr bgcolor='$color{'color22'}'>";
1627 print"<tr bgcolor='$color{'color20'}'>";
1629 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1630 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1631 print "<td width='39%' align='left'>";
1632 if($customgrp{$key}[3] eq 'Standard Network'){
1633 print &get_name
($customgrp{$key}[2])."</td>";
1635 print "$customgrp{$key}[2]</td>";
1637 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
1638 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1640 my ($colip,$colsub) = split("/",$ip);
1641 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1642 print"<td align='center' ".&getcolor
($colip).">".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1644 if ($delflag > 1 && $ip ne ''){
1645 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1647 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>";
1649 $helper=$customgrp{$key}[0];
1654 &Header
::closebox
();
1658 sub viewtableservice
1662 if(! -z
"$configsrv")
1664 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1665 &General
::readhasharray
("$configsrv", \
%customservice);
1666 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1667 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1668 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1669 &General
::readhasharray
("$fwconfigout", \
%fwout);
1671 <table width='100%' border='0' cellspacing='0'>
1672 <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>
1674 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1677 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1678 print" <tr bgcolor='${Header::colouryellow}'>";
1679 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1681 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1684 $srvcount=&getsrvcount
($customservice{$key}[0]);
1685 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
1686 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1688 </td><td align='center'>$srvcount x</td>
1689 <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' />
1690 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1691 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1692 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
1693 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
1695 if ($srvcount eq '0')
1697 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>";
1699 print"<td></td></tr>";
1703 &Header
::closebox
();
1706 sub viewtableservicegrp
1716 if (! -z
$configsrvgrp){
1717 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1718 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1719 &General
::readhasharray
("$configsrv", \
%customservice);
1720 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1721 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1722 &General
::readhasharray
("$fwconfigout", \
%fwout);
1723 my $number= keys %customservicegrp;
1724 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
1726 if ($helper ne $customservicegrp{$key}[0]){
1727 #Get used groupcounter
1728 $grpcount=&getsrvcount
($customservicegrp{$key}[0]);
1730 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1731 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1739 $grpname=$customservicegrp{$key}[0];
1740 if ($customservicegrp{$key}[2] eq "none"){
1741 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1745 $remark="$customservicegrp{$key}[1]";
1746 if($count >=2){print"</table>";}
1747 print "<br><b><u>$grpname</u></b> ";
1748 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1749 print " <b>$Lang::tr{'used'}:</b> $grpcount x";
1750 if($grpcount == '0')
1752 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>";
1754 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>";
1755 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>";
1757 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1758 print" <tr bgcolor='${Header::colouryellow}'>";
1759 }elsif ($count %2 == 0){
1760 print"<tr bgcolor='$color{'color22'}'>";
1762 print"<tr bgcolor='$color{'color20'}'>";
1764 #Set fields if we use protocols in servicegroups
1765 if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
1768 if ($customservicegrp{$key}[2] eq 'GRE'){$protocol='GRE';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} GRE";}
1769 if ($customservicegrp{$key}[2] eq 'ESP'){$protocol='ESP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} ESP";}
1770 if ($customservicegrp{$key}[2] eq 'AH'){$protocol='AH';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} AH";}
1771 if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
1772 if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
1773 if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
1774 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1775 foreach my $srv (sort keys %customservice){
1776 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1777 $protocol=$customservice{$srv}[2];
1778 $port=$customservice{$srv}[1];
1782 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1783 if ($delflag gt '1'){
1784 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1786 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
1787 if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
1788 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2]'></form></td></tr>";
1790 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$protocol'></form></td></tr>";
1792 $helper=$customservicegrp{$key}[0];
1795 &Header
::closebox
();
1801 my %hash=%{(shift)};
1802 foreach my $key (keys %hash) {
1803 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1812 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1814 foreach my $key (keys %customservicegrp) {
1815 if($customservicegrp{$key}[0] eq $name){
1823 &General
::readhasharray
("$configsrv", \
%customservice );
1825 foreach my $key (keys %customservice) {
1826 if($customservice{$key}[0] eq $name){
1835 my %hash=%{(shift)};
1837 foreach my $key (keys %hash) {
1838 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1846 my %hash=%{(shift)};
1847 &General
::readhasharray
("$confignet", \
%hash);
1848 foreach my $key (keys %hash) {
1849 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1856 sub checkservicegroup
1858 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1860 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1862 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1863 return $errormessage;
1865 #check empty selectbox
1866 if (keys %customservice lt 1)
1868 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1870 #check if name already exists
1871 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1872 foreach my $key (keys %customservicegrp) {
1873 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1874 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1879 #check if service already exists in group
1880 foreach my $key (keys %customservicegrp) {
1881 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1882 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1885 return $errormessage;
1889 if ($errormessage) {
1890 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1891 print "<class name='base'>$errormessage\n";
1892 print " </class>\n";
1893 &Header
::closebox
();
1899 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1900 print "<class name='base'>$hint\n";
1901 print " </class>\n";
1902 &Header
::closebox
();
1908 &General
::setup_default_networks
(\
%defaultNetworks);
1909 foreach my $network (sort keys %defaultNetworks)
1911 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1916 my $searchstring=shift;
1918 #Count services used in servicegroups
1919 foreach my $key (keys %customgrp) {
1920 if($customgrp{$key}[2] eq $searchstring){
1924 #Count services used in firewall - config
1925 foreach my $key1 (keys %fwfwd) {
1926 if($fwfwd{$key1}[4] eq $searchstring){
1929 if($fwfwd{$key1}[6] eq $searchstring){
1933 #Count services used in firewall - input
1934 foreach my $key2 (keys %fwinp) {
1935 if($fwinp{$key2}[4] eq $searchstring){
1938 if($fwinp{$key2}[6] eq $searchstring){
1942 #Count services used in firewall - outgoing
1943 foreach my $key3 (keys %fwout) {
1944 if($fwout{$key3}[4] eq $searchstring){
1947 if($fwout{$key3}[6] eq $searchstring){
1955 my $searchstring=shift;
1957 #Count services used in servicegroups
1958 foreach my $key (keys %customgrp) {
1959 if($customgrp{$key}[2] eq $searchstring){
1963 #Count services used in firewall - config
1964 foreach my $key1 (keys %fwfwd) {
1965 if($fwfwd{$key1}[4] eq $searchstring){
1968 if($fwfwd{$key1}[6] eq $searchstring){
1972 #Count services used in firewall - input
1973 foreach my $key2 (keys %fwinp) {
1974 if($fwinp{$key2}[4] eq $searchstring){
1977 if($fwinp{$key2}[6] eq $searchstring){
1981 #Count services used in firewall - outgoing
1982 foreach my $key3 (keys %fwout) {
1983 if($fwout{$key3}[4] eq $searchstring){
1986 if($fwout{$key3}[6] eq $searchstring){
1994 my $searchstring=shift;
1996 #Count services used in servicegroups
1997 foreach my $key (keys %customservicegrp) {
1998 if($customservicegrp{$key}[2] eq $searchstring){
2002 #Count services used in firewall - config
2003 foreach my $key1 (keys %fwfwd) {
2004 if($fwfwd{$key1}[15] eq $searchstring){
2008 #Count services used in firewall - input
2009 foreach my $key2 (keys %fwinp) {
2010 if($fwinp{$key2}[15] eq $searchstring){
2014 #Count services used in firewall - outgoing
2015 foreach my $key3 (keys %fwout) {
2016 if($fwout{$key3}[15] eq $searchstring){
2027 &General
::readhasharray
("$config",\
%hash);
2028 foreach my $key (keys %hash) {
2029 if($hash{$key}[2] eq $target){
2033 &General
::writehasharray
("$config",\
%hash);
2040 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
2042 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
2043 $fwhostsettings{'BLK_IP'}='readonly';
2044 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2045 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2047 #check if name collides with CCD Netname
2048 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2049 foreach my $key (keys %ccdnet) {
2050 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2051 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
2052 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2053 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2057 #check if IP collides with CCD NetIP
2058 if ($fwhostsettings{'type'} ne 'mac'){
2059 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2060 foreach my $key (keys %ccdnet) {
2061 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
2062 if($ccdnet{$key}[1] eq $test){
2063 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
2064 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
2065 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
2066 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2071 #check if name collides with CCD Hostname
2072 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2073 foreach my $key (keys %ccdhost) {
2074 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
2075 if($ip eq $fwhostsettings{'IP'}){
2076 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
2077 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2081 #check if IP collides with CCD HostIP (only hosts)
2082 if ($edit eq 'edithost')
2084 foreach my $key (keys %ccdhost) {
2085 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
2086 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
2087 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
2088 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2093 #check if network with this name already exists
2094 &General
::readhasharray
("$confignet", \
%customnetwork);
2095 if (!&checkname
(\
%customnetwork))
2097 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
2098 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2099 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2101 #check if network ip already exists
2102 if (!&checkip
(\
%customnetwork,1))
2104 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
2105 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2107 #check if host with this name already exists
2108 &General
::readhasharray
("$confighost", \
%customhost);
2109 if (!&checkname
(\
%customhost))
2111 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
2112 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2113 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2115 #check if host with this ip already exists
2116 if (!&checkip
(\
%customhost,2))
2118 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
2128 #get address from IPSEC NETWORK
2129 if ($type eq 'IpSec Network'){
2130 foreach my $key (keys %ipsecconf) {
2131 if ($ipsecconf{$key}[1] eq $name){
2132 return $ipsecconf{$key}[11];
2135 &deletefromgrp
($name,$configgrp);
2138 #get address from IPSEC HOST
2139 if ($type eq 'IpSec Host'){
2140 foreach my $key (keys %ipsecconf) {
2141 if ($ipsecconf{$key}[1] eq $name){
2142 return $ipsecconf{$key}[10];
2145 &deletefromgrp
($name,$configgrp);
2148 #get address from ovpn ccd Net-2-Net
2149 if ($type eq 'OpenVPN N-2-N'){
2150 foreach my $key (keys %ccdhost) {
2151 if($ccdhost{$key}[1] eq $name){
2152 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2153 $b=&General
::iporsubtodec
($b);
2157 &deletefromgrp
($name,$configgrp);
2160 #get address from ovpn ccd static host
2161 if ($type eq 'OpenVPN static host'){
2162 foreach my $key (keys %ccdhost) {
2163 if($ccdhost{$key}[1] eq $name){
2164 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2165 $b=&General
::iporsubtodec
($b);
2169 &deletefromgrp
($name,$configgrp);
2172 #get address from ovpn ccd static net
2173 if ($type eq 'OpenVPN static network'){
2174 foreach my $key (keys %ccdnet) {
2175 if ($ccdnet{$key}[0] eq $name){
2176 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2177 $b=&General
::iporsubtodec
($b);
2183 #check custom addresses
2184 if ($type eq 'Custom Host'){
2185 foreach my $key (keys %customhost) {
2186 if ($customhost{$key}[0] eq $name){
2187 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2193 ##check custom networks
2194 if ($type eq 'Custom Network'){
2195 foreach my $key (keys %customnetwork) {
2196 if($customnetwork{$key}[0] eq $name){
2197 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2202 #check standard networks
2203 if ($type eq 'Standard Network'){
2204 if ($name =~ /OpenVPN/i){
2206 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2207 return $ovpn{'DOVPN_SUBNET'};
2209 if ($name eq 'GREEN'){
2211 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2212 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2214 if ($name eq 'BLUE'){
2216 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2217 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2219 if ($name eq 'ORANGE'){
2221 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2222 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2224 if ($name eq 'ALL'){
2225 return "0.0.0.0/0.0.0.0";
2227 if ($name =~ /IPsec/i){
2229 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2230 return $hash{'RW_NET'};
2237 &General
::readhasharray
("$confignet", \
%customnetwork);
2238 &General
::readhasharray
("$confighost", \
%customhost);
2239 foreach my $key (sort keys %customgrp ){
2240 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2241 foreach my $key1 (sort keys %customnetwork){
2242 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2243 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2249 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2250 foreach my $key2 (sort keys %customhost){
2251 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2252 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2259 &General
::writehasharray
("$confignet", \
%customnetwork);
2260 &General
::writehasharray
("$confighost", \
%customhost);
2265 &General
::readhasharray
("$configsrv", \
%customservice);
2266 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2268 foreach my $key (sort keys %customservicegrp){
2269 if ($customservicegrp{$key}[0] eq $grp ){
2270 foreach my $key2 (sort keys %customservice){
2271 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2272 $customservice{$key2}[4]--;
2277 &General
::writehasharray
("$configsrv", \
%customservice);
2283 my %hash=%{(shift)};
2285 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2286 $errormessage=$Lang::tr
{'fwhost err name1'};
2288 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2289 $errormessage=$Lang::tr
{'fwhost err port'};
2292 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2293 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2295 #change dashes with :
2296 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2298 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2299 $fwhostsettings{'SRV_PORT'} = "1:65535";
2301 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2302 $fwhostsettings{'SRV_PORT'} = "1:$2";
2304 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2305 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2307 if($fwhostsettings{'PROT'} ne 'ICMP'){
2308 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2310 # a new service has to have a different name
2311 foreach my $key (keys %hash){
2312 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2313 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2317 return $errormessage;
2321 # Checks a hostname against RFC1035
2322 my $hostname = $_[0];
2324 # Each part should be at least two characters in length
2325 # but no more than 63 characters
2326 if (length ($hostname) < 1 || length ($hostname) > 63) {
2328 # Only valid characters are a-z, A-Z, 0-9 and -
2329 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2331 # First character can only be a letter or a digit
2332 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2334 # Last character can only be a letter or a digit
2335 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2341 # Checks a hostname against RFC1035
2343 # Each part should be at least two characters in length
2344 # but no more than 63 characters
2345 if (length ($remark) < 1 || length ($remark) > 255) {
2347 # Only valid characters are a-z, A-Z, 0-9 and -
2348 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2350 # First character can only be a letter or a digit
2351 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2353 # Last character can only be a letter or a digit
2354 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2358 &Header
::closebigbox
();
2359 &Header
::closepage
();