]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/fwhosts.cgi
3e59a9d9dbf6d4161d14990a0b76c70f5342b23e
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
;
1103 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpname')
1105 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1106 if ($fwhostsettings{'oldsrvgrpname'} ne $fwhostsettings{'srvgrp'}){
1107 #Check new groupname
1108 if (!&validhostname
($fwhostsettings{'srvgrp'})){
1109 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1111 if (!$errormessage){
1112 #Rename group in customservicegroup
1113 foreach my $key (keys %customservicegrp) {
1114 if($customservicegrp{$key}[0] eq $fwhostsettings{'oldsrvgrpname'}){
1115 $customservicegrp{$key}[0]=$fwhostsettings{'srvgrp'};
1118 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
1119 #change name in FW Rules
1120 &changenameinfw
($fwhostsettings{'oldsrvgrpname'},$fwhostsettings{'srvgrp'},15);
1124 &viewtableservicegrp
;
1126 if ($fwhostsettings{'ACTION'} eq 'changegrpname')
1128 &General
::readhasharray
("$configgrp", \
%customgrp );
1129 if ($fwhostsettings{'oldgrpname'} ne $fwhostsettings{'grp'}){
1130 #Check new groupname
1131 if (!&validhostname
($fwhostsettings{'grp'})){
1132 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1134 if (!$errormessage){
1135 #Rename group in customservicegroup
1136 foreach my $key (keys %customgrp) {
1137 if($customgrp{$key}[0] eq $fwhostsettings{'oldgrpname'}){
1138 $customgrp{$key}[0]=$fwhostsettings{'grp'};
1141 &General
::writehasharray
("$configgrp", \
%customgrp );
1142 #change name in FW Rules
1143 &changenameinfw
($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
1150 if($fwhostsettings{'ACTION'} eq '')
1156 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1157 print "$Lang::tr{'fwhost welcome'}";
1159 <br><br><table border='0' width='100%'>
1160 <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>
1161 <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>
1162 <tr><td colspan='6'><hr></td></tr></table>
1164 &Header
::closebox
();
1172 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1173 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1174 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1176 <table border='0' width='100%'>
1177 <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>
1178 <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>
1179 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1180 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1181 <tr><td colspan='6'><br><hr></td></tr><tr>
1183 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1185 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>";
1187 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'>";
1189 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>";
1190 &Header
::closebox
();
1196 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1197 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1198 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1200 <table border='0' width='100%'>
1201 <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>
1202 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1203 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1204 <tr><td colspan='5'><hr></td></tr><tr>
1207 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1210 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>";
1212 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'>";
1214 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>";
1215 &Header
::closebox
();
1222 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1223 &General
::setup_default_networks
(\
%defaultNetworks);
1224 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1225 &General
::readhasharray
("$confignet", \
%customnetwork);
1226 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1227 &General
::readhasharray
("$confighost", \
%customhost);
1228 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1232 $checked{'check1'}{'off'} = '';
1233 $checked{'check1'}{'on'} = '';
1234 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1235 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1236 $fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'};
1237 my $grp=$fwhostsettings{'grp_name'};
1238 my $rem=$fwhostsettings{'remark'};
1239 if ($fwhostsettings{'update'} eq ''){
1241 <table width='100%' border='0'>
1242 <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>
1243 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1244 <tr><td colspan='2'><br><hr></td></tr></table>
1248 <table width='100%' border='0'><form method='post' style='display:inline'>
1249 <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>
1250 <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>
1254 if ($fwhostsettings{'update'} eq 'on'){
1256 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1257 <table width='100%' border='0'>
1258 <tr><td width=50% valign='top'>
1259 <table width='100%' border='0'>
1260 <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;'>
1262 foreach my $network (sort keys %defaultNetworks)
1264 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1265 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1266 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1267 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1268 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1269 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1270 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1271 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1272 if ($ownnet{$defnet}){
1273 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1275 print ">$network</option>";
1278 print"</select></td></tr>";
1279 if (! -z
$confignet){
1280 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;'>";
1281 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1282 print"<option>$customnetwork{$key}[0]</option>";
1284 print"</select></td></tr>";
1286 if (! -z
$confighost){
1287 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;'>";
1288 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1289 print"<option>$customhost{$key}[0]</option>";
1291 print"</select></td></tr>";
1295 print"</td><td valign='top'><table width='100%' border='0'>";
1297 if (! -z
$configccdnet){
1298 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;'>";
1299 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1301 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1303 print"</select></td></tr>";
1306 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1308 if ($ccdhost{$key}[33] ne ''){
1309 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 '');
1311 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1314 if ($show eq '1'){$show='';print"</select></td></tr>";}
1316 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1317 if($ccdhost{$key}[3] eq 'net'){
1318 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 '');
1320 print"<option>$ccdhost{$key}[1]</option>";
1323 if ($show eq '1'){$show='';print"</select></td></tr>";}
1325 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1326 if ($ipsecconf{$key}[3] eq 'net'){
1327 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 '');
1329 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1332 if ($show eq '1'){$show='';print"</select></td></tr>";}
1334 print"</td></tr></table>";
1335 print"<br><br><hr>";
1337 print"<table border='0' width='100%'>";
1338 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>";
1339 &Header
::closebox
();
1345 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1346 if ($fwhostsettings{'updatesrv'} eq 'on')
1348 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1349 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1350 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1351 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1354 <table width='100%' border='0'><form method='post'>
1355 <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>
1356 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1358 foreach ("TCP","UDP","ICMP")
1360 if ($_ eq $fwhostsettings{'PROT'})
1362 print"<option selected>$_</option>";
1364 print"<option>$_</option>";
1368 </select></td></tr></table>
1369 <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'>
1371 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1372 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1373 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1374 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1375 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1377 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1381 </select></td></tr></table></div>
1382 <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>
1383 <table width='100%' border='0'><tr><td colspan='6'><br><hr></td></tr>
1384 <tr><td colspan='6' align='right'>
1386 if ($fwhostsettings{'updatesrv'} eq 'on')
1389 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1390 <input type='hidden' name='ACTION' value='updateservice'>
1391 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1392 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1393 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1394 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1398 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1401 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1404 &Header
::closebox
();
1412 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1413 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1414 $fwhostsettings{'oldsrvgrpname'}=$fwhostsettings{'SRVGRP_NAME'};
1415 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1417 <table width='100%' border='0'><form method='post'>
1418 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1419 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1420 <tr><td colspan='2'><br><hr></tr>
1425 <table width='100%' border='0'><form method='post' style='display:inline'>
1426 <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>
1427 <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>
1428 <tr><td colspan='4'><br><hr></td></td></tr>
1432 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1434 <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%'>
1435 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'add'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1437 &General
::readhasharray
("$configsrv", \
%customservice);
1438 #Protocols for use in servicegroups
1439 print "<optgroup label='$Lang::tr{'fwhost cust service'}'>";
1440 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1442 print "<option>$customservice{$key}[0]</option>";
1444 print "</optgroup>";
1445 print "<optgroup label='$Lang::tr{'protocol'}'>";
1446 print "<option>GRE</option>";
1447 print "<option>AH</option>";
1448 print "<option>ESP</option>";
1449 print "<option>IGMP</option>";
1450 print "<option>IPIP</option>";
1451 print "<option value='IPV6'>IPv6 encap</option>";
1452 print "</optgroup>";
1455 <tr><td colspan='4'><br><br></td></tr>
1456 <tr><td colspan='4'><hr></td></tr>
1461 <table width='100%' border='0'>
1462 <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>
1465 &Header
::closebox
();
1470 if(! -z
$confignet){
1471 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1472 &General
::readhasharray
("$confignet", \
%customnetwork);
1473 &General
::readhasharray
("$configgrp", \
%customgrp);
1474 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1475 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1476 &General
::readhasharray
("$fwconfigout", \
%fwout);
1477 if (!keys %customnetwork)
1479 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1482 <table border='0' width='100%' cellspacing='0'>
1483 <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>
1487 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1488 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1489 print" <tr bgcolor='${Header::colouryellow}'>";
1492 print" <tr bgcolor='$color{'color22'}'>";
1495 print" <tr bgcolor='$color{'color20'}'>";
1497 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1498 my $netcount=&getnetcount
($customnetwork{$key}[0]);
1499 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>";
1501 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1502 <input type='hidden' name='ACTION' value='editnet'>
1503 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1504 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1505 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1506 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1509 if($netcount == '0')
1511 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>";
1513 print"<td></td></tr>";
1518 &Header
::closebox
();
1525 #Check if IP is part of OpenVPN N2N subnet
1526 foreach my $key (sort keys %ccdhost){
1527 if ($ccdhost{$key}[3] eq 'net'){
1528 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1529 if (&General
::IpInSubnet
($c,$a,$b)){
1530 $tdcolor="style='color:$Header::colourovpn ;'";
1535 #Check if IP is part of OpenVPN dynamic subnet
1536 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1537 if (&General
::IpInSubnet
($c,$a,$b)){
1538 $tdcolor="style='color: $Header::colourovpn;'";
1541 #Check if IP is part of OpenVPN static subnet
1542 foreach my $key (sort keys %ccdnet){
1543 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1544 $b =&General
::iporsubtodec
($b);
1545 if (&General
::IpInSubnet
($c,$a,$b)){
1546 $tdcolor="style='color: $Header::colourovpn;'";
1550 #Check if IP is part of IPsec RW network
1551 if ($ipsecsettings{'RW_NET'} ne ''){
1552 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1553 $b=&General
::iporsubtodec
($b);
1554 if (&General
::IpInSubnet
($c,$a,$b)){
1555 $tdcolor="style='color: $Header::colourvpn;'";
1559 #Check if IP is part of a IPsec N2N network
1560 foreach my $key (sort keys %ipsecconf){
1561 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1562 if (&General
::IpInSubnet
($c,$a,$b)){
1563 $tdcolor="style='color: $Header::colourvpn;'";
1572 if (! -z
$confighost){
1573 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1574 &General
::readhasharray
("$confighost", \
%customhost);
1575 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1576 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1577 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1578 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1579 &General
::readhasharray
("$fwconfigout", \
%fwout);
1580 &General
::readhasharray
("$configgrp", \
%customgrp);
1581 if (!keys %customhost)
1583 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1586 <table border='0' width='100%' cellspacing='0'>
1587 <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>
1591 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1592 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1593 print" <tr bgcolor='${Header::colouryellow}'>";
1594 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1595 else{ print" <tr bgcolor='$color{'color20'}'>";}
1596 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1597 $customhost{$key}[4]=~s/\s+//g;
1599 $hostcount=&gethostcount
($customhost{$key}[0]);
1600 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>";
1602 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1603 <input type='hidden' name='ACTION' value='edithost' />
1604 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1605 <input type='hidden' name='IP' value='$ip' />
1606 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1607 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1610 if($hostcount == '0')
1612 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>";
1614 print"<td width='1%'></td></tr>";
1619 &Header
::closebox
();
1624 if(! -z
"$configgrp"){
1625 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1626 &General
::readhasharray
("$configgrp", \
%customgrp);
1627 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1628 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1629 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1630 &General
::readhasharray
("$confighost", \
%customhost);
1631 &General
::readhasharray
("$confignet", \
%customnetwork);
1632 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1633 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1634 &General
::readhasharray
("$fwconfigout", \
%fwout);
1642 if (!keys %customgrp)
1644 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1646 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1648 if ($helper ne $customgrp{$key}[0]){
1650 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1651 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1660 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
1661 $grpname=$customgrp{$key}[0];
1662 $remark="$customgrp{$key}[1]";
1663 if($count gt 1){ print"</table>";}
1664 print "<br><b><u>$grpname</u></b> ";
1665 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1666 my $netgrpcount=&getnetcount
($grpname);
1667 print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
1668 if($netgrpcount == '0')
1670 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>";
1672 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>";
1673 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>";
1676 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1677 print" <tr bgcolor='${Header::colouryellow}'>";
1678 }elsif ($count %2 == 0){
1679 print"<tr bgcolor='$color{'color22'}'>";
1681 print"<tr bgcolor='$color{'color20'}'>";
1683 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1684 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1685 print "<td width='39%' align='left'>";
1686 if($customgrp{$key}[3] eq 'Standard Network'){
1687 print &get_name
($customgrp{$key}[2])."</td>";
1689 print "$customgrp{$key}[2]</td>";
1691 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
1692 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1694 my ($colip,$colsub) = split("/",$ip);
1695 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1696 print"<td align='center' ".&getcolor
($colip).">".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1698 if ($delflag > 1 && $ip ne ''){
1699 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1701 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>";
1703 $helper=$customgrp{$key}[0];
1708 &Header
::closebox
();
1712 sub viewtableservice
1716 if(! -z
"$configsrv")
1718 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1719 &General
::readhasharray
("$configsrv", \
%customservice);
1720 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1721 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1722 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1723 &General
::readhasharray
("$fwconfigout", \
%fwout);
1725 <table width='100%' border='0' cellspacing='0'>
1726 <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>
1728 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1731 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1732 print" <tr bgcolor='${Header::colouryellow}'>";
1733 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1735 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1738 $srvcount=&getsrvcount
($customservice{$key}[0]);
1739 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
1740 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1742 </td><td align='center'>$srvcount x</td>
1743 <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' />
1744 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1745 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1746 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
1747 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
1749 if ($srvcount eq '0')
1751 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>";
1753 print"<td></td></tr>";
1757 &Header
::closebox
();
1760 sub viewtableservicegrp
1770 if (! -z
$configsrvgrp){
1771 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1772 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1773 &General
::readhasharray
("$configsrv", \
%customservice);
1774 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1775 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1776 &General
::readhasharray
("$fwconfigout", \
%fwout);
1777 my $number= keys %customservicegrp;
1778 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
1780 if ($helper ne $customservicegrp{$key}[0]){
1781 #Get used groupcounter
1782 $grpcount=&getsrvcount
($customservicegrp{$key}[0]);
1784 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1785 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1793 $grpname=$customservicegrp{$key}[0];
1794 if ($customservicegrp{$key}[2] eq "none"){
1795 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1799 $remark="$customservicegrp{$key}[1]";
1800 if($count >=2){print"</table>";}
1801 print "<br><b><u>$grpname</u></b> ";
1802 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1803 print " <b>$Lang::tr{'used'}:</b> $grpcount x";
1804 if($grpcount == '0')
1806 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>";
1808 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>";
1809 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>";
1811 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1812 print" <tr bgcolor='${Header::colouryellow}'>";
1813 }elsif ($count %2 == 0){
1814 print"<tr bgcolor='$color{'color22'}'>";
1816 print"<tr bgcolor='$color{'color20'}'>";
1818 #Set fields if we use protocols in servicegroups
1819 if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
1822 if ($customservicegrp{$key}[2] eq 'GRE'){$protocol='GRE';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} GRE";}
1823 if ($customservicegrp{$key}[2] eq 'ESP'){$protocol='ESP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} ESP";}
1824 if ($customservicegrp{$key}[2] eq 'AH'){$protocol='AH';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} AH";}
1825 if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
1826 if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
1827 if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
1828 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1829 foreach my $srv (sort keys %customservice){
1830 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1831 $protocol=$customservice{$srv}[2];
1832 $port=$customservice{$srv}[1];
1836 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1837 if ($delflag gt '1'){
1838 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1840 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
1841 if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
1842 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2]'></form></td></tr>";
1844 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$protocol'></form></td></tr>";
1846 $helper=$customservicegrp{$key}[0];
1849 &Header
::closebox
();
1855 my %hash=%{(shift)};
1856 foreach my $key (keys %hash) {
1857 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1866 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1868 foreach my $key (keys %customservicegrp) {
1869 if($customservicegrp{$key}[0] eq $name){
1877 &General
::readhasharray
("$configsrv", \
%customservice );
1879 foreach my $key (keys %customservice) {
1880 if($customservice{$key}[0] eq $name){
1889 my %hash=%{(shift)};
1891 foreach my $key (keys %hash) {
1892 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1900 my %hash=%{(shift)};
1901 &General
::readhasharray
("$confignet", \
%hash);
1902 foreach my $key (keys %hash) {
1903 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1910 sub checkservicegroup
1912 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1914 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1916 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1917 return $errormessage;
1919 #check empty selectbox
1920 if (keys %customservice lt 1)
1922 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1924 #check if name already exists
1925 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1926 foreach my $key (keys %customservicegrp) {
1927 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1928 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1933 #check if service already exists in group
1934 foreach my $key (keys %customservicegrp) {
1935 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1936 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1939 return $errormessage;
1943 if ($errormessage) {
1944 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1945 print "<class name='base'>$errormessage\n";
1946 print " </class>\n";
1947 &Header
::closebox
();
1953 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1954 print "<class name='base'>$hint\n";
1955 print " </class>\n";
1956 &Header
::closebox
();
1962 &General
::setup_default_networks
(\
%defaultNetworks);
1963 foreach my $network (sort keys %defaultNetworks)
1965 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1970 my $searchstring=shift;
1972 #Count services used in servicegroups
1973 foreach my $key (keys %customgrp) {
1974 if($customgrp{$key}[2] eq $searchstring){
1978 #Count services used in firewall - config
1979 foreach my $key1 (keys %fwfwd) {
1980 if($fwfwd{$key1}[4] eq $searchstring){
1983 if($fwfwd{$key1}[6] eq $searchstring){
1987 #Count services used in firewall - input
1988 foreach my $key2 (keys %fwinp) {
1989 if($fwinp{$key2}[4] eq $searchstring){
1992 if($fwinp{$key2}[6] eq $searchstring){
1996 #Count services used in firewall - outgoing
1997 foreach my $key3 (keys %fwout) {
1998 if($fwout{$key3}[4] eq $searchstring){
2001 if($fwout{$key3}[6] eq $searchstring){
2009 my $searchstring=shift;
2011 #Count services used in servicegroups
2012 foreach my $key (keys %customgrp) {
2013 if($customgrp{$key}[2] eq $searchstring){
2017 #Count services used in firewall - config
2018 foreach my $key1 (keys %fwfwd) {
2019 if($fwfwd{$key1}[4] eq $searchstring){
2022 if($fwfwd{$key1}[6] eq $searchstring){
2026 #Count services used in firewall - input
2027 foreach my $key2 (keys %fwinp) {
2028 if($fwinp{$key2}[4] eq $searchstring){
2031 if($fwinp{$key2}[6] eq $searchstring){
2035 #Count services used in firewall - outgoing
2036 foreach my $key3 (keys %fwout) {
2037 if($fwout{$key3}[4] eq $searchstring){
2040 if($fwout{$key3}[6] eq $searchstring){
2048 my $searchstring=shift;
2050 #Count services used in servicegroups
2051 foreach my $key (keys %customservicegrp) {
2052 if($customservicegrp{$key}[2] eq $searchstring){
2056 #Count services used in firewall - config
2057 foreach my $key1 (keys %fwfwd) {
2058 if($fwfwd{$key1}[15] eq $searchstring){
2062 #Count services used in firewall - input
2063 foreach my $key2 (keys %fwinp) {
2064 if($fwinp{$key2}[15] eq $searchstring){
2068 #Count services used in firewall - outgoing
2069 foreach my $key3 (keys %fwout) {
2070 if($fwout{$key3}[15] eq $searchstring){
2081 &General
::readhasharray
("$config",\
%hash);
2082 foreach my $key (keys %hash) {
2083 if($hash{$key}[2] eq $target){
2087 &General
::writehasharray
("$config",\
%hash);
2094 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
2096 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
2097 $fwhostsettings{'BLK_IP'}='readonly';
2098 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2099 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2101 #check if name collides with CCD Netname
2102 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2103 foreach my $key (keys %ccdnet) {
2104 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2105 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
2106 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2107 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2111 #check if IP collides with CCD NetIP
2112 if ($fwhostsettings{'type'} ne 'mac'){
2113 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2114 foreach my $key (keys %ccdnet) {
2115 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
2116 if($ccdnet{$key}[1] eq $test){
2117 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
2118 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
2119 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
2120 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2125 #check if name collides with CCD Hostname
2126 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2127 foreach my $key (keys %ccdhost) {
2128 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
2129 if($ip eq $fwhostsettings{'IP'}){
2130 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
2131 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2135 #check if IP collides with CCD HostIP (only hosts)
2136 if ($edit eq 'edithost')
2138 foreach my $key (keys %ccdhost) {
2139 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
2140 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
2141 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
2142 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2147 #check if network with this name already exists
2148 &General
::readhasharray
("$confignet", \
%customnetwork);
2149 if (!&checkname
(\
%customnetwork))
2151 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
2152 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2153 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2155 #check if network ip already exists
2156 if (!&checkip
(\
%customnetwork,1))
2158 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
2159 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2161 #check if host with this name already exists
2162 &General
::readhasharray
("$confighost", \
%customhost);
2163 if (!&checkname
(\
%customhost))
2165 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
2166 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2167 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2169 #check if host with this ip already exists
2170 if (!&checkip
(\
%customhost,2))
2172 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
2182 #get address from IPSEC NETWORK
2183 if ($type eq 'IpSec Network'){
2184 foreach my $key (keys %ipsecconf) {
2185 if ($ipsecconf{$key}[1] eq $name){
2186 return $ipsecconf{$key}[11];
2189 &deletefromgrp
($name,$configgrp);
2192 #get address from IPSEC HOST
2193 if ($type eq 'IpSec Host'){
2194 foreach my $key (keys %ipsecconf) {
2195 if ($ipsecconf{$key}[1] eq $name){
2196 return $ipsecconf{$key}[10];
2199 &deletefromgrp
($name,$configgrp);
2202 #get address from ovpn ccd Net-2-Net
2203 if ($type eq 'OpenVPN N-2-N'){
2204 foreach my $key (keys %ccdhost) {
2205 if($ccdhost{$key}[1] eq $name){
2206 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2207 $b=&General
::iporsubtodec
($b);
2211 &deletefromgrp
($name,$configgrp);
2214 #get address from ovpn ccd static host
2215 if ($type eq 'OpenVPN static host'){
2216 foreach my $key (keys %ccdhost) {
2217 if($ccdhost{$key}[1] eq $name){
2218 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2219 $b=&General
::iporsubtodec
($b);
2223 &deletefromgrp
($name,$configgrp);
2226 #get address from ovpn ccd static net
2227 if ($type eq 'OpenVPN static network'){
2228 foreach my $key (keys %ccdnet) {
2229 if ($ccdnet{$key}[0] eq $name){
2230 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2231 $b=&General
::iporsubtodec
($b);
2237 #check custom addresses
2238 if ($type eq 'Custom Host'){
2239 foreach my $key (keys %customhost) {
2240 if ($customhost{$key}[0] eq $name){
2241 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2247 ##check custom networks
2248 if ($type eq 'Custom Network'){
2249 foreach my $key (keys %customnetwork) {
2250 if($customnetwork{$key}[0] eq $name){
2251 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2256 #check standard networks
2257 if ($type eq 'Standard Network'){
2258 if ($name =~ /OpenVPN/i){
2260 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2261 return $ovpn{'DOVPN_SUBNET'};
2263 if ($name eq 'GREEN'){
2265 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2266 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2268 if ($name eq 'BLUE'){
2270 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2271 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2273 if ($name eq 'ORANGE'){
2275 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2276 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2278 if ($name eq 'ALL'){
2279 return "0.0.0.0/0.0.0.0";
2281 if ($name =~ /IPsec/i){
2283 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2284 return $hash{'RW_NET'};
2291 &General
::readhasharray
("$confignet", \
%customnetwork);
2292 &General
::readhasharray
("$confighost", \
%customhost);
2293 foreach my $key (sort keys %customgrp ){
2294 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2295 foreach my $key1 (sort keys %customnetwork){
2296 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2297 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2303 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2304 foreach my $key2 (sort keys %customhost){
2305 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2306 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2313 &General
::writehasharray
("$confignet", \
%customnetwork);
2314 &General
::writehasharray
("$confighost", \
%customhost);
2319 &General
::readhasharray
("$configsrv", \
%customservice);
2320 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2322 foreach my $key (sort keys %customservicegrp){
2323 if ($customservicegrp{$key}[0] eq $grp ){
2324 foreach my $key2 (sort keys %customservice){
2325 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2326 $customservice{$key2}[4]--;
2331 &General
::writehasharray
("$configsrv", \
%customservice);
2339 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2340 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2341 &General
::readhasharray
("$fwconfigout", \
%fwout);
2342 #Rename group in Firewall-CONFIG
2343 foreach my $key1 (keys %fwfwd) {
2344 if($fwfwd{$key1}[$fld] eq $old){
2345 $fwfwd{$key1}[$fld]=$new;
2348 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd );
2349 #Rename group in Firewall-INPUT
2350 foreach my $key2 (keys %fwinp) {
2351 if($fwinp{$key2}[$fld] eq $old){
2352 $fwinp{$key2}[$fld]=$new;
2355 &General
::writehasharray
("$fwconfiginp", \
%fwinp );
2356 #Rename group in Firewall-OUTGOING
2357 foreach my $key3 (keys %fwout) {
2358 if($fwout{$key3}[$fld] eq $old){
2359 $fwout{$key3}[$fld]=$new;
2362 &General
::writehasharray
("$fwconfigout", \
%fwout );
2367 my %hash=%{(shift)};
2369 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2370 $errormessage=$Lang::tr
{'fwhost err name1'};
2372 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2373 $errormessage=$Lang::tr
{'fwhost err port'};
2376 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2377 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2379 #change dashes with :
2380 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2382 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2383 $fwhostsettings{'SRV_PORT'} = "1:65535";
2385 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2386 $fwhostsettings{'SRV_PORT'} = "1:$2";
2388 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2389 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2391 if($fwhostsettings{'PROT'} ne 'ICMP'){
2392 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2394 # a new service has to have a different name
2395 foreach my $key (keys %hash){
2396 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2397 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2401 return $errormessage;
2405 # Checks a hostname against RFC1035
2406 my $hostname = $_[0];
2408 # Each part should be at least two characters in length
2409 # but no more than 63 characters
2410 if (length ($hostname) < 1 || length ($hostname) > 63) {
2412 # Only valid characters are a-z, A-Z, 0-9 and -
2413 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2415 # First character can only be a letter or a digit
2416 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2418 # Last character can only be a letter or a digit
2419 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2425 # Checks a hostname against RFC1035
2427 # Each part should be at least two characters in length
2428 # but no more than 63 characters
2429 if (length ($remark) < 1 || length ($remark) > 255) {
2431 # Only valid characters are a-z, A-Z, 0-9 and -
2432 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2434 # First character can only be a letter or a digit
2435 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2437 # Last character can only be a letter or a digit
2438 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2442 &Header
::closebigbox
();
2443 &Header
::closepage
();