]>
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);
689 # Check for existing group name.
690 if (!&checkgroup
($grp) && $fwhostsettings{'update'} ne 'on'){
691 $errormessage = $Lang::tr
{'fwhost err grpexist'};
695 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
696 $errormessage = $Lang::tr
{'fwhost err remark'};
699 if ($fwhostsettings{'update'} eq 'on'){
700 @target=$fwhostsettings{'COUNTRY_CODE'};
703 #check if host/net exists in grp
704 my $test="$grp,$fwhostsettings{'oldremark'},@target";
705 foreach my $key (keys %customgeoipgrp) {
706 my $test1="$customgeoipgrp{$key}[0],$customgeoipgrp{$key}[1],$customgeoipgrp{$key}[2]";
707 if ($test1 eq $test){
708 $errormessage=$Lang::tr
{'fwhost err isingrp'};
709 $fwhostsettings{'update'} = 'on';
715 #on first save, we have an empty @target, so fill it with nothing
716 my $targetvalues=@target;
717 if ($targetvalues == '0'){
720 #on update, we have to delete the dummy entry
721 foreach my $key (keys %customgeoipgrp){
722 if ($customgeoipgrp{$key}[0] eq $grp && $customgeoipgrp{$key}[2] eq "none"){
723 delete $customgeoipgrp{$key};
727 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
728 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
729 #create array with new lines
730 foreach my $line (@target){
731 push (@newgrp,"$grp,$rem,$line");
734 my $key = &General
::findhasharraykey
(\
%customgeoipgrp);
735 foreach my $line (@newgrp){
736 foreach my $i (0 .. 3) { $customgeoipgrp{$key}[$i] = "";}
737 my ($a,$b,$c,$d) = split (",",$line);
738 $customgeoipgrp{$key}[0] = $a;
739 $customgeoipgrp{$key}[1] = $b;
740 $customgeoipgrp{$key}[2] = $c;
741 $customgeoipgrp{$key}[3] = $type;
743 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
744 #update counter in Host/Net
745 $fwhostsettings{'update'}='on';
747 #check if ruleupdate is needed
749 $geoipgrpcount=&getgeoipcount
($grp);
750 if($geoipgrpcount > 0 )
752 &General
::firewall_config_changed
();
757 if ($fwhostsettings{'ACTION'} eq 'saveservice')
760 &General
::readhasharray
("$configsrv", \
%customservice );
761 &General
::readhasharray
("$configgrp", \
%customgrp);
762 $errormessage=&checkports
(\
%customservice);
763 if ($fwhostsettings{'PROT'} eq 'ICMP'){
764 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
765 foreach my $key (keys %icmptypes){
766 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
767 $ICMP=$icmptypes{$key}[0];
771 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
772 if ($fwhostsettings{'PROT'} ne 'ICMP'){$ICMP='BLANK';}
773 #Check if a group with the same name already exists
774 if (!&checkgroup
($fwhostsettings{'SRV_NAME'})){
775 $errormessage = $Lang::tr
{'fwhost err grpexist'};
778 my $key = &General
::findhasharraykey
(\
%customservice);
779 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
780 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
781 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
782 $customservice{$key}[2] = $fwhostsettings{'PROT'};
783 $customservice{$key}[3] = $ICMP;
784 &General
::writehasharray
("$configsrv", \
%customservice );
786 $fwhostsettings{'SRV_NAME'}='';
787 $fwhostsettings{'SRV_PORT'}='';
788 $fwhostsettings{'PROT'}='';
789 $fwhostsettings{'ICMP_TYPES'}='';
793 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
799 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
800 &General
::readhasharray
("$configsrv", \
%customservice );
801 $errormessage=&checkservicegroup
;
802 #Check if we have more than 15 services from one Protocol in the group
803 #iptables can only handle 15 ports/portranges via multiport
804 foreach my $key (keys %customservicegrp){
805 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
806 foreach my $key1 (keys %customservice){
807 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
808 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
809 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
810 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
814 if ($tcpcounter > 14){
815 $errormessage=$Lang::tr
{'fwhost err maxservicetcp'};
817 if ($udpcounter > 14){
818 $errormessage=$Lang::tr
{'fwhost err maxserviceudp'};
823 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
824 $errormessage .= $Lang::tr
{'fwhost err remark'};
826 #Check if there is already a service with the same name
827 if(!&checkservice
($fwhostsettings{'SRVGRP_NAME'})){
828 $errormessage .= $Lang::tr
{'fwhost err srv exists'};
831 #on first save, we have to enter a dummy value
832 if ($fwhostsettings{'CUST_SRV'} eq ''){
833 $fwhostsettings{'CUST_SRV'}='none';
835 #on update, we have to delete the dummy entry
836 foreach my $key (keys %customservicegrp){
837 if ($customservicegrp{$key}[2] eq 'none' && $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
838 delete $customservicegrp{$key};
842 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
843 #check if remark has also changed
844 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
846 foreach my $key (keys %customservicegrp)
848 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
850 $customservicegrp{$key}[1]='';
851 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
855 my $key = &General
::findhasharraykey
(\
%customservicegrp);
856 foreach my $i (0 .. 2) { $customservice{$key}[$i] = "";}
857 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
858 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
859 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
860 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
861 $fwhostsettings{'updatesrvgrp'}='on';
863 &checkrulereload
($fwhostsettings{'SRVGRP_NAME'});
865 &viewtableservicegrp
;
868 if ($fwhostsettings{'ACTION'} eq 'editnet')
873 if ($fwhostsettings{'ACTION'} eq 'edithost')
878 if ($fwhostsettings{'ACTION'} eq 'editgrp')
880 $fwhostsettings{'update'}='on';
884 if ($fwhostsettings{'ACTION'} eq 'editgeoipgrp')
886 $fwhostsettings{'update'}='on';
890 if ($fwhostsettings{'ACTION'} eq 'editservice')
892 $fwhostsettings{'updatesrv'}='on';
895 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
897 $fwhostsettings{'updatesrvgrp'} = 'on';
899 &viewtableservicegrp
;
902 if ($fwhostsettings{'ACTION'} eq 'resetnet')
904 $fwhostsettings{'HOSTNAME'} ="";
905 $fwhostsettings{'IP'} ="";
906 $fwhostsettings{'SUBNET'} ="";
909 if ($fwhostsettings{'ACTION'} eq 'resethost')
911 $fwhostsettings{'HOSTNAME'} ="";
912 $fwhostsettings{'IP'} ="";
913 $fwhostsettings{'type'} ="";
916 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
918 $fwhostsettings{'grp_name'} ="";
919 $fwhostsettings{'remark'} ="";
922 if ($fwhostsettings{'ACTION'} eq 'resetgeoipgrp')
924 $fwhostsettings{'grp_name'} ="";
925 $fwhostsettings{'remark'} ="";
929 if ($fwhostsettings{'ACTION'} eq 'delnet')
931 &General
::readhasharray
("$confignet", \
%customnetwork);
932 foreach my $key (keys %customnetwork) {
933 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
934 delete $customnetwork{$key};
935 &General
::writehasharray
("$confignet", \
%customnetwork);
942 if ($fwhostsettings{'ACTION'} eq 'delhost')
944 &General
::readhasharray
("$confighost", \
%customhost);
945 foreach my $key (keys %customhost) {
946 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
947 delete $customhost{$key};
948 &General
::writehasharray
("$confighost", \
%customhost);
955 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
959 &General
::readhasharray
("$configgrp", \
%customgrp);
960 foreach my $key (keys %customgrp){
961 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
962 $grpname=$customgrp{$key}[0];
963 $grpremark=$customgrp{$key}[1];
964 #check if we delete the last entry, then generate dummy
965 if ($fwhostsettings{'last'} eq 'on'){
966 $customgrp{$key}[1] = '';
967 $customgrp{$key}[2] = 'none';
968 $customgrp{$key}[3] = '';
969 $fwhostsettings{'last'}='';
972 delete $customgrp{$key};
976 &General
::writehasharray
("$configgrp", \
%customgrp);
977 &General
::firewall_config_changed
();
978 if ($fwhostsettings{'update'} eq 'on'){
979 $fwhostsettings{'remark'}= $grpremark;
980 $fwhostsettings{'grp_name'}=$grpname;
985 if ($fwhostsettings{'ACTION'} eq 'deletegeoipgrpentry')
989 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
990 foreach my $key (keys %customgeoipgrp){
991 if($customgeoipgrp{$key}[0].",".$customgeoipgrp{$key}[1].",".$customgeoipgrp{$key}[2].",".$customgeoipgrp{$key}[3] eq $fwhostsettings{'delentry'}){
992 $grpname=$customgeoipgrp{$key}[0];
993 $grpremark=$customgeoipgrp{$key}[1];
994 #check if we delete the last entry, then generate dummy
995 if ($fwhostsettings{'last'} eq 'on'){
996 $customgeoipgrp{$key}[1] = '';
997 $customgeoipgrp{$key}[2] = 'none';
998 $customgeoipgrp{$key}[3] = '';
999 $fwhostsettings{'last'}='';
1002 delete $customgeoipgrp{$key};
1006 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
1007 &General
::firewall_config_changed
();
1008 if ($fwhostsettings{'update'} eq 'on'){
1009 $fwhostsettings{'remark'}= $grpremark;
1010 $fwhostsettings{'grp_name'}=$grpname;
1016 if ($fwhostsettings{'ACTION'} eq 'delgrp')
1018 &General
::readhasharray
("$configgrp", \
%customgrp);
1019 &decrease
($fwhostsettings{'grp_name'});
1020 foreach my $key (sort keys %customgrp)
1022 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
1024 delete $customgrp{$key};
1027 &General
::writehasharray
("$configgrp", \
%customgrp);
1028 $fwhostsettings{'grp_name'}='';
1032 if ($fwhostsettings{'ACTION'} eq 'delgeoipgrp')
1034 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
1035 &decrease
($fwhostsettings{'grp_name'});
1036 foreach my $key (sort keys %customgeoipgrp)
1038 if($customgeoipgrp{$key}[0] eq $fwhostsettings{'grp_name'})
1040 delete $customgeoipgrp{$key};
1043 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
1044 $fwhostsettings{'grp_name'}='';
1048 if ($fwhostsettings{'ACTION'} eq 'delservice')
1050 &General
::readhasharray
("$configsrv", \
%customservice);
1051 foreach my $key (keys %customservice) {
1052 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
1053 delete $customservice{$key};
1054 &General
::writehasharray
("$configsrv", \
%customservice);
1058 $fwhostsettings{'SRV_NAME'}='';
1059 $fwhostsettings{'SRV_PORT'}='';
1060 $fwhostsettings{'PROT'}='';
1063 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
1065 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1066 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
1067 foreach my $key (sort keys %customservicegrp)
1069 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
1071 delete $customservicegrp{$key};
1074 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1075 $fwhostsettings{'SRVGRP_NAME'}='';
1077 &viewtableservicegrp
;
1079 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
1083 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1084 foreach my $key (keys %customservicegrp){
1085 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'})
1087 $grpname=$customservicegrp{$key}[0];
1088 $grpremark=$customservicegrp{$key}[1];
1089 if($fwhostsettings{'last'} eq 'on'){
1090 $customservicegrp{$key}[2] = 'none';
1091 $fwhostsettings{'last'} = '';
1094 delete $customservicegrp{$key};
1098 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1099 &General
::firewall_config_changed
();
1100 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1101 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1102 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1105 &viewtableservicegrp
;
1107 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1112 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1117 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1122 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgeoipgrp'})
1127 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1131 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1134 &viewtableservicegrp
;
1136 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1138 &General
::readhasharray
("$configgrp", \
%customgrp);
1139 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1140 foreach my $key (sort keys %customgrp)
1142 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1144 $customgrp{$key}[1]='';
1145 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1148 &General
::writehasharray
("$configgrp", \
%customgrp);
1149 $fwhostsettings{'update'}='on';
1150 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1152 $errormessage=$Lang::tr
{'fwhost err remark'};
1153 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1154 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1155 $fwhostsettings{'update'} = 'on';
1157 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1161 if ($fwhostsettings{'ACTION'} eq 'changegeoipgrpremark')
1163 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
1164 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1165 foreach my $key (sort keys %customgeoipgrp)
1167 if($customgeoipgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgeoipgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1169 $customgeoipgrp{$key}[1]='';
1170 $customgeoipgrp{$key}[1]=$fwhostsettings{'newrem'};
1173 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
1174 $fwhostsettings{'update'}='on';
1175 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1177 $errormessage=$Lang::tr
{'fwhost err remark'};
1178 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1179 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1180 $fwhostsettings{'update'} = 'on';
1182 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1186 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1188 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1189 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1190 foreach my $key (sort keys %customservicegrp)
1192 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1194 $customservicegrp{$key}[1]='';
1195 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1198 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1199 $fwhostsettings{'updatesrvgrp'}='on';
1200 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1201 }elsif($fwhostsettings{'oldsrvrem'} eq $fwhostsettings{'newsrvrem'}){
1203 &viewtableservicegrp
;
1205 $errormessage=$Lang::tr
{'fwhost err remark'};
1206 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1207 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1208 $fwhostsettings{'updatesrvgrp'} = 'on';
1210 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1212 &viewtableservicegrp
;
1214 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpname')
1216 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1217 if ($fwhostsettings{'oldsrvgrpname'} ne $fwhostsettings{'srvgrp'}){
1218 #Check new groupname
1219 if (!&validhostname
($fwhostsettings{'srvgrp'})){
1220 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1222 if (!$errormessage){
1223 #Rename group in customservicegroup
1224 foreach my $key (keys %customservicegrp) {
1225 if($customservicegrp{$key}[0] eq $fwhostsettings{'oldsrvgrpname'}){
1226 $customservicegrp{$key}[0]=$fwhostsettings{'srvgrp'};
1229 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
1230 #change name in FW Rules
1231 &changenameinfw
($fwhostsettings{'oldsrvgrpname'},$fwhostsettings{'srvgrp'},15);
1235 &viewtableservicegrp
;
1237 if ($fwhostsettings{'ACTION'} eq 'changegrpname')
1239 &General
::readhasharray
("$configgrp", \
%customgrp );
1240 if ($fwhostsettings{'oldgrpname'} ne $fwhostsettings{'grp'}){
1241 #Check new groupname
1242 if (!&validhostname
($fwhostsettings{'grp'})){
1243 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1245 if (!$errormessage){
1246 #Rename group in customservicegroup
1247 foreach my $key (keys %customgrp) {
1248 if($customgrp{$key}[0] eq $fwhostsettings{'oldgrpname'}){
1249 $customgrp{$key}[0]=$fwhostsettings{'grp'};
1252 &General
::writehasharray
("$configgrp", \
%customgrp );
1253 #change name in FW Rules
1254 &changenameinfw
($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
1260 if ($fwhostsettings{'ACTION'} eq 'changegeoipgrpname')
1262 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp );
1263 if ($fwhostsettings{'oldgrpname'} ne $fwhostsettings{'grp'}){
1264 #Check new groupname
1265 if (!&validhostname
($fwhostsettings{'grp'})){
1266 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1268 if (!$errormessage){
1270 foreach my $key (keys %customgeoipgrp) {
1271 if($customgeoipgrp{$key}[0] eq $fwhostsettings{'oldgrpname'}){
1272 $customgeoipgrp{$key}[0]=$fwhostsettings{'grp'};
1275 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp );
1276 #change name in FW Rules
1277 &changenameinfw
($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
1284 if($fwhostsettings{'ACTION'} eq '')
1290 &Header
::openbox
('100%', 'left',);
1291 print "$Lang::tr{'fwhost welcome'}";
1293 <br><br><table border='0' width='100%'>
1294 <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>
1295 <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>
1296 <tr><td colspan='6'></td></tr></table>
1298 &Header
::closebox
();
1306 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1307 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1308 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1310 <table border='0' width='100%' >
1311 <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>
1312 <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>
1313 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1314 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1315 <tr><td colspan='6'><br></td></tr><tr>
1317 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1319 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'}'>";
1321 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'>";
1323 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>";
1324 &Header
::closebox
();
1330 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1331 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1332 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1334 <table width='100%'>
1335 <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>
1336 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1337 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1338 <tr><td colspan='5'><br></td></tr><tr>
1341 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1344 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>";
1346 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'>";
1348 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>";
1349 &Header
::closebox
();
1356 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1357 &General
::setup_default_networks
(\
%defaultNetworks);
1358 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1359 &General
::readhasharray
("$confignet", \
%customnetwork);
1360 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1361 &General
::readhasharray
("$confighost", \
%customhost);
1362 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1366 $checked{'check1'}{'off'} = '';
1367 $checked{'check1'}{'on'} = '';
1368 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1369 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1370 $fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'};
1371 my $grp=$fwhostsettings{'grp_name'};
1372 my $rem=$fwhostsettings{'remark'};
1373 if ($fwhostsettings{'update'} eq ''){
1375 <table width='100%' border='0'>
1377 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1378 <td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='30'></td>
1381 <td>$Lang::tr{'remark'}:</td>
1382 <td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 99%;'></td>
1385 <td colspan='2'><br></td>
1391 <table width='100%' border='0'><form method='post'>
1393 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1394 <td style='width:30%;'><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' size='30'></td>
1395 <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>
1398 <tr><form method='post' style='display:inline'>
1399 <td>$Lang::tr{'remark'}:</td>
1400 <td colspan='2' style='width:98%;'><input type='TEXT' name='newrem' value='$fwhostsettings{'remark'}' style='width:98%;'></td>
1401 <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>
1407 if ($fwhostsettings{'update'} eq 'on'){
1409 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1410 <table width='100%' border='0'>
1411 <tr><td width=50% valign='top'>
1412 <table width='90%' border='0'>
1414 <td style='width:15em;'>
1416 <input type='radio' name='grp2' value='std_net' id='DEFAULT_SRC_ADR' checked>
1417 $Lang::tr{'fwhost stdnet'}
1420 <td style='text-align:right;'>
1421 <select name='DEFAULT_SRC_ADR' style='width:16em;'>
1423 foreach my $network (sort keys %defaultNetworks)
1425 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1426 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1427 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1428 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1429 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1430 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1431 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1432 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1433 if ($ownnet{$defnet}){
1434 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1436 print ">$network</option>";
1439 print"</select></td></tr>";
1440 if (! -z
$confignet){
1445 <input type='radio' name='grp2' id='CUST_SRC_NET' value='cust_net' $checked{'grp2'}{'cust_net'}>
1446 $Lang::tr{'fwhost cust net'}:
1449 <td style='text-align:right;'>
1450 <select name='CUST_SRC_NET' style='width:16em;'>";
1452 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1453 print"<option>$customnetwork{$key}[0]</option>";
1455 print"</select></td></tr>";
1457 if (! -z
$confighost){
1462 <input type='radio' name='grp2' id='CUST_SRC_HOST' value='cust_host' $checked{'grp2'}{'cust_host'}>
1463 $Lang::tr{'fwhost cust addr'}:
1466 <td style='text-align:right;'>
1467 <select name='CUST_SRC_HOST' style='width:16em;'>";
1469 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1470 print"<option>$customhost{$key}[0]</option>";
1472 print"</select></td></tr>";
1476 print"</td><td align='right' style='vertical-align:top;'><table width='90%' border='0'>";
1478 if (! -z
$configccdnet){
1480 <td style='width:15em;'>
1482 <input type='radio' name='grp2' id='OVPN_CCD_NET' value='ovpn_net' $checked{'grp2'}{'ovpn_net'}>
1483 $Lang::tr{'fwhost ccdnet'}
1486 <td style='text-align:right;'>
1487 <select name='OVPN_CCD_NET' style='width:16em;'>";
1489 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1491 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1493 print"</select></td></tr>";
1496 my @ovpn_clients=();
1497 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1499 if ($ccdhost{$key}[33] ne ''){
1501 push (@ovpn_clients,$ccdhost{$key}[1]);
1507 <td style='width:15em;'>
1509 <input type='radio' name='grp2' value='ovpn_host' $checked{'grp2'}{'ovpn_host'}>
1510 $Lang::tr{'fwhost ccdhost'}
1513 <td style='text-align:right;'>
1514 <select name='OVPN_CCD_HOST' style='width:16em;'>" if ($show eq '');
1516 foreach(@ovpn_clients){
1517 print"<option value='$_'>$_</option>";
1519 print"</select></td></tr>";
1523 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1524 if($ccdhost{$key}[3] eq 'net'){
1526 push (@OVPN_N2N,$ccdhost{$key}[1]);
1532 <td style='width:15em;'>
1534 <input type='radio' name='grp2' id='OVPN_N2N' value='ovpn_n2n' $checked{'grp2'}{'ovpn_n2n'}>
1535 $Lang::tr{'fwhost ovpn_n2n'}:
1538 <td style='text-align:right;'>
1539 <select name='OVPN_N2N' style='width:16em;'>"
1542 print"<option>$_</option>";
1544 print"</select></td></tr>";
1548 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1549 if ($ipsecconf{$key}[3] eq 'net'){
1551 push (@IPSEC_N2N,$ipsecconf{$key}[1]);
1557 <td style='width:15em;'>
1559 <input type='radio' name='grp2' id='IPSEC_NET' value='ipsec_net' $checked{'grp2'}{'ipsec_net'}>
1560 $Lang::tr{'fwhost ipsec net'}
1563 <td style='text-align:right;'>
1564 <select name='IPSEC_NET' style='width:16em;'>"
1566 foreach(@IPSEC_N2N){
1567 print"<option value='$_'>$_</option>";
1570 print"</select></td></tr>";
1572 print"</td></tr></table>";
1575 print"<table width='100%'>";
1576 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>";
1577 &Header
::closebox
();
1584 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgeoipgrp'});
1588 $checked{'check1'}{'off'} = '';
1589 $checked{'check1'}{'on'} = '';
1590 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1591 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1592 $fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'};
1593 my $grp=$fwhostsettings{'grp_name'};
1594 my $rem=$fwhostsettings{'remark'};
1595 if ($fwhostsettings{'update'} eq ''){
1597 <table width='100%' border='0'>
1599 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1600 <td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='30'></td>
1603 <td>$Lang::tr{'remark'}:</td>
1604 <td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 99%;'></td>
1607 <td colspan='2'><br></td>
1613 <table width='100%' border='0'>
1614 <form method='post'><tr>
1615 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1616 <td style='width:30%;'><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' size='30'></td>
1618 <input type='submit' value='$Lang::tr{'fwhost change'}'>
1619 <input type='hidden' name='oldgrpname' value='$fwhostsettings{'oldgrpname'}'>
1620 <input type='hidden' name='ACTION' value='changegeoipgrpname'>
1624 <tr><form method='post' style='display:inline'>
1625 <td>$Lang::tr{'remark'}:</td>
1626 <td colspan='2' style='width:98%;'>
1627 <input type='TEXT' name='newrem' value='$fwhostsettings{'remark'}' style='width:98%;'>
1630 <input type='submit' value='$Lang::tr{'fwhost change'}'>
1631 <input type='hidden' name='grp' value='$fwhostsettings{'grp_name'}'>
1632 <input type='hidden' name='oldrem' value='$fwhostsettings{'oldremark'}'>
1633 <input type='hidden' name='ACTION' value='changegeoipgrpremark'>
1640 if ($fwhostsettings{'update'} eq 'on') {
1641 my @geoip_locations = &fwlib
::get_geoip_locations
();
1644 <form method='post'>
1645 <input type='hidden' name='remark' value='$rem'>
1646 <input type='hidden' name='grp_name' value='$grp'>
1648 <table width='100%' border='0'>
1650 <td style='text-align:left;'>
1651 <select name='COUNTRY_CODE' style='width:16em;'>";
1653 foreach my $location (@geoip_locations) {
1654 # Get full country name.
1655 my $fullname = &GeoIP
::get_full_country_name
($location);
1657 print"<option value='$location'>$location - $fullname</option>\n";
1668 <table width='100%'>
1669 <tr><td style='text-align:right;'>
1670 <input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1671 <input type='hidden' name='oldremark' value='$fwhostsettings{'oldremark'}'>
1672 <input type='hidden' name='update' value=\"$fwhostsettings{'update'}\">
1673 <input type='hidden' name='ACTION' value='savegeoipgrp' >
1676 <form method='post' style='display:inline'>
1678 <input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'>
1679 <input type='hidden' name='ACTION' value='resetgeoipgrp'>
1684 &Header
::closebox
();
1690 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1691 if ($fwhostsettings{'updatesrv'} eq 'on')
1693 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1694 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1695 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1696 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1699 <table width='100%' border='0'><form method='post'>
1700 <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>
1701 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1703 foreach ("TCP","UDP","ICMP")
1705 if ($_ eq $fwhostsettings{'PROT'})
1707 print"<option selected>$_</option>";
1709 print"<option>$_</option>";
1713 </select></td></tr></table>
1714 <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'>
1716 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1717 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1718 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1719 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1720 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1722 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1726 </select></td></tr></table></div>
1727 <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>
1728 <table width='100%' border='0'><tr><td colspan='6'><br></td></tr>
1729 <tr><td colspan='6' align='right'>
1731 if ($fwhostsettings{'updatesrv'} eq 'on')
1734 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1735 <input type='hidden' name='ACTION' value='updateservice'>
1736 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1737 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1738 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1739 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1743 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1746 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1749 &Header
::closebox
();
1757 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1758 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1759 $fwhostsettings{'oldsrvgrpname'}=$fwhostsettings{'SRVGRP_NAME'};
1760 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1762 <table width='100%' border='0'><form method='post'>
1763 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1764 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1765 <tr><td colspan='2'><br></tr>
1770 <table width='100%'><form method='post' style='display:inline'>
1771 <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>
1773 <form method='post'>
1775 $Lang::tr{'remark'}:
1778 <input type='text' name='newsrvrem' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width:98%;'>
1781 <input type='submit' value='$Lang::tr{'fwhost change'}'>
1782 <input type='hidden' name='oldsrvrem' value='$fwhostsettings{'oldsrvgrpremark'}'>
1783 <input type='hidden' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}'>
1784 <input type='hidden' name='ACTION' value='changesrvgrpremark' >
1796 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1798 <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%'>
1799 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'add'}: </td><td><select name='CUST_SRV' style='min-width:185px;'>
1801 &General
::readhasharray
("$configsrv", \
%customservice);
1802 #Protocols for use in servicegroups
1803 print "<optgroup label='$Lang::tr{'fwhost cust service'}'>";
1804 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1806 print "<option>$customservice{$key}[0]</option>";
1808 print "</optgroup>";
1809 print "<optgroup label='$Lang::tr{'protocol'}'>";
1810 print "<option>GRE</option>";
1811 print "<option>AH</option>";
1812 print "<option>ESP</option>";
1813 print "<option>IGMP</option>";
1814 print "<option>IPIP</option>";
1815 print "<option value='IPV6'>IPv6 encap</option>";
1816 print "</optgroup>";
1819 <tr><td colspan='4'><br><br></td></tr>
1820 <tr><td colspan='4'></td></tr>
1825 <table width='100%'>
1826 <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>
1829 &Header
::closebox
();
1834 if(! -z
$confignet){
1835 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1836 &General
::readhasharray
("$confignet", \
%customnetwork);
1837 &General
::readhasharray
("$configgrp", \
%customgrp);
1838 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1839 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1840 &General
::readhasharray
("$fwconfigout", \
%fwout);
1842 if (!keys %customnetwork)
1844 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1847 <table width='100%' cellspacing='0' class='tbl'>
1848 <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>
1853 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1854 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1856 $col="bgcolor='${Header::colouryellow}'";
1859 $col="bgcolor='$color{'color20'}'";
1863 $col="bgcolor='$color{'color22'}'";
1866 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1867 my $netcount=&getnetcount
($customnetwork{$key}[0]);
1868 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>";
1870 <td width='1%' $col><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
1871 <input type='hidden' name='ACTION' value='editnet'>
1872 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1873 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1874 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1875 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1878 if($netcount == '0')
1880 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>";
1882 print"<td $col></td></tr>";
1887 &Header
::closebox
();
1898 if (&General
::validmac
($c)){ return $c;}
1900 #Check if we got a full IP with subnet then split it
1901 if($c =~ /^(.*?)\/(.*?
)$/){
1902 ($sip,$scidr) = split ("/",$c);
1907 #Now check if IP is part of ORANGE,BLUE or GREEN
1908 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1909 $tdcolor="<font style='color: $Header::colourorange;'>$c</font>";
1912 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1913 $tdcolor="<font style='color: $Header::colourgreen;'>$c</font>";
1916 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1917 $tdcolor="<font style='color: $Header::colourblue;'>$c</font>";
1920 if ("$sip/$scidr" eq "0.0.0.0/0"){
1921 $tdcolor="<font style='color: $Header::colourred;'>$c</font>";
1924 #Check if IP is part of OpenVPN N2N subnet
1925 foreach my $key (sort keys %ccdhost){
1926 if ($ccdhost{$key}[3] eq 'net'){
1927 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1928 if (&General
::IpInSubnet
($sip,$a,$b)){
1929 $tdcolor="<font style='color:$Header::colourovpn ;'>$c</font>";
1935 #Check if IP is part of OpenVPN dynamic subnet
1936 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1937 if (&General
::IpInSubnet
($sip,$a,$b)){
1938 $tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
1942 #Check if IP is part of OpenVPN static subnet
1943 foreach my $key (sort keys %ccdnet){
1944 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1945 $b =&General
::iporsubtodec
($b);
1946 if (&General
::IpInSubnet
($sip,$a,$b)){
1947 $tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
1952 #Check if IP is part of IPsec RW network
1953 if ($ipsecsettings{'RW_NET'} ne ''){
1954 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1955 $b=&General
::iporsubtodec
($b);
1956 if (&General
::IpInSubnet
($sip,$a,$b)){
1957 $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
1962 #Check if IP is part of a IPsec N2N network
1963 foreach my $key (sort keys %ipsecconf){
1964 if ($ipsecconf{$key}[11]){
1965 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1966 $b=&General
::iporsubtodec
($b);
1967 if (&General
::IpInSubnet
($sip,$a,$b)){
1968 $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
1977 if (! -z
$confighost){
1978 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1979 &General
::readhasharray
("$confighost", \
%customhost);
1980 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1981 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1982 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1983 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1984 &General
::readhasharray
("$fwconfigout", \
%fwout);
1985 &General
::readhasharray
("$configgrp", \
%customgrp);
1986 if (!keys %customhost)
1988 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1991 <table width='100%' cellspacing='0' class='tbl'>
1992 <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>
1997 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1998 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
2000 $col="bgcolor='${Header::colouryellow}'";
2001 }elsif ($count % 2){
2003 $col="bgcolor='$color{'color20'}'";
2005 $col="bgcolor='$color{'color22'}'";
2008 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
2009 $customhost{$key}[4]=~s/\s+//g;
2011 $hostcount=&gethostcount
($customhost{$key}[0]);
2012 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>";
2014 <td width='1%' $col><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
2015 <input type='hidden' name='ACTION' value='edithost' />
2016 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
2017 <input type='hidden' name='IP' value='$ip' />
2018 <input type='hidden' name='type' value='$customhost{$key}[1]' />
2019 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
2022 if($hostcount == '0')
2024 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>";
2026 print"<td width='1%' $col></td></tr>";
2031 &Header
::closebox
();
2036 if(! -z
"$configgrp"){
2037 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
2038 &General
::readhasharray
("$configgrp", \
%customgrp);
2039 &General
::readhasharray
("$configipsec", \
%ipsecconf);
2040 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2041 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2042 &General
::readhasharray
("$confighost", \
%customhost);
2043 &General
::readhasharray
("$confignet", \
%customnetwork);
2044 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2045 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2046 &General
::readhasharray
("$fwconfigout", \
%fwout);
2056 if (!keys %customgrp)
2058 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
2060 #get all groups in a hash
2061 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
2062 push (@counter,$customgrp{$key}[0]);
2064 foreach my $key1 (@counter) {
2067 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
2069 if ($helper ne $customgrp{$key}[0]){
2071 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
2072 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
2081 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
2082 $grpname=$customgrp{$key}[0];
2083 $remark="$customgrp{$key}[1]";
2084 if($count gt 1){ print"</table>";$count=1;}
2085 print "<br><b><u>$grpname</u></b> ";
2086 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
2087 my $netgrpcount=&getnetcount
($grpname);
2088 print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
2089 if($netgrpcount == '0')
2091 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>";
2093 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>";
2094 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>";
2097 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
2099 $col="bgcolor='${Header::colouryellow}'";
2100 }elsif ($count %2 == 0){
2102 $col="bgcolor='$color{'color20'}'";
2105 $col="bgcolor='$color{'color22'}'";
2107 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
2110 $col="bgcolor='${Header::colouryellow}'";
2112 print "<td width='39%' align='left' $col>";
2113 if($customgrp{$key}[3] eq 'Standard Network'){
2114 print &get_name
($customgrp{$key}[2])."</td>";
2116 print "$customgrp{$key}[2]</td>";
2118 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
2119 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'>";
2121 my ($colip,$colsub) = split("/",$ip);
2122 $ip="$colip/".&General
::iporsubtocidr
($colsub) if ($colsub);
2123 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'>";
2125 if ($delflag > 0 && $ip ne ''){
2126 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' />";
2127 #check if this group has only one entry
2128 foreach my $key2 (keys %hash) {
2129 if ($hash{$key2}<2 && $key2 eq $customgrp{$key}[0]){
2130 print "<input type='hidden' name='last' value='on'>" ;
2134 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>";
2135 $helper=$customgrp{$key}[0];
2140 &Header
::closebox
();
2144 sub viewtablegeoipgrp
2146 # If our filesize is "zero" there is nothing to read-in.
2147 if (-z
"$configgeoipgrp") {
2151 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust geoipgrp'});
2152 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
2153 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2154 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2155 &General
::readhasharray
("$fwconfigout", \
%fwout);
2167 # If there are no groups we are finished here.
2168 if (!keys %customgeoipgrp) {
2169 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
2173 # Put all groups in a hash.
2174 foreach my $key (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) }
2175 sort { ncmp
($customgeoipgrp{$a}[2],$customgeoipgrp{$b}[2]) } keys %customgeoipgrp) {
2176 push (@counter,$customgeoipgrp{$key}[0]);
2179 # Increase current used key.
2180 foreach my $key1 (@counter) {
2185 foreach my $key (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) }
2186 sort { ncmp
($customgeoipgrp{$a}[2],$customgeoipgrp{$b}[2]) } keys %customgeoipgrp) {
2188 if ($helper ne $customgeoipgrp{$key}[0]) {
2191 foreach my $key1 (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) }
2192 sort { ncmp
($customgeoipgrp{$a}[2],$customgeoipgrp{$b}[2]) } keys %customgeoipgrp) {
2194 if ($customgeoipgrp{$key}[0] eq $customgeoipgrp{$key1}[0])
2206 $grpname=$customgeoipgrp{$key}[0];
2209 $remark="$customgeoipgrp{$key}[1]";
2212 $country_code="$customgeoipgrp{$key}[2]";
2219 # Display groups header.
2220 print "<br><b><u>$grpname</u></b> \n";
2221 print "<b>$Lang::tr{'remark'}:</b>  $remark  \n" if ($remark ne '');
2224 my $geoipgrpcount=&getgeoipcount
($grpname);
2225 print "<b>$Lang::tr{'used'}:</b> $geoipgrpcount x";
2227 # Only display delete icon, if the group is not used by a firewall rule.
2228 if($geoipgrpcount == '0') {
2229 print"<form method='post' style='display:inline'>\n";
2230 print"<input type='image' src='/images/delete.gif' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' align='right' />\n";
2231 print"<input type='hidden' name='grp_name' value='$grpname' >\n";
2232 print"<input type='hidden' name='ACTION' value='delgeoipgrp'>\n";
2236 # Icon for group editing.
2238 <form method='post' style='display:inline'>
2239 <input type='image' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' align='right'/>
2240 <input type='hidden' name='grp_name' value='$grpname' >
2241 <input type='hidden' name='remark' value='$remark' >
2242 <input type='hidden' name='ACTION' value='editgeoipgrp'>
2245 <table width='100%' cellspacing='0' class='tbl'>
2247 # Display headlines if the group contains any entries.
2248 if ($country_code ne "none") {
2251 <td width='10%' align='center'>
2252 <b>$Lang::tr{'flag'}</b>
2255 <td width='10%'align='center'>
2256 <b>$Lang::tr{'countrycode'}</b>
2259 <td width='70%'align='left'>
2260 <b>$Lang::tr{'country'}</b>
2263 <td width='10%' align='right'></td>
2269 # Check if our group contains any entries.
2270 if ($country_code eq "none") {
2271 print "<tr><td>$Lang::tr{'fwhost err emptytable'}</td></tr>\n";
2273 # Check if we are currently editing a group and assign column backgound colors.
2275 if ( ($fwhostsettings{'ACTION'} eq 'editgeoipgrp' || $fwhostsettings{'update'} ne '')
2276 && $fwhostsettings{'grp_name'} eq $customgeoipgrp{$key}[0]) {
2277 $col="bgcolor='${Header::colouryellow}'";
2278 } elsif ($count %2 == 0){
2279 $col="bgcolor='$color{'color20'}'";
2281 $col="bgcolor='$color{'color22'}'";
2285 my $icon = &GeoIP
::get_flag_icon
($customgeoipgrp{$key}[2]);
2287 # Print column with flag icon.
2290 $col_content = "<img src='$icon' alt='$customgeoipgrp{$key}[2]' title='$customgeoipgrp{$key}[2]'>";
2292 $col_content = "<b>N/A</b>";
2295 print "<td align='center' $col>$col_content</td>\n";
2297 # Print column with country code.
2298 print "<td align='center' $col>$customgeoipgrp{$key}[2]</td>\n";
2300 # Print column with full country name.
2301 my $country_name = &GeoIP
::get_full_country_name
($customgeoipgrp{$key}[2]);
2302 print "<td align='left' $col>$country_name</td>\n";
2304 # Generate from for removing entries from a group.
2305 print "<td align='right' width='1%' $col><form method='post'>\n";
2308 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}'/>\n";
2310 # Check if this group only has a single entry.
2311 foreach my $key2 (keys %hash) {
2312 if ($hash{$key2}<2 && $key2 eq $customgeoipgrp{$key}[0]){
2313 print "<input type='hidden' name='last' value='on'>" ;
2318 print "<input type='hidden' name='ACTION' value='deletegeoipgrpentry'>\n";
2319 print "<input type='hidden' name='update' value='$fwhostsettings{'update'}'>\n";
2320 print "<input type='hidden' name='delentry' value='$grpname,$remark,$customgeoipgrp{$key}[2],$customgeoipgrp{$key}[3]'>\n";
2326 $helper=$customgeoipgrp{$key}[0];
2331 &Header
::closebox
();
2333 sub viewtableservice
2337 if(! -z
"$configsrv")
2339 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
2340 &General
::readhasharray
("$configsrv", \
%customservice);
2341 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2342 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2343 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2344 &General
::readhasharray
("$fwconfigout", \
%fwout);
2346 <table width='100%' cellspacing='0' class='tbl'>
2347 <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>
2350 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
2353 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
2355 $col="bgcolor='${Header::colouryellow}'";
2356 }elsif ($count % 2){
2358 $col="bgcolor='$color{'color22'}'";
2361 $col="bgcolor='$color{'color20'}'";
2364 <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>
2367 $srvcount=&getsrvcount
($customservice{$key}[0]);
2368 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
2369 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
2371 </td><td align='center' $col>$srvcount x</td>
2372 <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' />
2373 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
2374 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
2375 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
2376 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
2378 if ($srvcount eq '0')
2380 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>";
2382 print"<td $col></td></tr>";
2386 &Header
::closebox
();
2389 sub viewtableservicegrp
2404 if (! -z
$configsrvgrp){
2405 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
2406 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2407 &General
::readhasharray
("$configsrv", \
%customservice);
2408 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2409 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2410 &General
::readhasharray
("$fwconfigout", \
%fwout);
2411 my $number= keys %customservicegrp;
2412 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
2413 push (@counter,$customservicegrp{$key}[0]);
2415 foreach my $key1 (@counter) {
2418 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
2420 if ($helper ne $customservicegrp{$key}[0]){
2421 #Get used groupcounter
2422 $grpcount=&getsrvcount
($customservicegrp{$key}[0]);
2424 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
2425 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
2433 $grpname=$customservicegrp{$key}[0];
2434 if ($customservicegrp{$key}[2] eq "none"){
2435 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};
2439 $remark="$customservicegrp{$key}[1]";
2440 if($count >0){print"</table>";$count=1;}
2441 print "<br><b><u>$grpname</u></b> ";
2442 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
2443 print " <b>$Lang::tr{'used'}:</b> $grpcount x";
2444 if($grpcount == '0')
2446 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>";
2448 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>";
2449 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>";
2451 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
2453 $col="bgcolor='${Header::colouryellow}'";
2454 }elsif ($count %2 == 0){
2456 $col="bgcolor='$color{'color20'}'";
2459 $col="bgcolor='$color{'color22'}'";
2461 #make lines yellow if it is a dummy entry
2462 if ($customservicegrp{$key}[2] eq $Lang::tr
{'fwhost err emptytable'}){
2464 $col="bgcolor='${Header::colouryellow}'";
2466 #Set fields if we use protocols in servicegroups
2467 if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
2470 if ($customservicegrp{$key}[2] eq 'GRE'){$protocol='GRE';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} GRE";}
2471 if ($customservicegrp{$key}[2] eq 'ESP'){$protocol='ESP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} ESP";}
2472 if ($customservicegrp{$key}[2] eq 'AH'){$protocol='AH';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} AH";}
2473 if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
2474 if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
2475 if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
2476 print "<td width='39%' $col>$customservicegrp{$key}[2]</td>";
2477 foreach my $srv (sort keys %customservice){
2478 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
2479 $protocol=$customservice{$srv}[2];
2480 $port=$customservice{$srv}[1];
2484 print"<td align='center' $col>$port</td><td align='center' $col>$protocol</td><td width='1%' $col><form method='post'>";
2485 if ($delflag gt '0'){
2486 if ($customservicegrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
2487 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title=$Lang::tr{'delete'} />";
2489 #check if this group has only one entry
2490 foreach my $key2 (keys %hash) {
2491 if ($hash{$key2}<2 && $key2 eq $customservicegrp{$key}[0]){
2492 print "<input type='hidden' name='last' value='on'>" ;
2496 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
2497 if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
2498 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2]'></form></td></tr>";
2500 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$protocol'></form></td></tr>";
2502 $helper=$customservicegrp{$key}[0];
2505 &Header
::closebox
();
2511 my %hash=%{(shift)};
2512 foreach my $key (keys %hash) {
2513 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2522 &General
::readhasharray
("$configgrp", \
%customgrp );
2524 foreach my $key (keys %customservicegrp) {
2525 if($customservicegrp{$key}[0] eq $name){
2533 &General
::readhasharray
("$configsrv", \
%customservice );
2535 foreach my $key (keys %customservice) {
2536 if($customservice{$key}[0] eq $name){
2545 my %hash=%{(shift)};
2547 foreach my $key (keys %hash) {
2548 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
2556 my %hash=%{(shift)};
2557 &General
::readhasharray
("$confignet", \
%hash);
2558 foreach my $key (keys %hash) {
2559 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
2566 sub checkservicegroup
2568 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2570 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
2572 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
2573 return $errormessage;
2575 #check empty selectbox
2576 if (keys %customservice lt 1)
2578 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
2580 #check if name already exists
2581 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
2582 foreach my $key (keys %customservicegrp) {
2583 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
2584 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
2589 #check if service already exists in group
2590 foreach my $key (keys %customservicegrp) {
2591 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
2592 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
2595 return $errormessage;
2600 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2601 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2602 &General
::readhasharray
("$fwconfigout", \
%fwout);
2604 #check if service or servicegroup is used in rules
2605 foreach my $key (keys %fwfwd){
2606 if($search eq $fwfwd{$key}[15]){
2607 &General
::firewall_config_changed
();
2611 foreach my $key (keys %fwinp){
2612 if($search eq $fwinp{$key}[15]){
2613 &General
::firewall_config_changed
();
2617 foreach my $key (keys %fwout){
2618 if($search eq $fwout{$key}[15]){
2619 &General
::firewall_config_changed
();
2626 if ($errormessage) {
2627 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
2628 print "<class name='base'>$errormessage\n";
2629 print " </class>\n";
2630 &Header
::closebox
();
2636 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
2637 print "<class name='base'>$hint\n";
2638 print " </class>\n";
2639 &Header
::closebox
();
2645 &General
::setup_default_networks
(\
%defaultNetworks);
2646 foreach my $network (sort keys %defaultNetworks)
2648 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
2653 my $searchstring=shift;
2655 #Count services used in servicegroups
2656 foreach my $key (keys %customgrp) {
2657 if($customgrp{$key}[2] eq $searchstring){
2661 #Count services used in firewall - config
2662 foreach my $key1 (keys %fwfwd) {
2663 if($fwfwd{$key1}[4] eq $searchstring){
2666 if($fwfwd{$key1}[6] eq $searchstring){
2670 #Count services used in firewall - input
2671 foreach my $key2 (keys %fwinp) {
2672 if($fwinp{$key2}[4] eq $searchstring){
2675 if($fwinp{$key2}[6] eq $searchstring){
2679 #Count services used in firewall - outgoing
2680 foreach my $key3 (keys %fwout) {
2681 if($fwout{$key3}[4] eq $searchstring){
2684 if($fwout{$key3}[6] eq $searchstring){
2692 my $groupname=shift;
2695 # GeoIP groups are stored as "group:groupname" in the
2696 # firewall settings files.
2697 my $searchstring = join(':', "group",$groupname);
2699 # Count services used in firewall - forward
2700 foreach my $key1 (keys %fwfwd) {
2701 if($fwfwd{$key1}[4] eq $searchstring){
2704 if($fwfwd{$key1}[6] eq $searchstring){
2708 #Count services used in firewall - input
2709 foreach my $key2 (keys %fwinp) {
2710 if($fwinp{$key2}[4] eq $searchstring){
2713 if($fwinp{$key2}[6] eq $searchstring){
2717 #Count services used in firewall - outgoing
2718 foreach my $key3 (keys %fwout) {
2719 if($fwout{$key3}[4] eq $searchstring){
2722 if($fwout{$key3}[6] eq $searchstring){
2730 my $searchstring=shift;
2732 #Count services used in servicegroups
2733 foreach my $key (keys %customgrp) {
2734 if($customgrp{$key}[2] eq $searchstring){
2738 #Count services used in firewall - config
2739 foreach my $key1 (keys %fwfwd) {
2740 if($fwfwd{$key1}[4] eq $searchstring){
2743 if($fwfwd{$key1}[6] eq $searchstring){
2747 #Count services used in firewall - input
2748 foreach my $key2 (keys %fwinp) {
2749 if($fwinp{$key2}[4] eq $searchstring){
2752 if($fwinp{$key2}[6] eq $searchstring){
2756 #Count services used in firewall - outgoing
2757 foreach my $key3 (keys %fwout) {
2758 if($fwout{$key3}[4] eq $searchstring){
2761 if($fwout{$key3}[6] eq $searchstring){
2769 my $searchstring=shift;
2771 #Count services used in servicegroups
2772 foreach my $key (keys %customservicegrp) {
2773 if($customservicegrp{$key}[2] eq $searchstring){
2777 #Count services used in firewall - config
2778 foreach my $key1 (keys %fwfwd) {
2779 if($fwfwd{$key1}[15] eq $searchstring){
2783 #Count services used in firewall - input
2784 foreach my $key2 (keys %fwinp) {
2785 if($fwinp{$key2}[15] eq $searchstring){
2789 #Count services used in firewall - outgoing
2790 foreach my $key3 (keys %fwout) {
2791 if($fwout{$key3}[15] eq $searchstring){
2802 &General
::readhasharray
("$config",\
%hash);
2803 foreach my $key (keys %hash) {
2804 if($hash{$key}[2] eq $target){
2808 &General
::writehasharray
("$config",\
%hash);
2815 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
2817 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
2818 $fwhostsettings{'BLK_IP'}='readonly';
2819 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2820 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2822 #check if name collides with CCD Netname
2823 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2824 foreach my $key (keys %ccdnet) {
2825 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2826 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
2827 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2828 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2832 #check if IP collides with CCD NetIP
2833 if ($fwhostsettings{'type'} ne 'mac'){
2834 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2835 foreach my $key (keys %ccdnet) {
2836 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
2837 if($ccdnet{$key}[1] eq $test){
2838 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
2839 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
2840 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
2841 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2846 #check if name collides with CCD Hostname
2847 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2848 foreach my $key (keys %ccdhost) {
2849 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
2850 if($ip eq $fwhostsettings{'IP'}){
2851 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
2852 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2856 #check if IP collides with CCD HostIP (only hosts)
2857 if ($edit eq 'edithost')
2859 foreach my $key (keys %ccdhost) {
2860 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
2861 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
2862 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
2863 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2868 #check if network with this name already exists
2869 &General
::readhasharray
("$confignet", \
%customnetwork);
2870 if (!&checkname
(\
%customnetwork))
2872 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
2873 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2874 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2876 #check if network ip already exists
2877 if (!&checkip
(\
%customnetwork,1))
2879 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
2880 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2882 #check if host with this name already exists
2883 &General
::readhasharray
("$confighost", \
%customhost);
2884 if (!&checkname
(\
%customhost))
2886 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
2887 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2888 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2890 #check if host with this ip already exists
2891 if (!&checkip
(\
%customhost,2))
2893 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
2903 #get address from IPSEC NETWORK
2904 if ($type eq 'IpSec Network'){
2905 foreach my $key (keys %ipsecconf) {
2906 if ($ipsecconf{$key}[1] eq $name){
2907 return $ipsecconf{$key}[11];
2910 &deletefromgrp
($name,$configgrp);
2913 #get address from IPSEC HOST
2914 if ($type eq 'IpSec Host'){
2915 foreach my $key (keys %ipsecconf) {
2916 if ($ipsecconf{$key}[1] eq $name){
2917 return $ipsecconf{$key}[10];
2920 &deletefromgrp
($name,$configgrp);
2923 #get address from ovpn ccd Net-2-Net
2924 if ($type eq 'OpenVPN N-2-N'){
2925 foreach my $key (keys %ccdhost) {
2926 if($ccdhost{$key}[1] eq $name){
2927 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2928 $b=&General
::iporsubtodec
($b);
2932 &deletefromgrp
($name,$configgrp);
2935 #get address from ovpn ccd static host
2936 if ($type eq 'OpenVPN static host'){
2937 foreach my $key (keys %ccdhost) {
2938 if($ccdhost{$key}[1] eq $name){
2939 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2940 $b=&General
::iporsubtodec
($b);
2944 &deletefromgrp
($name,$configgrp);
2947 #get address from ovpn ccd static net
2948 if ($type eq 'OpenVPN static network'){
2949 foreach my $key (keys %ccdnet) {
2950 if ($ccdnet{$key}[0] eq $name){
2951 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2952 $b=&General
::iporsubtodec
($b);
2958 #check custom addresses
2959 if ($type eq 'Custom Host'){
2960 foreach my $key (keys %customhost) {
2961 if ($customhost{$key}[0] eq $name){
2962 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2968 ##check custom networks
2969 if ($type eq 'Custom Network'){
2970 foreach my $key (keys %customnetwork) {
2971 if($customnetwork{$key}[0] eq $name){
2972 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2977 #check standard networks
2978 if ($type eq 'Standard Network'){
2979 if ($name =~ /OpenVPN/i){
2981 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2982 return $ovpn{'DOVPN_SUBNET'};
2984 if ($name eq 'GREEN'){
2986 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2987 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2989 if ($name eq 'BLUE'){
2991 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2992 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2994 if ($name eq 'ORANGE'){
2996 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2997 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2999 if ($name eq 'ALL'){
3000 return "0.0.0.0/0.0.0.0";
3002 if ($name =~ /IPsec/i){
3004 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
3005 return $hash{'RW_NET'};
3007 if ($name eq 'RED'){
3015 &General
::readhasharray
("$confignet", \
%customnetwork);
3016 &General
::readhasharray
("$confighost", \
%customhost);
3017 foreach my $key (sort keys %customgrp ){
3018 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
3019 foreach my $key1 (sort keys %customnetwork){
3020 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
3021 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
3027 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
3028 foreach my $key2 (sort keys %customhost){
3029 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
3030 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
3037 &General
::writehasharray
("$confignet", \
%customnetwork);
3038 &General
::writehasharray
("$confighost", \
%customhost);
3043 &General
::readhasharray
("$configsrv", \
%customservice);
3044 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
3046 foreach my $key (sort keys %customservicegrp){
3047 if ($customservicegrp{$key}[0] eq $grp ){
3048 foreach my $key2 (sort keys %customservice){
3049 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
3050 $customservice{$key2}[4]--;
3055 &General
::writehasharray
("$configsrv", \
%customservice);
3063 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
3064 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
3065 &General
::readhasharray
("$fwconfigout", \
%fwout);
3066 #Rename group in Firewall-CONFIG
3067 foreach my $key1 (keys %fwfwd) {
3068 if($fwfwd{$key1}[$fld] eq $old){
3069 $fwfwd{$key1}[$fld]=$new;
3072 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd );
3073 #Rename group in Firewall-INPUT
3074 foreach my $key2 (keys %fwinp) {
3075 if($fwinp{$key2}[$fld] eq $old){
3076 $fwinp{$key2}[$fld]=$new;
3079 &General
::writehasharray
("$fwconfiginp", \
%fwinp );
3080 #Rename group in Firewall-OUTGOING
3081 foreach my $key3 (keys %fwout) {
3082 if($fwout{$key3}[$fld] eq $old){
3083 $fwout{$key3}[$fld]=$new;
3086 &General
::writehasharray
("$fwconfigout", \
%fwout );
3091 my %hash=%{(shift)};
3093 if ($fwhostsettings{'SRV_NAME'} eq '' ){
3094 $errormessage=$Lang::tr
{'fwhost err name1'};
3096 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
3097 $errormessage=$Lang::tr
{'fwhost err port'};
3100 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
3101 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
3103 #change dashes with :
3104 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
3106 if ($fwhostsettings{'SRV_PORT'} eq "*") {
3107 $fwhostsettings{'SRV_PORT'} = "1:65535";
3109 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
3110 $fwhostsettings{'SRV_PORT'} = "1:$2";
3112 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
3113 $fwhostsettings{'SRV_PORT'} = "$1:65535";
3115 if($fwhostsettings{'PROT'} ne 'ICMP'){
3116 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
3118 # a new service has to have a different name
3119 foreach my $key (keys %hash){
3120 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
3121 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
3125 return $errormessage;
3129 # Checks a hostname against RFC1035
3130 my $hostname = $_[0];
3132 # Each part should be at least two characters in length
3133 # but no more than 63 characters
3134 if (length ($hostname) < 1 || length ($hostname) > 63) {
3136 # Only valid characters are a-z, A-Z, 0-9 and -
3137 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
3139 # First character can only be a letter or a digit
3140 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
3142 # Last character can only be a letter or a digit
3143 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
3149 # Checks a hostname against RFC1035
3151 # Each part should be at least two characters in length
3152 # but no more than 63 characters
3153 if (length ($remark) < 1 || length ($remark) > 255) {
3155 # Only valid characters are a-z, A-Z, 0-9 and -
3156 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
3158 # First character can only be a letter or a digit
3159 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
3161 # Last character can only be a letter or a digit
3162 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
3166 &Header
::closebigbox
();
3167 &Header
::closepage
();