]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/fwhosts.cgi
ae135ab33cdd31d889c84732d8acf38b925663b0
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'};
242 &checkrulereload
($customservicegrp{$key}[0]);
245 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
247 &checkrulereload
($fwhostsettings{'SRV_NAME'});
248 $fwhostsettings{'SRV_NAME'} = '';
249 $fwhostsettings{'SRV_PORT'} = '';
250 $fwhostsettings{'PROT'} = '';
251 $fwhostsettings{'ICMP'} = '';
252 $fwhostsettings{'oldsrvicmp'} = '';
253 $fwhostsettings{'updatesrv'} = '';
255 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
256 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
257 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
258 $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
259 $fwhostsettings{'updatesrv'}= 'on';
264 if ($fwhostsettings{'ACTION'} eq 'savenet' )
267 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
268 #check if all fields are set
269 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
271 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
276 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
278 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
279 $fwhostsettings{'BLK_HOST'} ='readonly';
280 $fwhostsettings{'NOCHECK'} ='false';
281 $fwhostsettings{'error'} ='on';
284 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
285 $errormessage=$Lang::tr
{'fwhost err remark'};
286 $fwhostsettings{'error'} ='on';
288 #check if subnet is sigle host
289 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
291 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
293 if($fwhostsettings{'error'} ne 'on'){
294 #check if we use one of ipfire's networks (green,orange,blue)
295 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
297 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
298 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
299 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
301 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
303 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
304 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
305 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
307 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
309 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
310 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
311 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
313 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
315 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
316 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
317 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
320 #only check plausi when no error till now
322 &plausicheck
("editnet");
324 #check if network ip is part of an already used one
325 if(&checksubnet
(\
%customnetwork))
327 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
328 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
330 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
332 $fwhostsettings{'actualize'} = '';
333 my $key = &General
::findhasharraykey
(\
%customnetwork);
334 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
335 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
336 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
337 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
338 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
339 &General
::writehasharray
("$confignet", \
%customnetwork);
340 undef %customnetwork;
344 &General
::readhasharray
("$confignet", \
%customnetwork);
345 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
346 if ($fwhostsettings{'update'} == '0'){
347 foreach my $key (keys %customnetwork) {
348 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
349 delete $customnetwork{$key};
355 #get count if actualize is 'on'
356 if($fwhostsettings{'actualize'} eq 'on'){
357 $fwhostsettings{'actualize'} = '';
358 #check if we need to reload rules
359 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
362 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
363 #check if we need to update groups
364 &General
::readhasharray
("$configgrp", \
%customgrp);
365 foreach my $key (sort keys %customgrp){
366 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
367 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
371 &General
::writehasharray
("$configgrp", \
%customgrp);
372 #check if we need to update firewallrules
373 if ( ! -z
$fwconfigfwd ){
374 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
375 foreach my $line (sort keys %fwfwd){
376 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
377 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
379 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
380 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
383 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
385 if ( ! -z
$fwconfiginp ){
386 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
387 foreach my $line (sort keys %fwinp){
388 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
389 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
392 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
396 my $key = &General
::findhasharraykey
(\
%customnetwork);
397 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
398 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
399 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
400 #convert ip when leading '0' in byte
401 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
402 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
403 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
404 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
405 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
406 &General
::writehasharray
("$confignet", \
%customnetwork);
407 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
408 undef %customnetwork;
409 $fwhostsettings{'HOSTNAME'}='';
410 $fwhostsettings{'IP'}='';
411 $fwhostsettings{'SUBNET'}='';
412 $fwhostsettings{'NETREMARK'}='';
413 #check if an edited net affected groups and need to reload rules
414 if ($needrules eq 'on'){
415 &General
::firewall_config_changed
();
425 if ($fwhostsettings{'ACTION'} eq 'savehost')
428 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
429 $fwhostsettings{'SUBNET'}='32';
430 #check if all fields are set
431 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
433 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
434 $fwhostsettings{'ACTION'} = 'edithost';
436 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
437 $fwhostsettings{'type'} = 'mac';
438 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
439 $fwhostsettings{'type'} = 'ip';
441 $fwhostsettings{'type'} = '';
442 $errormessage=$Lang::tr
{'fwhost err ipmac'};
445 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
446 $errormessage=$Lang::tr
{'fwhost err remark'};
449 if ($fwhostsettings{'type'} eq 'ip'){
451 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
452 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
454 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
455 $fwhostsettings{'error'}='on';
457 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
458 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
459 $fwhostsettings{'error'}='on';
461 #check if net or broadcast
462 my @tmp= split (/\./,$fwhostsettings{'IP'});
463 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
464 $errormessage=$Lang::tr
{'fwhost err hostip'};
467 #only check plausi when no error till now
469 &plausicheck
("edithost");
471 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
472 $fwhostsettings{'actualize'} = '';
473 my $key = &General
::findhasharraykey
(\
%customhost);
474 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
475 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
476 $customhost{$key}[1] = $fwhostsettings{'type'} ;
477 if($customhost{$key}[1] eq 'ip'){
478 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
480 $customhost{$key}[2] = $fwhostsettings{'orgip'};
482 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
483 &General
::writehasharray
("$confighost", \
%customhost);
487 #get count if host was edited
488 if($fwhostsettings{'actualize'} eq 'on'){
489 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
492 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
493 #check if we need to update groups
494 &General
::readhasharray
("$configgrp", \
%customgrp);
495 foreach my $key (sort keys %customgrp){
496 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
497 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
500 &General
::writehasharray
("$configgrp", \
%customgrp);
501 #check if we need to update firewallrules
502 if ( ! -z
$fwconfigfwd ){
503 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
504 foreach my $line (sort keys %fwfwd){
505 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
506 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
508 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
509 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
512 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
514 if ( ! -z
$fwconfiginp ){
515 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
516 foreach my $line (sort keys %fwinp){
517 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
518 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
521 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
525 my $key = &General
::findhasharraykey
(\
%customhost);
526 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
527 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
528 $customhost{$key}[1] = $fwhostsettings{'type'} ;
529 if ($fwhostsettings{'type'} eq 'ip'){
530 #convert ip when leading '0' in byte
531 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
532 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
533 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
535 $customhost{$key}[2] = $fwhostsettings{'IP'};
537 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
538 &General
::writehasharray
("$confighost", \
%customhost);
540 $fwhostsettings{'HOSTNAME'}='';
541 $fwhostsettings{'IP'}='';
542 $fwhostsettings{'type'}='';
543 $fwhostsettings{'HOSTREMARK'}='';
544 #check if we need to update rules while host was edited
545 if($needrules eq 'on'){
546 &General
::firewall_config_changed
();
556 if ($fwhostsettings{'ACTION'} eq 'savegrp')
558 my $grp=$fwhostsettings{'grp_name'};
559 my $rem=$fwhostsettings{'remark'};
562 my $updcounter='off';
565 &General
::readhasharray
("$configgrp", \
%customgrp);
566 &General
::readhasharray
("$confignet", \
%customnetwork);
567 &General
::readhasharray
("$confighost", \
%customhost);
568 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
569 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
570 &General
::readhasharray
("$fwconfigout", \
%fwout);
572 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
574 if (!&checkgroup
($grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
576 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
577 $errormessage.=$Lang::tr
{'fwhost err remark'};
579 if ($fwhostsettings{'update'} eq 'on'){
580 #check standard networks
581 if ($fwhostsettings{'grp2'} eq 'std_net'){
582 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
583 $type='Standard Network';
585 #check custom networks
586 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
587 @target=$fwhostsettings{'CUST_SRC_NET'};
589 $type='Custom Network';
590 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
591 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
592 $fwhostsettings{'grp_name'}='';
593 $fwhostsettings{'remark'}='';
595 #check custom addresses
596 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
597 @target=$fwhostsettings{'CUST_SRC_HOST'};
600 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
601 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
602 $fwhostsettings{'grp_name'}='';
603 $fwhostsettings{'remark'}='';
605 #get address from ovpn ccd static net
606 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
607 @target=$fwhostsettings{'OVPN_CCD_NET'};
608 $type='OpenVPN static network';
609 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
610 $errormessage=$Lang::tr
{'fwhost err groupempty'};
611 $fwhostsettings{'grp_name'}='';
612 $fwhostsettings{'remark'}='';
614 #get address from ovpn ccd static host
615 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
616 @target=$fwhostsettings{'OVPN_CCD_HOST'};
617 $type='OpenVPN static host';
618 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
619 $errormessage=$Lang::tr
{'fwhost err groupempty'};
621 #get address from ovpn ccd Net-2-Net
622 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
623 @target=$fwhostsettings{'OVPN_N2N'};
624 $type='OpenVPN N-2-N';
625 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
626 $errormessage=$Lang::tr
{'fwhost err groupempty'};
627 $fwhostsettings{'grp_name'}='';
628 $fwhostsettings{'remark'}='';
630 #get address from IPSEC HOST
631 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
632 @target=$fwhostsettings{'IPSEC_HOST'};
634 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
635 $errormessage=$Lang::tr
{'fwhost err groupempty'};
636 $fwhostsettings{'grp_name'}='';
637 $fwhostsettings{'remark'}='';
639 #get address from IPSEC NETWORK
640 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
641 @target=$fwhostsettings{'IPSEC_NET'};
642 $type='IpSec Network';
643 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
644 $errormessage=$Lang::tr
{'fwhost err groupempty'};
645 $fwhostsettings{'grp_name'}='';
646 $fwhostsettings{'remark'}='';
648 #check if host/net exists in grp
650 my $test="$grp,$fwhostsettings{'oldremark'},@target";
651 foreach my $key (keys %customgrp) {
652 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
653 if ($test1 eq $test){
654 $errormessage=$Lang::tr
{'fwhost err isingrp'};
655 $fwhostsettings{'update'} = 'on';
661 #on first save, we have an empty @target, so fill it with nothing
662 my $targetvalues=@target;
663 if ($targetvalues == '0'){
666 #on update, we have to delete the dummy entry
667 foreach my $key (keys %customgrp){
668 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
669 delete $customgrp{$key};
673 &General
::writehasharray
("$configgrp", \
%customgrp);
674 &General
::readhasharray
("$configgrp", \
%customgrp);
675 #create array with new lines
676 foreach my $line (@target){
677 push (@newgrp,"$grp,$rem,$line");
680 my $key = &General
::findhasharraykey
(\
%customgrp);
681 foreach my $line (@newgrp){
682 foreach my $i (0 .. 3) { $customgrp{$key}[$i] = "";}
683 my ($a,$b,$c,$d) = split (",",$line);
684 $customgrp{$key}[0] = $a;
685 $customgrp{$key}[1] = $b;
686 $customgrp{$key}[2] = $c;
687 $customgrp{$key}[3] = $type;
689 &General
::writehasharray
("$configgrp", \
%customgrp);
690 #update counter in Host/Net
691 $fwhostsettings{'update'}='on';
693 #check if ruleupdate is needed
695 $netgrpcount=&getnetcount
($grp);
696 if($netgrpcount > 0 )
698 &General
::firewall_config_changed
();
703 if ($fwhostsettings{'ACTION'} eq 'saveservice')
706 &General
::readhasharray
("$configsrv", \
%customservice );
707 &General
::readhasharray
("$configgrp", \
%customgrp);
708 $errormessage=&checkports
(\
%customservice);
709 if ($fwhostsettings{'PROT'} eq 'ICMP'){
710 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
711 foreach my $key (keys %icmptypes){
712 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
713 $ICMP=$icmptypes{$key}[0];
717 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
718 if ($fwhostsettings{'PROT'} ne 'ICMP'){$ICMP='BLANK';}
719 #Check if a group with the same name already exists
720 if (!&checkgroup
($fwhostsettings{'SRV_NAME'})){
721 $errormessage = $Lang::tr
{'fwhost err grpexist'};
724 my $key = &General
::findhasharraykey
(\
%customservice);
725 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
726 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
727 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
728 $customservice{$key}[2] = $fwhostsettings{'PROT'};
729 $customservice{$key}[3] = $ICMP;
730 &General
::writehasharray
("$configsrv", \
%customservice );
732 $fwhostsettings{'SRV_NAME'}='';
733 $fwhostsettings{'SRV_PORT'}='';
734 $fwhostsettings{'PROT'}='';
735 $fwhostsettings{'ICMP_TYPES'}='';
739 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
745 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
746 &General
::readhasharray
("$configsrv", \
%customservice );
747 $errormessage=&checkservicegroup
;
748 #Check if we have more than 15 services from one Protocol in the group
749 #iptables can only handle 15 ports/portranges via multiport
750 foreach my $key (keys %customservicegrp){
751 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
752 foreach my $key1 (keys %customservice){
753 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
754 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
755 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
756 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
760 if ($tcpcounter > 15){
761 $errormessage=$Lang::tr
{'fwhost err maxservicetcp'};
763 if ($udpcounter > 15){
764 $errormessage=$Lang::tr
{'fwhost err maxserviceudp'};
769 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
770 $errormessage .= $Lang::tr
{'fwhost err remark'};
772 #Check if there is already a service with the same name
773 if(!&checkservice
($fwhostsettings{'SRVGRP_NAME'})){
774 $errormessage .= $Lang::tr
{'fwhost err srv exists'};
777 #on first save, we have to enter a dummy value
778 if ($fwhostsettings{'CUST_SRV'} eq ''){
779 $fwhostsettings{'CUST_SRV'}='none';
781 #on update, we have to delete the dummy entry
782 foreach my $key (keys %customservicegrp){
783 if ($customservicegrp{$key}[2] eq 'none'){
784 delete $customservicegrp{$key};
788 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
789 #check if remark has also changed
790 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
792 foreach my $key (keys %customservicegrp)
794 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
796 $customservicegrp{$key}[1]='';
797 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
801 my $key = &General
::findhasharraykey
(\
%customservicegrp);
802 foreach my $i (0 .. 2) { $customservice{$key}[$i] = "";}
803 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
804 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
805 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
806 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
807 $fwhostsettings{'updatesrvgrp'}='on';
809 &checkrulereload
($fwhostsettings{'SRVGRP_NAME'});
811 &viewtableservicegrp
;
814 if ($fwhostsettings{'ACTION'} eq 'editnet')
819 if ($fwhostsettings{'ACTION'} eq 'edithost')
824 if ($fwhostsettings{'ACTION'} eq 'editgrp')
826 $fwhostsettings{'update'}='on';
830 if ($fwhostsettings{'ACTION'} eq 'editservice')
832 $fwhostsettings{'updatesrv'}='on';
835 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
837 $fwhostsettings{'updatesrvgrp'} = 'on';
839 &viewtableservicegrp
;
842 if ($fwhostsettings{'ACTION'} eq 'resetnet')
844 $fwhostsettings{'HOSTNAME'} ="";
845 $fwhostsettings{'IP'} ="";
846 $fwhostsettings{'SUBNET'} ="";
849 if ($fwhostsettings{'ACTION'} eq 'resethost')
851 $fwhostsettings{'HOSTNAME'} ="";
852 $fwhostsettings{'IP'} ="";
853 $fwhostsettings{'type'} ="";
856 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
858 $fwhostsettings{'grp_name'} ="";
859 $fwhostsettings{'remark'} ="";
863 if ($fwhostsettings{'ACTION'} eq 'delnet')
865 &General
::readhasharray
("$confignet", \
%customnetwork);
866 foreach my $key (keys %customnetwork) {
867 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
868 delete $customnetwork{$key};
869 &General
::writehasharray
("$confignet", \
%customnetwork);
876 if ($fwhostsettings{'ACTION'} eq 'delhost')
878 &General
::readhasharray
("$confighost", \
%customhost);
879 foreach my $key (keys %customhost) {
880 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
881 delete $customhost{$key};
882 &General
::writehasharray
("$confighost", \
%customhost);
889 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
893 &General
::readhasharray
("$configgrp", \
%customgrp);
894 foreach my $key (keys %customgrp){
895 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
896 #decrease count from source host/net
897 if ($customgrp{$key}[3] eq 'Custom Network'){
898 &General
::readhasharray
("$confignet", \
%customnetwork);
899 foreach my $key1 (keys %customnetwork){
900 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
901 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
905 &General
::writehasharray
("$confignet", \
%customnetwork);
907 if ($customgrp{$key}[3] eq 'Custom Host'){
908 &General
::readhasharray
("$confighost", \
%customhost);
909 foreach my $key1 (keys %customhost){
910 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
911 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
915 &General
::writehasharray
("$confighost", \
%customhost);
917 $grpname=$customgrp{$key}[0];
918 $grpremark=$customgrp{$key}[1];
919 delete $customgrp{$key};
922 &General
::writehasharray
("$configgrp", \
%customgrp);
923 if ($fwhostsettings{'grpcnt'} > 0){
924 &General
::firewall_config_changed
();
926 if ($fwhostsettings{'update'} eq 'on'){
927 $fwhostsettings{'remark'}= $grpremark;
928 $fwhostsettings{'grp_name'}=$grpname;
933 if ($fwhostsettings{'ACTION'} eq 'delgrp')
935 &General
::readhasharray
("$configgrp", \
%customgrp);
936 &decrease
($fwhostsettings{'grp_name'});
937 foreach my $key (sort keys %customgrp)
939 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
941 delete $customgrp{$key};
944 &General
::writehasharray
("$configgrp", \
%customgrp);
945 $fwhostsettings{'grp_name'}='';
949 if ($fwhostsettings{'ACTION'} eq 'delservice')
951 &General
::readhasharray
("$configsrv", \
%customservice);
952 foreach my $key (keys %customservice) {
953 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
954 delete $customservice{$key};
955 &General
::writehasharray
("$configsrv", \
%customservice);
959 $fwhostsettings{'SRV_NAME'}='';
960 $fwhostsettings{'SRV_PORT'}='';
961 $fwhostsettings{'PROT'}='';
964 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
966 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
967 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
968 foreach my $key (sort keys %customservicegrp)
970 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
972 delete $customservicegrp{$key};
975 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
976 $fwhostsettings{'SRVGRP_NAME'}='';
978 &viewtableservicegrp
;
980 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
984 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
985 &General
::readhasharray
("$configsrv", \
%customservice);
986 foreach my $key (keys %customservicegrp){
987 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'})
989 #decrease count from source service
990 foreach my $key1 (sort keys %customservice){
991 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
992 $customservice{$key1}[4]--;
996 $grpname=$customservicegrp{$key}[0];
997 $grpremark=$customservicegrp{$key}[1];
998 delete $customservicegrp{$key};
1001 &General
::writehasharray
("$configsrv", \
%customservice);
1002 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1003 &General
::firewall_config_changed
();
1004 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1005 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1006 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1009 &viewtableservicegrp
;
1012 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1017 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1022 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1027 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1031 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1034 &viewtableservicegrp
;
1036 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1038 &General
::readhasharray
("$configgrp", \
%customgrp);
1039 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1040 foreach my $key (sort keys %customgrp)
1042 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1044 $customgrp{$key}[1]='';
1045 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1048 &General
::writehasharray
("$configgrp", \
%customgrp);
1049 $fwhostsettings{'update'}='on';
1050 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1052 $errormessage=$Lang::tr
{'fwhost err remark'};
1053 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1054 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1055 $fwhostsettings{'update'} = 'on';
1057 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1061 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1063 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1064 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1065 foreach my $key (sort keys %customservicegrp)
1067 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1069 $customservicegrp{$key}[1]='';
1070 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1073 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1074 $fwhostsettings{'updatesrvgrp'}='on';
1075 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1076 }elsif($fwhostsettings{'oldsrvrem'} eq $fwhostsettings{'newsrvrem'}){
1078 &viewtableservicegrp
;
1080 $errormessage=$Lang::tr
{'fwhost err remark'};
1081 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1082 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1083 $fwhostsettings{'updatesrvgrp'} = 'on';
1085 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1087 &viewtableservicegrp
;
1089 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpname')
1091 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1092 if ($fwhostsettings{'oldsrvgrpname'} ne $fwhostsettings{'srvgrp'}){
1093 #Check new groupname
1094 if (!&validhostname
($fwhostsettings{'srvgrp'})){
1095 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1097 if (!$errormessage){
1098 #Rename group in customservicegroup
1099 foreach my $key (keys %customservicegrp) {
1100 if($customservicegrp{$key}[0] eq $fwhostsettings{'oldsrvgrpname'}){
1101 $customservicegrp{$key}[0]=$fwhostsettings{'srvgrp'};
1104 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
1105 #change name in FW Rules
1106 &changenameinfw
($fwhostsettings{'oldsrvgrpname'},$fwhostsettings{'srvgrp'},15);
1110 &viewtableservicegrp
;
1112 if ($fwhostsettings{'ACTION'} eq 'changegrpname')
1114 &General
::readhasharray
("$configgrp", \
%customgrp );
1115 if ($fwhostsettings{'oldgrpname'} ne $fwhostsettings{'grp'}){
1116 #Check new groupname
1117 if (!&validhostname
($fwhostsettings{'grp'})){
1118 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1120 if (!$errormessage){
1121 #Rename group in customservicegroup
1122 foreach my $key (keys %customgrp) {
1123 if($customgrp{$key}[0] eq $fwhostsettings{'oldgrpname'}){
1124 $customgrp{$key}[0]=$fwhostsettings{'grp'};
1127 &General
::writehasharray
("$configgrp", \
%customgrp );
1128 #change name in FW Rules
1129 &changenameinfw
($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
1136 if($fwhostsettings{'ACTION'} eq '')
1142 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1143 print "$Lang::tr{'fwhost welcome'}";
1145 <br><br><table border='0' width='100%'>
1146 <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>
1147 <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>
1148 <tr><td colspan='6'><hr></td></tr></table>
1150 &Header
::closebox
();
1158 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1159 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1160 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1162 <table border='0' width='100%'>
1163 <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>
1164 <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>
1165 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1166 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1167 <tr><td colspan='6'><br><hr></td></tr><tr>
1169 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1171 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>";
1173 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'>";
1175 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>";
1176 &Header
::closebox
();
1182 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1183 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1184 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1186 <table border='0' width='100%'>
1187 <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>
1188 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1189 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1190 <tr><td colspan='5'><hr></td></tr><tr>
1193 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1196 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>";
1198 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'>";
1200 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>";
1201 &Header
::closebox
();
1208 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1209 &General
::setup_default_networks
(\
%defaultNetworks);
1210 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1211 &General
::readhasharray
("$confignet", \
%customnetwork);
1212 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1213 &General
::readhasharray
("$confighost", \
%customhost);
1214 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1218 $checked{'check1'}{'off'} = '';
1219 $checked{'check1'}{'on'} = '';
1220 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1221 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1222 $fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'};
1223 my $grp=$fwhostsettings{'grp_name'};
1224 my $rem=$fwhostsettings{'remark'};
1225 if ($fwhostsettings{'update'} eq ''){
1227 <table width='100%' border='0'>
1228 <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>
1229 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1230 <tr><td colspan='2'><br><hr></td></tr></table>
1234 <table width='100%' border='0'><form method='post' style='display:inline'>
1235 <tr><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost addgrpname'}</td><td width='20%'><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' ></td><td><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldgrpname' value='$fwhostsettings{'oldgrpname'}'><input type='hidden' name='ACTION' value='changegrpname'></td><td></td></form></tr>
1236 <tr><form method='post' style='display:inline'><td>$Lang::tr{'remark'}:</td><td colspan='2'><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>
1240 if ($fwhostsettings{'update'} eq 'on'){
1242 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1243 <table width='100%' border='0'>
1244 <tr><td width=50% valign='top'>
1245 <table width='100%' border='0'>
1246 <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;'>
1248 foreach my $network (sort keys %defaultNetworks)
1250 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1251 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1252 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1253 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1254 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1255 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1256 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1257 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1258 if ($ownnet{$defnet}){
1259 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1261 print ">$network</option>";
1264 print"</select></td></tr>";
1265 if (! -z
$confignet){
1266 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;'>";
1267 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1268 print"<option>$customnetwork{$key}[0]</option>";
1270 print"</select></td></tr>";
1272 if (! -z
$confighost){
1273 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;'>";
1274 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1275 print"<option>$customhost{$key}[0]</option>";
1277 print"</select></td></tr>";
1281 print"</td><td valign='top'><table width='100%' border='0'>";
1283 if (! -z
$configccdnet){
1284 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;'>";
1285 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1287 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1289 print"</select></td></tr>";
1292 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1294 if ($ccdhost{$key}[33] ne ''){
1295 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 '');
1297 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1300 if ($show eq '1'){$show='';print"</select></td></tr>";}
1302 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1303 if($ccdhost{$key}[3] eq 'net'){
1304 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 '');
1306 print"<option>$ccdhost{$key}[1]</option>";
1309 if ($show eq '1'){$show='';print"</select></td></tr>";}
1311 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1312 if ($ipsecconf{$key}[3] eq 'net'){
1313 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 '');
1315 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1318 if ($show eq '1'){$show='';print"</select></td></tr>";}
1320 print"</td></tr></table>";
1321 print"<br><br><hr>";
1323 print"<table border='0' width='100%'>";
1324 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>";
1325 &Header
::closebox
();
1331 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1332 if ($fwhostsettings{'updatesrv'} eq 'on')
1334 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1335 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1336 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1337 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1340 <table width='100%' border='0'><form method='post'>
1341 <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>
1342 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1344 foreach ("TCP","UDP","ICMP")
1346 if ($_ eq $fwhostsettings{'PROT'})
1348 print"<option selected>$_</option>";
1350 print"<option>$_</option>";
1354 </select></td></tr></table>
1355 <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'>
1357 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1358 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1359 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1360 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1361 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1363 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1367 </select></td></tr></table></div>
1368 <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>
1369 <table width='100%' border='0'><tr><td colspan='6'><br><hr></td></tr>
1370 <tr><td colspan='6' align='right'>
1372 if ($fwhostsettings{'updatesrv'} eq 'on')
1375 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1376 <input type='hidden' name='ACTION' value='updateservice'>
1377 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1378 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1379 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1380 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1384 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1387 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1390 &Header
::closebox
();
1398 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1399 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1400 $fwhostsettings{'oldsrvgrpname'}=$fwhostsettings{'SRVGRP_NAME'};
1401 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1403 <table width='100%' border='0'><form method='post'>
1404 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1405 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1406 <tr><td colspan='2'><br><hr></tr>
1411 <table width='100%' border='0'><form method='post' style='display:inline'>
1412 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td width='20%'><input type='text' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}' size='14'></td><td align='left'><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldsrvgrpname' value='$fwhostsettings{'oldsrvgrpname'}'><input type='hidden' name='ACTION' value='changesrvgrpname'></td><td width='3%'></td></form></tr>
1413 <tr><form method='post'><td width='10%'>$Lang::tr{'remark'}:</td><td colspan='2'><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>
1414 <tr><td colspan='4'><br><hr></td></td></tr>
1418 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1420 <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%'>
1421 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'add'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1423 &General
::readhasharray
("$configsrv", \
%customservice);
1424 #Protocols for use in servicegroups
1425 print "<optgroup label='$Lang::tr{'fwhost cust service'}'>";
1426 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1428 print "<option>$customservice{$key}[0]</option>";
1430 print "</optgroup>";
1431 print "<optgroup label='$Lang::tr{'protocol'}'>";
1432 print "<option>GRE</option>";
1433 print "<option>AH</option>";
1434 print "<option>ESP</option>";
1435 print "<option>IGMP</option>";
1436 print "<option>IPIP</option>";
1437 print "<option value='IPV6'>IPv6 encap</option>";
1438 print "</optgroup>";
1441 <tr><td colspan='4'><br><br></td></tr>
1442 <tr><td colspan='4'><hr></td></tr>
1447 <table width='100%' border='0'>
1448 <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>
1451 &Header
::closebox
();
1456 if(! -z
$confignet){
1457 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1458 &General
::readhasharray
("$confignet", \
%customnetwork);
1459 &General
::readhasharray
("$configgrp", \
%customgrp);
1460 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1461 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1462 &General
::readhasharray
("$fwconfigout", \
%fwout);
1463 if (!keys %customnetwork)
1465 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1468 <table border='0' width='100%' cellspacing='0'>
1469 <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>
1473 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1474 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1475 print" <tr bgcolor='${Header::colouryellow}'>";
1478 print" <tr bgcolor='$color{'color22'}'>";
1481 print" <tr bgcolor='$color{'color20'}'>";
1483 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1484 my $netcount=&getnetcount
($customnetwork{$key}[0]);
1485 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>";
1487 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1488 <input type='hidden' name='ACTION' value='editnet'>
1489 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1490 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1491 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1492 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1495 if($netcount == '0')
1497 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>";
1499 print"<td></td></tr>";
1504 &Header
::closebox
();
1511 #Check if IP is part of OpenVPN N2N subnet
1512 foreach my $key (sort keys %ccdhost){
1513 if ($ccdhost{$key}[3] eq 'net'){
1514 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1515 if (&General
::IpInSubnet
($c,$a,$b)){
1516 $tdcolor="style='color:$Header::colourovpn ;'";
1521 #Check if IP is part of OpenVPN dynamic subnet
1522 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1523 if (&General
::IpInSubnet
($c,$a,$b)){
1524 $tdcolor="style='color: $Header::colourovpn;'";
1527 #Check if IP is part of OpenVPN static subnet
1528 foreach my $key (sort keys %ccdnet){
1529 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1530 $b =&General
::iporsubtodec
($b);
1531 if (&General
::IpInSubnet
($c,$a,$b)){
1532 $tdcolor="style='color: $Header::colourovpn;'";
1536 #Check if IP is part of IPsec RW network
1537 if ($ipsecsettings{'RW_NET'} ne ''){
1538 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1539 $b=&General
::iporsubtodec
($b);
1540 if (&General
::IpInSubnet
($c,$a,$b)){
1541 $tdcolor="style='color: $Header::colourvpn;'";
1545 #Check if IP is part of a IPsec N2N network
1546 foreach my $key (sort keys %ipsecconf){
1547 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1548 if (&General
::IpInSubnet
($c,$a,$b)){
1549 $tdcolor="style='color: $Header::colourvpn;'";
1558 if (! -z
$confighost){
1559 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1560 &General
::readhasharray
("$confighost", \
%customhost);
1561 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1562 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1563 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1564 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1565 &General
::readhasharray
("$fwconfigout", \
%fwout);
1566 &General
::readhasharray
("$configgrp", \
%customgrp);
1567 if (!keys %customhost)
1569 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1572 <table border='0' width='100%' cellspacing='0'>
1573 <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>
1577 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1578 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1579 print" <tr bgcolor='${Header::colouryellow}'>";
1580 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1581 else{ print" <tr bgcolor='$color{'color20'}'>";}
1582 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1583 $customhost{$key}[4]=~s/\s+//g;
1585 $hostcount=&gethostcount
($customhost{$key}[0]);
1586 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>";
1588 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1589 <input type='hidden' name='ACTION' value='edithost' />
1590 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1591 <input type='hidden' name='IP' value='$ip' />
1592 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1593 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1596 if($hostcount == '0')
1598 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>";
1600 print"<td width='1%'></td></tr>";
1605 &Header
::closebox
();
1610 if(! -z
"$configgrp"){
1611 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1612 &General
::readhasharray
("$configgrp", \
%customgrp);
1613 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1614 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1615 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1616 &General
::readhasharray
("$confighost", \
%customhost);
1617 &General
::readhasharray
("$confignet", \
%customnetwork);
1618 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1619 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1620 &General
::readhasharray
("$fwconfigout", \
%fwout);
1628 if (!keys %customgrp)
1630 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1632 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1634 if ($helper ne $customgrp{$key}[0]){
1636 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1637 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1646 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
1647 $grpname=$customgrp{$key}[0];
1648 $remark="$customgrp{$key}[1]";
1649 if($count gt 1){ print"</table>";}
1650 print "<br><b><u>$grpname</u></b> ";
1651 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1652 my $netgrpcount=&getnetcount
($grpname);
1653 print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
1654 if($netgrpcount == '0')
1656 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>";
1658 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>";
1659 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>";
1662 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1663 print" <tr bgcolor='${Header::colouryellow}'>";
1664 }elsif ($count %2 == 0){
1665 print"<tr bgcolor='$color{'color22'}'>";
1667 print"<tr bgcolor='$color{'color20'}'>";
1669 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1670 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1671 print "<td width='39%' align='left'>";
1672 if($customgrp{$key}[3] eq 'Standard Network'){
1673 print &get_name
($customgrp{$key}[2])."</td>";
1675 print "$customgrp{$key}[2]</td>";
1677 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
1678 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1680 my ($colip,$colsub) = split("/",$ip);
1681 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1682 print"<td align='center' ".&getcolor
($colip).">".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1684 if ($delflag > 1 && $ip ne ''){
1685 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1687 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>";
1689 $helper=$customgrp{$key}[0];
1694 &Header
::closebox
();
1698 sub viewtableservice
1702 if(! -z
"$configsrv")
1704 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1705 &General
::readhasharray
("$configsrv", \
%customservice);
1706 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1707 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1708 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1709 &General
::readhasharray
("$fwconfigout", \
%fwout);
1711 <table width='100%' border='0' cellspacing='0'>
1712 <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>
1714 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1717 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1718 print" <tr bgcolor='${Header::colouryellow}'>";
1719 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1721 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1724 $srvcount=&getsrvcount
($customservice{$key}[0]);
1725 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
1726 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1728 </td><td align='center'>$srvcount x</td>
1729 <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' />
1730 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1731 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1732 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
1733 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
1735 if ($srvcount eq '0')
1737 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>";
1739 print"<td></td></tr>";
1743 &Header
::closebox
();
1746 sub viewtableservicegrp
1756 if (! -z
$configsrvgrp){
1757 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1758 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1759 &General
::readhasharray
("$configsrv", \
%customservice);
1760 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1761 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1762 &General
::readhasharray
("$fwconfigout", \
%fwout);
1763 my $number= keys %customservicegrp;
1764 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
1766 if ($helper ne $customservicegrp{$key}[0]){
1767 #Get used groupcounter
1768 $grpcount=&getsrvcount
($customservicegrp{$key}[0]);
1770 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1771 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1779 $grpname=$customservicegrp{$key}[0];
1780 if ($customservicegrp{$key}[2] eq "none"){
1781 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1785 $remark="$customservicegrp{$key}[1]";
1786 if($count >=2){print"</table>";}
1787 print "<br><b><u>$grpname</u></b> ";
1788 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1789 print " <b>$Lang::tr{'used'}:</b> $grpcount x";
1790 if($grpcount == '0')
1792 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>";
1794 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>";
1795 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>";
1797 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1798 print" <tr bgcolor='${Header::colouryellow}'>";
1799 }elsif ($count %2 == 0){
1800 print"<tr bgcolor='$color{'color22'}'>";
1802 print"<tr bgcolor='$color{'color20'}'>";
1804 #Set fields if we use protocols in servicegroups
1805 if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
1808 if ($customservicegrp{$key}[2] eq 'GRE'){$protocol='GRE';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} GRE";}
1809 if ($customservicegrp{$key}[2] eq 'ESP'){$protocol='ESP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} ESP";}
1810 if ($customservicegrp{$key}[2] eq 'AH'){$protocol='AH';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} AH";}
1811 if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
1812 if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
1813 if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
1814 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1815 foreach my $srv (sort keys %customservice){
1816 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1817 $protocol=$customservice{$srv}[2];
1818 $port=$customservice{$srv}[1];
1822 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1823 if ($delflag gt '1'){
1824 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1826 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
1827 if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
1828 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2]'></form></td></tr>";
1830 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$protocol'></form></td></tr>";
1832 $helper=$customservicegrp{$key}[0];
1835 &Header
::closebox
();
1841 my %hash=%{(shift)};
1842 foreach my $key (keys %hash) {
1843 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1852 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1854 foreach my $key (keys %customservicegrp) {
1855 if($customservicegrp{$key}[0] eq $name){
1863 &General
::readhasharray
("$configsrv", \
%customservice );
1865 foreach my $key (keys %customservice) {
1866 if($customservice{$key}[0] eq $name){
1875 my %hash=%{(shift)};
1877 foreach my $key (keys %hash) {
1878 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1886 my %hash=%{(shift)};
1887 &General
::readhasharray
("$confignet", \
%hash);
1888 foreach my $key (keys %hash) {
1889 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1896 sub checkservicegroup
1898 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1900 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1902 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1903 return $errormessage;
1905 #check empty selectbox
1906 if (keys %customservice lt 1)
1908 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1910 #check if name already exists
1911 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1912 foreach my $key (keys %customservicegrp) {
1913 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1914 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1919 #check if service already exists in group
1920 foreach my $key (keys %customservicegrp) {
1921 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1922 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1925 return $errormessage;
1930 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1931 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1932 &General
::readhasharray
("$fwconfigout", \
%fwout);
1934 #check if service or servicegroup is used in rules
1935 foreach my $key (keys %fwfwd){
1936 if($search eq $fwfwd{$key}[15]){
1937 &General
::firewall_config_changed
();
1941 foreach my $key (keys %fwinp){
1942 if($search eq $fwinp{$key}[15]){
1943 &General
::firewall_config_changed
();
1947 foreach my $key (keys %fwout){
1948 if($search eq $fwout{$key}[15]){
1949 &General
::firewall_config_changed
();
1956 if ($errormessage) {
1957 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1958 print "<class name='base'>$errormessage\n";
1959 print " </class>\n";
1960 &Header
::closebox
();
1966 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1967 print "<class name='base'>$hint\n";
1968 print " </class>\n";
1969 &Header
::closebox
();
1975 &General
::setup_default_networks
(\
%defaultNetworks);
1976 foreach my $network (sort keys %defaultNetworks)
1978 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1983 my $searchstring=shift;
1985 #Count services used in servicegroups
1986 foreach my $key (keys %customgrp) {
1987 if($customgrp{$key}[2] eq $searchstring){
1991 #Count services used in firewall - config
1992 foreach my $key1 (keys %fwfwd) {
1993 if($fwfwd{$key1}[4] eq $searchstring){
1996 if($fwfwd{$key1}[6] eq $searchstring){
2000 #Count services used in firewall - input
2001 foreach my $key2 (keys %fwinp) {
2002 if($fwinp{$key2}[4] eq $searchstring){
2005 if($fwinp{$key2}[6] eq $searchstring){
2009 #Count services used in firewall - outgoing
2010 foreach my $key3 (keys %fwout) {
2011 if($fwout{$key3}[4] eq $searchstring){
2014 if($fwout{$key3}[6] eq $searchstring){
2022 my $searchstring=shift;
2024 #Count services used in servicegroups
2025 foreach my $key (keys %customgrp) {
2026 if($customgrp{$key}[2] eq $searchstring){
2030 #Count services used in firewall - config
2031 foreach my $key1 (keys %fwfwd) {
2032 if($fwfwd{$key1}[4] eq $searchstring){
2035 if($fwfwd{$key1}[6] eq $searchstring){
2039 #Count services used in firewall - input
2040 foreach my $key2 (keys %fwinp) {
2041 if($fwinp{$key2}[4] eq $searchstring){
2044 if($fwinp{$key2}[6] eq $searchstring){
2048 #Count services used in firewall - outgoing
2049 foreach my $key3 (keys %fwout) {
2050 if($fwout{$key3}[4] eq $searchstring){
2053 if($fwout{$key3}[6] eq $searchstring){
2061 my $searchstring=shift;
2063 #Count services used in servicegroups
2064 foreach my $key (keys %customservicegrp) {
2065 if($customservicegrp{$key}[2] eq $searchstring){
2069 #Count services used in firewall - config
2070 foreach my $key1 (keys %fwfwd) {
2071 if($fwfwd{$key1}[15] eq $searchstring){
2075 #Count services used in firewall - input
2076 foreach my $key2 (keys %fwinp) {
2077 if($fwinp{$key2}[15] eq $searchstring){
2081 #Count services used in firewall - outgoing
2082 foreach my $key3 (keys %fwout) {
2083 if($fwout{$key3}[15] eq $searchstring){
2094 &General
::readhasharray
("$config",\
%hash);
2095 foreach my $key (keys %hash) {
2096 if($hash{$key}[2] eq $target){
2100 &General
::writehasharray
("$config",\
%hash);
2107 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
2109 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
2110 $fwhostsettings{'BLK_IP'}='readonly';
2111 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2112 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2114 #check if name collides with CCD Netname
2115 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2116 foreach my $key (keys %ccdnet) {
2117 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2118 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
2119 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2120 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2124 #check if IP collides with CCD NetIP
2125 if ($fwhostsettings{'type'} ne 'mac'){
2126 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2127 foreach my $key (keys %ccdnet) {
2128 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
2129 if($ccdnet{$key}[1] eq $test){
2130 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
2131 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
2132 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
2133 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2138 #check if name collides with CCD Hostname
2139 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2140 foreach my $key (keys %ccdhost) {
2141 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
2142 if($ip eq $fwhostsettings{'IP'}){
2143 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
2144 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2148 #check if IP collides with CCD HostIP (only hosts)
2149 if ($edit eq 'edithost')
2151 foreach my $key (keys %ccdhost) {
2152 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
2153 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
2154 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
2155 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2160 #check if network with this name already exists
2161 &General
::readhasharray
("$confignet", \
%customnetwork);
2162 if (!&checkname
(\
%customnetwork))
2164 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
2165 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2166 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2168 #check if network ip already exists
2169 if (!&checkip
(\
%customnetwork,1))
2171 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
2172 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2174 #check if host with this name already exists
2175 &General
::readhasharray
("$confighost", \
%customhost);
2176 if (!&checkname
(\
%customhost))
2178 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
2179 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2180 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2182 #check if host with this ip already exists
2183 if (!&checkip
(\
%customhost,2))
2185 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
2195 #get address from IPSEC NETWORK
2196 if ($type eq 'IpSec Network'){
2197 foreach my $key (keys %ipsecconf) {
2198 if ($ipsecconf{$key}[1] eq $name){
2199 return $ipsecconf{$key}[11];
2202 &deletefromgrp
($name,$configgrp);
2205 #get address from IPSEC HOST
2206 if ($type eq 'IpSec Host'){
2207 foreach my $key (keys %ipsecconf) {
2208 if ($ipsecconf{$key}[1] eq $name){
2209 return $ipsecconf{$key}[10];
2212 &deletefromgrp
($name,$configgrp);
2215 #get address from ovpn ccd Net-2-Net
2216 if ($type eq 'OpenVPN N-2-N'){
2217 foreach my $key (keys %ccdhost) {
2218 if($ccdhost{$key}[1] eq $name){
2219 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2220 $b=&General
::iporsubtodec
($b);
2224 &deletefromgrp
($name,$configgrp);
2227 #get address from ovpn ccd static host
2228 if ($type eq 'OpenVPN static host'){
2229 foreach my $key (keys %ccdhost) {
2230 if($ccdhost{$key}[1] eq $name){
2231 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2232 $b=&General
::iporsubtodec
($b);
2236 &deletefromgrp
($name,$configgrp);
2239 #get address from ovpn ccd static net
2240 if ($type eq 'OpenVPN static network'){
2241 foreach my $key (keys %ccdnet) {
2242 if ($ccdnet{$key}[0] eq $name){
2243 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2244 $b=&General
::iporsubtodec
($b);
2250 #check custom addresses
2251 if ($type eq 'Custom Host'){
2252 foreach my $key (keys %customhost) {
2253 if ($customhost{$key}[0] eq $name){
2254 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2260 ##check custom networks
2261 if ($type eq 'Custom Network'){
2262 foreach my $key (keys %customnetwork) {
2263 if($customnetwork{$key}[0] eq $name){
2264 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2269 #check standard networks
2270 if ($type eq 'Standard Network'){
2271 if ($name =~ /OpenVPN/i){
2273 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2274 return $ovpn{'DOVPN_SUBNET'};
2276 if ($name eq 'GREEN'){
2278 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2279 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2281 if ($name eq 'BLUE'){
2283 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2284 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2286 if ($name eq 'ORANGE'){
2288 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2289 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2291 if ($name eq 'ALL'){
2292 return "0.0.0.0/0.0.0.0";
2294 if ($name =~ /IPsec/i){
2296 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2297 return $hash{'RW_NET'};
2304 &General
::readhasharray
("$confignet", \
%customnetwork);
2305 &General
::readhasharray
("$confighost", \
%customhost);
2306 foreach my $key (sort keys %customgrp ){
2307 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2308 foreach my $key1 (sort keys %customnetwork){
2309 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2310 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2316 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2317 foreach my $key2 (sort keys %customhost){
2318 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2319 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2326 &General
::writehasharray
("$confignet", \
%customnetwork);
2327 &General
::writehasharray
("$confighost", \
%customhost);
2332 &General
::readhasharray
("$configsrv", \
%customservice);
2333 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2335 foreach my $key (sort keys %customservicegrp){
2336 if ($customservicegrp{$key}[0] eq $grp ){
2337 foreach my $key2 (sort keys %customservice){
2338 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2339 $customservice{$key2}[4]--;
2344 &General
::writehasharray
("$configsrv", \
%customservice);
2352 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2353 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2354 &General
::readhasharray
("$fwconfigout", \
%fwout);
2355 #Rename group in Firewall-CONFIG
2356 foreach my $key1 (keys %fwfwd) {
2357 if($fwfwd{$key1}[$fld] eq $old){
2358 $fwfwd{$key1}[$fld]=$new;
2361 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd );
2362 #Rename group in Firewall-INPUT
2363 foreach my $key2 (keys %fwinp) {
2364 if($fwinp{$key2}[$fld] eq $old){
2365 $fwinp{$key2}[$fld]=$new;
2368 &General
::writehasharray
("$fwconfiginp", \
%fwinp );
2369 #Rename group in Firewall-OUTGOING
2370 foreach my $key3 (keys %fwout) {
2371 if($fwout{$key3}[$fld] eq $old){
2372 $fwout{$key3}[$fld]=$new;
2375 &General
::writehasharray
("$fwconfigout", \
%fwout );
2380 my %hash=%{(shift)};
2382 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2383 $errormessage=$Lang::tr
{'fwhost err name1'};
2385 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2386 $errormessage=$Lang::tr
{'fwhost err port'};
2389 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2390 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2392 #change dashes with :
2393 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2395 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2396 $fwhostsettings{'SRV_PORT'} = "1:65535";
2398 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2399 $fwhostsettings{'SRV_PORT'} = "1:$2";
2401 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2402 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2404 if($fwhostsettings{'PROT'} ne 'ICMP'){
2405 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2407 # a new service has to have a different name
2408 foreach my $key (keys %hash){
2409 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2410 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2414 return $errormessage;
2418 # Checks a hostname against RFC1035
2419 my $hostname = $_[0];
2421 # Each part should be at least two characters in length
2422 # but no more than 63 characters
2423 if (length ($hostname) < 1 || length ($hostname) > 63) {
2425 # Only valid characters are a-z, A-Z, 0-9 and -
2426 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2428 # First character can only be a letter or a digit
2429 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2431 # Last character can only be a letter or a digit
2432 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2438 # Checks a hostname against RFC1035
2440 # Each part should be at least two characters in length
2441 # but no more than 63 characters
2442 if (length ($remark) < 1 || length ($remark) > 255) {
2444 # Only valid characters are a-z, A-Z, 0-9 and -
2445 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2447 # First character can only be a letter or a digit
2448 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2450 # Last character can only be a letter or a digit
2451 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2455 &Header
::closebigbox
();
2456 &Header
::closepage
();