]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/fwhosts.cgi
330b0f72d4f410e36385410e05cbf2fe28454774
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);
114 // Automatically select radio buttons when corresponding
115 // dropdown menu changes.
116 \$("select").change(function() {
117 var id = \$(this).attr("name");
118 \$('#' + id).prop("checked", true);
126 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
128 &General
::readhasharray
("$confignet", \
%customnetwork);
129 foreach my $key (keys %customnetwork)
131 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
133 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
134 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
135 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
136 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
137 $fwhostsettings{'count'} = $customnetwork{$key}[4];
138 delete $customnetwork{$key};
142 &General
::writehasharray
("$confignet", \
%customnetwork);
143 $fwhostsettings{'actualize'} = 'on';
144 $fwhostsettings{'ACTION'} = 'savenet';
146 if ($fwhostsettings{'ACTION'} eq 'updatehost')
149 &General
::readhasharray
("$confighost", \
%customhost);
150 foreach my $key (keys %customhost)
152 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
154 if ($customhost{$key}[1] eq 'ip'){
155 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
157 $ip = $customhost{$key}[2];
159 $fwhostsettings{'orgip'} = $ip;
160 $fwhostsettings{'count'} = $customhost{$key}[4];
161 delete $customhost{$key};
162 &General
::writehasharray
("$confighost", \
%customhost);
165 $fwhostsettings{'actualize'} = 'on';
166 if($fwhostsettings{'orgip'}){
167 $fwhostsettings{'ACTION'} = 'savehost';
169 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
172 if ($fwhostsettings{'ACTION'} eq 'updateservice')
176 $errormessage=&checkports
(\
%customservice);
177 if ($fwhostsettings{'oldsrvname'} ne $fwhostsettings{'SRV_NAME'} && !&checkgroup
($fwhostsettings{'SRV_NAME'})){
178 $errormessage=$Lang::tr
{'fwhost err grpexist'};
181 &General
::readhasharray
("$configsrv", \
%customservice);
182 foreach my $key (keys %customservice)
184 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
186 delete $customservice{$key};
187 &General
::writehasharray
("$configsrv", \
%customservice);
191 if ($fwhostsettings{'PROT'} ne 'ICMP'){
192 $fwhostsettings{'ICMP_TYPES'}='BLANK';
194 my $key1 = &General
::findhasharraykey
(\
%customservice);
195 #find out short ICMP-TYPE
196 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
197 foreach my $key (keys %icmptypes){
198 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
199 $fwhostsettings{'ICMP_TYPES'}=$icmptypes{$key}[0];
202 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
203 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
204 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
205 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
206 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
207 &General
::writehasharray
("$configsrv", \
%customservice);
208 #check if we need to update firewallrules
209 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
210 if ( ! -z
$fwconfigfwd ){
211 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
212 foreach my $key (sort keys %fwfwd){
213 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
214 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
217 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
219 if ( ! -z
$fwconfiginp ){
220 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
221 foreach my $line (sort keys %fwinp){
222 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
223 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
226 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
228 if ( ! -z
$fwconfigout ){
229 &General
::readhasharray
("$fwconfigout", \
%fwout);
230 foreach my $line (sort keys %fwout){
231 if ($fwout{$line}[15] eq $fwhostsettings{'oldsrvname'}){
232 $fwout{$line}[15] = $fwhostsettings{'SRV_NAME'};
235 &General
::writehasharray
("$fwconfigout", \
%fwout);
237 #check if we need to update groups
238 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
239 foreach my $key (sort keys %customservicegrp){
240 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
241 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
244 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
247 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
250 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
253 if($count gt 0 && $fwhostsettings{'oldsrvicmp'} ne $fwhostsettings{'ICMP'} ){
256 $fwhostsettings{'SRV_NAME'} = '';
257 $fwhostsettings{'SRV_PORT'} = '';
258 $fwhostsettings{'PROT'} = '';
259 $fwhostsettings{'ICMP'} = '';
260 $fwhostsettings{'oldsrvicmp'} = '';
261 $fwhostsettings{'updatesrv'} = '';
263 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
264 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
265 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
266 $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
267 $fwhostsettings{'updatesrv'}= 'on';
269 if($needrules eq 'on'){
270 &General
::firewall_config_changed
();
275 if ($fwhostsettings{'ACTION'} eq 'savenet' )
278 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
279 #check if all fields are set
280 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
282 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
287 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
289 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
290 $fwhostsettings{'BLK_HOST'} ='readonly';
291 $fwhostsettings{'NOCHECK'} ='false';
292 $fwhostsettings{'error'} ='on';
295 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
296 $errormessage=$Lang::tr
{'fwhost err remark'};
297 $fwhostsettings{'error'} ='on';
299 #check if subnet is sigle host
300 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
302 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
304 if($fwhostsettings{'error'} ne 'on'){
305 #check if we use one of ipfire's networks (green,orange,blue)
306 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
308 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
309 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
310 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
312 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
314 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
315 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
316 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
318 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
320 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
321 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
322 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
324 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
326 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
327 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
328 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
331 #only check plausi when no error till now
333 &plausicheck
("editnet");
335 #check if network ip is part of an already used one
336 if(&checksubnet
(\
%customnetwork))
338 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
339 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
341 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
343 $fwhostsettings{'actualize'} = '';
344 my $key = &General
::findhasharraykey
(\
%customnetwork);
345 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
346 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
347 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
348 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
349 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
350 &General
::writehasharray
("$confignet", \
%customnetwork);
351 undef %customnetwork;
355 &General
::readhasharray
("$confignet", \
%customnetwork);
356 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
357 if ($fwhostsettings{'update'} == '0'){
358 foreach my $key (keys %customnetwork) {
359 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
360 delete $customnetwork{$key};
366 #get count if actualize is 'on'
367 if($fwhostsettings{'actualize'} eq 'on'){
368 $fwhostsettings{'actualize'} = '';
369 #check if we need to reload rules
370 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
373 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
374 #check if we need to update groups
375 &General
::readhasharray
("$configgrp", \
%customgrp);
376 foreach my $key (sort keys %customgrp){
377 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
378 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
382 &General
::writehasharray
("$configgrp", \
%customgrp);
383 #check if we need to update firewallrules
384 if ( ! -z
$fwconfigfwd ){
385 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
386 foreach my $line (sort keys %fwfwd){
387 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
388 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
390 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
391 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
394 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
396 if ( ! -z
$fwconfiginp ){
397 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
398 foreach my $line (sort keys %fwinp){
399 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
400 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
403 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
407 my $key = &General
::findhasharraykey
(\
%customnetwork);
408 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
409 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
410 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
411 #convert ip when leading '0' in byte
412 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
413 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
414 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
415 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
416 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
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')
439 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
440 $fwhostsettings{'SUBNET'}='32';
441 #check if all fields are set
442 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
444 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
445 $fwhostsettings{'ACTION'} = 'edithost';
447 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
448 $fwhostsettings{'type'} = 'mac';
449 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
450 $fwhostsettings{'type'} = 'ip';
452 $fwhostsettings{'type'} = '';
453 $errormessage=$Lang::tr
{'fwhost err ipmac'};
456 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
457 $errormessage=$Lang::tr
{'fwhost err remark'};
460 if ($fwhostsettings{'type'} eq 'ip'){
462 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
463 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
465 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
466 $fwhostsettings{'error'}='on';
468 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
469 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
470 $fwhostsettings{'error'}='on';
472 #check if net or broadcast
473 my @tmp= split (/\./,$fwhostsettings{'IP'});
474 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
475 $errormessage=$Lang::tr
{'fwhost err hostip'};
478 #only check plausi when no error till now
480 &plausicheck
("edithost");
482 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
483 $fwhostsettings{'actualize'} = '';
484 my $key = &General
::findhasharraykey
(\
%customhost);
485 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
486 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
487 $customhost{$key}[1] = $fwhostsettings{'type'} ;
488 if($customhost{$key}[1] eq 'ip'){
489 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
491 $customhost{$key}[2] = $fwhostsettings{'orgip'};
493 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
494 &General
::writehasharray
("$confighost", \
%customhost);
498 #get count if host was edited
499 if($fwhostsettings{'actualize'} eq 'on'){
500 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
503 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
504 #check if we need to update groups
505 &General
::readhasharray
("$configgrp", \
%customgrp);
506 foreach my $key (sort keys %customgrp){
507 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
508 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
511 &General
::writehasharray
("$configgrp", \
%customgrp);
512 #check if we need to update firewallrules
513 if ( ! -z
$fwconfigfwd ){
514 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
515 foreach my $line (sort keys %fwfwd){
516 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
517 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
519 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
520 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
523 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
525 if ( ! -z
$fwconfiginp ){
526 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
527 foreach my $line (sort keys %fwinp){
528 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
529 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
532 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
536 my $key = &General
::findhasharraykey
(\
%customhost);
537 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
538 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
539 $customhost{$key}[1] = $fwhostsettings{'type'} ;
540 if ($fwhostsettings{'type'} eq 'ip'){
541 #convert ip when leading '0' in byte
542 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
543 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
544 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
546 $customhost{$key}[2] = $fwhostsettings{'IP'};
548 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
549 &General
::writehasharray
("$confighost", \
%customhost);
551 $fwhostsettings{'HOSTNAME'}='';
552 $fwhostsettings{'IP'}='';
553 $fwhostsettings{'type'}='';
554 $fwhostsettings{'HOSTREMARK'}='';
555 #check if we need to update rules while host was edited
556 if($needrules eq 'on'){
557 &General
::firewall_config_changed
();
567 if ($fwhostsettings{'ACTION'} eq 'savegrp')
569 my $grp=$fwhostsettings{'grp_name'};
570 my $rem=$fwhostsettings{'remark'};
573 my $updcounter='off';
576 &General
::readhasharray
("$configgrp", \
%customgrp);
577 &General
::readhasharray
("$confignet", \
%customnetwork);
578 &General
::readhasharray
("$confighost", \
%customhost);
579 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
580 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
581 &General
::readhasharray
("$fwconfigout", \
%fwout);
583 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
585 if (!&checkgroup
($grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
587 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
588 $errormessage.=$Lang::tr
{'fwhost err remark'};
590 if ($fwhostsettings{'update'} eq 'on'){
591 #check standard networks
592 if ($fwhostsettings{'grp2'} eq 'std_net'){
593 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
594 $type='Standard Network';
596 #check custom networks
597 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
598 @target=$fwhostsettings{'CUST_SRC_NET'};
600 $type='Custom Network';
601 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
602 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
603 $fwhostsettings{'grp_name'}='';
604 $fwhostsettings{'remark'}='';
606 #check custom addresses
607 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
608 @target=$fwhostsettings{'CUST_SRC_HOST'};
611 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
612 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
613 $fwhostsettings{'grp_name'}='';
614 $fwhostsettings{'remark'}='';
616 #get address from ovpn ccd static net
617 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
618 @target=$fwhostsettings{'OVPN_CCD_NET'};
619 $type='OpenVPN static network';
620 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
621 $errormessage=$Lang::tr
{'fwhost err groupempty'};
622 $fwhostsettings{'grp_name'}='';
623 $fwhostsettings{'remark'}='';
625 #get address from ovpn ccd static host
626 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
627 @target=$fwhostsettings{'OVPN_CCD_HOST'};
628 $type='OpenVPN static host';
629 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
630 $errormessage=$Lang::tr
{'fwhost err groupempty'};
632 #get address from ovpn ccd Net-2-Net
633 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
634 @target=$fwhostsettings{'OVPN_N2N'};
635 $type='OpenVPN N-2-N';
636 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
637 $errormessage=$Lang::tr
{'fwhost err groupempty'};
638 $fwhostsettings{'grp_name'}='';
639 $fwhostsettings{'remark'}='';
641 #get address from IPSEC HOST
642 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
643 @target=$fwhostsettings{'IPSEC_HOST'};
645 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
646 $errormessage=$Lang::tr
{'fwhost err groupempty'};
647 $fwhostsettings{'grp_name'}='';
648 $fwhostsettings{'remark'}='';
650 #get address from IPSEC NETWORK
651 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
652 @target=$fwhostsettings{'IPSEC_NET'};
653 $type='IpSec Network';
654 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
655 $errormessage=$Lang::tr
{'fwhost err groupempty'};
656 $fwhostsettings{'grp_name'}='';
657 $fwhostsettings{'remark'}='';
659 #check if host/net exists in grp
661 my $test="$grp,$fwhostsettings{'oldremark'},@target";
662 foreach my $key (keys %customgrp) {
663 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
664 if ($test1 eq $test){
665 $errormessage=$Lang::tr
{'fwhost err isingrp'};
666 $fwhostsettings{'update'} = 'on';
672 #on first save, we have an empty @target, so fill it with nothing
673 my $targetvalues=@target;
674 if ($targetvalues == '0'){
677 #on update, we have to delete the dummy entry
678 foreach my $key (keys %customgrp){
679 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
680 delete $customgrp{$key};
684 &General
::writehasharray
("$configgrp", \
%customgrp);
685 &General
::readhasharray
("$configgrp", \
%customgrp);
686 #create array with new lines
687 foreach my $line (@target){
688 push (@newgrp,"$grp,$rem,$line");
691 my $key = &General
::findhasharraykey
(\
%customgrp);
692 foreach my $line (@newgrp){
693 foreach my $i (0 .. 3) { $customgrp{$key}[$i] = "";}
694 my ($a,$b,$c,$d) = split (",",$line);
695 $customgrp{$key}[0] = $a;
696 $customgrp{$key}[1] = $b;
697 $customgrp{$key}[2] = $c;
698 $customgrp{$key}[3] = $type;
700 &General
::writehasharray
("$configgrp", \
%customgrp);
701 #update counter in Host/Net
702 $fwhostsettings{'update'}='on';
704 #check if ruleupdate is needed
706 $netgrpcount=&getnetcount
($grp);
707 if($netgrpcount > 0 )
709 &General
::firewall_config_changed
();
714 if ($fwhostsettings{'ACTION'} eq 'saveservice')
717 &General
::readhasharray
("$configsrv", \
%customservice );
718 &General
::readhasharray
("$configgrp", \
%customgrp);
719 $errormessage=&checkports
(\
%customservice);
720 if ($fwhostsettings{'PROT'} eq 'ICMP'){
721 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
722 foreach my $key (keys %icmptypes){
723 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
724 $ICMP=$icmptypes{$key}[0];
728 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
729 if ($fwhostsettings{'PROT'} ne 'ICMP'){$ICMP='BLANK';}
730 #Check if a group with the same name already exists
731 if (!&checkgroup
($fwhostsettings{'SRV_NAME'})){
732 $errormessage = $Lang::tr
{'fwhost err grpexist'};
735 my $key = &General
::findhasharraykey
(\
%customservice);
736 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
737 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
738 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
739 $customservice{$key}[2] = $fwhostsettings{'PROT'};
740 $customservice{$key}[3] = $ICMP;
741 &General
::writehasharray
("$configsrv", \
%customservice );
743 $fwhostsettings{'SRV_NAME'}='';
744 $fwhostsettings{'SRV_PORT'}='';
745 $fwhostsettings{'PROT'}='';
746 $fwhostsettings{'ICMP_TYPES'}='';
750 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
757 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
758 &General
::readhasharray
("$configsrv", \
%customservice );
759 $errormessage=&checkservicegroup
;
760 #Check if we have more than 15 services from one Protocol in the group
761 #iptables can only handle 15 ports/portranges via multiport
762 foreach my $key (keys %customservicegrp){
763 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
764 foreach my $key1 (keys %customservice){
765 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
766 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
767 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
768 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
772 if ($tcpcounter > 15){
773 $errormessage=$Lang::tr
{'fwhost err maxservicetcp'};
775 if ($udpcounter > 15){
776 $errormessage=$Lang::tr
{'fwhost err maxserviceudp'};
781 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
782 $errormessage .= $Lang::tr
{'fwhost err remark'};
784 #Check if there is already a service with the same name
785 if(!&checkservice
($fwhostsettings{'SRVGRP_NAME'})){
786 $errormessage .= $Lang::tr
{'fwhost err srv exists'};
789 #on first save, we have to enter a dummy value
790 if ($fwhostsettings{'CUST_SRV'} eq ''){
791 $fwhostsettings{'CUST_SRV'}='none';
793 #on update, we have to delete the dummy entry
794 foreach my $key (keys %customservicegrp){
795 if ($customservicegrp{$key}[2] eq 'none'){
796 delete $customservicegrp{$key};
800 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
801 #check if remark has also changed
802 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
804 foreach my $key (keys %customservicegrp)
806 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
808 $customservicegrp{$key}[1]='';
809 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
813 my $key = &General
::findhasharraykey
(\
%customservicegrp);
814 foreach my $i (0 .. 2) { $customservice{$key}[$i] = "";}
815 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
816 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
817 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
818 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
819 $fwhostsettings{'updatesrvgrp'}='on';
822 &General
::firewall_config_changed
();
825 &viewtableservicegrp
;
828 if ($fwhostsettings{'ACTION'} eq 'editnet')
833 if ($fwhostsettings{'ACTION'} eq 'edithost')
838 if ($fwhostsettings{'ACTION'} eq 'editgrp')
840 $fwhostsettings{'update'}='on';
844 if ($fwhostsettings{'ACTION'} eq 'editservice')
846 $fwhostsettings{'updatesrv'}='on';
849 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
851 $fwhostsettings{'updatesrvgrp'} = 'on';
853 &viewtableservicegrp
;
856 if ($fwhostsettings{'ACTION'} eq 'resetnet')
858 $fwhostsettings{'HOSTNAME'} ="";
859 $fwhostsettings{'IP'} ="";
860 $fwhostsettings{'SUBNET'} ="";
863 if ($fwhostsettings{'ACTION'} eq 'resethost')
865 $fwhostsettings{'HOSTNAME'} ="";
866 $fwhostsettings{'IP'} ="";
867 $fwhostsettings{'type'} ="";
870 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
872 $fwhostsettings{'grp_name'} ="";
873 $fwhostsettings{'remark'} ="";
877 if ($fwhostsettings{'ACTION'} eq 'delnet')
879 &General
::readhasharray
("$confignet", \
%customnetwork);
880 foreach my $key (keys %customnetwork) {
881 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
882 delete $customnetwork{$key};
883 &General
::writehasharray
("$confignet", \
%customnetwork);
890 if ($fwhostsettings{'ACTION'} eq 'delhost')
892 &General
::readhasharray
("$confighost", \
%customhost);
893 foreach my $key (keys %customhost) {
894 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
895 delete $customhost{$key};
896 &General
::writehasharray
("$confighost", \
%customhost);
903 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
907 &General
::readhasharray
("$configgrp", \
%customgrp);
908 foreach my $key (keys %customgrp){
909 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
910 #decrease count from source host/net
911 if ($customgrp{$key}[3] eq 'Custom Network'){
912 &General
::readhasharray
("$confignet", \
%customnetwork);
913 foreach my $key1 (keys %customnetwork){
914 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
915 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
919 &General
::writehasharray
("$confignet", \
%customnetwork);
921 if ($customgrp{$key}[3] eq 'Custom Host'){
922 &General
::readhasharray
("$confighost", \
%customhost);
923 foreach my $key1 (keys %customhost){
924 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
925 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
929 &General
::writehasharray
("$confighost", \
%customhost);
931 $grpname=$customgrp{$key}[0];
932 $grpremark=$customgrp{$key}[1];
933 delete $customgrp{$key};
936 &General
::writehasharray
("$configgrp", \
%customgrp);
937 if ($fwhostsettings{'grpcnt'} > 0){
938 &General
::firewall_config_changed
();
940 if ($fwhostsettings{'update'} eq 'on'){
941 $fwhostsettings{'remark'}= $grpremark;
942 $fwhostsettings{'grp_name'}=$grpname;
947 if ($fwhostsettings{'ACTION'} eq 'delgrp')
949 &General
::readhasharray
("$configgrp", \
%customgrp);
950 &decrease
($fwhostsettings{'grp_name'});
951 foreach my $key (sort keys %customgrp)
953 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
955 delete $customgrp{$key};
958 &General
::writehasharray
("$configgrp", \
%customgrp);
959 $fwhostsettings{'grp_name'}='';
963 if ($fwhostsettings{'ACTION'} eq 'delservice')
965 &General
::readhasharray
("$configsrv", \
%customservice);
966 foreach my $key (keys %customservice) {
967 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
968 delete $customservice{$key};
969 &General
::writehasharray
("$configsrv", \
%customservice);
973 $fwhostsettings{'SRV_NAME'}='';
974 $fwhostsettings{'SRV_PORT'}='';
975 $fwhostsettings{'PROT'}='';
978 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
980 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
981 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
982 foreach my $key (sort keys %customservicegrp)
984 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
986 delete $customservicegrp{$key};
989 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
990 $fwhostsettings{'SRVGRP_NAME'}='';
992 &viewtableservicegrp
;
994 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
998 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
999 &General
::readhasharray
("$configsrv", \
%customservice);
1000 foreach my $key (keys %customservicegrp){
1001 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'})
1003 #decrease count from source service
1004 foreach my $key1 (sort keys %customservice){
1005 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1006 $customservice{$key1}[4]--;
1010 $grpname=$customservicegrp{$key}[0];
1011 $grpremark=$customservicegrp{$key}[1];
1012 delete $customservicegrp{$key};
1015 &General
::writehasharray
("$configsrv", \
%customservice);
1016 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1017 &General
::firewall_config_changed
();
1018 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1019 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1020 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1023 &viewtableservicegrp
;
1026 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1031 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1036 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1041 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1045 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1048 &viewtableservicegrp
;
1050 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1052 &General
::readhasharray
("$configgrp", \
%customgrp);
1053 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1054 foreach my $key (sort keys %customgrp)
1056 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1058 $customgrp{$key}[1]='';
1059 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1062 &General
::writehasharray
("$configgrp", \
%customgrp);
1063 $fwhostsettings{'update'}='on';
1064 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1066 $errormessage=$Lang::tr
{'fwhost err remark'};
1067 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1068 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1069 $fwhostsettings{'update'} = 'on';
1071 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1075 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1077 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1078 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1079 foreach my $key (sort keys %customservicegrp)
1081 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1083 $customservicegrp{$key}[1]='';
1084 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1087 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1088 $fwhostsettings{'updatesrvgrp'}='on';
1089 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1090 }elsif($fwhostsettings{'oldsrvrem'} eq $fwhostsettings{'newsrvrem'}){
1092 &viewtableservicegrp
;
1094 $errormessage=$Lang::tr
{'fwhost err remark'};
1095 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1096 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1097 $fwhostsettings{'updatesrvgrp'} = 'on';
1099 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1101 &viewtableservicegrp
;
1104 if($fwhostsettings{'ACTION'} eq '')
1110 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1111 print "$Lang::tr{'fwhost welcome'}";
1113 <br><br><table border='0' width='100%'>
1114 <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>
1115 <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>
1116 <tr><td colspan='6'><hr></td></tr></table>
1118 &Header
::closebox
();
1126 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1127 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1128 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1130 <table border='0' width='100%'>
1131 <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>
1132 <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>
1133 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1134 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1135 <tr><td colspan='6'><br><hr></td></tr><tr>
1137 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1139 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>";
1141 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'>";
1143 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>";
1144 &Header
::closebox
();
1150 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1151 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1152 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1154 <table border='0' width='100%'>
1155 <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>
1156 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1157 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1158 <tr><td colspan='5'><hr></td></tr><tr>
1161 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1164 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>";
1166 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'>";
1168 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>";
1169 &Header
::closebox
();
1176 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1177 &General
::setup_default_networks
(\
%defaultNetworks);
1178 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1179 &General
::readhasharray
("$confignet", \
%customnetwork);
1180 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1181 &General
::readhasharray
("$confighost", \
%customhost);
1182 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1186 $checked{'check1'}{'off'} = '';
1187 $checked{'check1'}{'on'} = '';
1188 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1189 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1190 my $grp=$fwhostsettings{'grp_name'};
1191 my $rem=$fwhostsettings{'remark'};
1192 if ($fwhostsettings{'update'} eq ''){
1194 <table width='100%' border='0'>
1195 <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>
1196 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1197 <tr><td colspan='2'><br><hr></td></tr></table>
1201 <table width='100%' border='0'><form method='post' style='display:inline'>
1202 <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>
1203 <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>
1207 if ($fwhostsettings{'update'} eq 'on'){
1209 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1210 <table width='100%' border='0'>
1211 <tr><td width=50% valign='top'>
1212 <table width='100%' border='0'>
1213 <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;'>
1215 foreach my $network (sort keys %defaultNetworks)
1217 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1218 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1219 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1220 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1221 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1222 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1223 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1224 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1225 if ($ownnet{$defnet}){
1226 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1228 print ">$network</option>";
1231 print"</select></td></tr>";
1232 if (! -z
$confignet){
1233 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;'>";
1234 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1235 print"<option>$customnetwork{$key}[0]</option>";
1237 print"</select></td></tr>";
1239 if (! -z
$confighost){
1240 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;'>";
1241 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1242 print"<option>$customhost{$key}[0]</option>";
1244 print"</select></td></tr>";
1248 print"</td><td valign='top'><table width='100%' border='0'>";
1250 if (! -z
$configccdnet){
1251 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;'>";
1252 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1254 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1256 print"</select></td></tr>";
1259 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1261 if ($ccdhost{$key}[33] ne ''){
1262 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 '');
1264 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1267 if ($show eq '1'){$show='';print"</select></td></tr>";}
1269 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1270 if($ccdhost{$key}[3] eq 'net'){
1271 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 '');
1273 print"<option>$ccdhost{$key}[1]</option>";
1276 if ($show eq '1'){$show='';print"</select></td></tr>";}
1278 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1279 if ($ipsecconf{$key}[3] eq 'net'){
1280 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 '');
1282 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1285 if ($show eq '1'){$show='';print"</select></td></tr>";}
1287 print"</td></tr></table>";
1288 print"<br><br><hr>";
1290 print"<table border='0' width='100%'>";
1291 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>";
1292 &Header
::closebox
();
1298 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1299 if ($fwhostsettings{'updatesrv'} eq 'on')
1301 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1302 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1303 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1304 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1307 <table width='100%' border='0'><form method='post'>
1308 <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>
1309 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1311 foreach ("TCP","UDP","ICMP")
1313 if ($_ eq $fwhostsettings{'PROT'})
1315 print"<option selected>$_</option>";
1317 print"<option>$_</option>";
1321 </select></td></tr></table>
1322 <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'>
1324 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1325 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1326 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1327 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1328 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1330 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1334 </select></td></tr></table></div>
1335 <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>
1336 <table width='100%' border='0'><tr><td colspan='6'><br><hr></td></tr>
1337 <tr><td colspan='6' align='right'>
1339 if ($fwhostsettings{'updatesrv'} eq 'on')
1342 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1343 <input type='hidden' name='ACTION' value='updateservice'>
1344 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1345 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1346 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1347 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1351 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1354 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1357 &Header
::closebox
();
1365 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1366 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1367 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1369 <table width='100%' border='0'><form method='post'>
1370 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1371 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1372 <tr><td colspan='2'><br><hr></tr>
1377 <table width='100%' border='0'><form method='post' style='display:inline'>
1378 <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>
1379 <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>
1380 <tr><td colspan='3'><br><hr></td></td></tr>
1384 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1386 <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%'>
1387 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'add'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1389 &General
::readhasharray
("$configsrv", \
%customservice);
1390 #Protocols for use in servicegroups
1391 print "<optgroup label='$Lang::tr{'fwhost cust service'}'>";
1392 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1394 print "<option>$customservice{$key}[0]</option>";
1396 print "</optgroup>";
1397 print "<optgroup label='$Lang::tr{'protocol'}'>";
1398 print "<option>GRE</option>";
1399 print "<option>AH</option>";
1400 print "<option>ESP</option>";
1401 print "<option>IGMP</option>";
1402 print "<option>IPIP</option>";
1403 print "<option value='IPV6'>IPv6 encap</option>";
1404 print "</optgroup>";
1407 <tr><td colspan='4'><br><br></td></tr>
1408 <tr><td colspan='4'><hr></td></tr>
1413 <table width='100%' border='0'>
1414 <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>
1417 &Header
::closebox
();
1422 if(! -z
$confignet){
1423 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1424 &General
::readhasharray
("$confignet", \
%customnetwork);
1425 &General
::readhasharray
("$configgrp", \
%customgrp);
1426 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1427 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1428 &General
::readhasharray
("$fwconfigout", \
%fwout);
1429 if (!keys %customnetwork)
1431 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1434 <table border='0' width='100%' cellspacing='0'>
1435 <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>
1439 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1440 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1441 print" <tr bgcolor='${Header::colouryellow}'>";
1444 print" <tr bgcolor='$color{'color22'}'>";
1447 print" <tr bgcolor='$color{'color20'}'>";
1449 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1450 my $netcount=&getnetcount
($customnetwork{$key}[0]);
1451 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>";
1453 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1454 <input type='hidden' name='ACTION' value='editnet'>
1455 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1456 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1457 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1458 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1461 if($netcount == '0')
1463 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>";
1465 print"<td></td></tr>";
1470 &Header
::closebox
();
1477 #Check if IP is part of OpenVPN N2N subnet
1478 foreach my $key (sort keys %ccdhost){
1479 if ($ccdhost{$key}[3] eq 'net'){
1480 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1481 if (&General
::IpInSubnet
($c,$a,$b)){
1482 $tdcolor="style='color:$Header::colourovpn ;'";
1487 #Check if IP is part of OpenVPN dynamic subnet
1488 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1489 if (&General
::IpInSubnet
($c,$a,$b)){
1490 $tdcolor="style='color: $Header::colourovpn;'";
1493 #Check if IP is part of OpenVPN static subnet
1494 foreach my $key (sort keys %ccdnet){
1495 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1496 $b =&General
::iporsubtodec
($b);
1497 if (&General
::IpInSubnet
($c,$a,$b)){
1498 $tdcolor="style='color: $Header::colourovpn;'";
1502 #Check if IP is part of IPsec RW network
1503 if ($ipsecsettings{'RW_NET'} ne ''){
1504 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1505 $b=&General
::iporsubtodec
($b);
1506 if (&General
::IpInSubnet
($c,$a,$b)){
1507 $tdcolor="style='color: $Header::colourvpn;'";
1511 #Check if IP is part of a IPsec N2N network
1512 foreach my $key (sort keys %ipsecconf){
1513 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1514 if (&General
::IpInSubnet
($c,$a,$b)){
1515 $tdcolor="style='color: $Header::colourvpn;'";
1524 if (! -z
$confighost){
1525 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1526 &General
::readhasharray
("$confighost", \
%customhost);
1527 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1528 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1529 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1530 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1531 &General
::readhasharray
("$fwconfigout", \
%fwout);
1532 &General
::readhasharray
("$configgrp", \
%customgrp);
1533 if (!keys %customhost)
1535 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1538 <table border='0' width='100%' cellspacing='0'>
1539 <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>
1543 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1544 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1545 print" <tr bgcolor='${Header::colouryellow}'>";
1546 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1547 else{ print" <tr bgcolor='$color{'color20'}'>";}
1548 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1549 $customhost{$key}[4]=~s/\s+//g;
1551 $hostcount=&gethostcount
($customhost{$key}[0]);
1552 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>";
1554 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1555 <input type='hidden' name='ACTION' value='edithost' />
1556 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1557 <input type='hidden' name='IP' value='$ip' />
1558 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1559 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1562 if($hostcount == '0')
1564 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>";
1566 print"<td width='1%'></td></tr>";
1571 &Header
::closebox
();
1576 if(! -z
"$configgrp"){
1577 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1578 &General
::readhasharray
("$configgrp", \
%customgrp);
1579 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1580 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1581 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1582 &General
::readhasharray
("$confighost", \
%customhost);
1583 &General
::readhasharray
("$confignet", \
%customnetwork);
1584 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1585 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1586 &General
::readhasharray
("$fwconfigout", \
%fwout);
1594 if (!keys %customgrp)
1596 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1598 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1600 if ($helper ne $customgrp{$key}[0]){
1602 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1603 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1612 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
1613 $grpname=$customgrp{$key}[0];
1614 $remark="$customgrp{$key}[1]";
1615 if($count gt 1){ print"</table>";}
1616 print "<br><b><u>$grpname</u></b> ";
1617 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1618 my $netgrpcount=&getnetcount
($grpname);
1619 print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
1620 if($netgrpcount == '0')
1622 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>";
1624 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>";
1625 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>";
1628 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1629 print" <tr bgcolor='${Header::colouryellow}'>";
1630 }elsif ($count %2 == 0){
1631 print"<tr bgcolor='$color{'color22'}'>";
1633 print"<tr bgcolor='$color{'color20'}'>";
1635 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1636 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1637 print "<td width='39%' align='left'>";
1638 if($customgrp{$key}[3] eq 'Standard Network'){
1639 print &get_name
($customgrp{$key}[2])."</td>";
1641 print "$customgrp{$key}[2]</td>";
1643 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
1644 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1646 my ($colip,$colsub) = split("/",$ip);
1647 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1648 print"<td align='center' ".&getcolor
($colip).">".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1650 if ($delflag > 1 && $ip ne ''){
1651 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1653 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>";
1655 $helper=$customgrp{$key}[0];
1660 &Header
::closebox
();
1664 sub viewtableservice
1668 if(! -z
"$configsrv")
1670 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1671 &General
::readhasharray
("$configsrv", \
%customservice);
1672 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1673 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1674 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1675 &General
::readhasharray
("$fwconfigout", \
%fwout);
1677 <table width='100%' border='0' cellspacing='0'>
1678 <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>
1680 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1683 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1684 print" <tr bgcolor='${Header::colouryellow}'>";
1685 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1687 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1690 $srvcount=&getsrvcount
($customservice{$key}[0]);
1691 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
1692 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1694 </td><td align='center'>$srvcount x</td>
1695 <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' />
1696 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1697 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1698 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
1699 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
1701 if ($srvcount eq '0')
1703 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>";
1705 print"<td></td></tr>";
1709 &Header
::closebox
();
1712 sub viewtableservicegrp
1722 if (! -z
$configsrvgrp){
1723 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1724 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1725 &General
::readhasharray
("$configsrv", \
%customservice);
1726 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1727 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1728 &General
::readhasharray
("$fwconfigout", \
%fwout);
1729 my $number= keys %customservicegrp;
1730 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
1732 if ($helper ne $customservicegrp{$key}[0]){
1733 #Get used groupcounter
1734 $grpcount=&getsrvcount
($customservicegrp{$key}[0]);
1736 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1737 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1745 $grpname=$customservicegrp{$key}[0];
1746 if ($customservicegrp{$key}[2] eq "none"){
1747 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1751 $remark="$customservicegrp{$key}[1]";
1752 if($count >=2){print"</table>";}
1753 print "<br><b><u>$grpname</u></b> ";
1754 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1755 print " <b>$Lang::tr{'used'}:</b> $grpcount x";
1756 if($grpcount == '0')
1758 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>";
1760 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>";
1761 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>";
1763 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1764 print" <tr bgcolor='${Header::colouryellow}'>";
1765 }elsif ($count %2 == 0){
1766 print"<tr bgcolor='$color{'color22'}'>";
1768 print"<tr bgcolor='$color{'color20'}'>";
1770 #Set fields if we use protocols in servicegroups
1771 if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
1774 if ($customservicegrp{$key}[2] eq 'GRE'){$protocol='GRE';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} GRE";}
1775 if ($customservicegrp{$key}[2] eq 'ESP'){$protocol='ESP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} ESP";}
1776 if ($customservicegrp{$key}[2] eq 'AH'){$protocol='AH';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} AH";}
1777 if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
1778 if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
1779 if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
1780 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1781 foreach my $srv (sort keys %customservice){
1782 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1783 $protocol=$customservice{$srv}[2];
1784 $port=$customservice{$srv}[1];
1788 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1789 if ($delflag gt '1'){
1790 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1792 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
1793 if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
1794 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2]'></form></td></tr>";
1796 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$protocol'></form></td></tr>";
1798 $helper=$customservicegrp{$key}[0];
1801 &Header
::closebox
();
1807 my %hash=%{(shift)};
1808 foreach my $key (keys %hash) {
1809 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1818 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1820 foreach my $key (keys %customservicegrp) {
1821 if($customservicegrp{$key}[0] eq $name){
1829 &General
::readhasharray
("$configsrv", \
%customservice );
1831 foreach my $key (keys %customservice) {
1832 if($customservice{$key}[0] eq $name){
1841 my %hash=%{(shift)};
1843 foreach my $key (keys %hash) {
1844 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1852 my %hash=%{(shift)};
1853 &General
::readhasharray
("$confignet", \
%hash);
1854 foreach my $key (keys %hash) {
1855 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1862 sub checkservicegroup
1864 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1866 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1868 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1869 return $errormessage;
1871 #check empty selectbox
1872 if (keys %customservice lt 1)
1874 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1876 #check if name already exists
1877 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1878 foreach my $key (keys %customservicegrp) {
1879 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1880 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1885 #check if service already exists in group
1886 foreach my $key (keys %customservicegrp) {
1887 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1888 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1891 return $errormessage;
1895 if ($errormessage) {
1896 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1897 print "<class name='base'>$errormessage\n";
1898 print " </class>\n";
1899 &Header
::closebox
();
1905 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1906 print "<class name='base'>$hint\n";
1907 print " </class>\n";
1908 &Header
::closebox
();
1914 &General
::setup_default_networks
(\
%defaultNetworks);
1915 foreach my $network (sort keys %defaultNetworks)
1917 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1922 my $searchstring=shift;
1924 #Count services used in servicegroups
1925 foreach my $key (keys %customgrp) {
1926 if($customgrp{$key}[2] eq $searchstring){
1930 #Count services used in firewall - config
1931 foreach my $key1 (keys %fwfwd) {
1932 if($fwfwd{$key1}[4] eq $searchstring){
1935 if($fwfwd{$key1}[6] eq $searchstring){
1939 #Count services used in firewall - input
1940 foreach my $key2 (keys %fwinp) {
1941 if($fwinp{$key2}[4] eq $searchstring){
1944 if($fwinp{$key2}[6] eq $searchstring){
1948 #Count services used in firewall - outgoing
1949 foreach my $key3 (keys %fwout) {
1950 if($fwout{$key3}[4] eq $searchstring){
1953 if($fwout{$key3}[6] eq $searchstring){
1961 my $searchstring=shift;
1963 #Count services used in servicegroups
1964 foreach my $key (keys %customgrp) {
1965 if($customgrp{$key}[2] eq $searchstring){
1969 #Count services used in firewall - config
1970 foreach my $key1 (keys %fwfwd) {
1971 if($fwfwd{$key1}[4] eq $searchstring){
1974 if($fwfwd{$key1}[6] eq $searchstring){
1978 #Count services used in firewall - input
1979 foreach my $key2 (keys %fwinp) {
1980 if($fwinp{$key2}[4] eq $searchstring){
1983 if($fwinp{$key2}[6] eq $searchstring){
1987 #Count services used in firewall - outgoing
1988 foreach my $key3 (keys %fwout) {
1989 if($fwout{$key3}[4] eq $searchstring){
1992 if($fwout{$key3}[6] eq $searchstring){
2000 my $searchstring=shift;
2002 #Count services used in servicegroups
2003 foreach my $key (keys %customservicegrp) {
2004 if($customservicegrp{$key}[2] eq $searchstring){
2008 #Count services used in firewall - config
2009 foreach my $key1 (keys %fwfwd) {
2010 if($fwfwd{$key1}[15] eq $searchstring){
2014 #Count services used in firewall - input
2015 foreach my $key2 (keys %fwinp) {
2016 if($fwinp{$key2}[15] eq $searchstring){
2020 #Count services used in firewall - outgoing
2021 foreach my $key3 (keys %fwout) {
2022 if($fwout{$key3}[15] eq $searchstring){
2033 &General
::readhasharray
("$config",\
%hash);
2034 foreach my $key (keys %hash) {
2035 if($hash{$key}[2] eq $target){
2039 &General
::writehasharray
("$config",\
%hash);
2046 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
2048 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
2049 $fwhostsettings{'BLK_IP'}='readonly';
2050 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2051 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2053 #check if name collides with CCD Netname
2054 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2055 foreach my $key (keys %ccdnet) {
2056 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2057 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
2058 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2059 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2063 #check if IP collides with CCD NetIP
2064 if ($fwhostsettings{'type'} ne 'mac'){
2065 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2066 foreach my $key (keys %ccdnet) {
2067 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
2068 if($ccdnet{$key}[1] eq $test){
2069 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
2070 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
2071 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
2072 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2077 #check if name collides with CCD Hostname
2078 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2079 foreach my $key (keys %ccdhost) {
2080 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
2081 if($ip eq $fwhostsettings{'IP'}){
2082 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
2083 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2087 #check if IP collides with CCD HostIP (only hosts)
2088 if ($edit eq 'edithost')
2090 foreach my $key (keys %ccdhost) {
2091 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
2092 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
2093 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
2094 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2099 #check if network with this name already exists
2100 &General
::readhasharray
("$confignet", \
%customnetwork);
2101 if (!&checkname
(\
%customnetwork))
2103 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
2104 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2105 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2107 #check if network ip already exists
2108 if (!&checkip
(\
%customnetwork,1))
2110 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
2111 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2113 #check if host with this name already exists
2114 &General
::readhasharray
("$confighost", \
%customhost);
2115 if (!&checkname
(\
%customhost))
2117 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
2118 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2119 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2121 #check if host with this ip already exists
2122 if (!&checkip
(\
%customhost,2))
2124 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
2134 #get address from IPSEC NETWORK
2135 if ($type eq 'IpSec Network'){
2136 foreach my $key (keys %ipsecconf) {
2137 if ($ipsecconf{$key}[1] eq $name){
2138 return $ipsecconf{$key}[11];
2141 &deletefromgrp
($name,$configgrp);
2144 #get address from IPSEC HOST
2145 if ($type eq 'IpSec Host'){
2146 foreach my $key (keys %ipsecconf) {
2147 if ($ipsecconf{$key}[1] eq $name){
2148 return $ipsecconf{$key}[10];
2151 &deletefromgrp
($name,$configgrp);
2154 #get address from ovpn ccd Net-2-Net
2155 if ($type eq 'OpenVPN N-2-N'){
2156 foreach my $key (keys %ccdhost) {
2157 if($ccdhost{$key}[1] eq $name){
2158 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2159 $b=&General
::iporsubtodec
($b);
2163 &deletefromgrp
($name,$configgrp);
2166 #get address from ovpn ccd static host
2167 if ($type eq 'OpenVPN static host'){
2168 foreach my $key (keys %ccdhost) {
2169 if($ccdhost{$key}[1] eq $name){
2170 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2171 $b=&General
::iporsubtodec
($b);
2175 &deletefromgrp
($name,$configgrp);
2178 #get address from ovpn ccd static net
2179 if ($type eq 'OpenVPN static network'){
2180 foreach my $key (keys %ccdnet) {
2181 if ($ccdnet{$key}[0] eq $name){
2182 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2183 $b=&General
::iporsubtodec
($b);
2189 #check custom addresses
2190 if ($type eq 'Custom Host'){
2191 foreach my $key (keys %customhost) {
2192 if ($customhost{$key}[0] eq $name){
2193 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2199 ##check custom networks
2200 if ($type eq 'Custom Network'){
2201 foreach my $key (keys %customnetwork) {
2202 if($customnetwork{$key}[0] eq $name){
2203 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2208 #check standard networks
2209 if ($type eq 'Standard Network'){
2210 if ($name =~ /OpenVPN/i){
2212 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2213 return $ovpn{'DOVPN_SUBNET'};
2215 if ($name eq 'GREEN'){
2217 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2218 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2220 if ($name eq 'BLUE'){
2222 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2223 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2225 if ($name eq 'ORANGE'){
2227 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2228 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2230 if ($name eq 'ALL'){
2231 return "0.0.0.0/0.0.0.0";
2233 if ($name =~ /IPsec/i){
2235 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2236 return $hash{'RW_NET'};
2243 &General
::readhasharray
("$confignet", \
%customnetwork);
2244 &General
::readhasharray
("$confighost", \
%customhost);
2245 foreach my $key (sort keys %customgrp ){
2246 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2247 foreach my $key1 (sort keys %customnetwork){
2248 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2249 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2255 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2256 foreach my $key2 (sort keys %customhost){
2257 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2258 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2265 &General
::writehasharray
("$confignet", \
%customnetwork);
2266 &General
::writehasharray
("$confighost", \
%customhost);
2271 &General
::readhasharray
("$configsrv", \
%customservice);
2272 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2274 foreach my $key (sort keys %customservicegrp){
2275 if ($customservicegrp{$key}[0] eq $grp ){
2276 foreach my $key2 (sort keys %customservice){
2277 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2278 $customservice{$key2}[4]--;
2283 &General
::writehasharray
("$configsrv", \
%customservice);
2289 my %hash=%{(shift)};
2291 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2292 $errormessage=$Lang::tr
{'fwhost err name1'};
2294 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2295 $errormessage=$Lang::tr
{'fwhost err port'};
2298 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2299 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2301 #change dashes with :
2302 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2304 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2305 $fwhostsettings{'SRV_PORT'} = "1:65535";
2307 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2308 $fwhostsettings{'SRV_PORT'} = "1:$2";
2310 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2311 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2313 if($fwhostsettings{'PROT'} ne 'ICMP'){
2314 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2316 # a new service has to have a different name
2317 foreach my $key (keys %hash){
2318 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2319 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2323 return $errormessage;
2327 # Checks a hostname against RFC1035
2328 my $hostname = $_[0];
2330 # Each part should be at least two characters in length
2331 # but no more than 63 characters
2332 if (length ($hostname) < 1 || length ($hostname) > 63) {
2334 # Only valid characters are a-z, A-Z, 0-9 and -
2335 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2337 # First character can only be a letter or a digit
2338 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2340 # Last character can only be a letter or a digit
2341 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2347 # Checks a hostname against RFC1035
2349 # Each part should be at least two characters in length
2350 # but no more than 63 characters
2351 if (length ($remark) < 1 || length ($remark) > 255) {
2353 # Only valid characters are a-z, A-Z, 0-9 and -
2354 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2356 # First character can only be a letter or a digit
2357 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2359 # Last character can only be a letter or a digit
2360 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2364 &Header
::closebigbox
();
2365 &Header
::closepage
();