]>
git.ipfire.org Git - people/pmueller/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 "/var/ipfire/geoip-functions.pl";
31 require "/usr/lib/firewall/firewall-lib.pl";
32 require "${General::swroot}/lang.pl";
33 require "${General::swroot}/header.pl";
35 my %fwhostsettings=();
40 my %customservicegrp=();
41 my %customgeoipgrp=();
47 my %defaultNetworks=();
60 my $confignet = "${General::swroot}/fwhosts/customnetworks";
61 my $confighost = "${General::swroot}/fwhosts/customhosts";
62 my $configgrp = "${General::swroot}/fwhosts/customgroups";
63 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
64 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
65 my $configipsec = "${General::swroot}/vpn/config";
66 my $configsrv = "${General::swroot}/fwhosts/customservices";
67 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
68 my $configgeoipgrp = "${General::swroot}/fwhosts/customgeoipgrp";
69 my $fwconfigfwd = "${General::swroot}/firewall/config";
70 my $fwconfiginp = "${General::swroot}/firewall/input";
71 my $fwconfigout = "${General::swroot}/firewall/outgoing";
72 my $configovpn = "${General::swroot}/ovpn/settings";
73 my $configipsecrw = "${General::swroot}/vpn/settings";
75 unless (-e
$confignet) { system("touch $confignet"); }
76 unless (-e
$confighost) { system("touch $confighost"); }
77 unless (-e
$configgrp) { system("touch $configgrp"); }
78 unless (-e
$configsrv) { system("touch $configsrv"); }
79 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
80 unless (-e
$configgeoipgrp) { system("touch $configgeoipgrp"); }
82 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
83 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
84 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
85 &General
::readhash
("$configovpn", \
%ovpnsettings);
86 &General
::readhasharray
("$configipsec", \
%ipsecconf);
87 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
88 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
89 &Header
::getcgihash
(\
%fwhostsettings);
91 &Header
::showhttpheaders
();
92 &Header
::openpage
($Lang::tr
{'fwhost menu'}, 1, '');
93 &Header
::openbigbox
('100%', 'center');
98 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
99 var update_protocol = function() {
100 var protocol = \$("#protocol").val();
102 if (protocol === undefined)
105 // Check if we are dealing with a protocol, that knows ports.
106 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
108 \$("#PROTOKOLL").hide();
111 \$("#PROTOKOLL").show();
115 \$(document).ready(function() {
116 var protocol = \$("#protocol").val();
117 \$("#protocol").change(update_protocol);
119 // Automatically select radio buttons when corresponding
120 // dropdown menu changes.
121 \$("select").change(function() {
122 var id = \$(this).attr("name");
123 \$('#' + id).prop("checked", true);
131 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
133 &General
::readhasharray
("$confignet", \
%customnetwork);
134 foreach my $key (keys %customnetwork)
136 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
138 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
139 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
140 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
141 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
142 $fwhostsettings{'count'} = $customnetwork{$key}[4];
143 delete $customnetwork{$key};
147 &General
::writehasharray
("$confignet", \
%customnetwork);
148 $fwhostsettings{'actualize'} = 'on';
149 $fwhostsettings{'ACTION'} = 'savenet';
151 if ($fwhostsettings{'ACTION'} eq 'updatehost')
154 &General
::readhasharray
("$confighost", \
%customhost);
155 foreach my $key (keys %customhost)
157 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
159 if ($customhost{$key}[1] eq 'ip'){
160 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
162 $ip = $customhost{$key}[2];
164 $fwhostsettings{'orgip'} = $ip;
165 $fwhostsettings{'count'} = $customhost{$key}[4];
166 delete $customhost{$key};
167 &General
::writehasharray
("$confighost", \
%customhost);
170 $fwhostsettings{'actualize'} = 'on';
171 if($fwhostsettings{'orgip'}){
172 $fwhostsettings{'ACTION'} = 'savehost';
174 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
177 if ($fwhostsettings{'ACTION'} eq 'updateservice')
181 $errormessage=&checkports
(\
%customservice);
182 if ($fwhostsettings{'oldsrvname'} ne $fwhostsettings{'SRV_NAME'} && !&checkgroup
($fwhostsettings{'SRV_NAME'})){
183 $errormessage=$Lang::tr
{'fwhost err grpexist'};
186 &General
::readhasharray
("$configsrv", \
%customservice);
187 foreach my $key (keys %customservice)
189 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
191 delete $customservice{$key};
192 &General
::writehasharray
("$configsrv", \
%customservice);
196 if ($fwhostsettings{'PROT'} ne 'ICMP'){
197 $fwhostsettings{'ICMP_TYPES'}='BLANK';
199 my $key1 = &General
::findhasharraykey
(\
%customservice);
200 #find out short ICMP-TYPE
201 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
202 foreach my $key (keys %icmptypes){
203 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
204 $fwhostsettings{'ICMP_TYPES'}=$icmptypes{$key}[0];
207 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
208 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
209 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
210 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
211 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
212 &General
::writehasharray
("$configsrv", \
%customservice);
213 #check if we need to update firewallrules
214 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
215 if ( ! -z
$fwconfigfwd ){
216 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
217 foreach my $key (sort keys %fwfwd){
218 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
219 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
222 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
224 if ( ! -z
$fwconfiginp ){
225 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
226 foreach my $line (sort keys %fwinp){
227 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
228 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
231 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
233 if ( ! -z
$fwconfigout ){
234 &General
::readhasharray
("$fwconfigout", \
%fwout);
235 foreach my $line (sort keys %fwout){
236 if ($fwout{$line}[15] eq $fwhostsettings{'oldsrvname'}){
237 $fwout{$line}[15] = $fwhostsettings{'SRV_NAME'};
240 &General
::writehasharray
("$fwconfigout", \
%fwout);
242 #check if we need to update groups
243 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
244 foreach my $key (sort keys %customservicegrp){
245 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
246 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
247 &checkrulereload
($customservicegrp{$key}[0]);
250 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
252 &checkrulereload
($fwhostsettings{'SRV_NAME'});
253 $fwhostsettings{'SRV_NAME'} = '';
254 $fwhostsettings{'SRV_PORT'} = '';
255 $fwhostsettings{'PROT'} = '';
256 $fwhostsettings{'ICMP'} = '';
257 $fwhostsettings{'oldsrvicmp'} = '';
258 $fwhostsettings{'updatesrv'} = '';
260 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
261 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
262 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
263 $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
264 $fwhostsettings{'updatesrv'}= 'on';
269 if ($fwhostsettings{'ACTION'} eq 'savenet' )
272 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
273 #check if all fields are set
274 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
276 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
281 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
283 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
284 $fwhostsettings{'BLK_HOST'} ='readonly';
285 $fwhostsettings{'NOCHECK'} ='false';
286 $fwhostsettings{'error'} ='on';
289 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
290 $errormessage=$Lang::tr
{'fwhost err remark'};
291 $fwhostsettings{'error'} ='on';
293 #check if subnet is sigle host
294 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
296 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
298 if($fwhostsettings{'error'} ne 'on'){
299 my $fullip="$fwhostsettings{'IP'}/".&General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
300 $errormessage=$errormessage.&General
::checksubnets
($fwhostsettings{'HOSTNAME'},$fullip,"");
302 #only check plausi when no error till now
304 &plausicheck
("editnet");
306 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
308 $fwhostsettings{'actualize'} = '';
309 my $key = &General
::findhasharraykey
(\
%customnetwork);
310 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
311 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
312 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
313 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
314 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
315 &General
::writehasharray
("$confignet", \
%customnetwork);
316 undef %customnetwork;
319 &General
::readhasharray
("$confignet", \
%customnetwork);
320 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
321 if ($fwhostsettings{'update'} == '0'){
322 foreach my $key (keys %customnetwork) {
323 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
324 delete $customnetwork{$key};
330 #get count if actualize is 'on'
331 if($fwhostsettings{'actualize'} eq 'on'){
332 $fwhostsettings{'actualize'} = '';
333 #check if we need to reload rules
334 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
337 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
338 #check if we need to update groups
339 &General
::readhasharray
("$configgrp", \
%customgrp);
340 foreach my $key (sort keys %customgrp){
341 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
342 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
346 &General
::writehasharray
("$configgrp", \
%customgrp);
347 #check if we need to update firewallrules
348 if ( ! -z
$fwconfigfwd ){
349 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
350 foreach my $line (sort keys %fwfwd){
351 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
352 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
354 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
355 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
358 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
360 if ( ! -z
$fwconfiginp ){
361 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
362 foreach my $line (sort keys %fwinp){
363 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
364 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
367 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
371 my $key = &General
::findhasharraykey
(\
%customnetwork);
372 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
373 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
374 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
375 #convert ip when leading '0' in byte
376 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
377 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
378 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
379 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
380 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
381 &General
::writehasharray
("$confignet", \
%customnetwork);
382 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
383 undef %customnetwork;
384 $fwhostsettings{'HOSTNAME'}='';
385 $fwhostsettings{'IP'}='';
386 $fwhostsettings{'SUBNET'}='';
387 $fwhostsettings{'NETREMARK'}='';
388 #check if an edited net affected groups and need to reload rules
389 if ($needrules eq 'on'){
390 &General
::firewall_config_changed
();
395 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
401 if ($fwhostsettings{'ACTION'} eq 'savehost')
404 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
405 $fwhostsettings{'SUBNET'}='32';
406 #check if all fields are set
407 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
409 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
410 $fwhostsettings{'ACTION'} = 'edithost';
412 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
413 $fwhostsettings{'type'} = 'mac';
414 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
415 $fwhostsettings{'type'} = 'ip';
417 $fwhostsettings{'type'} = '';
418 $errormessage=$Lang::tr
{'fwhost err ipmac'};
421 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
422 $errormessage=$Lang::tr
{'fwhost err remark'};
425 if ($fwhostsettings{'type'} eq 'ip'){
427 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
428 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
430 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
431 $fwhostsettings{'error'}='on';
433 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
434 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
435 $fwhostsettings{'error'}='on';
437 #check if net or broadcast
438 my @tmp= split (/\./,$fwhostsettings{'IP'});
439 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
440 $errormessage=$Lang::tr
{'fwhost err hostip'};
443 #only check plausi when no error till now
445 &plausicheck
("edithost");
447 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
448 $fwhostsettings{'actualize'} = '';
449 my $key = &General
::findhasharraykey
(\
%customhost);
450 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
451 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
452 $customhost{$key}[1] = $fwhostsettings{'type'} ;
453 if($customhost{$key}[1] eq 'ip'){
454 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
456 $customhost{$key}[2] = $fwhostsettings{'orgip'};
458 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
459 &General
::writehasharray
("$confighost", \
%customhost);
463 #get count if host was edited
464 if($fwhostsettings{'actualize'} eq 'on'){
465 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
468 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
469 #check if we need to update groups
470 &General
::readhasharray
("$configgrp", \
%customgrp);
471 foreach my $key (sort keys %customgrp){
472 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
473 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
476 &General
::writehasharray
("$configgrp", \
%customgrp);
477 #check if we need to update firewallrules
478 if ( ! -z
$fwconfigfwd ){
479 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
480 foreach my $line (sort keys %fwfwd){
481 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
482 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
484 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
485 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
488 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
490 if ( ! -z
$fwconfiginp ){
491 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
492 foreach my $line (sort keys %fwinp){
493 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
494 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
497 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
501 my $key = &General
::findhasharraykey
(\
%customhost);
502 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
503 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
504 $customhost{$key}[1] = $fwhostsettings{'type'} ;
505 if ($fwhostsettings{'type'} eq 'ip'){
506 #convert ip when leading '0' in byte
507 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
508 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
509 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
511 $customhost{$key}[2] = $fwhostsettings{'IP'};
513 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
514 &General
::writehasharray
("$confighost", \
%customhost);
516 $fwhostsettings{'HOSTNAME'}='';
517 $fwhostsettings{'IP'}='';
518 $fwhostsettings{'type'}='';
519 $fwhostsettings{'HOSTREMARK'}='';
520 #check if we need to update rules while host was edited
521 if($needrules eq 'on'){
522 &General
::firewall_config_changed
();
532 if ($fwhostsettings{'ACTION'} eq 'savegrp')
534 my $grp=$fwhostsettings{'grp_name'};
535 my $rem=$fwhostsettings{'remark'};
538 my $updcounter='off';
541 &General
::readhasharray
("$configgrp", \
%customgrp);
542 &General
::readhasharray
("$confignet", \
%customnetwork);
543 &General
::readhasharray
("$confighost", \
%customhost);
544 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
545 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
546 &General
::readhasharray
("$fwconfigout", \
%fwout);
548 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
550 if (!&checkgroup
($grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
552 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
553 $errormessage.=$Lang::tr
{'fwhost err remark'};
555 if ($fwhostsettings{'update'} eq 'on'){
556 #check standard networks
557 if ($fwhostsettings{'grp2'} eq 'std_net'){
558 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
559 $type='Standard Network';
561 #check custom networks
562 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
563 @target=$fwhostsettings{'CUST_SRC_NET'};
565 $type='Custom Network';
566 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
567 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
568 $fwhostsettings{'grp_name'}='';
569 $fwhostsettings{'remark'}='';
571 #check custom addresses
572 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
573 @target=$fwhostsettings{'CUST_SRC_HOST'};
576 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
577 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
578 $fwhostsettings{'grp_name'}='';
579 $fwhostsettings{'remark'}='';
581 #get address from ovpn ccd static net
582 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
583 @target=$fwhostsettings{'OVPN_CCD_NET'};
584 $type='OpenVPN static network';
585 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
586 $errormessage=$Lang::tr
{'fwhost err groupempty'};
587 $fwhostsettings{'grp_name'}='';
588 $fwhostsettings{'remark'}='';
590 #get address from ovpn ccd static host
591 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
592 @target=$fwhostsettings{'OVPN_CCD_HOST'};
593 $type='OpenVPN static host';
594 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
595 $errormessage=$Lang::tr
{'fwhost err groupempty'};
597 #get address from ovpn ccd Net-2-Net
598 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
599 @target=$fwhostsettings{'OVPN_N2N'};
600 $type='OpenVPN N-2-N';
601 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
602 $errormessage=$Lang::tr
{'fwhost err groupempty'};
603 $fwhostsettings{'grp_name'}='';
604 $fwhostsettings{'remark'}='';
606 #get address from IPSEC HOST
607 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
608 @target=$fwhostsettings{'IPSEC_HOST'};
610 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
611 $errormessage=$Lang::tr
{'fwhost err groupempty'};
612 $fwhostsettings{'grp_name'}='';
613 $fwhostsettings{'remark'}='';
615 #get address from IPSEC NETWORK
616 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
617 @target=$fwhostsettings{'IPSEC_NET'};
618 $type='IpSec Network';
619 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
620 $errormessage=$Lang::tr
{'fwhost err groupempty'};
621 $fwhostsettings{'grp_name'}='';
622 $fwhostsettings{'remark'}='';
624 #check if host/net exists in grp
626 my $test="$grp,$fwhostsettings{'oldremark'},@target";
627 foreach my $key (keys %customgrp) {
628 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
629 if ($test1 eq $test){
630 $errormessage=$Lang::tr
{'fwhost err isingrp'};
631 $fwhostsettings{'update'} = 'on';
637 #on first save, we have an empty @target, so fill it with nothing
638 my $targetvalues=@target;
639 if ($targetvalues == '0'){
642 #on update, we have to delete the dummy entry
643 foreach my $key (keys %customgrp){
644 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
645 delete $customgrp{$key};
649 &General
::writehasharray
("$configgrp", \
%customgrp);
650 &General
::readhasharray
("$configgrp", \
%customgrp);
651 #create array with new lines
652 foreach my $line (@target){
653 push (@newgrp,"$grp,$rem,$line");
656 my $key = &General
::findhasharraykey
(\
%customgrp);
657 foreach my $line (@newgrp){
658 foreach my $i (0 .. 3) { $customgrp{$key}[$i] = "";}
659 my ($a,$b,$c,$d) = split (",",$line);
660 $customgrp{$key}[0] = $a;
661 $customgrp{$key}[1] = $b;
662 $customgrp{$key}[2] = $c;
663 $customgrp{$key}[3] = $type;
665 &General
::writehasharray
("$configgrp", \
%customgrp);
666 #update counter in Host/Net
667 $fwhostsettings{'update'}='on';
669 #check if ruleupdate is needed
671 $netgrpcount=&getnetcount
($grp);
672 if($netgrpcount > 0 )
674 &General
::firewall_config_changed
();
679 if ($fwhostsettings{'ACTION'} eq 'savegeoipgrp')
681 my $grp=$fwhostsettings{'grp_name'};
682 my $rem=$fwhostsettings{'remark'};
687 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
688 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
689 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
690 &General
::readhasharray
("$fwconfigout", \
%fwout);
692 # Check for existing group name.
693 if (!&checkgroup
($grp) && $fwhostsettings{'update'} ne 'on'){
694 $errormessage = $Lang::tr
{'fwhost err grpexist'};
698 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
699 $errormessage = $Lang::tr
{'fwhost err remark'};
702 if ($fwhostsettings{'update'} eq 'on'){
703 @target=$fwhostsettings{'COUNTRY_CODE'};
706 #check if host/net exists in grp
707 my $test="$grp,$fwhostsettings{'oldremark'},@target";
708 foreach my $key (keys %customgeoipgrp) {
709 my $test1="$customgeoipgrp{$key}[0],$customgeoipgrp{$key}[1],$customgeoipgrp{$key}[2]";
710 if ($test1 eq $test){
711 $errormessage=$Lang::tr
{'fwhost err isingrp'};
712 $fwhostsettings{'update'} = 'on';
718 #on first save, we have an empty @target, so fill it with nothing
719 my $targetvalues=@target;
720 if ($targetvalues == '0'){
723 #on update, we have to delete the dummy entry
724 foreach my $key (keys %customgeoipgrp){
725 if ($customgeoipgrp{$key}[0] eq $grp && $customgeoipgrp{$key}[2] eq "none"){
726 delete $customgeoipgrp{$key};
730 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
731 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
732 #create array with new lines
733 foreach my $line (@target){
734 push (@newgrp,"$grp,$rem,$line");
737 my $key = &General
::findhasharraykey
(\
%customgeoipgrp);
738 foreach my $line (@newgrp){
739 foreach my $i (0 .. 3) { $customgeoipgrp{$key}[$i] = "";}
740 my ($a,$b,$c,$d) = split (",",$line);
741 $customgeoipgrp{$key}[0] = $a;
742 $customgeoipgrp{$key}[1] = $b;
743 $customgeoipgrp{$key}[2] = $c;
744 $customgeoipgrp{$key}[3] = $type;
746 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
747 #update counter in Host/Net
748 $fwhostsettings{'update'}='on';
750 #check if ruleupdate is needed
752 $geoipgrpcount=&getgeoipcount
($grp);
753 if($geoipgrpcount > 0 )
755 &General
::firewall_config_changed
();
760 if ($fwhostsettings{'ACTION'} eq 'saveservice')
763 &General
::readhasharray
("$configsrv", \
%customservice );
764 &General
::readhasharray
("$configgrp", \
%customgrp);
765 $errormessage=&checkports
(\
%customservice);
766 if ($fwhostsettings{'PROT'} eq 'ICMP'){
767 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
768 foreach my $key (keys %icmptypes){
769 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
770 $ICMP=$icmptypes{$key}[0];
774 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
775 if ($fwhostsettings{'PROT'} ne 'ICMP'){$ICMP='BLANK';}
776 #Check if a group with the same name already exists
777 if (!&checkgroup
($fwhostsettings{'SRV_NAME'})){
778 $errormessage = $Lang::tr
{'fwhost err grpexist'};
781 my $key = &General
::findhasharraykey
(\
%customservice);
782 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
783 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
784 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
785 $customservice{$key}[2] = $fwhostsettings{'PROT'};
786 $customservice{$key}[3] = $ICMP;
787 &General
::writehasharray
("$configsrv", \
%customservice );
789 $fwhostsettings{'SRV_NAME'}='';
790 $fwhostsettings{'SRV_PORT'}='';
791 $fwhostsettings{'PROT'}='';
792 $fwhostsettings{'ICMP_TYPES'}='';
796 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
802 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
803 &General
::readhasharray
("$configsrv", \
%customservice );
804 $errormessage=&checkservicegroup
;
805 #Check if we have more than 15 services from one Protocol in the group
806 #iptables can only handle 15 ports/portranges via multiport
807 foreach my $key (keys %customservicegrp){
808 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
809 foreach my $key1 (keys %customservice){
810 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
811 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
812 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
813 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
817 if ($tcpcounter > 14){
818 $errormessage=$Lang::tr
{'fwhost err maxservicetcp'};
820 if ($udpcounter > 14){
821 $errormessage=$Lang::tr
{'fwhost err maxserviceudp'};
826 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
827 $errormessage .= $Lang::tr
{'fwhost err remark'};
829 #Check if there is already a service with the same name
830 if(!&checkservice
($fwhostsettings{'SRVGRP_NAME'})){
831 $errormessage .= $Lang::tr
{'fwhost err srv exists'};
834 #on first save, we have to enter a dummy value
835 if ($fwhostsettings{'CUST_SRV'} eq ''){
836 $fwhostsettings{'CUST_SRV'}='none';
838 #on update, we have to delete the dummy entry
839 foreach my $key (keys %customservicegrp){
840 if ($customservicegrp{$key}[2] eq 'none' && $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
841 delete $customservicegrp{$key};
845 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
846 #check if remark has also changed
847 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
849 foreach my $key (keys %customservicegrp)
851 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
853 $customservicegrp{$key}[1]='';
854 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
858 my $key = &General
::findhasharraykey
(\
%customservicegrp);
859 foreach my $i (0 .. 2) { $customservice{$key}[$i] = "";}
860 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
861 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
862 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
863 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
864 $fwhostsettings{'updatesrvgrp'}='on';
866 &checkrulereload
($fwhostsettings{'SRVGRP_NAME'});
868 &viewtableservicegrp
;
871 if ($fwhostsettings{'ACTION'} eq 'editnet')
876 if ($fwhostsettings{'ACTION'} eq 'edithost')
881 if ($fwhostsettings{'ACTION'} eq 'editgrp')
883 $fwhostsettings{'update'}='on';
887 if ($fwhostsettings{'ACTION'} eq 'editgeoipgrp')
889 $fwhostsettings{'update'}='on';
893 if ($fwhostsettings{'ACTION'} eq 'editservice')
895 $fwhostsettings{'updatesrv'}='on';
898 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
900 $fwhostsettings{'updatesrvgrp'} = 'on';
902 &viewtableservicegrp
;
905 if ($fwhostsettings{'ACTION'} eq 'resetnet')
907 $fwhostsettings{'HOSTNAME'} ="";
908 $fwhostsettings{'IP'} ="";
909 $fwhostsettings{'SUBNET'} ="";
912 if ($fwhostsettings{'ACTION'} eq 'resethost')
914 $fwhostsettings{'HOSTNAME'} ="";
915 $fwhostsettings{'IP'} ="";
916 $fwhostsettings{'type'} ="";
919 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
921 $fwhostsettings{'grp_name'} ="";
922 $fwhostsettings{'remark'} ="";
925 if ($fwhostsettings{'ACTION'} eq 'resetgeoipgrp')
927 $fwhostsettings{'grp_name'} ="";
928 $fwhostsettings{'remark'} ="";
932 if ($fwhostsettings{'ACTION'} eq 'delnet')
934 &General
::readhasharray
("$confignet", \
%customnetwork);
935 foreach my $key (keys %customnetwork) {
936 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
937 delete $customnetwork{$key};
938 &General
::writehasharray
("$confignet", \
%customnetwork);
945 if ($fwhostsettings{'ACTION'} eq 'delhost')
947 &General
::readhasharray
("$confighost", \
%customhost);
948 foreach my $key (keys %customhost) {
949 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
950 delete $customhost{$key};
951 &General
::writehasharray
("$confighost", \
%customhost);
958 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
962 &General
::readhasharray
("$configgrp", \
%customgrp);
963 foreach my $key (keys %customgrp){
964 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
965 $grpname=$customgrp{$key}[0];
966 $grpremark=$customgrp{$key}[1];
967 #check if we delete the last entry, then generate dummy
968 if ($fwhostsettings{'last'} eq 'on'){
969 $customgrp{$key}[1] = '';
970 $customgrp{$key}[2] = 'none';
971 $customgrp{$key}[3] = '';
972 $fwhostsettings{'last'}='';
975 delete $customgrp{$key};
979 &General
::writehasharray
("$configgrp", \
%customgrp);
980 &General
::firewall_config_changed
();
981 if ($fwhostsettings{'update'} eq 'on'){
982 $fwhostsettings{'remark'}= $grpremark;
983 $fwhostsettings{'grp_name'}=$grpname;
988 if ($fwhostsettings{'ACTION'} eq 'deletegeoipgrpentry')
992 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
993 foreach my $key (keys %customgeoipgrp){
994 if($customgeoipgrp{$key}[0].",".$customgeoipgrp{$key}[1].",".$customgeoipgrp{$key}[2].",".$customgeoipgrp{$key}[3] eq $fwhostsettings{'delentry'}){
995 $grpname=$customgeoipgrp{$key}[0];
996 $grpremark=$customgeoipgrp{$key}[1];
997 #check if we delete the last entry, then generate dummy
998 if ($fwhostsettings{'last'} eq 'on'){
999 $customgeoipgrp{$key}[1] = '';
1000 $customgeoipgrp{$key}[2] = 'none';
1001 $customgeoipgrp{$key}[3] = '';
1002 $fwhostsettings{'last'}='';
1005 delete $customgeoipgrp{$key};
1009 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
1010 &General
::firewall_config_changed
();
1011 if ($fwhostsettings{'update'} eq 'on'){
1012 $fwhostsettings{'remark'}= $grpremark;
1013 $fwhostsettings{'grp_name'}=$grpname;
1019 if ($fwhostsettings{'ACTION'} eq 'delgrp')
1021 &General
::readhasharray
("$configgrp", \
%customgrp);
1022 &decrease
($fwhostsettings{'grp_name'});
1023 foreach my $key (sort keys %customgrp)
1025 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
1027 delete $customgrp{$key};
1030 &General
::writehasharray
("$configgrp", \
%customgrp);
1031 $fwhostsettings{'grp_name'}='';
1035 if ($fwhostsettings{'ACTION'} eq 'delgeoipgrp')
1037 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
1038 &decrease
($fwhostsettings{'grp_name'});
1039 foreach my $key (sort keys %customgeoipgrp)
1041 if($customgeoipgrp{$key}[0] eq $fwhostsettings{'grp_name'})
1043 delete $customgeoipgrp{$key};
1046 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
1047 $fwhostsettings{'grp_name'}='';
1051 if ($fwhostsettings{'ACTION'} eq 'delservice')
1053 &General
::readhasharray
("$configsrv", \
%customservice);
1054 foreach my $key (keys %customservice) {
1055 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
1056 delete $customservice{$key};
1057 &General
::writehasharray
("$configsrv", \
%customservice);
1061 $fwhostsettings{'SRV_NAME'}='';
1062 $fwhostsettings{'SRV_PORT'}='';
1063 $fwhostsettings{'PROT'}='';
1066 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
1068 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1069 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
1070 foreach my $key (sort keys %customservicegrp)
1072 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
1074 delete $customservicegrp{$key};
1077 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1078 $fwhostsettings{'SRVGRP_NAME'}='';
1080 &viewtableservicegrp
;
1082 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
1086 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1087 foreach my $key (keys %customservicegrp){
1088 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'})
1090 $grpname=$customservicegrp{$key}[0];
1091 $grpremark=$customservicegrp{$key}[1];
1092 if($fwhostsettings{'last'} eq 'on'){
1093 $customservicegrp{$key}[2] = 'none';
1094 $fwhostsettings{'last'} = '';
1097 delete $customservicegrp{$key};
1101 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1102 &General
::firewall_config_changed
();
1103 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1104 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1105 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1108 &viewtableservicegrp
;
1110 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1115 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1120 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1125 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgeoipgrp'})
1130 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1134 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1137 &viewtableservicegrp
;
1139 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1141 &General
::readhasharray
("$configgrp", \
%customgrp);
1142 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1143 foreach my $key (sort keys %customgrp)
1145 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1147 $customgrp{$key}[1]='';
1148 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1151 &General
::writehasharray
("$configgrp", \
%customgrp);
1152 $fwhostsettings{'update'}='on';
1153 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1155 $errormessage=$Lang::tr
{'fwhost err remark'};
1156 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1157 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1158 $fwhostsettings{'update'} = 'on';
1160 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1164 if ($fwhostsettings{'ACTION'} eq 'changegeoipgrpremark')
1166 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
1167 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1168 foreach my $key (sort keys %customgeoipgrp)
1170 if($customgeoipgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgeoipgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1172 $customgeoipgrp{$key}[1]='';
1173 $customgeoipgrp{$key}[1]=$fwhostsettings{'newrem'};
1176 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
1177 $fwhostsettings{'update'}='on';
1178 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1180 $errormessage=$Lang::tr
{'fwhost err remark'};
1181 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1182 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1183 $fwhostsettings{'update'} = 'on';
1185 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1189 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1191 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1192 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1193 foreach my $key (sort keys %customservicegrp)
1195 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1197 $customservicegrp{$key}[1]='';
1198 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1201 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1202 $fwhostsettings{'updatesrvgrp'}='on';
1203 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1204 }elsif($fwhostsettings{'oldsrvrem'} eq $fwhostsettings{'newsrvrem'}){
1206 &viewtableservicegrp
;
1208 $errormessage=$Lang::tr
{'fwhost err remark'};
1209 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1210 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1211 $fwhostsettings{'updatesrvgrp'} = 'on';
1213 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1215 &viewtableservicegrp
;
1217 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpname')
1219 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1220 if ($fwhostsettings{'oldsrvgrpname'} ne $fwhostsettings{'srvgrp'}){
1221 #Check new groupname
1222 if (!&validhostname
($fwhostsettings{'srvgrp'})){
1223 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1225 if (!$errormessage){
1226 #Rename group in customservicegroup
1227 foreach my $key (keys %customservicegrp) {
1228 if($customservicegrp{$key}[0] eq $fwhostsettings{'oldsrvgrpname'}){
1229 $customservicegrp{$key}[0]=$fwhostsettings{'srvgrp'};
1232 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
1233 #change name in FW Rules
1234 &changenameinfw
($fwhostsettings{'oldsrvgrpname'},$fwhostsettings{'srvgrp'},15);
1238 &viewtableservicegrp
;
1240 if ($fwhostsettings{'ACTION'} eq 'changegrpname')
1242 &General
::readhasharray
("$configgrp", \
%customgrp );
1243 if ($fwhostsettings{'oldgrpname'} ne $fwhostsettings{'grp'}){
1244 #Check new groupname
1245 if (!&validhostname
($fwhostsettings{'grp'})){
1246 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1248 if (!$errormessage){
1249 #Rename group in customservicegroup
1250 foreach my $key (keys %customgrp) {
1251 if($customgrp{$key}[0] eq $fwhostsettings{'oldgrpname'}){
1252 $customgrp{$key}[0]=$fwhostsettings{'grp'};
1255 &General
::writehasharray
("$configgrp", \
%customgrp );
1256 #change name in FW Rules
1257 &changenameinfw
($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
1263 if ($fwhostsettings{'ACTION'} eq 'changegeoipgrpname')
1265 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp );
1266 if ($fwhostsettings{'oldgrpname'} ne $fwhostsettings{'grp'}){
1267 #Check new groupname
1268 if (!&validhostname
($fwhostsettings{'grp'})){
1269 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1271 if (!$errormessage){
1273 foreach my $key (keys %customgeoipgrp) {
1274 if($customgeoipgrp{$key}[0] eq $fwhostsettings{'oldgrpname'}){
1275 $customgeoipgrp{$key}[0]=$fwhostsettings{'grp'};
1278 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp );
1279 #change name in FW Rules
1280 &changenameinfw
($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
1287 if($fwhostsettings{'ACTION'} eq '')
1293 &Header
::openbox
('100%', 'left',);
1294 print "$Lang::tr{'fwhost welcome'}";
1296 <br><br><table border='0' width='100%'>
1297 <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'}' ><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newgeoipgrp'}' ></form></td>
1298 <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>
1299 <tr><td colspan='6'></td></tr></table>
1301 &Header
::closebox
();
1309 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1310 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1311 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1313 <table border='0' width='100%' >
1314 <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>
1315 <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>
1316 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1317 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1318 <tr><td colspan='6'><br></td></tr><tr>
1320 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1322 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'}'>";
1324 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'>";
1326 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>";
1327 &Header
::closebox
();
1333 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1334 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1335 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1337 <table width='100%'>
1338 <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>
1339 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1340 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1341 <tr><td colspan='5'><br></td></tr><tr>
1344 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1347 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>";
1349 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'>";
1351 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>";
1352 &Header
::closebox
();
1359 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1360 &General
::setup_default_networks
(\
%defaultNetworks);
1361 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1362 &General
::readhasharray
("$confignet", \
%customnetwork);
1363 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1364 &General
::readhasharray
("$confighost", \
%customhost);
1365 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1369 $checked{'check1'}{'off'} = '';
1370 $checked{'check1'}{'on'} = '';
1371 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1372 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1373 $fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'};
1374 my $grp=$fwhostsettings{'grp_name'};
1375 my $rem=$fwhostsettings{'remark'};
1376 if ($fwhostsettings{'update'} eq ''){
1378 <table width='100%' border='0'>
1380 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1381 <td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='30'></td>
1384 <td>$Lang::tr{'remark'}:</td>
1385 <td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 99%;'></td>
1388 <td colspan='2'><br></td>
1394 <table width='100%' border='0'><form method='post'>
1396 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1397 <td style='width:30%;'><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' size='30'></td>
1398 <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>
1401 <tr><form method='post' style='display:inline'>
1402 <td>$Lang::tr{'remark'}:</td>
1403 <td colspan='2' style='width:98%;'><input type='TEXT' name='newrem' value='$fwhostsettings{'remark'}' style='width:98%;'></td>
1404 <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>
1410 if ($fwhostsettings{'update'} eq 'on'){
1412 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1413 <table width='100%' border='0'>
1414 <tr><td width=50% valign='top'>
1415 <table width='90%' border='0'>
1417 <td style='width:15em;'>
1419 <input type='radio' name='grp2' value='std_net' id='DEFAULT_SRC_ADR' checked>
1420 $Lang::tr{'fwhost stdnet'}
1423 <td style='text-align:right;'>
1424 <select name='DEFAULT_SRC_ADR' style='width:16em;'>
1426 foreach my $network (sort keys %defaultNetworks)
1428 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1429 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1430 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1431 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1432 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1433 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1434 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1435 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1436 if ($ownnet{$defnet}){
1437 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1439 print ">$network</option>";
1442 print"</select></td></tr>";
1443 if (! -z
$confignet){
1448 <input type='radio' name='grp2' id='CUST_SRC_NET' value='cust_net' $checked{'grp2'}{'cust_net'}>
1449 $Lang::tr{'fwhost cust net'}:
1452 <td style='text-align:right;'>
1453 <select name='CUST_SRC_NET' style='width:16em;'>";
1455 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1456 print"<option>$customnetwork{$key}[0]</option>";
1458 print"</select></td></tr>";
1460 if (! -z
$confighost){
1465 <input type='radio' name='grp2' id='CUST_SRC_HOST' value='cust_host' $checked{'grp2'}{'cust_host'}>
1466 $Lang::tr{'fwhost cust addr'}:
1469 <td style='text-align:right;'>
1470 <select name='CUST_SRC_HOST' style='width:16em;'>";
1472 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1473 print"<option>$customhost{$key}[0]</option>";
1475 print"</select></td></tr>";
1479 print"</td><td align='right' style='vertical-align:top;'><table width='90%' border='0'>";
1481 if (! -z
$configccdnet){
1483 <td style='width:15em;'>
1485 <input type='radio' name='grp2' id='OVPN_CCD_NET' value='ovpn_net' $checked{'grp2'}{'ovpn_net'}>
1486 $Lang::tr{'fwhost ccdnet'}
1489 <td style='text-align:right;'>
1490 <select name='OVPN_CCD_NET' style='width:16em;'>";
1492 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1494 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1496 print"</select></td></tr>";
1499 my @ovpn_clients=();
1500 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1502 if ($ccdhost{$key}[33] ne ''){
1504 push (@ovpn_clients,$ccdhost{$key}[1]);
1510 <td style='width:15em;'>
1512 <input type='radio' name='grp2' value='ovpn_host' $checked{'grp2'}{'ovpn_host'}>
1513 $Lang::tr{'fwhost ccdhost'}
1516 <td style='text-align:right;'>
1517 <select name='OVPN_CCD_HOST' style='width:16em;'>" if ($show eq '');
1519 foreach(@ovpn_clients){
1520 print"<option value='$_'>$_</option>";
1522 print"</select></td></tr>";
1526 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1527 if($ccdhost{$key}[3] eq 'net'){
1529 push (@OVPN_N2N,$ccdhost{$key}[1]);
1535 <td style='width:15em;'>
1537 <input type='radio' name='grp2' id='OVPN_N2N' value='ovpn_n2n' $checked{'grp2'}{'ovpn_n2n'}>
1538 $Lang::tr{'fwhost ovpn_n2n'}:
1541 <td style='text-align:right;'>
1542 <select name='OVPN_N2N' style='width:16em;'>"
1545 print"<option>$_</option>";
1547 print"</select></td></tr>";
1551 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1552 if ($ipsecconf{$key}[3] eq 'net'){
1554 push (@IPSEC_N2N,$ipsecconf{$key}[1]);
1560 <td style='width:15em;'>
1562 <input type='radio' name='grp2' id='IPSEC_NET' value='ipsec_net' $checked{'grp2'}{'ipsec_net'}>
1563 $Lang::tr{'fwhost ipsec net'}
1566 <td style='text-align:right;'>
1567 <select name='IPSEC_NET' style='width:16em;'>"
1569 foreach(@IPSEC_N2N){
1570 print"<option value='$_'>$_</option>";
1573 print"</select></td></tr>";
1575 print"</td></tr></table>";
1578 print"<table width='100%'>";
1579 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>";
1580 &Header
::closebox
();
1587 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgeoipgrp'});
1591 $checked{'check1'}{'off'} = '';
1592 $checked{'check1'}{'on'} = '';
1593 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1594 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1595 $fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'};
1596 my $grp=$fwhostsettings{'grp_name'};
1597 my $rem=$fwhostsettings{'remark'};
1598 if ($fwhostsettings{'update'} eq ''){
1600 <table width='100%' border='0'>
1602 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1603 <td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='30'></td>
1606 <td>$Lang::tr{'remark'}:</td>
1607 <td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 99%;'></td>
1610 <td colspan='2'><br></td>
1616 <table width='100%' border='0'>
1617 <form method='post'><tr>
1618 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1619 <td style='width:30%;'><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' size='30'></td>
1621 <input type='submit' value='$Lang::tr{'fwhost change'}'>
1622 <input type='hidden' name='oldgrpname' value='$fwhostsettings{'oldgrpname'}'>
1623 <input type='hidden' name='ACTION' value='changegeoipgrpname'>
1627 <tr><form method='post' style='display:inline'>
1628 <td>$Lang::tr{'remark'}:</td>
1629 <td colspan='2' style='width:98%;'>
1630 <input type='TEXT' name='newrem' value='$fwhostsettings{'remark'}' style='width:98%;'>
1633 <input type='submit' value='$Lang::tr{'fwhost change'}'>
1634 <input type='hidden' name='grp' value='$fwhostsettings{'grp_name'}'>
1635 <input type='hidden' name='oldrem' value='$fwhostsettings{'oldremark'}'>
1636 <input type='hidden' name='ACTION' value='changegeoipgrpremark'>
1643 if ($fwhostsettings{'update'} eq 'on') {
1644 my @geoip_locations = &fwlib
::get_geoip_locations
();
1647 <form method='post'>
1648 <input type='hidden' name='remark' value='$rem'>
1649 <input type='hidden' name='grp_name' value='$grp'>
1651 <table width='100%' border='0'>
1653 <td style='text-align:left;'>
1654 <select name='COUNTRY_CODE' style='width:16em;'>";
1656 foreach my $location (@geoip_locations) {
1657 # Get full country name.
1658 my $fullname = &GeoIP
::get_full_country_name
($location);
1660 print"<option value='$location'>$location - $fullname</option>\n";
1671 <table width='100%'>
1672 <tr><td style='text-align:right;'>
1673 <input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1674 <input type='hidden' name='oldremark' value='$fwhostsettings{'oldremark'}'>
1675 <input type='hidden' name='update' value=\"$fwhostsettings{'update'}\">
1676 <input type='hidden' name='ACTION' value='savegeoipgrp' >
1679 <form method='post' style='display:inline'>
1681 <input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'>
1682 <input type='hidden' name='ACTION' value='resetgeoipgrp'>
1687 &Header
::closebox
();
1693 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1694 if ($fwhostsettings{'updatesrv'} eq 'on')
1696 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1697 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1698 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1699 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1702 <table width='100%' border='0'><form method='post'>
1703 <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>
1704 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1706 foreach ("TCP","UDP","ICMP")
1708 if ($_ eq $fwhostsettings{'PROT'})
1710 print"<option selected>$_</option>";
1712 print"<option>$_</option>";
1716 </select></td></tr></table>
1717 <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'>
1719 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1720 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1721 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1722 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1723 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1725 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1729 </select></td></tr></table></div>
1730 <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>
1731 <table width='100%' border='0'><tr><td colspan='6'><br></td></tr>
1732 <tr><td colspan='6' align='right'>
1734 if ($fwhostsettings{'updatesrv'} eq 'on')
1737 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1738 <input type='hidden' name='ACTION' value='updateservice'>
1739 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1740 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1741 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1742 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1746 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1749 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1752 &Header
::closebox
();
1760 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1761 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1762 $fwhostsettings{'oldsrvgrpname'}=$fwhostsettings{'SRVGRP_NAME'};
1763 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1765 <table width='100%' border='0'><form method='post'>
1766 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1767 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1768 <tr><td colspan='2'><br></tr>
1773 <table width='100%'><form method='post' style='display:inline'>
1774 <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>
1776 <form method='post'>
1778 $Lang::tr{'remark'}:
1781 <input type='text' name='newsrvrem' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width:98%;'>
1784 <input type='submit' value='$Lang::tr{'fwhost change'}'>
1785 <input type='hidden' name='oldsrvrem' value='$fwhostsettings{'oldsrvgrpremark'}'>
1786 <input type='hidden' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}'>
1787 <input type='hidden' name='ACTION' value='changesrvgrpremark' >
1799 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1801 <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%'>
1802 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'add'}: </td><td><select name='CUST_SRV' style='min-width:185px;'>
1804 &General
::readhasharray
("$configsrv", \
%customservice);
1805 #Protocols for use in servicegroups
1806 print "<optgroup label='$Lang::tr{'fwhost cust service'}'>";
1807 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1809 print "<option>$customservice{$key}[0]</option>";
1811 print "</optgroup>";
1812 print "<optgroup label='$Lang::tr{'protocol'}'>";
1813 print "<option>GRE</option>";
1814 print "<option>AH</option>";
1815 print "<option>ESP</option>";
1816 print "<option>IGMP</option>";
1817 print "<option>IPIP</option>";
1818 print "<option value='IPV6'>IPv6 encap</option>";
1819 print "</optgroup>";
1822 <tr><td colspan='4'><br><br></td></tr>
1823 <tr><td colspan='4'></td></tr>
1828 <table width='100%'>
1829 <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>
1832 &Header
::closebox
();
1837 if(! -z
$confignet){
1838 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1839 &General
::readhasharray
("$confignet", \
%customnetwork);
1840 &General
::readhasharray
("$configgrp", \
%customgrp);
1841 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1842 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1843 &General
::readhasharray
("$fwconfigout", \
%fwout);
1845 if (!keys %customnetwork)
1847 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1850 <table width='100%' cellspacing='0' class='tbl'>
1851 <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>
1856 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1857 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1859 $col="bgcolor='${Header::colouryellow}'";
1862 $col="bgcolor='$color{'color20'}'";
1866 $col="bgcolor='$color{'color22'}'";
1869 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1870 my $netcount=&getnetcount
($customnetwork{$key}[0]);
1871 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>";
1873 <td width='1%' $col><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
1874 <input type='hidden' name='ACTION' value='editnet'>
1875 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1876 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1877 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1878 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1881 if($netcount == '0')
1883 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>";
1885 print"<td $col></td></tr>";
1890 &Header
::closebox
();
1901 if (&General
::validmac
($c)){ return $c;}
1903 #Check if we got a full IP with subnet then split it
1904 if($c =~ /^(.*?)\/(.*?
)$/){
1905 ($sip,$scidr) = split ("/",$c);
1910 #Now check if IP is part of ORANGE,BLUE or GREEN
1911 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1912 $tdcolor="<font style='color: $Header::colourorange;'>$c</font>";
1915 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1916 $tdcolor="<font style='color: $Header::colourgreen;'>$c</font>";
1919 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1920 $tdcolor="<font style='color: $Header::colourblue;'>$c</font>";
1923 if ("$sip/$scidr" eq "0.0.0.0/0"){
1924 $tdcolor="<font style='color: $Header::colourred;'>$c</font>";
1927 #Check if IP is part of OpenVPN N2N subnet
1928 foreach my $key (sort keys %ccdhost){
1929 if ($ccdhost{$key}[3] eq 'net'){
1930 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1931 if (&General
::IpInSubnet
($sip,$a,$b)){
1932 $tdcolor="<font style='color:$Header::colourovpn ;'>$c</font>";
1938 #Check if IP is part of OpenVPN dynamic subnet
1939 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1940 if (&General
::IpInSubnet
($sip,$a,$b)){
1941 $tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
1945 #Check if IP is part of OpenVPN static subnet
1946 foreach my $key (sort keys %ccdnet){
1947 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1948 $b =&General
::iporsubtodec
($b);
1949 if (&General
::IpInSubnet
($sip,$a,$b)){
1950 $tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
1955 #Check if IP is part of IPsec RW network
1956 if ($ipsecsettings{'RW_NET'} ne ''){
1957 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1958 $b=&General
::iporsubtodec
($b);
1959 if (&General
::IpInSubnet
($sip,$a,$b)){
1960 $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
1965 #Check if IP is part of a IPsec N2N network
1966 foreach my $key (sort keys %ipsecconf){
1967 if ($ipsecconf{$key}[11]){
1968 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1969 $b=&General
::iporsubtodec
($b);
1970 if (&General
::IpInSubnet
($sip,$a,$b)){
1971 $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
1980 if (! -z
$confighost){
1981 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1982 &General
::readhasharray
("$confighost", \
%customhost);
1983 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1984 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1985 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1986 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1987 &General
::readhasharray
("$fwconfigout", \
%fwout);
1988 &General
::readhasharray
("$configgrp", \
%customgrp);
1989 if (!keys %customhost)
1991 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1994 <table width='100%' cellspacing='0' class='tbl'>
1995 <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>
2000 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
2001 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
2003 $col="bgcolor='${Header::colouryellow}'";
2004 }elsif ($count % 2){
2006 $col="bgcolor='$color{'color20'}'";
2008 $col="bgcolor='$color{'color22'}'";
2011 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
2012 $customhost{$key}[4]=~s/\s+//g;
2014 $hostcount=&gethostcount
($customhost{$key}[0]);
2015 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>";
2017 <td width='1%' $col><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
2018 <input type='hidden' name='ACTION' value='edithost' />
2019 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
2020 <input type='hidden' name='IP' value='$ip' />
2021 <input type='hidden' name='type' value='$customhost{$key}[1]' />
2022 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
2025 if($hostcount == '0')
2027 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>";
2029 print"<td width='1%' $col></td></tr>";
2034 &Header
::closebox
();
2039 if(! -z
"$configgrp"){
2040 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
2041 &General
::readhasharray
("$configgrp", \
%customgrp);
2042 &General
::readhasharray
("$configipsec", \
%ipsecconf);
2043 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2044 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2045 &General
::readhasharray
("$confighost", \
%customhost);
2046 &General
::readhasharray
("$confignet", \
%customnetwork);
2047 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2048 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2049 &General
::readhasharray
("$fwconfigout", \
%fwout);
2059 if (!keys %customgrp)
2061 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
2063 #get all groups in a hash
2064 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
2065 push (@counter,$customgrp{$key}[0]);
2067 foreach my $key1 (@counter) {
2070 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
2072 if ($helper ne $customgrp{$key}[0]){
2074 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
2075 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
2084 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
2085 $grpname=$customgrp{$key}[0];
2086 $remark="$customgrp{$key}[1]";
2087 if($count gt 1){ print"</table>";$count=1;}
2088 print "<br><b><u>$grpname</u></b> ";
2089 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
2090 my $netgrpcount=&getnetcount
($grpname);
2091 print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
2092 if($netgrpcount == '0')
2094 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>";
2096 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>";
2097 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>";
2100 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
2102 $col="bgcolor='${Header::colouryellow}'";
2103 }elsif ($count %2 == 0){
2105 $col="bgcolor='$color{'color20'}'";
2108 $col="bgcolor='$color{'color22'}'";
2110 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
2113 $col="bgcolor='${Header::colouryellow}'";
2115 print "<td width='39%' align='left' $col>";
2116 if($customgrp{$key}[3] eq 'Standard Network'){
2117 print &get_name
($customgrp{$key}[2])."</td>";
2119 print "$customgrp{$key}[2]</td>";
2121 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
2122 print "<td align='center' $col>$Lang::tr{'fwhost deleted'}</td><td align='center' $col>$Lang::tr{'fwhost '.$customgrp{$key}[3]}</td><td width='1%' $col><form method='post'>";
2124 my ($colip,$colsub) = split("/",$ip);
2125 $ip="$colip/".&General
::iporsubtocidr
($colsub) if ($colsub);
2126 print"<td align='center' $col>".&getcolor
($ip)."</td><td align='center' $col>$Lang::tr{'fwhost '.$customgrp{$key}[3]}</td><td width='1%' $col><form method='post'>";
2128 if ($delflag > 0 && $ip ne ''){
2129 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' />";
2130 #check if this group has only one entry
2131 foreach my $key2 (keys %hash) {
2132 if ($hash{$key2}<2 && $key2 eq $customgrp{$key}[0]){
2133 print "<input type='hidden' name='last' value='on'>" ;
2137 print"<input type='hidden' name='ACTION' value='deletegrphost'><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>";
2138 $helper=$customgrp{$key}[0];
2143 &Header
::closebox
();
2147 sub viewtablegeoipgrp
2149 # If our filesize is "zero" there is nothing to read-in.
2150 if (-z
"$configgeoipgrp") {
2154 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust geoipgrp'});
2155 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
2156 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2157 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2158 &General
::readhasharray
("$fwconfigout", \
%fwout);
2170 # If there are no groups we are finished here.
2171 if (!keys %customgeoipgrp) {
2172 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
2176 # Put all groups in a hash.
2177 foreach my $key (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) }
2178 sort { ncmp
($customgeoipgrp{$a}[2],$customgeoipgrp{$b}[2]) } keys %customgeoipgrp) {
2179 push (@counter,$customgeoipgrp{$key}[0]);
2182 # Increase current used key.
2183 foreach my $key1 (@counter) {
2188 foreach my $key (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) }
2189 sort { ncmp
($customgeoipgrp{$a}[2],$customgeoipgrp{$b}[2]) } keys %customgeoipgrp) {
2191 if ($helper ne $customgeoipgrp{$key}[0]) {
2194 foreach my $key1 (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) }
2195 sort { ncmp
($customgeoipgrp{$a}[2],$customgeoipgrp{$b}[2]) } keys %customgeoipgrp) {
2197 if ($customgeoipgrp{$key}[0] eq $customgeoipgrp{$key1}[0])
2209 $grpname=$customgeoipgrp{$key}[0];
2212 $remark="$customgeoipgrp{$key}[1]";
2215 $country_code="$customgeoipgrp{$key}[2]";
2222 # Display groups header.
2223 print "<br><b><u>$grpname</u></b> \n";
2224 print "<b>$Lang::tr{'remark'}:</b>  $remark  \n" if ($remark ne '');
2227 my $geoipgrpcount=&getgeoipcount
($grpname);
2228 print "<b>$Lang::tr{'used'}:</b> $geoipgrpcount x";
2230 # Only display delete icon, if the group is not used by a firewall rule.
2231 if($geoipgrpcount == '0') {
2232 print"<form method='post' style='display:inline'>\n";
2233 print"<input type='image' src='/images/delete.gif' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' align='right' />\n";
2234 print"<input type='hidden' name='grp_name' value='$grpname' >\n";
2235 print"<input type='hidden' name='ACTION' value='delgeoipgrp'>\n";
2239 # Icon for group editing.
2241 <form method='post' style='display:inline'>
2242 <input type='image' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' align='right'/>
2243 <input type='hidden' name='grp_name' value='$grpname' >
2244 <input type='hidden' name='remark' value='$remark' >
2245 <input type='hidden' name='ACTION' value='editgeoipgrp'>
2248 <table width='100%' cellspacing='0' class='tbl'>
2250 # Display headlines if the group contains any entries.
2251 if ($country_code ne "none") {
2254 <td width='10%' align='center'>
2255 <b>$Lang::tr{'flag'}</b>
2258 <td width='10%'align='center'>
2259 <b>$Lang::tr{'countrycode'}</b>
2262 <td width='70%'align='left'>
2263 <b>$Lang::tr{'country'}</b>
2266 <td width='10%' align='right'></td>
2272 # Check if our group contains any entries.
2273 if ($country_code eq "none") {
2274 print "<tr><td>$Lang::tr{'fwhost err emptytable'}</td></tr>\n";
2276 # Check if we are currently editing a group and assign column backgound colors.
2278 if ( ($fwhostsettings{'ACTION'} eq 'editgeoipgrp' || $fwhostsettings{'update'} ne '')
2279 && $fwhostsettings{'grp_name'} eq $customgeoipgrp{$key}[0]) {
2280 $col="bgcolor='${Header::colouryellow}'";
2281 } elsif ($count %2 == 0){
2282 $col="bgcolor='$color{'color20'}'";
2284 $col="bgcolor='$color{'color22'}'";
2288 my $icon = &GeoIP
::get_flag_icon
($customgeoipgrp{$key}[2]);
2290 # Print column with flag icon.
2293 $col_content = "<img src='$icon' alt='$customgeoipgrp{$key}[2]' title='$customgeoipgrp{$key}[2]'>";
2295 $col_content = "<b>N/A</b>";
2298 print "<td align='center' $col>$col_content</td>\n";
2300 # Print column with country code.
2301 print "<td align='center' $col>$customgeoipgrp{$key}[2]</td>\n";
2303 # Print column with full country name.
2304 my $country_name = &GeoIP
::get_full_country_name
($customgeoipgrp{$key}[2]);
2305 print "<td align='left' $col>$country_name</td>\n";
2307 # Generate from for removing entries from a group.
2308 print "<td align='right' width='1%' $col><form method='post'>\n";
2311 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}'/>\n";
2313 # Check if this group only has a single entry.
2314 foreach my $key2 (keys %hash) {
2315 if ($hash{$key2}<2 && $key2 eq $customgeoipgrp{$key}[0]){
2316 print "<input type='hidden' name='last' value='on'>" ;
2321 print "<input type='hidden' name='ACTION' value='deletegeoipgrpentry'>\n";
2322 print "<input type='hidden' name='update' value='$fwhostsettings{'update'}'>\n";
2323 print "<input type='hidden' name='delentry' value='$grpname,$remark,$customgeoipgrp{$key}[2],$customgeoipgrp{$key}[3]'>\n";
2329 $helper=$customgeoipgrp{$key}[0];
2334 &Header
::closebox
();
2336 sub viewtableservice
2340 if(! -z
"$configsrv")
2342 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
2343 &General
::readhasharray
("$configsrv", \
%customservice);
2344 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2345 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2346 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2347 &General
::readhasharray
("$fwconfigout", \
%fwout);
2349 <table width='100%' cellspacing='0' class='tbl'>
2350 <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>
2353 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
2356 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
2358 $col="bgcolor='${Header::colouryellow}'";
2359 }elsif ($count % 2){
2361 $col="bgcolor='$color{'color22'}'";
2364 $col="bgcolor='$color{'color20'}'";
2367 <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>
2370 $srvcount=&getsrvcount
($customservice{$key}[0]);
2371 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
2372 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
2374 </td><td align='center' $col>$srvcount x</td>
2375 <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' />
2376 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
2377 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
2378 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
2379 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
2381 if ($srvcount eq '0')
2383 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>";
2385 print"<td $col></td></tr>";
2389 &Header
::closebox
();
2392 sub viewtableservicegrp
2407 if (! -z
$configsrvgrp){
2408 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
2409 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2410 &General
::readhasharray
("$configsrv", \
%customservice);
2411 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2412 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2413 &General
::readhasharray
("$fwconfigout", \
%fwout);
2414 my $number= keys %customservicegrp;
2415 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
2416 push (@counter,$customservicegrp{$key}[0]);
2418 foreach my $key1 (@counter) {
2421 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
2423 if ($helper ne $customservicegrp{$key}[0]){
2424 #Get used groupcounter
2425 $grpcount=&getsrvcount
($customservicegrp{$key}[0]);
2427 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
2428 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
2436 $grpname=$customservicegrp{$key}[0];
2437 if ($customservicegrp{$key}[2] eq "none"){
2438 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};
2442 $remark="$customservicegrp{$key}[1]";
2443 if($count >0){print"</table>";$count=1;}
2444 print "<br><b><u>$grpname</u></b> ";
2445 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
2446 print " <b>$Lang::tr{'used'}:</b> $grpcount x";
2447 if($grpcount == '0')
2449 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>";
2451 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>";
2452 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>";
2454 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
2456 $col="bgcolor='${Header::colouryellow}'";
2457 }elsif ($count %2 == 0){
2459 $col="bgcolor='$color{'color20'}'";
2462 $col="bgcolor='$color{'color22'}'";
2464 #make lines yellow if it is a dummy entry
2465 if ($customservicegrp{$key}[2] eq $Lang::tr
{'fwhost err emptytable'}){
2467 $col="bgcolor='${Header::colouryellow}'";
2469 #Set fields if we use protocols in servicegroups
2470 if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
2473 if ($customservicegrp{$key}[2] eq 'GRE'){$protocol='GRE';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} GRE";}
2474 if ($customservicegrp{$key}[2] eq 'ESP'){$protocol='ESP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} ESP";}
2475 if ($customservicegrp{$key}[2] eq 'AH'){$protocol='AH';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} AH";}
2476 if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
2477 if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
2478 if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
2479 print "<td width='39%' $col>$customservicegrp{$key}[2]</td>";
2480 foreach my $srv (sort keys %customservice){
2481 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
2482 $protocol=$customservice{$srv}[2];
2483 $port=$customservice{$srv}[1];
2487 print"<td align='center' $col>$port</td><td align='center' $col>$protocol</td><td width='1%' $col><form method='post'>";
2488 if ($delflag gt '0'){
2489 if ($customservicegrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
2490 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title=$Lang::tr{'delete'} />";
2492 #check if this group has only one entry
2493 foreach my $key2 (keys %hash) {
2494 if ($hash{$key2}<2 && $key2 eq $customservicegrp{$key}[0]){
2495 print "<input type='hidden' name='last' value='on'>" ;
2499 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
2500 if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
2501 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2]'></form></td></tr>";
2503 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$protocol'></form></td></tr>";
2505 $helper=$customservicegrp{$key}[0];
2508 &Header
::closebox
();
2514 my %hash=%{(shift)};
2515 foreach my $key (keys %hash) {
2516 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2525 &General
::readhasharray
("$configgrp", \
%customgrp );
2527 foreach my $key (keys %customservicegrp) {
2528 if($customservicegrp{$key}[0] eq $name){
2536 &General
::readhasharray
("$configsrv", \
%customservice );
2538 foreach my $key (keys %customservice) {
2539 if($customservice{$key}[0] eq $name){
2548 my %hash=%{(shift)};
2550 foreach my $key (keys %hash) {
2551 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
2559 my %hash=%{(shift)};
2560 &General
::readhasharray
("$confignet", \
%hash);
2561 foreach my $key (keys %hash) {
2562 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
2569 sub checkservicegroup
2571 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2573 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
2575 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
2576 return $errormessage;
2578 #check empty selectbox
2579 if (keys %customservice lt 1)
2581 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
2583 #check if name already exists
2584 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
2585 foreach my $key (keys %customservicegrp) {
2586 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
2587 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
2592 #check if service already exists in group
2593 foreach my $key (keys %customservicegrp) {
2594 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
2595 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
2598 return $errormessage;
2603 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2604 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2605 &General
::readhasharray
("$fwconfigout", \
%fwout);
2607 #check if service or servicegroup is used in rules
2608 foreach my $key (keys %fwfwd){
2609 if($search eq $fwfwd{$key}[15]){
2610 &General
::firewall_config_changed
();
2614 foreach my $key (keys %fwinp){
2615 if($search eq $fwinp{$key}[15]){
2616 &General
::firewall_config_changed
();
2620 foreach my $key (keys %fwout){
2621 if($search eq $fwout{$key}[15]){
2622 &General
::firewall_config_changed
();
2629 if ($errormessage) {
2630 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
2631 print "<class name='base'>$errormessage\n";
2632 print " </class>\n";
2633 &Header
::closebox
();
2639 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
2640 print "<class name='base'>$hint\n";
2641 print " </class>\n";
2642 &Header
::closebox
();
2648 &General
::setup_default_networks
(\
%defaultNetworks);
2649 foreach my $network (sort keys %defaultNetworks)
2651 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
2656 my $searchstring=shift;
2658 #Count services used in servicegroups
2659 foreach my $key (keys %customgrp) {
2660 if($customgrp{$key}[2] eq $searchstring){
2664 #Count services used in firewall - config
2665 foreach my $key1 (keys %fwfwd) {
2666 if($fwfwd{$key1}[4] eq $searchstring){
2669 if($fwfwd{$key1}[6] eq $searchstring){
2673 #Count services used in firewall - input
2674 foreach my $key2 (keys %fwinp) {
2675 if($fwinp{$key2}[4] eq $searchstring){
2678 if($fwinp{$key2}[6] eq $searchstring){
2682 #Count services used in firewall - outgoing
2683 foreach my $key3 (keys %fwout) {
2684 if($fwout{$key3}[4] eq $searchstring){
2687 if($fwout{$key3}[6] eq $searchstring){
2695 my $groupname=shift;
2698 # GeoIP groups are stored as "group:groupname" in the
2699 # firewall settings files.
2700 my $searchstring = join(':', "group",$groupname);
2702 # Count services used in firewall - forward
2703 foreach my $key1 (keys %fwfwd) {
2704 if($fwfwd{$key1}[4] eq $searchstring){
2707 if($fwfwd{$key1}[6] eq $searchstring){
2711 #Count services used in firewall - input
2712 foreach my $key2 (keys %fwinp) {
2713 if($fwinp{$key2}[4] eq $searchstring){
2716 if($fwinp{$key2}[6] eq $searchstring){
2720 #Count services used in firewall - outgoing
2721 foreach my $key3 (keys %fwout) {
2722 if($fwout{$key3}[4] eq $searchstring){
2725 if($fwout{$key3}[6] eq $searchstring){
2733 my $searchstring=shift;
2735 #Count services used in servicegroups
2736 foreach my $key (keys %customgrp) {
2737 if($customgrp{$key}[2] eq $searchstring){
2741 #Count services used in firewall - config
2742 foreach my $key1 (keys %fwfwd) {
2743 if($fwfwd{$key1}[4] eq $searchstring){
2746 if($fwfwd{$key1}[6] eq $searchstring){
2750 #Count services used in firewall - input
2751 foreach my $key2 (keys %fwinp) {
2752 if($fwinp{$key2}[4] eq $searchstring){
2755 if($fwinp{$key2}[6] eq $searchstring){
2759 #Count services used in firewall - outgoing
2760 foreach my $key3 (keys %fwout) {
2761 if($fwout{$key3}[4] eq $searchstring){
2764 if($fwout{$key3}[6] eq $searchstring){
2772 my $searchstring=shift;
2774 #Count services used in servicegroups
2775 foreach my $key (keys %customservicegrp) {
2776 if($customservicegrp{$key}[2] eq $searchstring){
2780 #Count services used in firewall - config
2781 foreach my $key1 (keys %fwfwd) {
2782 if($fwfwd{$key1}[15] eq $searchstring){
2786 #Count services used in firewall - input
2787 foreach my $key2 (keys %fwinp) {
2788 if($fwinp{$key2}[15] eq $searchstring){
2792 #Count services used in firewall - outgoing
2793 foreach my $key3 (keys %fwout) {
2794 if($fwout{$key3}[15] eq $searchstring){
2805 &General
::readhasharray
("$config",\
%hash);
2806 foreach my $key (keys %hash) {
2807 if($hash{$key}[2] eq $target){
2811 &General
::writehasharray
("$config",\
%hash);
2818 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
2820 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
2821 $fwhostsettings{'BLK_IP'}='readonly';
2822 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2823 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2825 #check if name collides with CCD Netname
2826 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2827 foreach my $key (keys %ccdnet) {
2828 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2829 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
2830 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2831 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2835 #check if IP collides with CCD NetIP
2836 if ($fwhostsettings{'type'} ne 'mac'){
2837 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2838 foreach my $key (keys %ccdnet) {
2839 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
2840 if($ccdnet{$key}[1] eq $test){
2841 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
2842 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
2843 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
2844 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2849 #check if name collides with CCD Hostname
2850 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2851 foreach my $key (keys %ccdhost) {
2852 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
2853 if($ip eq $fwhostsettings{'IP'}){
2854 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
2855 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2859 #check if IP collides with CCD HostIP (only hosts)
2860 if ($edit eq 'edithost')
2862 foreach my $key (keys %ccdhost) {
2863 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
2864 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
2865 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
2866 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2871 #check if network with this name already exists
2872 &General
::readhasharray
("$confignet", \
%customnetwork);
2873 if (!&checkname
(\
%customnetwork))
2875 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
2876 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2877 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2879 #check if network ip already exists
2880 if (!&checkip
(\
%customnetwork,1))
2882 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
2883 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2885 #check if host with this name already exists
2886 &General
::readhasharray
("$confighost", \
%customhost);
2887 if (!&checkname
(\
%customhost))
2889 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
2890 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2891 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2893 #check if host with this ip already exists
2894 if (!&checkip
(\
%customhost,2))
2896 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
2906 #get address from IPSEC NETWORK
2907 if ($type eq 'IpSec Network'){
2908 foreach my $key (keys %ipsecconf) {
2909 if ($ipsecconf{$key}[1] eq $name){
2910 return $ipsecconf{$key}[11];
2913 &deletefromgrp
($name,$configgrp);
2916 #get address from IPSEC HOST
2917 if ($type eq 'IpSec Host'){
2918 foreach my $key (keys %ipsecconf) {
2919 if ($ipsecconf{$key}[1] eq $name){
2920 return $ipsecconf{$key}[10];
2923 &deletefromgrp
($name,$configgrp);
2926 #get address from ovpn ccd Net-2-Net
2927 if ($type eq 'OpenVPN N-2-N'){
2928 foreach my $key (keys %ccdhost) {
2929 if($ccdhost{$key}[1] eq $name){
2930 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2931 $b=&General
::iporsubtodec
($b);
2935 &deletefromgrp
($name,$configgrp);
2938 #get address from ovpn ccd static host
2939 if ($type eq 'OpenVPN static host'){
2940 foreach my $key (keys %ccdhost) {
2941 if($ccdhost{$key}[1] eq $name){
2942 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2943 $b=&General
::iporsubtodec
($b);
2947 &deletefromgrp
($name,$configgrp);
2950 #get address from ovpn ccd static net
2951 if ($type eq 'OpenVPN static network'){
2952 foreach my $key (keys %ccdnet) {
2953 if ($ccdnet{$key}[0] eq $name){
2954 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2955 $b=&General
::iporsubtodec
($b);
2961 #check custom addresses
2962 if ($type eq 'Custom Host'){
2963 foreach my $key (keys %customhost) {
2964 if ($customhost{$key}[0] eq $name){
2965 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2971 ##check custom networks
2972 if ($type eq 'Custom Network'){
2973 foreach my $key (keys %customnetwork) {
2974 if($customnetwork{$key}[0] eq $name){
2975 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2980 #check standard networks
2981 if ($type eq 'Standard Network'){
2982 if ($name =~ /OpenVPN/i){
2984 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2985 return $ovpn{'DOVPN_SUBNET'};
2987 if ($name eq 'GREEN'){
2989 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2990 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2992 if ($name eq 'BLUE'){
2994 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2995 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2997 if ($name eq 'ORANGE'){
2999 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
3000 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
3002 if ($name eq 'ALL'){
3003 return "0.0.0.0/0.0.0.0";
3005 if ($name =~ /IPsec/i){
3007 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
3008 return $hash{'RW_NET'};
3010 if ($name eq 'RED'){
3018 &General
::readhasharray
("$confignet", \
%customnetwork);
3019 &General
::readhasharray
("$confighost", \
%customhost);
3020 foreach my $key (sort keys %customgrp ){
3021 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
3022 foreach my $key1 (sort keys %customnetwork){
3023 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
3024 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
3030 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
3031 foreach my $key2 (sort keys %customhost){
3032 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
3033 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
3040 &General
::writehasharray
("$confignet", \
%customnetwork);
3041 &General
::writehasharray
("$confighost", \
%customhost);
3046 &General
::readhasharray
("$configsrv", \
%customservice);
3047 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
3049 foreach my $key (sort keys %customservicegrp){
3050 if ($customservicegrp{$key}[0] eq $grp ){
3051 foreach my $key2 (sort keys %customservice){
3052 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
3053 $customservice{$key2}[4]--;
3058 &General
::writehasharray
("$configsrv", \
%customservice);
3066 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
3067 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
3068 &General
::readhasharray
("$fwconfigout", \
%fwout);
3069 #Rename group in Firewall-CONFIG
3070 foreach my $key1 (keys %fwfwd) {
3071 if($fwfwd{$key1}[$fld] eq $old){
3072 $fwfwd{$key1}[$fld]=$new;
3075 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd );
3076 #Rename group in Firewall-INPUT
3077 foreach my $key2 (keys %fwinp) {
3078 if($fwinp{$key2}[$fld] eq $old){
3079 $fwinp{$key2}[$fld]=$new;
3082 &General
::writehasharray
("$fwconfiginp", \
%fwinp );
3083 #Rename group in Firewall-OUTGOING
3084 foreach my $key3 (keys %fwout) {
3085 if($fwout{$key3}[$fld] eq $old){
3086 $fwout{$key3}[$fld]=$new;
3089 &General
::writehasharray
("$fwconfigout", \
%fwout );
3094 my %hash=%{(shift)};
3096 if ($fwhostsettings{'SRV_NAME'} eq '' ){
3097 $errormessage=$Lang::tr
{'fwhost err name1'};
3099 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
3100 $errormessage=$Lang::tr
{'fwhost err port'};
3103 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
3104 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
3106 #change dashes with :
3107 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
3109 if ($fwhostsettings{'SRV_PORT'} eq "*") {
3110 $fwhostsettings{'SRV_PORT'} = "1:65535";
3112 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
3113 $fwhostsettings{'SRV_PORT'} = "1:$2";
3115 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
3116 $fwhostsettings{'SRV_PORT'} = "$1:65535";
3118 if($fwhostsettings{'PROT'} ne 'ICMP'){
3119 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
3121 # a new service has to have a different name
3122 foreach my $key (keys %hash){
3123 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
3124 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
3128 return $errormessage;
3132 # Checks a hostname against RFC1035
3133 my $hostname = $_[0];
3135 # Each part should be at least two characters in length
3136 # but no more than 63 characters
3137 if (length ($hostname) < 1 || length ($hostname) > 63) {
3139 # Only valid characters are a-z, A-Z, 0-9 and -
3140 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
3142 # First character can only be a letter or a digit
3143 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
3145 # Last character can only be a letter or a digit
3146 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
3152 # Checks a hostname against RFC1035
3154 # Each part should be at least two characters in length
3155 # but no more than 63 characters
3156 if (length ($remark) < 1 || length ($remark) > 255) {
3158 # Only valid characters are a-z, A-Z, 0-9 and -
3159 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
3161 # First character can only be a letter or a digit
3162 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
3164 # Last character can only be a letter or a digit
3165 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
3169 &Header
::closebigbox
();
3170 &Header
::closepage
();