]>
git.ipfire.org Git - 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/network-functions.pl';
31 require "/var/ipfire/geoip-functions.pl";
32 require "/usr/lib/firewall/firewall-lib.pl";
33 require "${General::swroot}/lang.pl";
34 require "${General::swroot}/header.pl";
36 my %fwhostsettings=();
41 my %customservicegrp=();
42 my %customgeoipgrp=();
48 my %defaultNetworks=();
61 my $confignet = "${General::swroot}/fwhosts/customnetworks";
62 my $confighost = "${General::swroot}/fwhosts/customhosts";
63 my $configgrp = "${General::swroot}/fwhosts/customgroups";
64 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
65 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
66 my $configipsec = "${General::swroot}/vpn/config";
67 my $configsrv = "${General::swroot}/fwhosts/customservices";
68 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
69 my $configgeoipgrp = "${General::swroot}/fwhosts/customgeoipgrp";
70 my $fwconfigfwd = "${General::swroot}/firewall/config";
71 my $fwconfiginp = "${General::swroot}/firewall/input";
72 my $fwconfigout = "${General::swroot}/firewall/outgoing";
73 my $configovpn = "${General::swroot}/ovpn/settings";
74 my $configipsecrw = "${General::swroot}/vpn/settings";
76 unless (-e
$confignet) { system("touch $confignet"); }
77 unless (-e
$confighost) { system("touch $confighost"); }
78 unless (-e
$configgrp) { system("touch $configgrp"); }
79 unless (-e
$configsrv) { system("touch $configsrv"); }
80 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
81 unless (-e
$configgeoipgrp) { system("touch $configgeoipgrp"); }
83 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
84 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
85 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
86 &General
::readhash
("$configovpn", \
%ovpnsettings);
87 &General
::readhasharray
("$configipsec", \
%ipsecconf);
88 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
89 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
90 &Header
::getcgihash
(\
%fwhostsettings);
92 &Header
::showhttpheaders
();
93 &Header
::openpage
($Lang::tr
{'fwhost menu'}, 1, '');
94 &Header
::openbigbox
('100%', 'center');
99 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
100 var update_protocol = function() {
101 var protocol = \$("#protocol").val();
103 if (protocol === undefined)
106 // Check if we are dealing with a protocol, that knows ports.
107 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
109 \$("#PROTOKOLL").hide();
112 \$("#PROTOKOLL").show();
116 \$(document).ready(function() {
117 var protocol = \$("#protocol").val();
118 \$("#protocol").change(update_protocol);
120 // Automatically select radio buttons when corresponding
121 // dropdown menu changes.
122 \$("select").change(function() {
123 var id = \$(this).attr("name");
124 \$('#' + id).prop("checked", true);
132 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
134 &General
::readhasharray
("$confignet", \
%customnetwork);
135 foreach my $key (keys %customnetwork)
137 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
139 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
140 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
141 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
142 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
143 $fwhostsettings{'count'} = $customnetwork{$key}[4];
144 delete $customnetwork{$key};
148 &General
::writehasharray
("$confignet", \
%customnetwork);
149 $fwhostsettings{'actualize'} = 'on';
150 $fwhostsettings{'ACTION'} = 'savenet';
152 if ($fwhostsettings{'ACTION'} eq 'updatehost')
155 &General
::readhasharray
("$confighost", \
%customhost);
156 foreach my $key (keys %customhost)
158 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
160 if ($customhost{$key}[1] eq 'ip'){
161 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
163 $ip = $customhost{$key}[2];
165 $fwhostsettings{'orgip'} = $ip;
166 $fwhostsettings{'count'} = $customhost{$key}[4];
167 delete $customhost{$key};
168 &General
::writehasharray
("$confighost", \
%customhost);
171 $fwhostsettings{'actualize'} = 'on';
172 if($fwhostsettings{'orgip'}){
173 $fwhostsettings{'ACTION'} = 'savehost';
175 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
178 if ($fwhostsettings{'ACTION'} eq 'updateservice')
182 $errormessage=&checkports
(\
%customservice);
183 if ($fwhostsettings{'oldsrvname'} ne $fwhostsettings{'SRV_NAME'} && !&checkgroup
($fwhostsettings{'SRV_NAME'})){
184 $errormessage=$Lang::tr
{'fwhost err grpexist'};
187 &General
::readhasharray
("$configsrv", \
%customservice);
188 foreach my $key (keys %customservice)
190 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
192 delete $customservice{$key};
193 &General
::writehasharray
("$configsrv", \
%customservice);
197 if ($fwhostsettings{'PROT'} ne 'ICMP'){
198 $fwhostsettings{'ICMP_TYPES'}='BLANK';
200 my $key1 = &General
::findhasharraykey
(\
%customservice);
201 #find out short ICMP-TYPE
202 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
203 foreach my $key (keys %icmptypes){
204 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
205 $fwhostsettings{'ICMP_TYPES'}=$icmptypes{$key}[0];
208 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
209 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
210 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
211 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
212 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
213 &General
::writehasharray
("$configsrv", \
%customservice);
214 #check if we need to update firewallrules
215 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
216 if ( ! -z
$fwconfigfwd ){
217 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
218 foreach my $key (sort keys %fwfwd){
219 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
220 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
223 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
225 if ( ! -z
$fwconfiginp ){
226 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
227 foreach my $line (sort keys %fwinp){
228 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
229 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
232 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
234 if ( ! -z
$fwconfigout ){
235 &General
::readhasharray
("$fwconfigout", \
%fwout);
236 foreach my $line (sort keys %fwout){
237 if ($fwout{$line}[15] eq $fwhostsettings{'oldsrvname'}){
238 $fwout{$line}[15] = $fwhostsettings{'SRV_NAME'};
241 &General
::writehasharray
("$fwconfigout", \
%fwout);
243 #check if we need to update groups
244 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
245 foreach my $key (sort keys %customservicegrp){
246 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
247 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
248 &checkrulereload
($customservicegrp{$key}[0]);
251 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
253 &checkrulereload
($fwhostsettings{'SRV_NAME'});
254 $fwhostsettings{'SRV_NAME'} = '';
255 $fwhostsettings{'SRV_PORT'} = '';
256 $fwhostsettings{'PROT'} = '';
257 $fwhostsettings{'ICMP'} = '';
258 $fwhostsettings{'oldsrvicmp'} = '';
259 $fwhostsettings{'updatesrv'} = '';
261 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
262 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
263 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
264 $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
265 $fwhostsettings{'updatesrv'}= 'on';
270 if ($fwhostsettings{'ACTION'} eq 'savenet' )
273 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
274 #check if all fields are set
275 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
277 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
281 #convert ip if leading '0' exists
282 $fwhostsettings{'IP'} = &Network
::ip_remove_zero
($fwhostsettings{'IP'});
285 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
287 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
288 $fwhostsettings{'BLK_HOST'} ='readonly';
289 $fwhostsettings{'NOCHECK'} ='false';
290 $fwhostsettings{'error'} ='on';
293 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
294 $errormessage=$Lang::tr
{'fwhost err remark'};
295 $fwhostsettings{'error'} ='on';
297 #check if subnet is sigle host
298 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
300 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
302 if($fwhostsettings{'error'} ne 'on'){
303 my $fullip="$fwhostsettings{'IP'}/".&General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
304 $errormessage=$errormessage.&General
::checksubnets
($fwhostsettings{'HOSTNAME'},$fullip,"","exact");
306 #only check plausi when no error till now
308 &plausicheck
("editnet");
310 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
312 $fwhostsettings{'actualize'} = '';
313 my $key = &General
::findhasharraykey
(\
%customnetwork);
314 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
315 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
316 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
317 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
318 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
319 &General
::writehasharray
("$confignet", \
%customnetwork);
320 undef %customnetwork;
323 &General
::readhasharray
("$confignet", \
%customnetwork);
324 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
325 if ($fwhostsettings{'update'} == '0'){
326 foreach my $key (keys %customnetwork) {
327 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
328 delete $customnetwork{$key};
334 #get count if actualize is 'on'
335 if($fwhostsettings{'actualize'} eq 'on'){
336 $fwhostsettings{'actualize'} = '';
337 #check if we need to reload rules
338 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
341 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
342 #check if we need to update groups
343 &General
::readhasharray
("$configgrp", \
%customgrp);
344 foreach my $key (sort keys %customgrp){
345 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
346 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
350 &General
::writehasharray
("$configgrp", \
%customgrp);
351 #check if we need to update firewallrules
352 if ( ! -z
$fwconfigfwd ){
353 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
354 foreach my $line (sort keys %fwfwd){
355 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
356 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
358 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
359 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
362 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
364 if ( ! -z
$fwconfiginp ){
365 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
366 foreach my $line (sort keys %fwinp){
367 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
368 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
371 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
375 my $key = &General
::findhasharraykey
(\
%customnetwork);
376 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
377 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
378 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
379 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
380 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
381 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
382 &General
::writehasharray
("$confignet", \
%customnetwork);
383 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
384 undef %customnetwork;
385 $fwhostsettings{'HOSTNAME'}='';
386 $fwhostsettings{'IP'}='';
387 $fwhostsettings{'SUBNET'}='';
388 $fwhostsettings{'NETREMARK'}='';
389 #check if an edited net affected groups and need to reload rules
390 if ($needrules eq 'on'){
391 &General
::firewall_config_changed
();
396 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
402 if ($fwhostsettings{'ACTION'} eq 'savehost')
405 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
406 $fwhostsettings{'SUBNET'}='32';
407 #check if all fields are set
408 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
410 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
411 $fwhostsettings{'ACTION'} = 'edithost';
413 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
414 $fwhostsettings{'type'} = 'mac';
415 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
416 $fwhostsettings{'type'} = 'ip';
418 $fwhostsettings{'type'} = '';
419 $errormessage=$Lang::tr
{'fwhost err ipmac'};
422 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
423 $errormessage=$Lang::tr
{'fwhost err remark'};
426 if ($fwhostsettings{'type'} eq 'ip'){
427 #convert ip if leading '0' exists
428 $fwhostsettings{'IP'} = &Network
::ip_remove_zero
($fwhostsettings{'IP'});
431 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
432 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
434 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
435 $fwhostsettings{'error'}='on';
437 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
438 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
439 $fwhostsettings{'error'}='on';
441 #check if net or broadcast
442 my @tmp= split (/\./,$fwhostsettings{'IP'});
443 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
444 $errormessage=$Lang::tr
{'fwhost err hostip'};
447 #only check plausi when no error till now
449 &plausicheck
("edithost");
451 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
452 $fwhostsettings{'actualize'} = '';
453 my $key = &General
::findhasharraykey
(\
%customhost);
454 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
455 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
456 $customhost{$key}[1] = $fwhostsettings{'type'} ;
457 if($customhost{$key}[1] eq 'ip'){
458 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
460 $customhost{$key}[2] = $fwhostsettings{'orgip'};
462 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
463 &General
::writehasharray
("$confighost", \
%customhost);
467 #get count if host was edited
468 if($fwhostsettings{'actualize'} eq 'on'){
469 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
472 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
473 #check if we need to update groups
474 &General
::readhasharray
("$configgrp", \
%customgrp);
475 foreach my $key (sort keys %customgrp){
476 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
477 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
480 &General
::writehasharray
("$configgrp", \
%customgrp);
481 #check if we need to update firewallrules
482 if ( ! -z
$fwconfigfwd ){
483 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
484 foreach my $line (sort keys %fwfwd){
485 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
486 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
488 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
489 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
492 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
494 if ( ! -z
$fwconfiginp ){
495 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
496 foreach my $line (sort keys %fwinp){
497 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
498 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
501 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
505 my $key = &General
::findhasharraykey
(\
%customhost);
506 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
507 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
508 $customhost{$key}[1] = $fwhostsettings{'type'} ;
509 if ($fwhostsettings{'type'} eq 'ip'){
510 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
512 $customhost{$key}[2] = $fwhostsettings{'IP'};
514 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
515 &General
::writehasharray
("$confighost", \
%customhost);
517 $fwhostsettings{'HOSTNAME'}='';
518 $fwhostsettings{'IP'}='';
519 $fwhostsettings{'type'}='';
520 $fwhostsettings{'HOSTREMARK'}='';
521 #check if we need to update rules while host was edited
522 if($needrules eq 'on'){
523 &General
::firewall_config_changed
();
533 if ($fwhostsettings{'ACTION'} eq 'savegrp')
535 my $grp=$fwhostsettings{'grp_name'};
536 my $rem=$fwhostsettings{'remark'};
539 my $updcounter='off';
542 &General
::readhasharray
("$configgrp", \
%customgrp);
543 &General
::readhasharray
("$confignet", \
%customnetwork);
544 &General
::readhasharray
("$confighost", \
%customhost);
545 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
546 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
547 &General
::readhasharray
("$fwconfigout", \
%fwout);
549 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
551 if (!&checkgroup
($grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr
{'fwhost err grpexist'};}
553 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
554 $errormessage.=$Lang::tr
{'fwhost err remark'};
556 if ($fwhostsettings{'update'} eq 'on'){
557 #check standard networks
558 if ($fwhostsettings{'grp2'} eq 'std_net'){
559 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
560 $type='Standard Network';
562 #check custom networks
563 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
564 @target=$fwhostsettings{'CUST_SRC_NET'};
566 $type='Custom Network';
567 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
568 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
569 $fwhostsettings{'grp_name'}='';
570 $fwhostsettings{'remark'}='';
572 #check custom addresses
573 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
574 @target=$fwhostsettings{'CUST_SRC_HOST'};
577 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
578 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
579 $fwhostsettings{'grp_name'}='';
580 $fwhostsettings{'remark'}='';
582 #get address from ovpn ccd static net
583 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
584 @target=$fwhostsettings{'OVPN_CCD_NET'};
585 $type='OpenVPN static network';
586 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
587 $errormessage=$Lang::tr
{'fwhost err groupempty'};
588 $fwhostsettings{'grp_name'}='';
589 $fwhostsettings{'remark'}='';
591 #get address from ovpn ccd static host
592 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
593 @target=$fwhostsettings{'OVPN_CCD_HOST'};
594 $type='OpenVPN static host';
595 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
596 $errormessage=$Lang::tr
{'fwhost err groupempty'};
598 #get address from ovpn ccd Net-2-Net
599 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
600 @target=$fwhostsettings{'OVPN_N2N'};
601 $type='OpenVPN N-2-N';
602 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
603 $errormessage=$Lang::tr
{'fwhost err groupempty'};
604 $fwhostsettings{'grp_name'}='';
605 $fwhostsettings{'remark'}='';
607 #get address from IPSEC HOST
608 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
609 @target=$fwhostsettings{'IPSEC_HOST'};
611 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
612 $errormessage=$Lang::tr
{'fwhost err groupempty'};
613 $fwhostsettings{'grp_name'}='';
614 $fwhostsettings{'remark'}='';
616 #get address from IPSEC NETWORK
617 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
618 @target=$fwhostsettings{'IPSEC_NET'};
619 $type='IpSec Network';
620 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
621 $errormessage=$Lang::tr
{'fwhost err groupempty'};
622 $fwhostsettings{'grp_name'}='';
623 $fwhostsettings{'remark'}='';
625 #check if host/net exists in grp
627 my $test="$grp,$fwhostsettings{'oldremark'},@target,$type";
628 foreach my $key (keys %customgrp) {
629 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2],$customgrp{$key}[3]";
630 if ($test1 eq $test){
631 $errormessage=$Lang::tr
{'fwhost err isingrp'};
632 $fwhostsettings{'update'} = 'on';
638 #on first save, we have an empty @target, so fill it with nothing
639 my $targetvalues=@target;
640 if ($targetvalues == '0'){
643 #on update, we have to delete the dummy entry
644 foreach my $key (keys %customgrp){
645 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
646 delete $customgrp{$key};
650 &General
::writehasharray
("$configgrp", \
%customgrp);
651 &General
::readhasharray
("$configgrp", \
%customgrp);
652 #create array with new lines
653 foreach my $line (@target){
654 push (@newgrp,"$grp,$rem,$line");
657 my $key = &General
::findhasharraykey
(\
%customgrp);
658 foreach my $line (@newgrp){
659 foreach my $i (0 .. 3) { $customgrp{$key}[$i] = "";}
660 my ($a,$b,$c,$d) = split (",",$line);
661 $customgrp{$key}[0] = $a;
662 $customgrp{$key}[1] = $b;
663 $customgrp{$key}[2] = $c;
664 $customgrp{$key}[3] = $type;
666 &General
::writehasharray
("$configgrp", \
%customgrp);
667 #update counter in Host/Net
668 $fwhostsettings{'update'}='on';
670 #check if ruleupdate is needed
672 $netgrpcount=&getnetcount
($grp);
673 if($netgrpcount > 0 )
675 &General
::firewall_config_changed
();
680 if ($fwhostsettings{'ACTION'} eq 'savegeoipgrp')
682 my $grp=$fwhostsettings{'grp_name'};
683 my $rem=$fwhostsettings{'remark'};
688 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
689 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
690 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
691 &General
::readhasharray
("$fwconfigout", \
%fwout);
693 # Check for existing group name.
694 if (!&checkgroup
($grp) && $fwhostsettings{'update'} ne 'on'){
695 $errormessage = $Lang::tr
{'fwhost err grpexist'};
699 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
700 $errormessage = $Lang::tr
{'fwhost err remark'};
703 if ($fwhostsettings{'update'} eq 'on'){
704 @target=$fwhostsettings{'COUNTRY_CODE'};
707 #check if host/net exists in grp
708 my $test="$grp,$fwhostsettings{'oldremark'},@target";
709 foreach my $key (keys %customgeoipgrp) {
710 my $test1="$customgeoipgrp{$key}[0],$customgeoipgrp{$key}[1],$customgeoipgrp{$key}[2]";
711 if ($test1 eq $test){
712 $errormessage=$Lang::tr
{'fwhost err isingrp'};
713 $fwhostsettings{'update'} = 'on';
719 #on first save, we have an empty @target, so fill it with nothing
720 my $targetvalues=@target;
721 if ($targetvalues == '0'){
724 #on update, we have to delete the dummy entry
725 foreach my $key (keys %customgeoipgrp){
726 if ($customgeoipgrp{$key}[0] eq $grp && $customgeoipgrp{$key}[2] eq "none"){
727 delete $customgeoipgrp{$key};
731 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
732 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
733 #create array with new lines
734 foreach my $line (@target){
735 push (@newgrp,"$grp,$rem,$line");
738 my $key = &General
::findhasharraykey
(\
%customgeoipgrp);
739 foreach my $line (@newgrp){
740 foreach my $i (0 .. 3) { $customgeoipgrp{$key}[$i] = "";}
741 my ($a,$b,$c,$d) = split (",",$line);
742 $customgeoipgrp{$key}[0] = $a;
743 $customgeoipgrp{$key}[1] = $b;
744 $customgeoipgrp{$key}[2] = $c;
745 $customgeoipgrp{$key}[3] = $type;
747 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
748 #update counter in Host/Net
749 $fwhostsettings{'update'}='on';
751 #check if ruleupdate is needed
753 $geoipgrpcount=&getgeoipcount
($grp);
754 if($geoipgrpcount > 0 )
756 &General
::firewall_config_changed
();
761 if ($fwhostsettings{'ACTION'} eq 'saveservice')
764 &General
::readhasharray
("$configsrv", \
%customservice );
765 &General
::readhasharray
("$configgrp", \
%customgrp);
766 $errormessage=&checkports
(\
%customservice);
767 if ($fwhostsettings{'PROT'} eq 'ICMP'){
768 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
769 foreach my $key (keys %icmptypes){
770 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
771 $ICMP=$icmptypes{$key}[0];
775 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
776 if ($fwhostsettings{'PROT'} ne 'ICMP'){$ICMP='BLANK';}
777 #Check if a group with the same name already exists
778 if (!&checkgroup
($fwhostsettings{'SRV_NAME'})){
779 $errormessage = $Lang::tr
{'fwhost err grpexist'};
782 my $key = &General
::findhasharraykey
(\
%customservice);
783 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
784 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
785 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
786 $customservice{$key}[2] = $fwhostsettings{'PROT'};
787 $customservice{$key}[3] = $ICMP;
788 &General
::writehasharray
("$configsrv", \
%customservice );
790 $fwhostsettings{'SRV_NAME'}='';
791 $fwhostsettings{'SRV_PORT'}='';
792 $fwhostsettings{'PROT'}='';
793 $fwhostsettings{'ICMP_TYPES'}='';
797 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
803 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
804 &General
::readhasharray
("$configsrv", \
%customservice );
805 $errormessage=&checkservicegroup
;
806 #Check if we have more than 15 services from one Protocol in the group
807 #iptables can only handle 15 ports/portranges via multiport
808 foreach my $key (keys %customservicegrp){
809 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
810 foreach my $key1 (keys %customservice){
811 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
812 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
813 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
814 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
818 if ($tcpcounter > 14){
819 $errormessage=$Lang::tr
{'fwhost err maxservicetcp'};
821 if ($udpcounter > 14){
822 $errormessage=$Lang::tr
{'fwhost err maxserviceudp'};
827 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
828 $errormessage .= $Lang::tr
{'fwhost err remark'};
830 #Check if there is already a service with the same name
831 if(!&checkservice
($fwhostsettings{'SRVGRP_NAME'})){
832 $errormessage .= $Lang::tr
{'fwhost err srv exists'};
835 #on first save, we have to enter a dummy value
836 if ($fwhostsettings{'CUST_SRV'} eq ''){
837 $fwhostsettings{'CUST_SRV'}='none';
839 #on update, we have to delete the dummy entry
840 foreach my $key (keys %customservicegrp){
841 if ($customservicegrp{$key}[2] eq 'none' && $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
842 delete $customservicegrp{$key};
846 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
847 #check if remark has also changed
848 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
850 foreach my $key (keys %customservicegrp)
852 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
854 $customservicegrp{$key}[1]='';
855 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
859 my $key = &General
::findhasharraykey
(\
%customservicegrp);
860 foreach my $i (0 .. 2) { $customservice{$key}[$i] = "";}
861 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
862 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
863 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
864 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
865 $fwhostsettings{'updatesrvgrp'}='on';
867 &checkrulereload
($fwhostsettings{'SRVGRP_NAME'});
869 &viewtableservicegrp
;
872 if ($fwhostsettings{'ACTION'} eq 'editnet')
877 if ($fwhostsettings{'ACTION'} eq 'edithost')
882 if ($fwhostsettings{'ACTION'} eq 'editgrp')
884 $fwhostsettings{'update'}='on';
888 if ($fwhostsettings{'ACTION'} eq 'editgeoipgrp')
890 $fwhostsettings{'update'}='on';
894 if ($fwhostsettings{'ACTION'} eq 'editservice')
896 $fwhostsettings{'updatesrv'}='on';
899 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
901 $fwhostsettings{'updatesrvgrp'} = 'on';
903 &viewtableservicegrp
;
906 if ($fwhostsettings{'ACTION'} eq 'resetnet')
908 $fwhostsettings{'HOSTNAME'} ="";
909 $fwhostsettings{'IP'} ="";
910 $fwhostsettings{'SUBNET'} ="";
913 if ($fwhostsettings{'ACTION'} eq 'resethost')
915 $fwhostsettings{'HOSTNAME'} ="";
916 $fwhostsettings{'IP'} ="";
917 $fwhostsettings{'type'} ="";
920 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
922 $fwhostsettings{'grp_name'} ="";
923 $fwhostsettings{'remark'} ="";
926 if ($fwhostsettings{'ACTION'} eq 'resetgeoipgrp')
928 $fwhostsettings{'grp_name'} ="";
929 $fwhostsettings{'remark'} ="";
933 if ($fwhostsettings{'ACTION'} eq 'delnet')
935 &General
::readhasharray
("$confignet", \
%customnetwork);
936 foreach my $key (keys %customnetwork) {
937 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
938 delete $customnetwork{$key};
939 &General
::writehasharray
("$confignet", \
%customnetwork);
946 if ($fwhostsettings{'ACTION'} eq 'delhost')
948 &General
::readhasharray
("$confighost", \
%customhost);
949 foreach my $key (keys %customhost) {
950 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
951 delete $customhost{$key};
952 &General
::writehasharray
("$confighost", \
%customhost);
959 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
963 &General
::readhasharray
("$configgrp", \
%customgrp);
964 foreach my $key (keys %customgrp){
965 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
966 $grpname=$customgrp{$key}[0];
967 $grpremark=$customgrp{$key}[1];
968 #check if we delete the last entry, then generate dummy
969 if ($fwhostsettings{'last'} eq 'on'){
970 $customgrp{$key}[1] = '';
971 $customgrp{$key}[2] = 'none';
972 $customgrp{$key}[3] = '';
973 $fwhostsettings{'last'}='';
976 delete $customgrp{$key};
980 &General
::writehasharray
("$configgrp", \
%customgrp);
981 &General
::firewall_config_changed
();
982 if ($fwhostsettings{'update'} eq 'on'){
983 $fwhostsettings{'remark'}= $grpremark;
984 $fwhostsettings{'grp_name'}=$grpname;
989 if ($fwhostsettings{'ACTION'} eq 'deletegeoipgrpentry')
993 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
994 foreach my $key (keys %customgeoipgrp){
995 if($customgeoipgrp{$key}[0].",".$customgeoipgrp{$key}[1].",".$customgeoipgrp{$key}[2].",".$customgeoipgrp{$key}[3] eq $fwhostsettings{'delentry'}){
996 $grpname=$customgeoipgrp{$key}[0];
997 $grpremark=$customgeoipgrp{$key}[1];
998 #check if we delete the last entry, then generate dummy
999 if ($fwhostsettings{'last'} eq 'on'){
1000 $customgeoipgrp{$key}[1] = '';
1001 $customgeoipgrp{$key}[2] = 'none';
1002 $customgeoipgrp{$key}[3] = '';
1003 $fwhostsettings{'last'}='';
1006 delete $customgeoipgrp{$key};
1010 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
1011 &General
::firewall_config_changed
();
1012 if ($fwhostsettings{'update'} eq 'on'){
1013 $fwhostsettings{'remark'}= $grpremark;
1014 $fwhostsettings{'grp_name'}=$grpname;
1020 if ($fwhostsettings{'ACTION'} eq 'delgrp')
1022 &General
::readhasharray
("$configgrp", \
%customgrp);
1023 &decrease
($fwhostsettings{'grp_name'});
1024 foreach my $key (sort keys %customgrp)
1026 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
1028 delete $customgrp{$key};
1031 &General
::writehasharray
("$configgrp", \
%customgrp);
1032 $fwhostsettings{'grp_name'}='';
1036 if ($fwhostsettings{'ACTION'} eq 'delgeoipgrp')
1038 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
1039 &decrease
($fwhostsettings{'grp_name'});
1040 foreach my $key (sort keys %customgeoipgrp)
1042 if($customgeoipgrp{$key}[0] eq $fwhostsettings{'grp_name'})
1044 delete $customgeoipgrp{$key};
1047 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
1048 $fwhostsettings{'grp_name'}='';
1052 if ($fwhostsettings{'ACTION'} eq 'delservice')
1054 &General
::readhasharray
("$configsrv", \
%customservice);
1055 foreach my $key (keys %customservice) {
1056 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
1057 delete $customservice{$key};
1058 &General
::writehasharray
("$configsrv", \
%customservice);
1062 $fwhostsettings{'SRV_NAME'}='';
1063 $fwhostsettings{'SRV_PORT'}='';
1064 $fwhostsettings{'PROT'}='';
1067 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
1069 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1070 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
1071 foreach my $key (sort keys %customservicegrp)
1073 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
1075 delete $customservicegrp{$key};
1078 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1079 $fwhostsettings{'SRVGRP_NAME'}='';
1081 &viewtableservicegrp
;
1083 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
1087 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1088 foreach my $key (keys %customservicegrp){
1089 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'})
1091 $grpname=$customservicegrp{$key}[0];
1092 $grpremark=$customservicegrp{$key}[1];
1093 if($fwhostsettings{'last'} eq 'on'){
1094 $customservicegrp{$key}[2] = 'none';
1095 $fwhostsettings{'last'} = '';
1098 delete $customservicegrp{$key};
1102 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1103 &General
::firewall_config_changed
();
1104 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1105 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1106 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1109 &viewtableservicegrp
;
1111 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1116 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1121 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1126 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgeoipgrp'})
1131 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1135 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1138 &viewtableservicegrp
;
1140 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1142 &General
::readhasharray
("$configgrp", \
%customgrp);
1143 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1144 foreach my $key (sort keys %customgrp)
1146 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1148 $customgrp{$key}[1]='';
1149 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1152 &General
::writehasharray
("$configgrp", \
%customgrp);
1153 $fwhostsettings{'update'}='on';
1154 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1156 $errormessage=$Lang::tr
{'fwhost err remark'};
1157 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1158 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1159 $fwhostsettings{'update'} = 'on';
1161 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1165 if ($fwhostsettings{'ACTION'} eq 'changegeoipgrpremark')
1167 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
1168 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1169 foreach my $key (sort keys %customgeoipgrp)
1171 if($customgeoipgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgeoipgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1173 $customgeoipgrp{$key}[1]='';
1174 $customgeoipgrp{$key}[1]=$fwhostsettings{'newrem'};
1177 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp);
1178 $fwhostsettings{'update'}='on';
1179 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1181 $errormessage=$Lang::tr
{'fwhost err remark'};
1182 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1183 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1184 $fwhostsettings{'update'} = 'on';
1186 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1190 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1192 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1193 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1194 foreach my $key (sort keys %customservicegrp)
1196 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1198 $customservicegrp{$key}[1]='';
1199 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1202 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1203 $fwhostsettings{'updatesrvgrp'}='on';
1204 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1205 }elsif($fwhostsettings{'oldsrvrem'} eq $fwhostsettings{'newsrvrem'}){
1207 &viewtableservicegrp
;
1209 $errormessage=$Lang::tr
{'fwhost err remark'};
1210 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1211 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1212 $fwhostsettings{'updatesrvgrp'} = 'on';
1214 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1216 &viewtableservicegrp
;
1218 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpname')
1220 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1221 if ($fwhostsettings{'oldsrvgrpname'} ne $fwhostsettings{'srvgrp'}){
1222 #Check new groupname
1223 if (!&validhostname
($fwhostsettings{'srvgrp'})){
1224 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1226 if (!$errormessage){
1227 #Rename group in customservicegroup
1228 foreach my $key (keys %customservicegrp) {
1229 if($customservicegrp{$key}[0] eq $fwhostsettings{'oldsrvgrpname'}){
1230 $customservicegrp{$key}[0]=$fwhostsettings{'srvgrp'};
1233 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
1234 #change name in FW Rules
1235 &changenameinfw
($fwhostsettings{'oldsrvgrpname'},$fwhostsettings{'srvgrp'},15);
1239 &viewtableservicegrp
;
1241 if ($fwhostsettings{'ACTION'} eq 'changegrpname')
1243 &General
::readhasharray
("$configgrp", \
%customgrp );
1244 if ($fwhostsettings{'oldgrpname'} ne $fwhostsettings{'grp'}){
1245 #Check new groupname
1246 if (!&validhostname
($fwhostsettings{'grp'})){
1247 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1249 if (!$errormessage){
1250 #Rename group in customservicegroup
1251 foreach my $key (keys %customgrp) {
1252 if($customgrp{$key}[0] eq $fwhostsettings{'oldgrpname'}){
1253 $customgrp{$key}[0]=$fwhostsettings{'grp'};
1256 &General
::writehasharray
("$configgrp", \
%customgrp );
1257 #change name in FW Rules
1258 &changenameinfw
($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
1264 if ($fwhostsettings{'ACTION'} eq 'changegeoipgrpname')
1266 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp );
1267 if ($fwhostsettings{'oldgrpname'} ne $fwhostsettings{'grp'}){
1268 #Check new groupname
1269 if (!&validhostname
($fwhostsettings{'grp'})){
1270 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1272 if (!$errormessage){
1274 foreach my $key (keys %customgeoipgrp) {
1275 if($customgeoipgrp{$key}[0] eq $fwhostsettings{'oldgrpname'}){
1276 $customgeoipgrp{$key}[0]=$fwhostsettings{'grp'};
1279 &General
::writehasharray
("$configgeoipgrp", \
%customgeoipgrp );
1280 #change name in FW Rules
1281 &changenameinfw
($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
1288 if($fwhostsettings{'ACTION'} eq '')
1294 &Header
::openbox
('100%', 'left',);
1295 print "$Lang::tr{'fwhost welcome'}";
1297 <br><br><table border='0' width='100%'>
1298 <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>
1299 <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>
1300 <tr><td colspan='6'></td></tr></table>
1302 &Header
::closebox
();
1310 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1311 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1312 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1314 <table border='0' width='100%' >
1315 <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>
1316 <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>
1317 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1318 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1319 <tr><td colspan='6'><br></td></tr><tr>
1321 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1323 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'}'>";
1325 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'>";
1327 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>";
1328 &Header
::closebox
();
1334 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1335 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1336 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1338 <table width='100%'>
1339 <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>
1340 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1341 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1342 <tr><td colspan='5'><br></td></tr><tr>
1345 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1348 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>";
1350 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'>";
1352 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>";
1353 &Header
::closebox
();
1360 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1361 &General
::setup_default_networks
(\
%defaultNetworks);
1362 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1363 &General
::readhasharray
("$confignet", \
%customnetwork);
1364 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1365 &General
::readhasharray
("$confighost", \
%customhost);
1366 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1370 $checked{'check1'}{'off'} = '';
1371 $checked{'check1'}{'on'} = '';
1372 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1373 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1374 $fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'};
1375 my $grp=$fwhostsettings{'grp_name'};
1376 my $rem=$fwhostsettings{'remark'};
1377 if ($fwhostsettings{'update'} eq ''){
1379 <table width='100%' border='0'>
1381 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1382 <td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='30'></td>
1385 <td>$Lang::tr{'remark'}:</td>
1386 <td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 99%;'></td>
1389 <td colspan='2'><br></td>
1395 <table width='100%' border='0'><form method='post'>
1397 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1398 <td style='width:30%;'><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' size='30'></td>
1399 <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>
1402 <tr><form method='post' style='display:inline'>
1403 <td>$Lang::tr{'remark'}:</td>
1404 <td colspan='2' style='width:98%;'><input type='TEXT' name='newrem' value='$fwhostsettings{'remark'}' style='width:98%;'></td>
1405 <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>
1411 if ($fwhostsettings{'update'} eq 'on'){
1413 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1414 <table width='100%' border='0'>
1415 <tr><td width=50% valign='top'>
1416 <table width='90%' border='0'>
1418 <td style='width:15em;'>
1420 <input type='radio' name='grp2' value='std_net' id='DEFAULT_SRC_ADR' checked>
1421 $Lang::tr{'fwhost stdnet'}
1424 <td style='text-align:right;'>
1425 <select name='DEFAULT_SRC_ADR' style='width:16em;'>
1427 foreach my $network (sort keys %defaultNetworks)
1429 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1430 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1431 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1432 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1433 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1434 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1435 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1436 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1437 if ($ownnet{$defnet}){
1438 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1440 print ">$network</option>";
1443 print"</select></td></tr>";
1444 if (! -z
$confignet){
1449 <input type='radio' name='grp2' id='CUST_SRC_NET' value='cust_net' $checked{'grp2'}{'cust_net'}>
1450 $Lang::tr{'fwhost cust net'}:
1453 <td style='text-align:right;'>
1454 <select name='CUST_SRC_NET' style='width:16em;'>";
1456 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1457 print"<option>$customnetwork{$key}[0]</option>";
1459 print"</select></td></tr>";
1461 if (! -z
$confighost){
1466 <input type='radio' name='grp2' id='CUST_SRC_HOST' value='cust_host' $checked{'grp2'}{'cust_host'}>
1467 $Lang::tr{'fwhost cust addr'}:
1470 <td style='text-align:right;'>
1471 <select name='CUST_SRC_HOST' style='width:16em;'>";
1473 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1474 print"<option>$customhost{$key}[0]</option>";
1476 print"</select></td></tr>";
1480 print"</td><td align='right' style='vertical-align:top;'><table width='90%' border='0'>";
1482 if (! -z
$configccdnet){
1484 <td style='width:15em;'>
1486 <input type='radio' name='grp2' id='OVPN_CCD_NET' value='ovpn_net' $checked{'grp2'}{'ovpn_net'}>
1487 $Lang::tr{'fwhost ccdnet'}
1490 <td style='text-align:right;'>
1491 <select name='OVPN_CCD_NET' style='width:16em;'>";
1493 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1495 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1497 print"</select></td></tr>";
1500 my @ovpn_clients=();
1501 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1503 if ($ccdhost{$key}[33] ne ''){
1505 push (@ovpn_clients,$ccdhost{$key}[1]);
1511 <td style='width:15em;'>
1513 <input type='radio' name='grp2' value='ovpn_host' $checked{'grp2'}{'ovpn_host'}>
1514 $Lang::tr{'fwhost ccdhost'}
1517 <td style='text-align:right;'>
1518 <select name='OVPN_CCD_HOST' style='width:16em;'>" if ($show eq '');
1520 foreach(@ovpn_clients){
1521 print"<option value='$_'>$_</option>";
1523 print"</select></td></tr>";
1527 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1528 if($ccdhost{$key}[3] eq 'net'){
1530 push (@OVPN_N2N,$ccdhost{$key}[1]);
1536 <td style='width:15em;'>
1538 <input type='radio' name='grp2' id='OVPN_N2N' value='ovpn_n2n' $checked{'grp2'}{'ovpn_n2n'}>
1539 $Lang::tr{'fwhost ovpn_n2n'}:
1542 <td style='text-align:right;'>
1543 <select name='OVPN_N2N' style='width:16em;'>"
1546 print"<option>$_</option>";
1548 print"</select></td></tr>";
1552 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1553 if ($ipsecconf{$key}[3] eq 'net'){
1555 push (@IPSEC_N2N,$ipsecconf{$key}[1]);
1561 <td style='width:15em;'>
1563 <input type='radio' name='grp2' id='IPSEC_NET' value='ipsec_net' $checked{'grp2'}{'ipsec_net'}>
1564 $Lang::tr{'fwhost ipsec net'}
1567 <td style='text-align:right;'>
1568 <select name='IPSEC_NET' style='width:16em;'>"
1570 foreach(@IPSEC_N2N){
1571 print"<option value='$_'>$_</option>";
1574 print"</select></td></tr>";
1576 print"</td></tr></table>";
1579 print"<table width='100%'>";
1580 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>";
1581 &Header
::closebox
();
1588 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgeoipgrp'});
1592 $checked{'check1'}{'off'} = '';
1593 $checked{'check1'}{'on'} = '';
1594 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1595 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1596 $fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'};
1597 my $grp=$fwhostsettings{'grp_name'};
1598 my $rem=$fwhostsettings{'remark'};
1599 if ($fwhostsettings{'update'} eq ''){
1601 <table width='100%' border='0'>
1603 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1604 <td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='30'></td>
1607 <td>$Lang::tr{'remark'}:</td>
1608 <td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 99%;'></td>
1611 <td colspan='2'><br></td>
1617 <table width='100%' border='0'>
1618 <form method='post'><tr>
1619 <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
1620 <td style='width:30%;'><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' size='30'></td>
1622 <input type='submit' value='$Lang::tr{'fwhost change'}'>
1623 <input type='hidden' name='oldgrpname' value='$fwhostsettings{'oldgrpname'}'>
1624 <input type='hidden' name='ACTION' value='changegeoipgrpname'>
1628 <tr><form method='post' style='display:inline'>
1629 <td>$Lang::tr{'remark'}:</td>
1630 <td colspan='2' style='width:98%;'>
1631 <input type='TEXT' name='newrem' value='$fwhostsettings{'remark'}' style='width:98%;'>
1634 <input type='submit' value='$Lang::tr{'fwhost change'}'>
1635 <input type='hidden' name='grp' value='$fwhostsettings{'grp_name'}'>
1636 <input type='hidden' name='oldrem' value='$fwhostsettings{'oldremark'}'>
1637 <input type='hidden' name='ACTION' value='changegeoipgrpremark'>
1644 if ($fwhostsettings{'update'} eq 'on') {
1645 my @geoip_locations = &fwlib
::get_geoip_locations
();
1648 <form method='post'>
1649 <input type='hidden' name='remark' value='$rem'>
1650 <input type='hidden' name='grp_name' value='$grp'>
1652 <table width='100%' border='0'>
1654 <td style='text-align:left;'>
1655 <select name='COUNTRY_CODE' style='width:16em;'>";
1657 foreach my $location (@geoip_locations) {
1658 # Get full country name.
1659 my $fullname = &GeoIP
::get_full_country_name
($location);
1661 print"<option value='$location'>$location - $fullname</option>\n";
1672 <table width='100%'>
1673 <tr><td style='text-align:right;'>
1674 <input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1675 <input type='hidden' name='oldremark' value='$fwhostsettings{'oldremark'}'>
1676 <input type='hidden' name='update' value=\"$fwhostsettings{'update'}\">
1677 <input type='hidden' name='ACTION' value='savegeoipgrp' >
1680 <form method='post' style='display:inline'>
1682 <input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'>
1683 <input type='hidden' name='ACTION' value='resetgeoipgrp'>
1688 &Header
::closebox
();
1694 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1695 if ($fwhostsettings{'updatesrv'} eq 'on')
1697 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1698 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1699 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1700 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1703 <table width='100%' border='0'><form method='post'>
1704 <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>
1705 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1707 foreach ("TCP","UDP","ICMP")
1709 if ($_ eq $fwhostsettings{'PROT'})
1711 print"<option selected>$_</option>";
1713 print"<option>$_</option>";
1717 </select></td></tr></table>
1718 <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'>
1720 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1721 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1722 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1723 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1724 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1726 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1730 </select></td></tr></table></div>
1731 <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>
1732 <table width='100%' border='0'><tr><td colspan='6'><br></td></tr>
1733 <tr><td colspan='6' align='right'>
1735 if ($fwhostsettings{'updatesrv'} eq 'on')
1738 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1739 <input type='hidden' name='ACTION' value='updateservice'>
1740 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1741 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1742 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1743 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1747 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1750 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1753 &Header
::closebox
();
1761 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1762 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1763 $fwhostsettings{'oldsrvgrpname'}=$fwhostsettings{'SRVGRP_NAME'};
1764 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1766 <table width='100%' border='0'><form method='post'>
1767 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1768 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1769 <tr><td colspan='2'><br></tr>
1774 <table width='100%'><form method='post' style='display:inline'>
1775 <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>
1777 <form method='post'>
1779 $Lang::tr{'remark'}:
1782 <input type='text' name='newsrvrem' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width:98%;'>
1785 <input type='submit' value='$Lang::tr{'fwhost change'}'>
1786 <input type='hidden' name='oldsrvrem' value='$fwhostsettings{'oldsrvgrpremark'}'>
1787 <input type='hidden' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}'>
1788 <input type='hidden' name='ACTION' value='changesrvgrpremark' >
1800 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1802 <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%'>
1803 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'add'}: </td><td><select name='CUST_SRV' style='min-width:185px;'>
1805 &General
::readhasharray
("$configsrv", \
%customservice);
1806 #Protocols for use in servicegroups
1807 print "<optgroup label='$Lang::tr{'fwhost cust service'}'>";
1808 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1810 print "<option>$customservice{$key}[0]</option>";
1812 print "</optgroup>";
1813 print "<optgroup label='$Lang::tr{'protocol'}'>";
1814 print "<option>GRE</option>";
1815 print "<option>AH</option>";
1816 print "<option>ESP</option>";
1817 print "<option>IGMP</option>";
1818 print "<option>IPIP</option>";
1819 print "<option value='IPV6'>IPv6 encap</option>";
1820 print "</optgroup>";
1823 <tr><td colspan='4'><br><br></td></tr>
1824 <tr><td colspan='4'></td></tr>
1829 <table width='100%'>
1830 <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>
1833 &Header
::closebox
();
1838 if(! -z
$confignet){
1839 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1840 &General
::readhasharray
("$confignet", \
%customnetwork);
1841 &General
::readhasharray
("$configgrp", \
%customgrp);
1842 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1843 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1844 &General
::readhasharray
("$fwconfigout", \
%fwout);
1846 if (!keys %customnetwork)
1848 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1851 <table width='100%' cellspacing='0' class='tbl'>
1852 <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>
1857 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1858 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1860 $col="bgcolor='${Header::colouryellow}'";
1863 $col="bgcolor='$color{'color20'}'";
1867 $col="bgcolor='$color{'color22'}'";
1870 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1871 my $netcount=&getnetcount
($customnetwork{$key}[0]);
1872 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>";
1874 <td width='1%' $col><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
1875 <input type='hidden' name='ACTION' value='editnet'>
1876 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1877 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1878 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1879 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1882 if($netcount == '0')
1884 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>";
1886 print"<td $col></td></tr>";
1891 &Header
::closebox
();
1902 if (&General
::validmac
($c)){ return $c;}
1904 #Check if we got a full IP with subnet then split it
1905 if($c =~ /^(.*?)\/(.*?
)$/){
1906 ($sip,$scidr) = split ("/",$c);
1911 #Now check if IP is part of ORANGE,BLUE or GREEN
1912 if ( &Header
::orange_used
() && &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1913 $tdcolor="<font style='color: $Header::colourorange;'>$c</font>";
1916 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1917 $tdcolor="<font style='color: $Header::colourgreen;'>$c</font>";
1920 if ( &Header
::blue_used
() && &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1921 $tdcolor="<font style='color: $Header::colourblue;'>$c</font>";
1924 if ("$sip/$scidr" eq "0.0.0.0/0"){
1925 $tdcolor="<font style='color: $Header::colourred;'>$c</font>";
1928 #Check if IP is part of OpenVPN N2N subnet
1929 foreach my $key (sort keys %ccdhost){
1930 if ($ccdhost{$key}[3] eq 'net'){
1931 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1932 if (&General
::IpInSubnet
($sip,$a,$b)){
1933 $tdcolor="<font style='color:$Header::colourovpn ;'>$c</font>";
1939 #Check if IP is part of OpenVPN dynamic subnet
1940 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1941 if (&General
::IpInSubnet
($sip,$a,$b)){
1942 $tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
1946 #Check if IP is part of OpenVPN static subnet
1947 foreach my $key (sort keys %ccdnet){
1948 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1949 $b =&General
::iporsubtodec
($b);
1950 if (&General
::IpInSubnet
($sip,$a,$b)){
1951 $tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
1956 #Check if IP is part of IPsec RW network
1957 if ($ipsecsettings{'RW_NET'} ne ''){
1958 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1959 $b=&General
::iporsubtodec
($b);
1960 if (&General
::IpInSubnet
($sip,$a,$b)){
1961 $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
1966 #Check if IP is part of a IPsec N2N network
1967 foreach my $key (sort keys %ipsecconf){
1968 if ($ipsecconf{$key}[11]){
1969 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1970 $b=&General
::iporsubtodec
($b);
1971 if (&General
::IpInSubnet
($sip,$a,$b)){
1972 $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
1981 if (! -z
$confighost){
1982 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1983 &General
::readhasharray
("$confighost", \
%customhost);
1984 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1985 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1986 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
1987 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
1988 &General
::readhasharray
("$fwconfigout", \
%fwout);
1989 &General
::readhasharray
("$configgrp", \
%customgrp);
1990 if (!keys %customhost)
1992 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1995 <table width='100%' cellspacing='0' class='tbl'>
1996 <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>
2001 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
2002 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
2004 $col="bgcolor='${Header::colouryellow}'";
2005 }elsif ($count % 2){
2007 $col="bgcolor='$color{'color20'}'";
2009 $col="bgcolor='$color{'color22'}'";
2012 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
2013 $customhost{$key}[4]=~s/\s+//g;
2015 $hostcount=&gethostcount
($customhost{$key}[0]);
2016 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>";
2018 <td width='1%' $col><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
2019 <input type='hidden' name='ACTION' value='edithost' />
2020 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
2021 <input type='hidden' name='IP' value='$ip' />
2022 <input type='hidden' name='type' value='$customhost{$key}[1]' />
2023 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
2026 if($hostcount == '0')
2028 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>";
2030 print"<td width='1%' $col></td></tr>";
2035 &Header
::closebox
();
2040 if(! -z
"$configgrp"){
2041 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
2042 &General
::readhasharray
("$configgrp", \
%customgrp);
2043 &General
::readhasharray
("$configipsec", \
%ipsecconf);
2044 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2045 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2046 &General
::readhasharray
("$confighost", \
%customhost);
2047 &General
::readhasharray
("$confignet", \
%customnetwork);
2048 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2049 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2050 &General
::readhasharray
("$fwconfigout", \
%fwout);
2060 if (!keys %customgrp)
2062 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
2064 #get all groups in a hash
2065 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
2066 push (@counter,$customgrp{$key}[0]);
2068 foreach my $key1 (@counter) {
2071 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
2073 if ($helper ne $customgrp{$key}[0]){
2075 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
2076 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
2085 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};}
2086 $grpname=$customgrp{$key}[0];
2087 $remark="$customgrp{$key}[1]";
2088 if($count gt 1){ print"</table>";$count=1;}
2089 print "<br><b><u>$grpname</u></b> ";
2090 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
2091 my $netgrpcount=&getnetcount
($grpname);
2092 print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
2093 if($netgrpcount == '0')
2095 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>";
2097 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>";
2098 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>";
2101 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
2103 $col="bgcolor='${Header::colouryellow}'";
2104 }elsif ($count %2 == 0){
2106 $col="bgcolor='$color{'color20'}'";
2109 $col="bgcolor='$color{'color22'}'";
2111 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
2114 $col="bgcolor='${Header::colouryellow}'";
2116 print "<td width='39%' align='left' $col>";
2117 if($customgrp{$key}[3] eq 'Standard Network'){
2118 print &get_name
($customgrp{$key}[2])."</td>";
2120 print "$customgrp{$key}[2]</td>";
2122 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
2123 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'>";
2125 my ($colip,$colsub) = split("/",$ip);
2126 $ip="$colip/".&General
::iporsubtocidr
($colsub) if ($colsub);
2127 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'>";
2129 if ($delflag > 0 && $ip ne ''){
2130 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' />";
2131 #check if this group has only one entry
2132 foreach my $key2 (keys %hash) {
2133 if ($hash{$key2}<2 && $key2 eq $customgrp{$key}[0]){
2134 print "<input type='hidden' name='last' value='on'>" ;
2138 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>";
2139 $helper=$customgrp{$key}[0];
2144 &Header
::closebox
();
2148 sub viewtablegeoipgrp
2150 # If our filesize is "zero" there is nothing to read-in.
2151 if (-z
"$configgeoipgrp") {
2155 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust geoipgrp'});
2156 &General
::readhasharray
("$configgeoipgrp", \
%customgeoipgrp);
2157 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2158 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2159 &General
::readhasharray
("$fwconfigout", \
%fwout);
2171 # If there are no groups we are finished here.
2172 if (!keys %customgeoipgrp) {
2173 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
2177 # Put all groups in a hash.
2178 foreach my $key (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) }
2179 sort { ncmp
($customgeoipgrp{$a}[2],$customgeoipgrp{$b}[2]) } keys %customgeoipgrp) {
2180 push (@counter,$customgeoipgrp{$key}[0]);
2183 # Increase current used key.
2184 foreach my $key1 (@counter) {
2189 foreach my $key (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) }
2190 sort { ncmp
($customgeoipgrp{$a}[2],$customgeoipgrp{$b}[2]) } keys %customgeoipgrp) {
2192 if ($helper ne $customgeoipgrp{$key}[0]) {
2195 foreach my $key1 (sort { ncmp
($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) }
2196 sort { ncmp
($customgeoipgrp{$a}[2],$customgeoipgrp{$b}[2]) } keys %customgeoipgrp) {
2198 if ($customgeoipgrp{$key}[0] eq $customgeoipgrp{$key1}[0])
2210 $grpname=$customgeoipgrp{$key}[0];
2213 $remark="$customgeoipgrp{$key}[1]";
2216 $country_code="$customgeoipgrp{$key}[2]";
2223 # Display groups header.
2224 print "<br><b><u>$grpname</u></b> \n";
2225 print "<b>$Lang::tr{'remark'}:</b>  $remark  \n" if ($remark ne '');
2228 my $geoipgrpcount=&getgeoipcount
($grpname);
2229 print "<b>$Lang::tr{'used'}:</b> $geoipgrpcount x";
2231 # Only display delete icon, if the group is not used by a firewall rule.
2232 if($geoipgrpcount == '0') {
2233 print"<form method='post' style='display:inline'>\n";
2234 print"<input type='image' src='/images/delete.gif' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' align='right' />\n";
2235 print"<input type='hidden' name='grp_name' value='$grpname' >\n";
2236 print"<input type='hidden' name='ACTION' value='delgeoipgrp'>\n";
2240 # Icon for group editing.
2242 <form method='post' style='display:inline'>
2243 <input type='image' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' align='right'/>
2244 <input type='hidden' name='grp_name' value='$grpname' >
2245 <input type='hidden' name='remark' value='$remark' >
2246 <input type='hidden' name='ACTION' value='editgeoipgrp'>
2249 <table width='100%' cellspacing='0' class='tbl'>
2251 # Display headlines if the group contains any entries.
2252 if ($country_code ne "none") {
2255 <td width='10%' align='center'>
2256 <b>$Lang::tr{'flag'}</b>
2259 <td width='10%'align='center'>
2260 <b>$Lang::tr{'countrycode'}</b>
2263 <td width='70%'align='left'>
2264 <b>$Lang::tr{'country'}</b>
2267 <td width='10%' align='right'></td>
2273 # Check if our group contains any entries.
2274 if ($country_code eq "none") {
2275 print "<tr><td>$Lang::tr{'fwhost err emptytable'}</td></tr>\n";
2277 # Check if we are currently editing a group and assign column backgound colors.
2279 if ( ($fwhostsettings{'ACTION'} eq 'editgeoipgrp' || $fwhostsettings{'update'} ne '')
2280 && $fwhostsettings{'grp_name'} eq $customgeoipgrp{$key}[0]) {
2281 $col="bgcolor='${Header::colouryellow}'";
2282 } elsif ($count %2 == 0){
2283 $col="bgcolor='$color{'color20'}'";
2285 $col="bgcolor='$color{'color22'}'";
2289 my $icon = &GeoIP
::get_flag_icon
($customgeoipgrp{$key}[2]);
2291 # Print column with flag icon.
2294 $col_content = "<img src='$icon' alt='$customgeoipgrp{$key}[2]' title='$customgeoipgrp{$key}[2]'>";
2296 $col_content = "<b>N/A</b>";
2299 print "<td align='center' $col>$col_content</td>\n";
2301 # Print column with country code.
2302 print "<td align='center' $col>$customgeoipgrp{$key}[2]</td>\n";
2304 # Print column with full country name.
2305 my $country_name = &GeoIP
::get_full_country_name
($customgeoipgrp{$key}[2]);
2306 print "<td align='left' $col>$country_name</td>\n";
2308 # Generate from for removing entries from a group.
2309 print "<td align='right' width='1%' $col><form method='post'>\n";
2312 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}'/>\n";
2314 # Check if this group only has a single entry.
2315 foreach my $key2 (keys %hash) {
2316 if ($hash{$key2}<2 && $key2 eq $customgeoipgrp{$key}[0]){
2317 print "<input type='hidden' name='last' value='on'>" ;
2322 print "<input type='hidden' name='ACTION' value='deletegeoipgrpentry'>\n";
2323 print "<input type='hidden' name='update' value='$fwhostsettings{'update'}'>\n";
2324 print "<input type='hidden' name='delentry' value='$grpname,$remark,$customgeoipgrp{$key}[2],$customgeoipgrp{$key}[3]'>\n";
2330 $helper=$customgeoipgrp{$key}[0];
2335 &Header
::closebox
();
2337 sub viewtableservice
2341 if(! -z
"$configsrv")
2343 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
2344 &General
::readhasharray
("$configsrv", \
%customservice);
2345 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2346 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2347 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2348 &General
::readhasharray
("$fwconfigout", \
%fwout);
2350 <table width='100%' cellspacing='0' class='tbl'>
2351 <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>
2354 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
2357 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
2359 $col="bgcolor='${Header::colouryellow}'";
2360 }elsif ($count % 2){
2362 $col="bgcolor='$color{'color22'}'";
2365 $col="bgcolor='$color{'color20'}'";
2368 <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>
2371 $srvcount=&getsrvcount
($customservice{$key}[0]);
2372 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr
{'fwdfw all icmp'};}
2373 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
2375 </td><td align='center' $col>$srvcount x</td>
2376 <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' />
2377 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
2378 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
2379 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
2380 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
2382 if ($srvcount eq '0')
2384 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>";
2386 print"<td $col></td></tr>";
2390 &Header
::closebox
();
2393 sub viewtableservicegrp
2408 if (! -z
$configsrvgrp){
2409 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
2410 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2411 &General
::readhasharray
("$configsrv", \
%customservice);
2412 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2413 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2414 &General
::readhasharray
("$fwconfigout", \
%fwout);
2415 my $number= keys %customservicegrp;
2416 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
2417 push (@counter,$customservicegrp{$key}[0]);
2419 foreach my $key1 (@counter) {
2422 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
2424 if ($helper ne $customservicegrp{$key}[0]){
2425 #Get used groupcounter
2426 $grpcount=&getsrvcount
($customservicegrp{$key}[0]);
2428 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
2429 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
2437 $grpname=$customservicegrp{$key}[0];
2438 if ($customservicegrp{$key}[2] eq "none"){
2439 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost err emptytable'};
2443 $remark="$customservicegrp{$key}[1]";
2444 if($count >0){print"</table>";$count=1;}
2445 print "<br><b><u>$grpname</u></b> ";
2446 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
2447 print " <b>$Lang::tr{'used'}:</b> $grpcount x";
2448 if($grpcount == '0')
2450 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>";
2452 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>";
2453 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>";
2455 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
2457 $col="bgcolor='${Header::colouryellow}'";
2458 }elsif ($count %2 == 0){
2460 $col="bgcolor='$color{'color20'}'";
2463 $col="bgcolor='$color{'color22'}'";
2465 #make lines yellow if it is a dummy entry
2466 if ($customservicegrp{$key}[2] eq $Lang::tr
{'fwhost err emptytable'}){
2468 $col="bgcolor='${Header::colouryellow}'";
2470 #Set fields if we use protocols in servicegroups
2471 if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
2474 if ($customservicegrp{$key}[2] eq 'GRE'){$protocol='GRE';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} GRE";}
2475 if ($customservicegrp{$key}[2] eq 'ESP'){$protocol='ESP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} ESP";}
2476 if ($customservicegrp{$key}[2] eq 'AH'){$protocol='AH';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} AH";}
2477 if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
2478 if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
2479 if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
2480 print "<td width='39%' $col>$customservicegrp{$key}[2]</td>";
2481 foreach my $srv (sort keys %customservice){
2482 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
2483 $protocol=$customservice{$srv}[2];
2484 $port=$customservice{$srv}[1];
2488 print"<td align='center' $col>$port</td><td align='center' $col>$protocol</td><td width='1%' $col><form method='post'>";
2489 if ($delflag gt '0'){
2490 if ($customservicegrp{$key}[2] ne $Lang::tr
{'fwhost err emptytable'}){
2491 print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title=$Lang::tr{'delete'} />";
2493 #check if this group has only one entry
2494 foreach my $key2 (keys %hash) {
2495 if ($hash{$key2}<2 && $key2 eq $customservicegrp{$key}[0]){
2496 print "<input type='hidden' name='last' value='on'>" ;
2500 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
2501 if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
2502 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2]'></form></td></tr>";
2504 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$protocol'></form></td></tr>";
2506 $helper=$customservicegrp{$key}[0];
2509 &Header
::closebox
();
2515 my %hash=%{(shift)};
2516 foreach my $key (keys %hash) {
2517 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2526 &General
::readhasharray
("$configgrp", \
%customgrp );
2528 foreach my $key (keys %customservicegrp) {
2529 if($customservicegrp{$key}[0] eq $name){
2537 &General
::readhasharray
("$configsrv", \
%customservice );
2539 foreach my $key (keys %customservice) {
2540 if($customservice{$key}[0] eq $name){
2549 my %hash=%{(shift)};
2551 foreach my $key (keys %hash) {
2552 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
2558 sub checkservicegroup
2560 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2562 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
2564 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
2565 return $errormessage;
2567 #check empty selectbox
2568 if (keys %customservice lt 1)
2570 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
2572 #check if name already exists
2573 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
2574 foreach my $key (keys %customservicegrp) {
2575 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
2576 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
2581 #check if service already exists in group
2582 foreach my $key (keys %customservicegrp) {
2583 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
2584 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
2587 return $errormessage;
2592 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
2593 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
2594 &General
::readhasharray
("$fwconfigout", \
%fwout);
2596 #check if service or servicegroup is used in rules
2597 foreach my $key (keys %fwfwd){
2598 if($search eq $fwfwd{$key}[15]){
2599 &General
::firewall_config_changed
();
2603 foreach my $key (keys %fwinp){
2604 if($search eq $fwinp{$key}[15]){
2605 &General
::firewall_config_changed
();
2609 foreach my $key (keys %fwout){
2610 if($search eq $fwout{$key}[15]){
2611 &General
::firewall_config_changed
();
2618 if ($errormessage) {
2619 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
2620 print "<class name='base'>$errormessage\n";
2621 print " </class>\n";
2622 &Header
::closebox
();
2628 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
2629 print "<class name='base'>$hint\n";
2630 print " </class>\n";
2631 &Header
::closebox
();
2637 &General
::setup_default_networks
(\
%defaultNetworks);
2638 foreach my $network (sort keys %defaultNetworks)
2640 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
2645 my $searchstring=shift;
2647 #Count services used in servicegroups
2648 foreach my $key (keys %customgrp) {
2649 if($customgrp{$key}[2] eq $searchstring){
2653 #Count services used in firewall - config
2654 foreach my $key1 (keys %fwfwd) {
2655 if($fwfwd{$key1}[4] eq $searchstring){
2658 if($fwfwd{$key1}[6] eq $searchstring){
2662 #Count services used in firewall - input
2663 foreach my $key2 (keys %fwinp) {
2664 if($fwinp{$key2}[4] eq $searchstring){
2667 if($fwinp{$key2}[6] eq $searchstring){
2671 #Count services used in firewall - outgoing
2672 foreach my $key3 (keys %fwout) {
2673 if($fwout{$key3}[4] eq $searchstring){
2676 if($fwout{$key3}[6] eq $searchstring){
2684 my $groupname=shift;
2687 # GeoIP groups are stored as "group:groupname" in the
2688 # firewall settings files.
2689 my $searchstring = join(':', "group",$groupname);
2691 # Count services used in firewall - forward
2692 foreach my $key1 (keys %fwfwd) {
2693 if($fwfwd{$key1}[4] eq $searchstring){
2696 if($fwfwd{$key1}[6] eq $searchstring){
2700 #Count services used in firewall - input
2701 foreach my $key2 (keys %fwinp) {
2702 if($fwinp{$key2}[4] eq $searchstring){
2705 if($fwinp{$key2}[6] eq $searchstring){
2709 #Count services used in firewall - outgoing
2710 foreach my $key3 (keys %fwout) {
2711 if($fwout{$key3}[4] eq $searchstring){
2714 if($fwout{$key3}[6] eq $searchstring){
2722 my $searchstring=shift;
2724 #Count services used in servicegroups
2725 foreach my $key (keys %customgrp) {
2726 if($customgrp{$key}[2] eq $searchstring){
2730 #Count services used in firewall - config
2731 foreach my $key1 (keys %fwfwd) {
2732 if($fwfwd{$key1}[4] eq $searchstring){
2735 if($fwfwd{$key1}[6] eq $searchstring){
2739 #Count services used in firewall - input
2740 foreach my $key2 (keys %fwinp) {
2741 if($fwinp{$key2}[4] eq $searchstring){
2744 if($fwinp{$key2}[6] eq $searchstring){
2748 #Count services used in firewall - outgoing
2749 foreach my $key3 (keys %fwout) {
2750 if($fwout{$key3}[4] eq $searchstring){
2753 if($fwout{$key3}[6] eq $searchstring){
2761 my $searchstring=shift;
2763 #Count services used in servicegroups
2764 foreach my $key (keys %customservicegrp) {
2765 if($customservicegrp{$key}[2] eq $searchstring){
2769 #Count services used in firewall - config
2770 foreach my $key1 (keys %fwfwd) {
2771 if($fwfwd{$key1}[15] eq $searchstring){
2775 #Count services used in firewall - input
2776 foreach my $key2 (keys %fwinp) {
2777 if($fwinp{$key2}[15] eq $searchstring){
2781 #Count services used in firewall - outgoing
2782 foreach my $key3 (keys %fwout) {
2783 if($fwout{$key3}[15] eq $searchstring){
2794 &General
::readhasharray
("$config",\
%hash);
2795 foreach my $key (keys %hash) {
2796 if($hash{$key}[2] eq $target){
2800 &General
::writehasharray
("$config",\
%hash);
2807 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
2809 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
2810 $fwhostsettings{'BLK_IP'}='readonly';
2811 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2812 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2814 #check if name collides with CCD Netname
2815 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2816 foreach my $key (keys %ccdnet) {
2817 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2818 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
2819 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2820 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2824 #check if IP collides with CCD NetIP
2825 if ($fwhostsettings{'type'} ne 'mac'){
2826 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2827 foreach my $key (keys %ccdnet) {
2828 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
2829 if($ccdnet{$key}[1] eq $test){
2830 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
2831 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
2832 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
2833 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2838 #check if name collides with CCD Hostname
2839 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2840 foreach my $key (keys %ccdhost) {
2841 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
2842 if($ip eq $fwhostsettings{'IP'}){
2843 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
2844 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2848 #check if IP collides with CCD HostIP (only hosts)
2849 if ($edit eq 'edithost')
2851 foreach my $key (keys %ccdhost) {
2852 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
2853 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
2854 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
2855 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2860 #check if network with this name already exists
2861 &General
::readhasharray
("$confignet", \
%customnetwork);
2862 if (!&checkname
(\
%customnetwork))
2864 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
2865 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2866 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2868 #check if network ip already exists
2869 if (!&checkip
(\
%customnetwork,1))
2871 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
2872 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2874 #check if host with this name already exists
2875 &General
::readhasharray
("$confighost", \
%customhost);
2876 if (!&checkname
(\
%customhost))
2878 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
2879 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2880 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2882 #check if host with this ip already exists
2883 if (!&checkip
(\
%customhost,2))
2885 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
2895 #get address from IPSEC NETWORK
2896 if ($type eq 'IpSec Network'){
2897 foreach my $key (keys %ipsecconf) {
2898 if ($ipsecconf{$key}[1] eq $name){
2899 return $ipsecconf{$key}[11];
2902 &deletefromgrp
($name,$configgrp);
2905 #get address from IPSEC HOST
2906 if ($type eq 'IpSec Host'){
2907 foreach my $key (keys %ipsecconf) {
2908 if ($ipsecconf{$key}[1] eq $name){
2909 return $ipsecconf{$key}[10];
2912 &deletefromgrp
($name,$configgrp);
2915 #get address from ovpn ccd Net-2-Net
2916 if ($type eq 'OpenVPN N-2-N'){
2917 foreach my $key (keys %ccdhost) {
2918 if($ccdhost{$key}[1] eq $name){
2919 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2920 $b=&General
::iporsubtodec
($b);
2924 &deletefromgrp
($name,$configgrp);
2927 #get address from ovpn ccd static host
2928 if ($type eq 'OpenVPN static host'){
2929 foreach my $key (keys %ccdhost) {
2930 if($ccdhost{$key}[1] eq $name){
2931 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2932 $b=&General
::iporsubtodec
($b);
2936 &deletefromgrp
($name,$configgrp);
2939 #get address from ovpn ccd static net
2940 if ($type eq 'OpenVPN static network'){
2941 foreach my $key (keys %ccdnet) {
2942 if ($ccdnet{$key}[0] eq $name){
2943 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2944 $b=&General
::iporsubtodec
($b);
2950 #check custom addresses
2951 if ($type eq 'Custom Host'){
2952 foreach my $key (keys %customhost) {
2953 if ($customhost{$key}[0] eq $name){
2954 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2960 ##check custom networks
2961 if ($type eq 'Custom Network'){
2962 foreach my $key (keys %customnetwork) {
2963 if($customnetwork{$key}[0] eq $name){
2964 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2969 #check standard networks
2970 if ($type eq 'Standard Network'){
2971 if ($name =~ /OpenVPN/i){
2973 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
2974 return $ovpn{'DOVPN_SUBNET'};
2976 if ($name eq 'GREEN'){
2978 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2979 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2981 if ($name eq 'BLUE'){
2983 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2984 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2986 if ($name eq 'ORANGE'){
2988 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
2989 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2991 if ($name eq 'ALL'){
2992 return "0.0.0.0/0.0.0.0";
2994 if ($name =~ /IPsec/i){
2996 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
2997 return $hash{'RW_NET'};
2999 if ($name eq 'RED'){
3007 &General
::readhasharray
("$confignet", \
%customnetwork);
3008 &General
::readhasharray
("$confighost", \
%customhost);
3009 foreach my $key (sort keys %customgrp ){
3010 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
3011 foreach my $key1 (sort keys %customnetwork){
3012 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
3013 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
3019 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
3020 foreach my $key2 (sort keys %customhost){
3021 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
3022 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
3029 &General
::writehasharray
("$confignet", \
%customnetwork);
3030 &General
::writehasharray
("$confighost", \
%customhost);
3035 &General
::readhasharray
("$configsrv", \
%customservice);
3036 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
3038 foreach my $key (sort keys %customservicegrp){
3039 if ($customservicegrp{$key}[0] eq $grp ){
3040 foreach my $key2 (sort keys %customservice){
3041 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
3042 $customservice{$key2}[4]--;
3047 &General
::writehasharray
("$configsrv", \
%customservice);
3055 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
3056 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
3057 &General
::readhasharray
("$fwconfigout", \
%fwout);
3058 #Rename group in Firewall-CONFIG
3059 foreach my $key1 (keys %fwfwd) {
3060 if($fwfwd{$key1}[$fld] eq $old){
3061 $fwfwd{$key1}[$fld]=$new;
3064 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd );
3065 #Rename group in Firewall-INPUT
3066 foreach my $key2 (keys %fwinp) {
3067 if($fwinp{$key2}[$fld] eq $old){
3068 $fwinp{$key2}[$fld]=$new;
3071 &General
::writehasharray
("$fwconfiginp", \
%fwinp );
3072 #Rename group in Firewall-OUTGOING
3073 foreach my $key3 (keys %fwout) {
3074 if($fwout{$key3}[$fld] eq $old){
3075 $fwout{$key3}[$fld]=$new;
3078 &General
::writehasharray
("$fwconfigout", \
%fwout );
3083 my %hash=%{(shift)};
3085 if ($fwhostsettings{'SRV_NAME'} eq '' ){
3086 $errormessage=$Lang::tr
{'fwhost err name1'};
3088 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
3089 $errormessage=$Lang::tr
{'fwhost err port'};
3092 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
3093 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
3095 #change dashes with :
3096 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
3098 if ($fwhostsettings{'SRV_PORT'} eq "*") {
3099 $fwhostsettings{'SRV_PORT'} = "1:65535";
3101 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
3102 $fwhostsettings{'SRV_PORT'} = "1:$2";
3104 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
3105 $fwhostsettings{'SRV_PORT'} = "$1:65535";
3107 if($fwhostsettings{'PROT'} ne 'ICMP'){
3108 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
3110 # a new service has to have a different name
3111 foreach my $key (keys %hash){
3112 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
3113 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
3117 return $errormessage;
3121 # Checks a hostname against RFC1035
3122 my $hostname = $_[0];
3124 # Each part should be at least two characters in length
3125 # but no more than 63 characters
3126 if (length ($hostname) < 1 || length ($hostname) > 63) {
3128 # Only valid characters are a-z, A-Z, 0-9 and -
3129 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
3131 # First character can only be a letter or a digit
3132 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
3134 # Last character can only be a letter or a digit
3135 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
3141 # Checks a hostname against RFC1035
3143 # Each part should be at least two characters in length
3144 # but no more than 63 characters
3145 if (length ($remark) < 1 || length ($remark) > 255) {
3147 # Only valid characters are a-z, A-Z, 0-9 and -
3148 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
3150 # First character can only be a letter or a digit
3151 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
3153 # Last character can only be a letter or a digit
3154 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
3158 &Header
::closebigbox
();
3159 &Header
::closepage
();