]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/fwhosts.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
23 # enable only the following on debugging purpose
27 use CGI
::Carp
'fatalsToBrowser';
28 no warnings
'uninitialized';
29 require '/var/ipfire/general-functions.pl';
30 require "${General::swroot}/lang.pl";
31 require "${General::swroot}/header.pl";
33 my %fwhostsettings=();
38 my %customservicegrp=();
44 my %defaultNetworks=();
57 my $confignet = "${General::swroot}/fwhosts/customnetworks";
58 my $confighost = "${General::swroot}/fwhosts/customhosts";
59 my $configgrp = "${General::swroot}/fwhosts/customgroups";
60 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
61 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
62 my $configipsec = "${General::swroot}/vpn/config";
63 my $configsrv = "${General::swroot}/fwhosts/customservices";
64 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
65 my $fwconfigfwd = "${General::swroot}/firewall/config";
66 my $fwconfiginp = "${General::swroot}/firewall/input";
67 my $fwconfigout = "${General::swroot}/firewall/outgoing";
68 my $configovpn = "${General::swroot}/ovpn/settings";
70 my $configipsecrw = "${General::swroot}/vpn/settings";
72 unless (-e
$confignet) { system("touch $confignet"); }
73 unless (-e
$confighost) { system("touch $confighost"); }
74 unless (-e
$configgrp) { system("touch $configgrp"); }
75 unless (-e
$configsrv) { system("touch $configsrv"); }
76 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
78 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
79 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
80 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
81 &General
::readhash
("$configovpn", \
%ovpnsettings);
82 &General
::readhasharray
("$configipsec", \
%ipsecconf);
83 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
84 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
85 &Header
::getcgihash
(\
%fwhostsettings);
87 &Header
::showhttpheaders
();
88 &Header
::openpage
($Lang::tr
{'fwhost menu'}, 1, '');
89 &Header
::openbigbox
('100%', 'center');
94 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
95 var update_protocol = function() {
96 var protocol = \$("#protocol").val();
98 if (protocol === undefined)
101 // Check if we are dealing with a protocol, that knows ports.
102 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
104 \$("#PROTOKOLL").hide();
107 \$("#PROTOKOLL").show();
111 \$(document).ready(function() {
112 var protocol = \$("#protocol").val();
113 \$("#protocol").change(update_protocol);
115 // Automatically select radio buttons when corresponding
116 // dropdown menu changes.
117 \$("select").change(function() {
118 var id = \$(this).attr("name");
119 \$('#' + id).prop("checked", true);
127 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
129 &General
::readhasharray
("$confignet", \
%customnetwork);
130 foreach my $key (keys %customnetwork)
132 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
134 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
135 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
136 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
137 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
138 $fwhostsettings{'count'} = $customnetwork{$key}[4];
139 delete $customnetwork{$key};
143 &General
::writehasharray
("$confignet", \
%customnetwork);
144 $fwhostsettings{'actualize'} = 'on';
145 $fwhostsettings{'ACTION'} = 'savenet';
147 if ($fwhostsettings{'ACTION'} eq 'updatehost')
150 &General
::readhasharray
("$confighost", \
%customhost);
151 foreach my $key (keys %customhost)
153 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
155 if ($customhost{$key}[1] eq 'ip'){
156 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
158 $ip = $customhost{$key}[2];
160 $fwhostsettings{'orgip'} = $ip;
161 $fwhostsettings{'count'} = $customhost{$key}[4];
162 delete $customhost{$key};
163 &General
::writehasharray
("$confighost", \
%customhost);
166 $fwhostsettings{'actualize'} = 'on';
167 if($fwhostsettings{'orgip'}){
168 $fwhostsettings{'ACTION'} = 'savehost';
170 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
173 if ($fwhostsettings{'ACTION'} eq 'updateservice')
177 $errormessage=&checkports
(\
%customservice);
178 if ($fwhostsettings{'oldsrvname'} ne $fwhostsettings{'SRV_NAME'} && !&checkgroup
($fwhostsettings{'SRV_NAME'})){
179 $errormessage=$Lang::tr
{'fwhost err grpexist'};
182 &General
::readhasharray
("$configsrv", \
%customservice);
183 foreach my $key (keys %customservice)
185 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
187 delete $customservice{$key};
188 &General
::writehasharray
("$configsrv", \
%customservice);
192 if ($fwhostsettings{'PROT'} ne 'ICMP'){
193 $fwhostsettings{'ICMP_TYPES'}='BLANK';
195 my $key1 = &General
::findhasharraykey
(\
%customservice);
196 #find out short ICMP-TYPE
197 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
198 foreach my $key (keys %icmptypes){
199 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
200 $fwhostsettings{'ICMP_TYPES'}=$icmptypes{$key}[0];
203 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
204 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
205 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
206 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
207 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
208 &General
::writehasharray
("$configsrv", \
%customservice);
209 #check if we need to update firewallrules
210 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
211 if ( ! -z
$fwconfigfwd ){
212 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
213 foreach my $key (sort keys %fwfwd){
214 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
215 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
218 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
220 if ( ! -z
$fwconfiginp ){
221 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
222 foreach my $line (sort keys %fwinp){
223 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
224 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
227 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
229 if ( ! -z
$fwconfigout ){
230 &General
::readhasharray
("$fwconfigout", \
%fwout);
231 foreach my $line (sort keys %fwout){
232 if ($fwout{$line}[15] eq $fwhostsettings{'oldsrvname'}){
233 $fwout{$line}[15] = $fwhostsettings{'SRV_NAME'};
236 &General
::writehasharray
("$fwconfigout", \
%fwout);
238 #check if we need to update groups
239 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
240 foreach my $key (sort keys %customservicegrp){
241 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
242 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
243 &checkrulereload
($customservicegrp{$key}[0]);
246 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
248 &checkrulereload
($fwhostsettings{'SRV_NAME'});
249 $fwhostsettings{'SRV_NAME'} = '';
250 $fwhostsettings{'SRV_PORT'} = '';
251 $fwhostsettings{'PROT'} = '';
252 $fwhostsettings{'ICMP'} = '';
253 $fwhostsettings{'oldsrvicmp'} = '';
254 $fwhostsettings{'updatesrv'} = '';
256 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
257 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
258 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
259 $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
260 $fwhostsettings{'updatesrv'}= 'on';
265 if ($fwhostsettings{'ACTION'} eq 'savenet' )
268 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
269 #check if all fields are set
270 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
272 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
277 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
279 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
280 $fwhostsettings{'BLK_HOST'} ='readonly';
281 $fwhostsettings{'NOCHECK'} ='false';
282 $fwhostsettings{'error'} ='on';
285 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
286 $errormessage=$Lang::tr
{'fwhost err remark'};
287 $fwhostsettings{'error'} ='on';
289 #check if subnet is sigle host
290 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
292 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
294 if($fwhostsettings{'error'} ne 'on'){
295 #check if we use one of ipfire's networks (green,orange,blue)
296 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
298 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
299 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
300 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
302 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
304 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
305 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
306 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
308 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
310 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
311 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
312 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
314 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
316 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
317 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
318 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
321 #only check plausi when no error till now
323 &plausicheck
("editnet");
325 #check if network ip is part of an already used one
326 if(&checksubnet
(\
%customnetwork))
328 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
329 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
331 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
333 $fwhostsettings{'actualize'} = '';
334 my $key = &General
::findhasharraykey
(\
%customnetwork);
335 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
336 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
337 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
338 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
339 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
340 &General
::writehasharray
("$confignet", \
%customnetwork);
341 undef %customnetwork;
345 &General
::readhasharray
("$confignet", \
%customnetwork);
346 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
347 if ($fwhostsettings{'update'} == '0'){
348 foreach my $key (keys %customnetwork) {
349 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
350 delete $customnetwork{$key};
356 #get count if actualize is 'on'
357 if($fwhostsettings{'actualize'} eq 'on'){
358 $fwhostsettings{'actualize'} = '';
359 #check if we need to reload rules
360 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
363 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
364 #check if we need to update groups
365 &General
::readhasharray
("$configgrp", \
%customgrp);
366 foreach my $key (sort keys %customgrp){
367 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
368 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
372 &General
::writehasharray
("$configgrp", \
%customgrp);
373 #check if we need to update firewallrules
374 if ( ! -z
$fwconfigfwd ){
375 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
376 foreach my $line (sort keys %fwfwd){
377 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
378 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
380 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
381 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
384 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
386 if ( ! -z
$fwconfiginp ){
387 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
388 foreach my $line (sort keys %fwinp){
389 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
390 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
393 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
397 my $key = &General
::findhasharraykey
(\
%customnetwork);
398 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
399 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
400 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
401 #convert ip when leading '0' in byte
402 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
403 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
404 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
405 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
406 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
407 &General
::writehasharray
("$confignet", \
%customnetwork);
408 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
409 undef %customnetwork;
410 $fwhostsettings{'HOSTNAME'}='';
411 $fwhostsettings{'IP'}='';
412 $fwhostsettings{'SUBNET'}='';
413 $fwhostsettings{'NETREMARK'}='';
414 #check if an edited net affected groups and need to reload rules
415 if ($needrules eq 'on'){
416 &General
::firewall_config_changed
();
426 if ($fwhostsettings{'ACTION'} eq 'savehost')
429 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
430 $fwhostsettings{'SUBNET'}='32';
431 #check if all fields are set
432 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
434 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
435 $fwhostsettings{'ACTION'} = 'edithost';
437 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
438 $fwhostsettings{'type'} = 'mac';
439 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
440 $fwhostsettings{'type'} = 'ip';
442 $fwhostsettings{'type'} = '';
443 $errormessage=$Lang::tr
{'fwhost err ipmac'};
446 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
447 $errormessage=$Lang::tr
{'fwhost err remark'};
450 if ($fwhostsettings{'type'} eq 'ip'){
452 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
453 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
455 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
456 $fwhostsettings{'error'}='on';
458 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
459 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
460 $fwhostsettings{'error'}='on';
462 #check if net or broadcast
463 my @tmp= split (/\./,$fwhostsettings{'IP'});
464 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
465 $errormessage=$Lang::tr
{'fwhost err hostip'};
468 #only check plausi when no error till now
470 &plausicheck
("edithost");
472 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
473 $fwhostsettings{'actualize'} = '';
474 my $key = &General
::findhasharraykey
(\
%customhost);
475 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
476 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
477 $customhost{$key}[1] = $fwhostsettings{'type'} ;
478 if($customhost{$key}[1] eq 'ip'){
479 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
481 $customhost{$key}[2] = $fwhostsettings{'orgip'};
483 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
484 &General
::writehasharray
("$confighost", \
%customhost);
488 #get count if host was edited
489 if($fwhostsettings{'actualize'} eq 'on'){
490 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
493 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
494 #check if we need to update groups
495 &General
::readhasharray
("$configgrp", \
%customgrp);
496 foreach my $key (sort keys %customgrp){
497 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
498 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
501 &General
::writehasharray
("$configgrp", \
%customgrp);
502 #check if we need to update firewallrules
503 if ( ! -z
$fwconfigfwd ){
504 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
505 foreach my $line (sort keys %fwfwd){
506 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
507 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
509 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
510 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
513 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
515 if ( ! -z
$fwconfiginp ){
516 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
517 foreach my $line (sort keys %fwinp){
518 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
519 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
522 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
526 my $key = &General
::findhasharraykey
(\
%customhost);
527 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
528 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
529 $customhost{$key}[1] = $fwhostsettings{'type'} ;
530 if ($fwhostsettings{'type'} eq 'ip'){
531 #convert ip when leading '0' in byte
532 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
533 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
534 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
536 $customhost{$key}[2] = $fwhostsettings{'IP'};
538 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
539 &General
::writehasharray
("$confighost", \
%customhost);
541 $fwhostsettings{'HOSTNAME'}='';
542 $fwhostsettings{'IP'}='';
543 $fwhostsettings{'type'}='';
544 $fwhostsettings{'HOSTREMARK'}='';
545 #check if we need to update rules while host was edited
546 if($needrules eq 'on'){
547 &General
::firewall_config_changed
();
557 if ($fwhostsettings{'ACTION'} eq 'savegrp')
559 my $grp=$fwhostsettings{'grp_name'};
560 my $rem=$fwhostsettings{'remark'};
563 my $updcounter='off';
566 &General
::readhasharray
("$configgrp", \
%customgrp);
567 &General
::readhasharray
("$confignet", \
%customnetwork);
568 &General
::readhasharray
("$confighost", \
%customhost);
569 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
570 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
571 &General
::readhasharray
("$fwconfigout", \
%fwout);
573 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
575 if (!&checkgroup
($grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
577 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
578 $errormessage.=$Lang::tr
{'fwhost err remark'};
580 if ($fwhostsettings{'update'} eq 'on'){
581 #check standard networks
582 if ($fwhostsettings{'grp2'} eq 'std_net'){
583 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
584 $type='Standard Network';
586 #check custom networks
587 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
588 @target=$fwhostsettings{'CUST_SRC_NET'};
590 $type='Custom Network';
591 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
592 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
593 $fwhostsettings{'grp_name'}='';
594 $fwhostsettings{'remark'}='';
596 #check custom addresses
597 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
598 @target=$fwhostsettings{'CUST_SRC_HOST'};
601 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
602 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
603 $fwhostsettings{'grp_name'}='';
604 $fwhostsettings{'remark'}='';
606 #get address from ovpn ccd static net
607 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
608 @target=$fwhostsettings{'OVPN_CCD_NET'};
609 $type='OpenVPN static network';
610 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
611 $errormessage=$Lang::tr
{'fwhost err groupempty'};
612 $fwhostsettings{'grp_name'}='';
613 $fwhostsettings{'remark'}='';
615 #get address from ovpn ccd static host
616 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
617 @target=$fwhostsettings{'OVPN_CCD_HOST'};
618 $type='OpenVPN static host';
619 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
620 $errormessage=$Lang::tr
{'fwhost err groupempty'};
622 #get address from ovpn ccd Net-2-Net
623 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
624 @target=$fwhostsettings{'OVPN_N2N'};
625 $type='OpenVPN N-2-N';
626 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
627 $errormessage=$Lang::tr
{'fwhost err groupempty'};
628 $fwhostsettings{'grp_name'}='';
629 $fwhostsettings{'remark'}='';
631 #get address from IPSEC HOST
632 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
633 @target=$fwhostsettings{'IPSEC_HOST'};
635 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
636 $errormessage=$Lang::tr
{'fwhost err groupempty'};
637 $fwhostsettings{'grp_name'}='';
638 $fwhostsettings{'remark'}='';
640 #get address from IPSEC NETWORK
641 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
642 @target=$fwhostsettings{'IPSEC_NET'};
643 $type='IpSec Network';
644 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
645 $errormessage=$Lang::tr
{'fwhost err groupempty'};
646 $fwhostsettings{'grp_name'}='';
647 $fwhostsettings{'remark'}='';
649 #check if host/net exists in grp
651 my $test="$grp,$fwhostsettings{'oldremark'},@target";
652 foreach my $key (keys %customgrp) {
653 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
654 if ($test1 eq $test){
655 $errormessage=$Lang::tr
{'fwhost err isingrp'};
656 $fwhostsettings{'update'} = 'on';
662 #on first save, we have an empty @target, so fill it with nothing
663 my $targetvalues=@target;
664 if ($targetvalues == '0'){
667 #on update, we have to delete the dummy entry
668 foreach my $key (keys %customgrp){
669 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
670 delete $customgrp{$key};
674 &General
::writehasharray
("$configgrp", \
%customgrp);
675 &General
::readhasharray
("$configgrp", \
%customgrp);
676 #create array with new lines
677 foreach my $line (@target){
678 push (@newgrp,"$grp,$rem,$line");
681 my $key = &General
::findhasharraykey
(\
%customgrp);
682 foreach my $line (@newgrp){
683 foreach my $i (0 .. 3) { $customgrp{$key}[$i] = "";}
684 my ($a,$b,$c,$d) = split (",",$line);
685 $customgrp{$key}[0] = $a;
686 $customgrp{$key}[1] = $b;
687 $customgrp{$key}[2] = $c;
688 $customgrp{$key}[3] = $type;
690 &General
::writehasharray
("$configgrp", \
%customgrp);
691 #update counter in Host/Net
692 $fwhostsettings{'update'}='on';
694 #check if ruleupdate is needed
696 $netgrpcount=&getnetcount
($grp);
697 if($netgrpcount > 0 )
699 &General
::firewall_config_changed
();
704 if ($fwhostsettings{'ACTION'} eq 'saveservice')
707 &General
::readhasharray
("$configsrv", \
%customservice );
708 &General
::readhasharray
("$configgrp", \
%customgrp);
709 $errormessage=&checkports
(\
%customservice);
710 if ($fwhostsettings{'PROT'} eq 'ICMP'){
711 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
712 foreach my $key (keys %icmptypes){
713 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
714 $ICMP=$icmptypes{$key}[0];
718 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
719 if ($fwhostsettings{'PROT'} ne 'ICMP'){$ICMP='BLANK';}
720 #Check if a group with the same name already exists
721 if (!&checkgroup
($fwhostsettings{'SRV_NAME'})){
722 $errormessage = $Lang::tr
{'fwhost err grpexist'};
725 my $key = &General
::findhasharraykey
(\
%customservice);
726 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
727 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
728 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
729 $customservice{$key}[2] = $fwhostsettings{'PROT'};
730 $customservice{$key}[3] = $ICMP;
731 &General
::writehasharray
("$configsrv", \
%customservice );
733 $fwhostsettings{'SRV_NAME'}='';
734 $fwhostsettings{'SRV_PORT'}='';
735 $fwhostsettings{'PROT'}='';
736 $fwhostsettings{'ICMP_TYPES'}='';
740 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
746 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
747 &General
::readhasharray
("$configsrv", \
%customservice );
748 $errormessage=&checkservicegroup
;
749 #Check if we have more than 15 services from one Protocol in the group
750 #iptables can only handle 15 ports/portranges via multiport
751 foreach my $key (keys %customservicegrp){
752 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
753 foreach my $key1 (keys %customservice){
754 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
755 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
756 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
757 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
761 if ($tcpcounter > 15){
762 $errormessage=$Lang::tr
{'fwhost err maxservicetcp'};
764 if ($udpcounter > 15){
765 $errormessage=$Lang::tr
{'fwhost err maxserviceudp'};
770 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
771 $errormessage .= $Lang::tr
{'fwhost err remark'};
773 #Check if there is already a service with the same name
774 if(!&checkservice
($fwhostsettings{'SRVGRP_NAME'})){
775 $errormessage .= $Lang::tr
{'fwhost err srv exists'};
778 #on first save, we have to enter a dummy value
779 if ($fwhostsettings{'CUST_SRV'} eq ''){
780 $fwhostsettings{'CUST_SRV'}='none';
782 #on update, we have to delete the dummy entry
783 foreach my $key (keys %customservicegrp){
784 if ($customservicegrp{$key}[2] eq 'none' && $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
785 delete $customservicegrp{$key};
789 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
790 #check if remark has also changed
791 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
793 foreach my $key (keys %customservicegrp)
795 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
797 $customservicegrp{$key}[1]='';
798 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
802 my $key = &General
::findhasharraykey
(\
%customservicegrp);
803 foreach my $i (0 .. 2) { $customservice{$key}[$i] = "";}
804 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
805 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
806 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
807 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
808 $fwhostsettings{'updatesrvgrp'}='on';
810 &checkrulereload
($fwhostsettings{'SRVGRP_NAME'});
812 &viewtableservicegrp
;
815 if ($fwhostsettings{'ACTION'} eq 'editnet')
820 if ($fwhostsettings{'ACTION'} eq 'edithost')
825 if ($fwhostsettings{'ACTION'} eq 'editgrp')
827 $fwhostsettings{'update'}='on';
831 if ($fwhostsettings{'ACTION'} eq 'editservice')
833 $fwhostsettings{'updatesrv'}='on';
836 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
838 $fwhostsettings{'updatesrvgrp'} = 'on';
840 &viewtableservicegrp
;
843 if ($fwhostsettings{'ACTION'} eq 'resetnet')
845 $fwhostsettings{'HOSTNAME'} ="";
846 $fwhostsettings{'IP'} ="";
847 $fwhostsettings{'SUBNET'} ="";
850 if ($fwhostsettings{'ACTION'} eq 'resethost')
852 $fwhostsettings{'HOSTNAME'} ="";
853 $fwhostsettings{'IP'} ="";
854 $fwhostsettings{'type'} ="";
857 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
859 $fwhostsettings{'grp_name'} ="";
860 $fwhostsettings{'remark'} ="";
864 if ($fwhostsettings{'ACTION'} eq 'delnet')
866 &General
::readhasharray
("$confignet", \
%customnetwork);
867 foreach my $key (keys %customnetwork) {
868 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
869 delete $customnetwork{$key};
870 &General
::writehasharray
("$confignet", \
%customnetwork);
877 if ($fwhostsettings{'ACTION'} eq 'delhost')
879 &General
::readhasharray
("$confighost", \
%customhost);
880 foreach my $key (keys %customhost) {
881 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
882 delete $customhost{$key};
883 &General
::writehasharray
("$confighost", \
%customhost);
890 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
894 &General
::readhasharray
("$configgrp", \
%customgrp);
895 foreach my $key (keys %customgrp){
896 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
897 $grpname=$customgrp{$key}[0];
898 $grpremark=$customgrp{$key}[1];
899 #check if we delete the last entry, then generate dummy
900 if ($fwhostsettings{'last'} eq 'on'){
901 $customgrp{$key}[1] = '';
902 $customgrp{$key}[2] = 'none';
903 $customgrp{$key}[3] = '';
904 $fwhostsettings{'last'}='';
907 delete $customgrp{$key};
911 &General
::writehasharray
("$configgrp", \
%customgrp);
912 &General
::firewall_config_changed
();
913 if ($fwhostsettings{'grpcnt'} > 0){
914 &General
::firewall_config_changed
();
916 if ($fwhostsettings{'update'} eq 'on'){
917 $fwhostsettings{'remark'}= $grpremark;
918 $fwhostsettings{'grp_name'}=$grpname;
923 if ($fwhostsettings{'ACTION'} eq 'delgrp')
925 &General
::readhasharray
("$configgrp", \
%customgrp);
926 &decrease
($fwhostsettings{'grp_name'});
927 foreach my $key (sort keys %customgrp)
929 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
931 delete $customgrp{$key};
934 &General
::writehasharray
("$configgrp", \
%customgrp);
935 $fwhostsettings{'grp_name'}='';
939 if ($fwhostsettings{'ACTION'} eq 'delservice')
941 &General
::readhasharray
("$configsrv", \
%customservice);
942 foreach my $key (keys %customservice) {
943 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
944 delete $customservice{$key};
945 &General
::writehasharray
("$configsrv", \
%customservice);
949 $fwhostsettings{'SRV_NAME'}='';
950 $fwhostsettings{'SRV_PORT'}='';
951 $fwhostsettings{'PROT'}='';
954 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
956 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
957 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
958 foreach my $key (sort keys %customservicegrp)
960 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
962 delete $customservicegrp{$key};
965 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
966 $fwhostsettings{'SRVGRP_NAME'}='';
968 &viewtableservicegrp
;
970 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
974 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
975 foreach my $key (keys %customservicegrp){
976 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'})
978 $grpname=$customservicegrp{$key}[0];
979 $grpremark=$customservicegrp{$key}[1];
980 if($fwhostsettings{'last'} eq 'on'){
981 $customservicegrp{$key}[2] = 'none';
982 $fwhostsettings{'last'} = '';
985 delete $customservicegrp{$key};
989 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
990 &General
::firewall_config_changed
();
991 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
992 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
993 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
996 &viewtableservicegrp
;
998 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1003 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1008 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1013 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1017 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1020 &viewtableservicegrp
;
1022 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1024 &General
::readhasharray
("$configgrp", \
%customgrp);
1025 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1026 foreach my $key (sort keys %customgrp)
1028 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1030 $customgrp{$key}[1]='';
1031 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1034 &General
::writehasharray
("$configgrp", \
%customgrp);
1035 $fwhostsettings{'update'}='on';
1036 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1038 $errormessage=$Lang::tr
{'fwhost err remark'};
1039 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1040 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1041 $fwhostsettings{'update'} = 'on';
1043 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1047 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1049 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1050 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1051 foreach my $key (sort keys %customservicegrp)
1053 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1055 $customservicegrp{$key}[1]='';
1056 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1059 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1060 $fwhostsettings{'updatesrvgrp'}='on';
1061 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1062 }elsif($fwhostsettings{'oldsrvrem'} eq $fwhostsettings{'newsrvrem'}){
1064 &viewtableservicegrp
;
1066 $errormessage=$Lang::tr
{'fwhost err remark'};
1067 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1068 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1069 $fwhostsettings{'updatesrvgrp'} = 'on';
1071 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1073 &viewtableservicegrp
;
1075 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpname')
1077 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1078 if ($fwhostsettings{'oldsrvgrpname'} ne $fwhostsettings{'srvgrp'}){
1079 #Check new groupname
1080 if (!&validhostname
($fwhostsettings{'srvgrp'})){
1081 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1083 if (!$errormessage){
1084 #Rename group in customservicegroup
1085 foreach my $key (keys %customservicegrp) {
1086 if($customservicegrp{$key}[0] eq $fwhostsettings{'oldsrvgrpname'}){
1087 $customservicegrp{$key}[0]=$fwhostsettings{'srvgrp'};
1090 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
1091 #change name in FW Rules
1092 &changenameinfw
($fwhostsettings{'oldsrvgrpname'},$fwhostsettings{'srvgrp'},15);
1096 &viewtableservicegrp
;
1098 if ($fwhostsettings{'ACTION'} eq 'changegrpname')
1100 &General
::readhasharray
("$configgrp", \
%customgrp );
1101 if ($fwhostsettings{'oldgrpname'} ne $fwhostsettings{'grp'}){
1102 #Check new groupname
1103 if (!&validhostname
($fwhostsettings{'grp'})){
1104 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1106 if (!$errormessage){
1107 #Rename group in customservicegroup
1108 foreach my $key (keys %customgrp) {
1109 if($customgrp{$key}[0] eq $fwhostsettings{'oldgrpname'}){
1110 $customgrp{$key}[0]=$fwhostsettings{'grp'};
1113 &General
::writehasharray
("$configgrp", \
%customgrp );
1114 #change name in FW Rules
1115 &changenameinfw
($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
1122 if($fwhostsettings{'ACTION'} eq '')
1128 &Header
::openbox
('100%', 'left',);
1129 print "$Lang::tr{'fwhost welcome'}";
1131 <br><br><table border='0' width='100%'>
1132 <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>
1133 <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>
1134 <tr><td colspan='6'></td></tr></table>
1136 &Header
::closebox
();
1144 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1145 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1146 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1148 <table border='0' width='100%' >
1149 <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>
1150 <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>
1151 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1152 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1153 <tr><td colspan='6'><br></td></tr><tr>
1155 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1157 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'}'>";
1159 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'>";
1161 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>";
1162 &Header
::closebox
();
1168 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1169 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1170 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1172 <table width='100%'>
1173 <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>
1174 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1175 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1176 <tr><td colspan='5'><br></td></tr><tr>
1179 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1182 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>";
1184 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'>";
1186 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>";
1187 &Header
::closebox
();
1194 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1195 &General
::setup_default_networks
(\
%defaultNetworks);
1196 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1197 &General
::readhasharray
("$confignet", \
%customnetwork);
1198 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1199 &General
::readhasharray
("$confighost", \
%customhost);
1200 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1204 $checked{'check1'}{'off'} = '';
1205 $checked{'check1'}{'on'} = '';
1206 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1207 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1208 $fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'};
1209 my $grp=$fwhostsettings{'grp_name'};
1210 my $rem=$fwhostsettings{'remark'};
1211 if ($fwhostsettings{'update'} eq ''){
1213 <table width='100%' border='0'>
1215 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1216 <td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='30'></td>
1219 <td>$Lang::tr{'remark'}:</td>
1220 <td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 99%;'></td>
1223 <td colspan='2'><br></td>
1229 <table width='100%' border='0'><form method='post'>
1231 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1232 <td style='width:30%;'><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' size='30'></td>
1233 <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>
1236 <tr><form method='post' style='display:inline'>
1237 <td>$Lang::tr{'remark'}:</td>
1238 <td colspan='2' style='width:98%;'><input type='TEXT' name='newrem' value='$fwhostsettings{'remark'}' style='width:98%;'></td>
1239 <td align='right'><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='grp' value='$fwhostsettings{'grp_name'}'><input type='hidden' name='oldrem' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='ACTION' value='changegrpremark' ></td>
1245 if ($fwhostsettings{'update'} eq 'on'){
1247 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1248 <table width='100%' border='0'>
1249 <tr><td width=50% valign='top'>
1250 <table width='90%' border='0'>
1252 <td style='width:15em;'>
1254 <input type='radio' name='grp2' value='std_net' id='DEFAULT_SRC_ADR' checked>
1255 $Lang::tr{'fwhost stdnet'}
1258 <td style='text-align:right;'>
1259 <select name='DEFAULT_SRC_ADR' style='width:16em;'>
1261 foreach my $network (sort keys %defaultNetworks)
1263 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1264 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1265 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1266 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1267 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1268 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1269 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1270 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1271 if ($ownnet{$defnet}){
1272 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1274 print ">$network</option>";
1277 print"</select></td></tr>";
1278 if (! -z
$confignet){
1283 <input type='radio' name='grp2' id='CUST_SRC_NET' value='cust_net' $checked{'grp2'}{'cust_net'}>
1284 $Lang::tr{'fwhost cust net'}:
1287 <td style='text-align:right;'>
1288 <select name='CUST_SRC_NET' style='width:16em;'>";
1290 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1291 print"<option>$customnetwork{$key}[0]</option>";
1293 print"</select></td></tr>";
1295 if (! -z
$confighost){
1300 <input type='radio' name='grp2' id='CUST_SRC_HOST' value='cust_host' $checked{'grp2'}{'cust_host'}>
1301 $Lang::tr{'fwhost cust addr'}:
1304 <td style='text-align:right;'>
1305 <select name='CUST_SRC_HOST' style='width:16em;'>";
1307 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1308 print"<option>$customhost{$key}[0]</option>";
1310 print"</select></td></tr>";
1314 print"</td><td align='right' style='vertical-align:top;'><table width='90%' border='0'>";
1316 if (! -z
$configccdnet){
1318 <td style='width:15em;'>
1320 <input type='radio' name='grp2' id='OVPN_CCD_NET' value='ovpn_net' $checked{'grp2'}{'ovpn_net'}>
1321 $Lang::tr{'fwhost ccdnet'}
1324 <td style='text-align:right;'>
1325 <select name='OVPN_CCD_NET' style='width:16em;'>";
1327 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1329 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1331 print"</select></td></tr>";
1334 my @ovpn_clients=();
1335 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1337 if ($ccdhost{$key}[33] ne ''){
1339 push (@ovpn_clients,$ccdhost{$key}[1]);
1345 <td style='width:15em;'>
1347 <input type='radio' name='grp2' value='ovpn_host' $checked{'grp2'}{'ovpn_host'}>
1348 $Lang::tr{'fwhost ccdhost'}
1351 <td style='text-align:right;'>
1352 <select name='OVPN_CCD_HOST' style='width:16em;'>" if ($show eq '');
1354 foreach(@ovpn_clients){
1355 print"<option value='$_'>$_</option>";
1357 print"</select></td></tr>";
1361 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1362 if($ccdhost{$key}[3] eq 'net'){
1364 push (@OVPN_N2N,$ccdhost{$key}[1]);
1370 <td style='width:15em;'>
1372 <input type='radio' name='grp2' id='OVPN_N2N' value='ovpn_n2n' $checked{'grp2'}{'ovpn_n2n'}>
1373 $Lang::tr{'fwhost ovpn_n2n'}:
1376 <td style='text-align:right;'>
1377 <select name='OVPN_N2N' style='width:16em;'>"
1380 print"<option>$_</option>";
1382 print"</select></td></tr>";
1386 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1387 if ($ipsecconf{$key}[3] eq 'net'){
1389 push (@IPSEC_N2N,$ipsecconf{$key}[1]);
1395 <td style='width:15em;'>
1397 <input type='radio' name='grp2' id='IPSEC_NET' value='ipsec_net' $checked{'grp2'}{'ipsec_net'}>
1398 $Lang::tr{'fwhost ipsec net'}
1401 <td style='text-align:right;'>
1402 <select name='IPSEC_NET' style='width:16em;'>"
1404 foreach(@IPSEC_N2N){
1405 print"<option value='$_'>$_</option>";
1408 print"</select></td></tr>";
1410 print"</td></tr></table>";
1413 print"<table width='100%'>";
1414 print"<tr><td style='text-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>";
1415 &Header
::closebox
();
1421 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1422 if ($fwhostsettings{'updatesrv'} eq 'on')
1424 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1425 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1426 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1427 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1430 <table width='100%' border='0'><form method='post'>
1431 <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>
1432 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1434 foreach ("TCP","UDP","ICMP")
1436 if ($_ eq $fwhostsettings{'PROT'})
1438 print"<option selected>$_</option>";
1440 print"<option>$_</option>";
1444 </select></td></tr></table>
1445 <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'>
1447 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1448 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1449 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1450 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1451 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1453 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1457 </select></td></tr></table></div>
1458 <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>
1459 <table width='100%' border='0'><tr><td colspan='6'><br></td></tr>
1460 <tr><td colspan='6' align='right'>
1462 if ($fwhostsettings{'updatesrv'} eq 'on')
1465 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1466 <input type='hidden' name='ACTION' value='updateservice'>
1467 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1468 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1469 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1470 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1474 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1477 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1480 &Header
::closebox
();
1488 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1489 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1490 $fwhostsettings{'oldsrvgrpname'}=$fwhostsettings{'SRVGRP_NAME'};
1491 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1493 <table width='100%' border='0'><form method='post'>
1494 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1495 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1496 <tr><td colspan='2'><br></tr>
1501 <table width='100%'><form method='post' style='display:inline'>
1502 <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>
1504 <form method='post'>
1506 $Lang::tr{'remark'}:
1509 <input type='text' name='newsrvrem' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width:98%;'>
1512 <input type='submit' value='$Lang::tr{'fwhost change'}'>
1513 <input type='hidden' name='oldsrvrem' value='$fwhostsettings{'oldsrvgrpremark'}'>
1514 <input type='hidden' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}'>
1515 <input type='hidden' name='ACTION' value='changesrvgrpremark' >
1527 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1529 <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%'>
1530 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'add'}: </td><td><select name='CUST_SRV' style='min-width:185px;'>
1532 &General
::readhasharray
("$configsrv", \
%customservice);
1533 #Protocols for use in servicegroups
1534 print "<optgroup label='$Lang::tr{'fwhost cust service'}'>";
1535 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1537 print "<option>$customservice{$key}[0]</option>";
1539 print "</optgroup>";
1540 print "<optgroup label='$Lang::tr{'protocol'}'>";
1541 print "<option>GRE</option>";
1542 print "<option>AH</option>";
1543 print "<option>ESP</option>";
1544 print "<option>IGMP</option>";
1545 print "<option>IPIP</option>";
1546 print "<option value='IPV6'>IPv6 encap</option>";
1547 print "</optgroup>";
1550 <tr><td colspan='4'><br><br></td></tr>
1551 <tr><td colspan='4'></td></tr>
1556 <table width='100%'>
1557 <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>
1560 &Header
::closebox
();
1565 if(! -z
$confignet){
1566 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1567 &General
::readhasharray
("$confignet", \
%customnetwork);
1568 &General
::readhasharray
("$configgrp", \
%customgrp);
1569 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1570 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1571 &General
::readhasharray
("$fwconfigout", \
%fwout);
1573 if (!keys %customnetwork)
1575 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1578 <table width='100%' cellspacing='0' class='tbl'>
1579 <tr><th align='center'><b>$Lang::tr{'name'}</b></th><th align='center'><b>$Lang::tr{'fwhost netaddress'}</b></th><th align='center'><b>$Lang::tr{'remark'}</b></th><th align='center'><b>$Lang::tr{'used'}</b></th><th></th><th width='3%'></th></tr>
1584 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1585 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1587 $col="bgcolor='${Header::colouryellow}'";
1590 $col="bgcolor='$color{'color20'}'";
1594 $col="bgcolor='$color{'color22'}'";
1597 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1598 my $netcount=&getnetcount
($customnetwork{$key}[0]);
1599 print"<td width='20%' $col><form method='post'>$customnetwork{$key}[0]</td><td width='15%' align='center' $col>".&getcolor
($colnet)."</td><td width='40%' $col>$customnetwork{$key}[3]</td><td align='center' $col>$netcount x</td>";
1601 <td width='1%' $col><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
1602 <input type='hidden' name='ACTION' value='editnet'>
1603 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1604 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1605 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1606 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1609 if($netcount == '0')
1611 print"<td width='1%' $col><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>";
1613 print"<td $col></td></tr>";
1618 &Header
::closebox
();
1628 if (&General
::validmac
($c)){ return $c;}
1630 #Check if we got a full IP with subnet then split it
1631 if($c =~ /^(.*?)\/(.*?
)$/){
1632 ($sip,$scidr) = split ("/",$c);
1637 #Now check if IP is part of ORANGE,BLUE or GREEN
1638 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1639 $tdcolor="<font style='color: $Header::colourorange;'>$c</font>";
1642 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1643 $tdcolor="<font style='color: $Header::colourgreen;'>$c</font>";
1646 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1647 $tdcolor="<font style='color: $Header::colourblue;'>$c</font>";
1651 #Check if IP is part of OpenVPN N2N subnet
1652 foreach my $key (sort keys %ccdhost){
1653 if ($ccdhost{$key}[3] eq 'net'){
1654 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1655 if (&General
::IpInSubnet
($sip,$a,$b)){
1656 $tdcolor="<font style='color:$Header::colourovpn ;'>$c</font>";
1662 #Check if IP is part of OpenVPN dynamic subnet
1663 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1664 if (&General
::IpInSubnet
($sip,$a,$b)){
1665 $tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
1669 #Check if IP is part of OpenVPN static subnet
1670 foreach my $key (sort keys %ccdnet){
1671 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1672 $b =&General
::iporsubtodec
($b);
1673 if (&General
::IpInSubnet
($sip,$a,$b)){
1674 $tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
1679 #Check if IP is part of IPsec RW network
1680 if ($ipsecsettings{'RW_NET'} ne ''){
1681 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1682 $b=&General
::iporsubtodec
($b);
1683 if (&General
::IpInSubnet
($sip,$a,$b)){
1684 $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
1689 #Check if IP is part of a IPsec N2N network
1690 foreach my $key (sort keys %ipsecconf){
1691 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1692 if (&General
::IpInSubnet
($sip,$a,$b)){
1693 $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
1701 if (! -z
$confighost){
1702 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1703 &General
::readhasharray
("$confighost", \
%customhost);
1704 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1705 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1706 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1707 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1708 &General
::readhasharray
("$fwconfigout", \
%fwout);
1709 &General
::readhasharray
("$configgrp", \
%customgrp);
1710 if (!keys %customhost)
1712 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1715 <table width='100%' cellspacing='0' class='tbl'>
1716 <tr><th align='center'><b>$Lang::tr{'name'}</b></th><th align='center'><b>$Lang::tr{'fwhost ip_mac'}</b></th><th align='center'><b>$Lang::tr{'remark'}</b></th><th align='center'><b>$Lang::tr{'used'}</b></th><th></th><th width='3%'></th></tr>
1721 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1722 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1724 $col="bgcolor='${Header::colouryellow}'";
1725 }elsif ($count % 2){
1727 $col="bgcolor='$color{'color20'}'";
1729 $col="bgcolor='$color{'color22'}'";
1732 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1733 $customhost{$key}[4]=~s/\s+//g;
1735 $hostcount=&gethostcount
($customhost{$key}[0]);
1736 print"<td width='20%' $col>$customhost{$key}[0]</td><td width='20%' align='center' $col >".&getcolor
($ip)."</td><td width='50%' align='left' $col>$customhost{$key}[3]</td><td align='center' $col>$hostcount x</td>";
1738 <td width='1%' $col><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
1739 <input type='hidden' name='ACTION' value='edithost' />
1740 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1741 <input type='hidden' name='IP' value='$ip' />
1742 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1743 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1746 if($hostcount == '0')
1748 print"<td width='1%' $col><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>";
1750 print"<td width='1%' $col></td></tr>";
1755 &Header
::closebox
();
1760 if(! -z
"$configgrp"){
1761 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1762 &General
::readhasharray
("$configgrp", \
%customgrp);
1763 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1764 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1765 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1766 &General
::readhasharray
("$confighost", \
%customhost);
1767 &General
::readhasharray
("$confignet", \
%customnetwork);
1768 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1769 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1770 &General
::readhasharray
("$fwconfigout", \
%fwout);
1780 if (!keys %customgrp)
1782 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1784 #get all groups in a hash
1785 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1786 push (@counter,$customgrp{$key}[0]);
1788 foreach my $key1 (@counter) {
1791 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1793 if ($helper ne $customgrp{$key}[0]){
1795 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1796 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1805 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
1806 $grpname=$customgrp{$key}[0];
1807 $remark="$customgrp{$key}[1]";
1808 if($count gt 1){ print"</table>";$count=1;}
1809 print "<br><b><u>$grpname</u></b> ";
1810 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1811 my $netgrpcount=&getnetcount
($grpname);
1812 print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
1813 if($netgrpcount == '0')
1815 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>";
1817 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>";
1818 print"<table width='100%' cellspacing='0' class='tbl'><tr><th align='center'><b>$Lang::tr{'name'}</b></th><th align='center'><b>$Lang::tr{'fwhost ip_mac'}</b></th><th align='center' width='25%'><b>$Lang::tr{'fwhost type'}</th><th></th></tr>";
1821 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1823 $col="bgcolor='${Header::colouryellow}'";
1824 }elsif ($count %2 == 0){
1826 $col="bgcolor='$color{'color20'}'";
1829 $col="bgcolor='$color{'color22'}'";
1831 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1834 $col="bgcolor='${Header::colouryellow}'";
1836 print "<td width='39%' align='left' $col>";
1837 if($customgrp{$key}[3] eq 'Standard Network'){
1838 print &get_name
($customgrp{$key}[2])."</td>";
1840 print "$customgrp{$key}[2]</td>";
1842 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
1843 print "<td align='center' $col>$Lang::tr{'fwhost deleted'}</td><td align='center' $col>$customgrp{$key}[3]</td><td width='1%' $col><form method='post'>";
1845 my ($colip,$colsub) = split("/",$ip);
1846 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1847 print"<td align='center' $col>".&getcolor
($ip)."</td><td align='center' $col>$customgrp{$key}[3]</td><td width='1%' $col><form method='post'>";
1849 if ($delflag > 0 && $ip ne ''){
1850 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' />";
1851 #check if this group has only one entry
1852 foreach my $key2 (keys %hash) {
1853 if ($hash{$key2}<2 && $key2 eq $customgrp{$key}[0]){
1854 print "<input type='hidden' name='last' value='on'>" ;
1858 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>";
1860 $helper=$customgrp{$key}[0];
1865 &Header
::closebox
();
1869 sub viewtableservice
1873 if(! -z
"$configsrv")
1875 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1876 &General
::readhasharray
("$configsrv", \
%customservice);
1877 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1878 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1879 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1880 &General
::readhasharray
("$fwconfigout", \
%fwout);
1882 <table width='100%' cellspacing='0' class='tbl'>
1883 <tr><th align='center'><b>$Lang::tr{'fwhost srv_name'}</b></th><th align='center'><b>$Lang::tr{'fwhost prot'}</b></th><th align='center'><b>$Lang::tr{'fwhost port'}</b></th><th align='center'><b>ICMP</b></th><th align='center'><b>$Lang::tr{'fwhost used'}</b></th><th></th><th width='3%'></th></tr>
1886 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1889 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1891 $col="bgcolor='${Header::colouryellow}'";
1892 }elsif ($count % 2){
1894 $col="bgcolor='$color{'color22'}'";
1897 $col="bgcolor='$color{'color20'}'";
1900 <td $col>$customservice{$key}[0]</td><td align='center' $col>$customservice{$key}[2]</td><td align='center' $col>$customservice{$key}[1]</td><td align='center' $col>
1903 $srvcount=&getsrvcount
($customservice{$key}[0]);
1904 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
1905 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1907 </td><td align='center' $col>$srvcount x</td>
1908 <td width='1%' $col><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' />
1909 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1910 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1911 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
1912 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
1914 if ($srvcount eq '0')
1916 print"<td width='1%' $col><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>";
1918 print"<td $col></td></tr>";
1922 &Header
::closebox
();
1925 sub viewtableservicegrp
1940 if (! -z
$configsrvgrp){
1941 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1942 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1943 &General
::readhasharray
("$configsrv", \
%customservice);
1944 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1945 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1946 &General
::readhasharray
("$fwconfigout", \
%fwout);
1947 my $number= keys %customservicegrp;
1948 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
1949 push (@counter,$customservicegrp{$key}[0]);
1951 foreach my $key1 (@counter) {
1954 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
1956 if ($helper ne $customservicegrp{$key}[0]){
1957 #Get used groupcounter
1958 $grpcount=&getsrvcount
($customservicegrp{$key}[0]);
1960 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1961 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1969 $grpname=$customservicegrp{$key}[0];
1970 if ($customservicegrp{$key}[2] eq "none"){
1971 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};
1975 $remark="$customservicegrp{$key}[1]";
1976 if($count >0){print"</table>";$count=1;}
1977 print "<br><b><u>$grpname</u></b> ";
1978 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1979 print " <b>$Lang::tr{'used'}:</b> $grpcount x";
1980 if($grpcount == '0')
1982 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>";
1984 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>";
1985 print"<table width='100%' cellspacing='0' class='tbl'><tr><th align='center'><b>Name</b></th><th align='center'><b>$Lang::tr{'port'}</b></th><th align='center' width='25%'><b>$Lang::tr{'fwhost prot'}</th><th></th></tr>";
1987 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1989 $col="bgcolor='${Header::colouryellow}'";
1990 }elsif ($count %2 == 0){
1992 $col="bgcolor='$color{'color20'}'";
1995 $col="bgcolor='$color{'color22'}'";
1997 #make lines yellow if it is a dummy entry
1998 if ($customservicegrp{$key}[2] eq $Lang::tr
{'fwhost err emptytable'}){
2000 $col="bgcolor='${Header::colouryellow}'";
2002 #Set fields if we use protocols in servicegroups
2003 if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
2006 if ($customservicegrp{$key}[2] eq 'GRE'){$protocol='GRE';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} GRE";}
2007 if ($customservicegrp{$key}[2] eq 'ESP'){$protocol='ESP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} ESP";}
2008 if ($customservicegrp{$key}[2] eq 'AH'){$protocol='AH';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} AH";}
2009 if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
2010 if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
2011 if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
2012 print "<td width='39%' $col>$customservicegrp{$key}[2]</td>";
2013 foreach my $srv (sort keys %customservice){
2014 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
2015 $protocol=$customservice{$srv}[2];
2016 $port=$customservice{$srv}[1];
2020 print"<td align='center' $col>$port</td><td align='center' $col>$protocol</td><td width='1%' $col><form method='post'>";
2021 if ($delflag gt '0'){
2022 if ($customservicegrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
2023 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title=$Lang::tr{'delete'} />";
2025 #check if this group has only one entry
2026 foreach my $key2 (keys %hash) {
2027 if ($hash{$key2}<2 && $key2 eq $customservicegrp{$key}[0]){
2028 print "<input type='hidden' name='last' value='on'>" ;
2032 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
2033 if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
2034 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2]'></form></td></tr>";
2036 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$protocol'></form></td></tr>";
2038 $helper=$customservicegrp{$key}[0];
2041 &Header
::closebox
();
2047 my %hash=%{(shift)};
2048 foreach my $key (keys %hash) {
2049 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2058 &General
::readhasharray
("$configgrp", \
%customgrp );
2060 foreach my $key (keys %customservicegrp) {
2061 if($customservicegrp{$key}[0] eq $name){
2069 &General
::readhasharray
("$configsrv", \
%customservice );
2071 foreach my $key (keys %customservice) {
2072 if($customservice{$key}[0] eq $name){
2081 my %hash=%{(shift)};
2083 foreach my $key (keys %hash) {
2084 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
2092 my %hash=%{(shift)};
2093 &General
::readhasharray
("$confignet", \
%hash);
2094 foreach my $key (keys %hash) {
2095 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
2102 sub checkservicegroup
2104 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2106 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
2108 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
2109 return $errormessage;
2111 #check empty selectbox
2112 if (keys %customservice lt 1)
2114 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
2116 #check if name already exists
2117 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
2118 foreach my $key (keys %customservicegrp) {
2119 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
2120 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
2125 #check if service already exists in group
2126 foreach my $key (keys %customservicegrp) {
2127 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
2128 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
2131 return $errormessage;
2136 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2137 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2138 &General
::readhasharray
("$fwconfigout", \
%fwout);
2140 #check if service or servicegroup is used in rules
2141 foreach my $key (keys %fwfwd){
2142 if($search eq $fwfwd{$key}[15]){
2143 &General
::firewall_config_changed
();
2147 foreach my $key (keys %fwinp){
2148 if($search eq $fwinp{$key}[15]){
2149 &General
::firewall_config_changed
();
2153 foreach my $key (keys %fwout){
2154 if($search eq $fwout{$key}[15]){
2155 &General
::firewall_config_changed
();
2162 if ($errormessage) {
2163 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
2164 print "<class name='base'>$errormessage\n";
2165 print " </class>\n";
2166 &Header
::closebox
();
2172 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
2173 print "<class name='base'>$hint\n";
2174 print " </class>\n";
2175 &Header
::closebox
();
2181 &General
::setup_default_networks
(\
%defaultNetworks);
2182 foreach my $network (sort keys %defaultNetworks)
2184 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
2189 my $searchstring=shift;
2191 #Count services used in servicegroups
2192 foreach my $key (keys %customgrp) {
2193 if($customgrp{$key}[2] eq $searchstring){
2197 #Count services used in firewall - config
2198 foreach my $key1 (keys %fwfwd) {
2199 if($fwfwd{$key1}[4] eq $searchstring){
2202 if($fwfwd{$key1}[6] eq $searchstring){
2206 #Count services used in firewall - input
2207 foreach my $key2 (keys %fwinp) {
2208 if($fwinp{$key2}[4] eq $searchstring){
2211 if($fwinp{$key2}[6] eq $searchstring){
2215 #Count services used in firewall - outgoing
2216 foreach my $key3 (keys %fwout) {
2217 if($fwout{$key3}[4] eq $searchstring){
2220 if($fwout{$key3}[6] eq $searchstring){
2228 my $searchstring=shift;
2230 #Count services used in servicegroups
2231 foreach my $key (keys %customgrp) {
2232 if($customgrp{$key}[2] eq $searchstring){
2236 #Count services used in firewall - config
2237 foreach my $key1 (keys %fwfwd) {
2238 if($fwfwd{$key1}[4] eq $searchstring){
2241 if($fwfwd{$key1}[6] eq $searchstring){
2245 #Count services used in firewall - input
2246 foreach my $key2 (keys %fwinp) {
2247 if($fwinp{$key2}[4] eq $searchstring){
2250 if($fwinp{$key2}[6] eq $searchstring){
2254 #Count services used in firewall - outgoing
2255 foreach my $key3 (keys %fwout) {
2256 if($fwout{$key3}[4] eq $searchstring){
2259 if($fwout{$key3}[6] eq $searchstring){
2267 my $searchstring=shift;
2269 #Count services used in servicegroups
2270 foreach my $key (keys %customservicegrp) {
2271 if($customservicegrp{$key}[2] eq $searchstring){
2275 #Count services used in firewall - config
2276 foreach my $key1 (keys %fwfwd) {
2277 if($fwfwd{$key1}[15] eq $searchstring){
2281 #Count services used in firewall - input
2282 foreach my $key2 (keys %fwinp) {
2283 if($fwinp{$key2}[15] eq $searchstring){
2287 #Count services used in firewall - outgoing
2288 foreach my $key3 (keys %fwout) {
2289 if($fwout{$key3}[15] eq $searchstring){
2300 &General
::readhasharray
("$config",\
%hash);
2301 foreach my $key (keys %hash) {
2302 if($hash{$key}[2] eq $target){
2306 &General
::writehasharray
("$config",\
%hash);
2313 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
2315 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
2316 $fwhostsettings{'BLK_IP'}='readonly';
2317 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2318 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2320 #check if name collides with CCD Netname
2321 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2322 foreach my $key (keys %ccdnet) {
2323 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2324 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
2325 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2326 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2330 #check if IP collides with CCD NetIP
2331 if ($fwhostsettings{'type'} ne 'mac'){
2332 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2333 foreach my $key (keys %ccdnet) {
2334 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
2335 if($ccdnet{$key}[1] eq $test){
2336 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
2337 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
2338 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
2339 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2344 #check if name collides with CCD Hostname
2345 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2346 foreach my $key (keys %ccdhost) {
2347 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
2348 if($ip eq $fwhostsettings{'IP'}){
2349 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
2350 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2354 #check if IP collides with CCD HostIP (only hosts)
2355 if ($edit eq 'edithost')
2357 foreach my $key (keys %ccdhost) {
2358 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
2359 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
2360 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
2361 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2366 #check if network with this name already exists
2367 &General
::readhasharray
("$confignet", \
%customnetwork);
2368 if (!&checkname
(\
%customnetwork))
2370 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
2371 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2372 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2374 #check if network ip already exists
2375 if (!&checkip
(\
%customnetwork,1))
2377 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
2378 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2380 #check if host with this name already exists
2381 &General
::readhasharray
("$confighost", \
%customhost);
2382 if (!&checkname
(\
%customhost))
2384 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
2385 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2386 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2388 #check if host with this ip already exists
2389 if (!&checkip
(\
%customhost,2))
2391 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
2401 #get address from IPSEC NETWORK
2402 if ($type eq 'IpSec Network'){
2403 foreach my $key (keys %ipsecconf) {
2404 if ($ipsecconf{$key}[1] eq $name){
2405 return $ipsecconf{$key}[11];
2408 &deletefromgrp
($name,$configgrp);
2411 #get address from IPSEC HOST
2412 if ($type eq 'IpSec Host'){
2413 foreach my $key (keys %ipsecconf) {
2414 if ($ipsecconf{$key}[1] eq $name){
2415 return $ipsecconf{$key}[10];
2418 &deletefromgrp
($name,$configgrp);
2421 #get address from ovpn ccd Net-2-Net
2422 if ($type eq 'OpenVPN N-2-N'){
2423 foreach my $key (keys %ccdhost) {
2424 if($ccdhost{$key}[1] eq $name){
2425 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2426 $b=&General
::iporsubtodec
($b);
2430 &deletefromgrp
($name,$configgrp);
2433 #get address from ovpn ccd static host
2434 if ($type eq 'OpenVPN static host'){
2435 foreach my $key (keys %ccdhost) {
2436 if($ccdhost{$key}[1] eq $name){
2437 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2438 $b=&General
::iporsubtodec
($b);
2442 &deletefromgrp
($name,$configgrp);
2445 #get address from ovpn ccd static net
2446 if ($type eq 'OpenVPN static network'){
2447 foreach my $key (keys %ccdnet) {
2448 if ($ccdnet{$key}[0] eq $name){
2449 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2450 $b=&General
::iporsubtodec
($b);
2456 #check custom addresses
2457 if ($type eq 'Custom Host'){
2458 foreach my $key (keys %customhost) {
2459 if ($customhost{$key}[0] eq $name){
2460 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2466 ##check custom networks
2467 if ($type eq 'Custom Network'){
2468 foreach my $key (keys %customnetwork) {
2469 if($customnetwork{$key}[0] eq $name){
2470 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2475 #check standard networks
2476 if ($type eq 'Standard Network'){
2477 if ($name =~ /OpenVPN/i){
2479 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2480 return $ovpn{'DOVPN_SUBNET'};
2482 if ($name eq 'GREEN'){
2484 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2485 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2487 if ($name eq 'BLUE'){
2489 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2490 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2492 if ($name eq 'ORANGE'){
2494 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2495 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2497 if ($name eq 'ALL'){
2498 return "0.0.0.0/0.0.0.0";
2500 if ($name =~ /IPsec/i){
2502 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2503 return $hash{'RW_NET'};
2510 &General
::readhasharray
("$confignet", \
%customnetwork);
2511 &General
::readhasharray
("$confighost", \
%customhost);
2512 foreach my $key (sort keys %customgrp ){
2513 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2514 foreach my $key1 (sort keys %customnetwork){
2515 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2516 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2522 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2523 foreach my $key2 (sort keys %customhost){
2524 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2525 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2532 &General
::writehasharray
("$confignet", \
%customnetwork);
2533 &General
::writehasharray
("$confighost", \
%customhost);
2538 &General
::readhasharray
("$configsrv", \
%customservice);
2539 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2541 foreach my $key (sort keys %customservicegrp){
2542 if ($customservicegrp{$key}[0] eq $grp ){
2543 foreach my $key2 (sort keys %customservice){
2544 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2545 $customservice{$key2}[4]--;
2550 &General
::writehasharray
("$configsrv", \
%customservice);
2558 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2559 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2560 &General
::readhasharray
("$fwconfigout", \
%fwout);
2561 #Rename group in Firewall-CONFIG
2562 foreach my $key1 (keys %fwfwd) {
2563 if($fwfwd{$key1}[$fld] eq $old){
2564 $fwfwd{$key1}[$fld]=$new;
2567 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd );
2568 #Rename group in Firewall-INPUT
2569 foreach my $key2 (keys %fwinp) {
2570 if($fwinp{$key2}[$fld] eq $old){
2571 $fwinp{$key2}[$fld]=$new;
2574 &General
::writehasharray
("$fwconfiginp", \
%fwinp );
2575 #Rename group in Firewall-OUTGOING
2576 foreach my $key3 (keys %fwout) {
2577 if($fwout{$key3}[$fld] eq $old){
2578 $fwout{$key3}[$fld]=$new;
2581 &General
::writehasharray
("$fwconfigout", \
%fwout );
2586 my %hash=%{(shift)};
2588 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2589 $errormessage=$Lang::tr
{'fwhost err name1'};
2591 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2592 $errormessage=$Lang::tr
{'fwhost err port'};
2595 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2596 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2598 #change dashes with :
2599 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2601 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2602 $fwhostsettings{'SRV_PORT'} = "1:65535";
2604 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2605 $fwhostsettings{'SRV_PORT'} = "1:$2";
2607 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2608 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2610 if($fwhostsettings{'PROT'} ne 'ICMP'){
2611 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2613 # a new service has to have a different name
2614 foreach my $key (keys %hash){
2615 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2616 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2620 return $errormessage;
2624 # Checks a hostname against RFC1035
2625 my $hostname = $_[0];
2627 # Each part should be at least two characters in length
2628 # but no more than 63 characters
2629 if (length ($hostname) < 1 || length ($hostname) > 63) {
2631 # Only valid characters are a-z, A-Z, 0-9 and -
2632 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2634 # First character can only be a letter or a digit
2635 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2637 # Last character can only be a letter or a digit
2638 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2644 # Checks a hostname against RFC1035
2646 # Each part should be at least two characters in length
2647 # but no more than 63 characters
2648 if (length ($remark) < 1 || length ($remark) > 255) {
2650 # Only valid characters are a-z, A-Z, 0-9 and -
2651 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2653 # First character can only be a letter or a digit
2654 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2656 # Last character can only be a letter or a digit
2657 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2661 &Header
::closebigbox
();
2662 &Header
::closepage
();