]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/fwhosts.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2011 IPFire Team <info@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 ###############################################################################
21 # New function for forwarding firewall. To make it comfortable to create #
22 # rules, we need "spelling names" for single Hosts. If you have any questions #
23 # <amarx@ipfire.org> #
24 ###############################################################################
27 # enable only the following on debugging purpose
29 use CGI
::Carp
'fatalsToBrowser';
30 no warnings
'uninitialized';
31 require '/var/ipfire/general-functions.pl';
32 require "${General::swroot}/lang.pl";
33 require "${General::swroot}/header.pl";
35 my %fwhostsettings=();
40 my %customservicegrp=();
46 my %defaultNetworks=();
56 my $confignet = "${General::swroot}/fwhosts/customnetworks";
57 my $confighost = "${General::swroot}/fwhosts/customhosts";
58 my $configgrp = "${General::swroot}/fwhosts/customgroups";
59 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
60 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
61 my $configipsec = "${General::swroot}/vpn/config";
62 my $configsrv = "${General::swroot}/fwhosts/customservices";
63 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
64 my $fwconfigfwd = "${General::swroot}/forward/config";
65 my $fwconfiginp = "${General::swroot}/forward/input";
67 unless (-e
$confignet) { system("touch $confignet"); }
68 unless (-e
$confighost) { system("touch $confighost"); }
69 unless (-e
$configgrp) { system("touch $configgrp"); }
70 unless (-e
$configsrv) { system("touch $configsrv"); }
71 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
73 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
74 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
75 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
76 &Header
::getcgihash
(\
%fwhostsettings);
78 &Header
::showhttpheaders
();
79 &Header
::openpage
($Lang::tr
{'fwhost hosts'}, 1, '');
80 &Header
::openbigbox
('100%', 'center');
83 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
89 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
91 &General
::readhasharray
("$confignet", \
%customnetwork);
92 foreach my $key (keys %customnetwork)
94 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
96 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
97 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
98 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
99 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
100 $fwhostsettings{'count'} = $customnetwork{$key}[4];
101 delete $customnetwork{$key};
105 &General
::writehasharray
("$confignet", \
%customnetwork);
106 $fwhostsettings{'actualize'} = 'on';
107 $fwhostsettings{'ACTION'} = 'savenet';
109 if ($fwhostsettings{'ACTION'} eq 'updatehost')
112 &General
::readhasharray
("$confighost", \
%customhost);
113 foreach my $key (keys %customhost)
115 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
117 if ($customhost{$key}[1] eq 'ip'){
118 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
120 $ip = $customhost{$key}[2];
122 $fwhostsettings{'orgip'} = $ip;
123 $fwhostsettings{'count'} = $customhost{$key}[4];
124 delete $customhost{$key};
125 &General
::writehasharray
("$confighost", \
%customhost);
128 $fwhostsettings{'actualize'} = 'on';
129 if($fwhostsettings{'orgip'}){
130 $fwhostsettings{'ACTION'} = 'savehost';
132 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
135 if ($fwhostsettings{'ACTION'} eq 'updateservice')
139 $errormessage=&checkports
(\
%customservice);
141 &General
::readhasharray
("$configsrv", \
%customservice);
142 foreach my $key (keys %customservice)
144 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
146 $count=$customservice{$key}[4];
147 delete $customservice{$key};
148 &General
::writehasharray
("$configsrv", \
%customservice);
152 if ($fwhostsettings{'PROT'} ne 'ICMP'){
153 $fwhostsettings{'ICMP_TYPES'}='BLANK';
155 my $key1 = &General
::findhasharraykey
(\
%customservice);
156 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
157 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
158 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
159 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
160 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
161 $customservice{$key1}[4] = $count;
162 &General
::writehasharray
("$configsrv", \
%customservice);
163 #check if we need to update firewallrules
164 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
165 if ( ! -z
$fwconfigfwd ){
166 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
167 foreach my $key (sort keys %fwfwd){
168 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
169 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
172 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
174 if ( ! -z
$fwconfiginp ){
175 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
176 foreach my $line (sort keys %fwinp){
177 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
178 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
181 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
183 #check if we need to update groups
184 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
185 foreach my $key (sort keys %customservicegrp){
186 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
187 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
190 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
193 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
196 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
199 $fwhostsettings{'SRV_NAME'} = '';
200 $fwhostsettings{'SRV_PORT'} = '';
201 $fwhostsettings{'PROT'} = '';
203 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
204 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
205 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
206 $fwhostsettings{'updatesrv'}= 'on';
208 if($needrules eq 'on'){
214 if ($fwhostsettings{'ACTION'} eq 'savenet' )
218 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
219 #check if all fields are set
220 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
222 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
227 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
229 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
230 $fwhostsettings{'BLK_HOST'} ='readonly';
231 $fwhostsettings{'NOCHECK'} ='false';
232 $fwhostsettings{'error'} ='on';
235 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
236 $errormessage=$Lang::tr
{'fwhost err remark'};
237 $fwhostsettings{'error'} ='on';
239 #check if subnet is sigle host
240 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
242 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
244 if($fwhostsettings{'error'} ne 'on'){
245 #check if we use one of ipfire's networks (green,orange,blue)
246 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
248 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
249 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
250 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
252 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
254 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
255 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
256 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
258 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
260 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
261 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
262 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
264 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
266 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
267 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
268 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
271 #only check plausi when no error till now
273 &plausicheck
("editnet");
275 #check if network ip is part of an already used one
276 if(&checksubnet
(\
%customnetwork))
278 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
279 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
281 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
283 $fwhostsettings{'actualize'} = '';
284 my $key = &General
::findhasharraykey
(\
%customnetwork);
285 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
286 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
287 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
288 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
289 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
290 $customnetwork{$key}[4] = $fwhostsettings{'count'};
291 &General
::writehasharray
("$confignet", \
%customnetwork);
292 undef %customnetwork;
296 &General
::readhasharray
("$confignet", \
%customnetwork);
297 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
298 if ($fwhostsettings{'update'} == '0'){
299 foreach my $key (keys %customnetwork) {
300 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
301 $count=$customnetwork{$key}[4];
302 delete $customnetwork{$key};
308 #get count if actualize is 'on'
309 if($fwhostsettings{'actualize'} eq 'on'){
310 $fwhostsettings{'actualize'} = '';
311 $count=$fwhostsettings{'count'};
312 #check if we need to reload rules
313 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
316 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
317 #check if we need to update groups
318 &General
::readhasharray
("$configgrp", \
%customgrp);
319 foreach my $key (sort keys %customgrp){
320 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
321 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
325 &General
::writehasharray
("$configgrp", \
%customgrp);
326 #check if we need to update firewallrules
327 if ( ! -z
$fwconfigfwd ){
328 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
329 foreach my $line (sort keys %fwfwd){
330 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
331 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
333 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
334 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
337 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
339 if ( ! -z
$fwconfiginp ){
340 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
341 foreach my $line (sort keys %fwinp){
342 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
343 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
346 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
350 my $key = &General
::findhasharraykey
(\
%customnetwork);
351 foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";}
352 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
353 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
354 #convert ip when leading '0' in byte
355 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
356 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
357 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
358 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
359 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
360 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
361 $customnetwork{$key}[4] = $count;
362 &General
::writehasharray
("$confignet", \
%customnetwork);
363 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
364 undef %customnetwork;
365 $fwhostsettings{'HOSTNAME'}='';
366 $fwhostsettings{'IP'}='';
367 $fwhostsettings{'SUBNET'}='';
368 $fwhostsettings{'NETREMARK'}='';
369 #check if an edited net affected groups and need to reload rules
370 if ($needrules eq 'on'){
382 if ($fwhostsettings{'ACTION'} eq 'savehost')
386 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
387 $fwhostsettings{'SUBNET'}='32';
388 #check if all fields are set
389 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
391 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
392 $fwhostsettings{'ACTION'} = 'edithost';
394 if($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
395 $fwhostsettings{'type'} = 'mac';
396 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
397 $fwhostsettings{'type'} = 'ip';
398 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
399 $fwhostsettings{'type'} = 'mac';
400 }elsif($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
401 $fwhostsettings{'type'} = 'ip';
403 $fwhostsettings{'type'} = '';
404 $errormessage=$Lang::tr
{'fwhost err ipmac'};
406 if($fwhostsettings{'type'} eq 'mac' )
408 if ($fwhostsettings{'IP'}!~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/ )
410 $errormessage=$Lang::tr
{'fwhost err mac'};
414 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
415 $errormessage=$Lang::tr
{'fwhost err remark'};
418 if ($fwhostsettings{'type'} eq 'ip'){
420 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
421 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
423 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
424 $fwhostsettings{'error'}='on';
426 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
427 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
428 $fwhostsettings{'error'}='on';
430 #check if net or broadcast
431 my @tmp= split (/\./,$fwhostsettings{'IP'});
432 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
433 $errormessage=$Lang::tr
{'fwhost err hostip'};
436 #only check plausi when no error till now
438 &plausicheck
("edithost");
440 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
441 $fwhostsettings{'actualize'} = '';
442 my $key = &General
::findhasharraykey
(\
%customhost);
443 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
444 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
445 $customhost{$key}[1] = $fwhostsettings{'type'} ;
446 if($customhost{$key}[1] eq 'ip'){
447 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
449 $customhost{$key}[2] = $fwhostsettings{'orgip'};
451 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
452 $customhost{$key}[4] = $fwhostsettings{'count'};
453 &General
::writehasharray
("$confighost", \
%customhost);
457 #get count if host was edited
458 if($fwhostsettings{'actualize'} eq 'on'){
459 $count=$fwhostsettings{'count'};
460 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
463 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
464 #check if we need to update groups
465 &General
::readhasharray
("$configgrp", \
%customgrp);
466 foreach my $key (sort keys %customgrp){
467 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
468 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
472 &General
::writehasharray
("$configgrp", \
%customgrp);
473 #check if we need to update firewallrules
474 if ( ! -z
$fwconfigfwd ){
475 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
476 foreach my $line (sort keys %fwfwd){
477 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
478 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
480 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
481 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
484 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
486 if ( ! -z
$fwconfiginp ){
487 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
488 foreach my $line (sort keys %fwinp){
489 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
490 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
493 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
497 my $key = &General
::findhasharraykey
(\
%customhost);
498 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
499 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
500 $customhost{$key}[1] = $fwhostsettings{'type'} ;
501 if ($fwhostsettings{'type'} eq 'ip'){
502 #convert ip when leading '0' in byte
503 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
504 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
505 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
507 $customhost{$key}[2] = $fwhostsettings{'IP'};
509 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
510 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
511 $customhost{$key}[4] =$count;
512 &General
::writehasharray
("$confighost", \
%customhost);
514 $fwhostsettings{'HOSTNAME'}='';
515 $fwhostsettings{'IP'}='';
516 $fwhostsettings{'type'}='';
517 $fwhostsettings{'HOSTREMARK'}='';
518 #check if we need to update rules while host was edited
519 if($needrules eq 'on'){
530 if ($fwhostsettings{'ACTION'} eq 'savegrp')
532 my $grp=$fwhostsettings{'grp_name'};;
533 my $rem=$fwhostsettings{'remark'};
536 my $updcounter='off';
539 &General
::readhasharray
("$configgrp", \
%customgrp);
540 &General
::readhasharray
("$confignet", \
%customnetwork);
541 &General
::readhasharray
("$confighost", \
%customhost);
543 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
545 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
546 $errormessage.=$Lang::tr
{'fwhost err remark'};
548 if ($fwhostsettings{'update'} eq 'on'){
549 #check standard networks
550 if ($fwhostsettings{'grp2'} eq 'std_net'){
551 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
552 $type='Standard Network';
554 #check custom networks
555 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
556 @target=$fwhostsettings{'CUST_SRC_NET'};
558 $type='Custom Network';
559 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
560 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
561 $fwhostsettings{'grp_name'}='';
562 $fwhostsettings{'remark'}='';
564 #check custom addresses
565 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
566 @target=$fwhostsettings{'CUST_SRC_HOST'};
569 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
570 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
571 $fwhostsettings{'grp_name'}='';
572 $fwhostsettings{'remark'}='';
574 #get address from ovpn ccd static net
575 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
576 @target=$fwhostsettings{'OVPN_CCD_NET'};
577 $type='OpenVPN static network';
578 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
579 $errormessage=$Lang::tr
{'fwhost err groupempty'};
580 $fwhostsettings{'grp_name'}='';
581 $fwhostsettings{'remark'}='';
583 #get address from ovpn ccd static host
584 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
585 @target=$fwhostsettings{'OVPN_CCD_HOST'};
586 $type='OpenVPN static host';
587 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
588 $errormessage=$Lang::tr
{'fwhost err groupempty'};
590 #get address from ovpn ccd Net-2-Net
591 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
592 @target=$fwhostsettings{'OVPN_N2N'};
593 $type='OpenVPN N-2-N';
594 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
595 $errormessage=$Lang::tr
{'fwhost err groupempty'};
596 $fwhostsettings{'grp_name'}='';
597 $fwhostsettings{'remark'}='';
599 #get address from IPSEC HOST
600 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
601 @target=$fwhostsettings{'IPSEC_HOST'};
603 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
604 $errormessage=$Lang::tr
{'fwhost err groupempty'};
605 $fwhostsettings{'grp_name'}='';
606 $fwhostsettings{'remark'}='';
608 #get address from IPSEC NETWORK
609 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
610 @target=$fwhostsettings{'IPSEC_NET'};
611 $type='IpSec Network';
612 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
613 $errormessage=$Lang::tr
{'fwhost err groupempty'};
614 $fwhostsettings{'grp_name'}='';
615 $fwhostsettings{'remark'}='';
617 #check if host/net exists in grp
619 my $test="$grp,$fwhostsettings{'oldremark'},@target";
620 foreach my $key (keys %customgrp) {
621 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
622 if ($test1 eq $test){
623 $errormessage=$Lang::tr
{'fwhost err isingrp'};
624 $fwhostsettings{'update'} = 'on';
630 #on first save, we have an empty @target, so fill it with nothing
631 my $targetvalues=@target;
632 if ($targetvalues == '0'){
635 #on update, we have to delete the dummy entry
636 foreach my $key (keys %customgrp){
637 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
638 delete $customgrp{$key};
642 &General
::writehasharray
("$configgrp", \
%customgrp);
643 &General
::readhasharray
("$configgrp", \
%customgrp);
645 foreach my $key (keys %customgrp)
647 if($customgrp{$key}[0] eq $grp)
649 $count=$customgrp{$key}[4];
653 if ($count eq '' ){$count='0';}
655 #create array with new lines
656 foreach my $line (@target){
657 push (@newgrp,"$grp,$rem,$line");
660 my $key = &General
::findhasharraykey
(\
%customgrp);
661 foreach my $line (@newgrp){
662 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
663 my ($a,$b,$c,$d) = split (",",$line);
664 $customgrp{$key}[0] = $a;
665 $customgrp{$key}[1] = $b;
666 $customgrp{$key}[2] = $c;
667 $customgrp{$key}[3] = $type;
668 $customgrp{$key}[4] = $count;
670 &General
::writehasharray
("$configgrp", \
%customgrp);
671 #update counter in Host/Net
672 if($updcounter eq 'net'){
673 foreach my $key (keys %customnetwork) {
674 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
675 $customnetwork{$key}[4] = $customnetwork{$key}[4]+1;
679 &General
::writehasharray
("$confignet", \
%customnetwork);
680 }elsif($updcounter eq 'host'){
681 foreach my $key (keys %customhost) {
682 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
683 $customhost{$key}[4]=$customhost{$key}[3]+1;
686 &General
::writehasharray
("$confighost", \
%customhost);
688 $fwhostsettings{'update'}='on';
690 #check if ruleupdate is needed
698 if ($fwhostsettings{'ACTION'} eq 'saveservice')
701 &General
::readhasharray
("$configsrv", \
%customservice );
702 $errormessage=&checkports
(\
%customservice);
703 if ($fwhostsettings{'PROT'} eq 'ICMP'){
704 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
705 foreach my $key (keys %icmptypes){
706 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
707 $ICMP=$icmptypes{$key}[0];
711 if($ICMP eq ''){$ICMP='BLANK';}
713 my $key = &General
::findhasharraykey
(\
%customservice);
714 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
715 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
716 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
717 $customservice{$key}[2] = $fwhostsettings{'PROT'};
718 $customservice{$key}[3] = $ICMP;
719 $customservice{$key}[4] = 0;
720 &General
::writehasharray
("$configsrv", \
%customservice );
722 $fwhostsettings{'SRV_NAME'}='';
723 $fwhostsettings{'SRV_PORT'}='';
724 $fwhostsettings{'PROT'}='';
725 $fwhostsettings{'ICMP_TYPES'}='';
729 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
734 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
735 &General
::readhasharray
("$configsrv", \
%customservice );
736 $errormessage=&checkservicegroup
;
738 #on first save, we have to enter a dummy value
739 if ($fwhostsettings{'CUST_SRV'} eq ''){
740 $fwhostsettings{'CUST_SRV'}='none';
742 #on update, we have to delete the dummy entry
743 foreach my $key (keys %customservicegrp){
744 if ($customservicegrp{$key}[2] eq 'none'){
745 delete $customservicegrp{$key};
749 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
750 #check if remark has also changed
751 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
753 foreach my $key (keys %customservicegrp)
755 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
757 $customservicegrp{$key}[1]='';
758 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
763 foreach my $key (keys %customservicegrp)
765 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
767 $count=$customservicegrp{$key}[3];
771 if ($count eq '' ){$count='0';}
773 foreach my $key (sort keys %customservice){
774 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
775 $port=$customservice{$key}[1];
776 $prot=$customservice{$key}[2];
777 $customservice{$key}[4]++;
780 &General
::writehasharray
("$configsrv", \
%customservice );
781 my $key = &General
::findhasharraykey
(\
%customservicegrp);
782 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
783 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
784 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
785 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
786 $customservicegrp{$key}[3] = $count;
787 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
788 $fwhostsettings{'updatesrvgrp'}='on';
794 &viewtableservicegrp
;
797 if ($fwhostsettings{'ACTION'} eq 'editnet')
802 if ($fwhostsettings{'ACTION'} eq 'edithost')
807 if ($fwhostsettings{'ACTION'} eq 'editgrp')
809 $fwhostsettings{'update'}='on';
813 if ($fwhostsettings{'ACTION'} eq 'editservice')
815 $fwhostsettings{'updatesrv'}='on';
818 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
820 $fwhostsettings{'updatesrvgrp'} = 'on';
822 &viewtableservicegrp
;
825 if ($fwhostsettings{'ACTION'} eq 'resetnet')
827 $fwhostsettings{'HOSTNAME'} ="";
828 $fwhostsettings{'IP'} ="";
829 $fwhostsettings{'SUBNET'} ="";
832 if ($fwhostsettings{'ACTION'} eq 'resethost')
834 $fwhostsettings{'HOSTNAME'} ="";
835 $fwhostsettings{'IP'} ="";
836 $fwhostsettings{'type'} ="";
840 if ($fwhostsettings{'ACTION'} eq 'delnet')
842 &General
::readhasharray
("$confignet", \
%customnetwork);
843 foreach my $key (keys %customnetwork) {
844 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
845 delete $customnetwork{$key};
846 &General
::writehasharray
("$confignet", \
%customnetwork);
853 if ($fwhostsettings{'ACTION'} eq 'delhost')
855 &General
::readhasharray
("$confighost", \
%customhost);
856 foreach my $key (keys %customhost) {
857 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
858 delete $customhost{$key};
859 &General
::writehasharray
("$confighost", \
%customhost);
866 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
870 &General
::readhasharray
("$configgrp", \
%customgrp);
871 foreach my $key (keys %customgrp){
872 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
873 #decrease count from source host/net
874 if ($customgrp{$key}[3] eq 'Custom Network'){
875 &General
::readhasharray
("$confignet", \
%customnetwork);
876 foreach my $key1 (keys %customnetwork){
877 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
878 $customnetwork{$key1}[3] = $customnetwork{$key1}[3]-1;
882 &General
::writehasharray
("$confignet", \
%customnetwork);
884 if ($customgrp{$key}[3] eq 'Custom Host'){
885 &General
::readhasharray
("$confighost", \
%customhost);
886 foreach my $key1 (keys %customhost){
887 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
888 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
892 &General
::writehasharray
("$confighost", \
%customhost);
894 $grpname=$customgrp{$key}[0];
895 $grpremark=$customgrp{$key}[1];
896 delete $customgrp{$key};
899 &General
::writehasharray
("$configgrp", \
%customgrp);
900 if ($fwhostsettings{'grpcnt'} > 0){&rules
;}
901 if ($fwhostsettings{'update'} eq 'on'){
902 $fwhostsettings{'remark'}= $grpremark;
903 $fwhostsettings{'grp_name'}=$grpname;
908 if ($fwhostsettings{'ACTION'} eq 'delgrp')
910 &General
::readhasharray
("$configgrp", \
%customgrp);
911 &decrease
($fwhostsettings{'grp_name'});
912 foreach my $key (sort keys %customgrp)
914 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
916 delete $customgrp{$key};
919 &General
::writehasharray
("$configgrp", \
%customgrp);
920 $fwhostsettings{'grp_name'}='';
924 if ($fwhostsettings{'ACTION'} eq 'delservice')
926 &General
::readhasharray
("$configsrv", \
%customservice);
927 foreach my $key (keys %customservice) {
928 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
929 #&deletefromgrp($customhost{$key}[0],$configgrp);
930 delete $customservice{$key};
931 &General
::writehasharray
("$configsrv", \
%customservice);
935 $fwhostsettings{'SRV_NAME'}='';
936 $fwhostsettings{'SRV_PORT'}='';
937 $fwhostsettings{'PROT'}='';
940 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
942 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
943 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
944 foreach my $key (sort keys %customservicegrp)
946 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
948 delete $customservicegrp{$key};
951 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
952 $fwhostsettings{'SRVGRP_NAME'}='';
954 &viewtableservicegrp
;
956 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
960 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
961 &General
::readhasharray
("$configsrv", \
%customservice);
962 foreach my $key (keys %customservicegrp){
963 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
965 #decrease count from source service
966 foreach my $key1 (sort keys %customservice){
967 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
968 $customservice{$key1}[4]--;
972 &General
::writehasharray
("$configsrv", \
%customservice);
973 $grpname=$customservicegrp{$key}[0];
974 $grpremark=$customservicegrp{$key}[1];
975 delete $customservicegrp{$key};
978 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
980 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
981 #$fwhostsettings{'updatesrvgrp'}='on';
982 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
983 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
986 &viewtableservicegrp
;
989 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
994 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
999 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1004 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1008 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1011 &viewtableservicegrp
;
1013 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1015 &General
::readhasharray
("$configgrp", \
%customgrp);
1016 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1017 foreach my $key (sort keys %customgrp)
1019 #$customgrp{$key}[1]=~ s/\|/,/g;
1020 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1022 #$fwhostsettings{'newrem'}=~ s/,/\|/g;
1023 $customgrp{$key}[1]='';
1024 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1027 &General
::writehasharray
("$configgrp", \
%customgrp);
1028 $fwhostsettings{'update'}='on';
1029 #$fwhostsettings{'newrem'}=~ s/\|/,/g;
1030 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1032 $errormessage=$Lang::tr
{'fwhost err remark'};
1033 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1034 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1035 $fwhostsettings{'update'} = 'on';
1037 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1041 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1043 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1044 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1045 foreach my $key (sort keys %customservicegrp)
1047 #$customservicegrp{$key}[1]=~ s/\|/,/g;
1048 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1050 #$fwhostsettings{'newsrvrem'}=~ s/,/|/g;
1051 $customservicegrp{$key}[1]='';
1052 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1055 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1056 $fwhostsettings{'updatesrvgrp'}='on';
1057 #$fwhostsettings{'newsrvrem'}=~ s/\|/,/g;
1058 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1060 $errormessage=$Lang::tr
{'fwhost err remark'};
1061 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1062 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1063 $fwhostsettings{'updatesrvgrp'} = 'on';
1065 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1067 &viewtableservicegrp
;
1070 if($fwhostsettings{'ACTION'} eq '')
1078 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1080 <table border='0' width='100%'><form method='post'>
1081 <tr><td><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'}' /></td>
1082 <td align='right'><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservice'}' /><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservicegrp'}' /></td></tr>
1083 <tr><td colspan='6'><hr></hr></td>
1087 if (-f
"${General::swroot}/fwhosts/reread"){
1088 print "</tr><tr><td colspan='6'><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: red; font-weight: bold;' >$Lang::tr{'fwhost reread'}</td>";
1090 print"</tr></table></form>";
1092 &Header
::closebox
();
1100 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1101 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1103 <table border='0' width='100%'><form method='post' style='display:inline' >
1104 <tr><td>$Lang::tr{'name'}:</td><td><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'}><script>document.getElementById('textbox1').focus()</script></td><td>$Lang::tr{'fwhost netaddress'}:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='14'></td><td align='right'>$Lang::tr{'netmask'}:</td><td align='right'><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='14'></td></tr>
1105 <tr><td>$Lang::tr{'remark'}:</td><td colspan='5'><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' size='64'></td></tr>
1106 <tr><td colspan='6'><hr></hr></td></tr><tr>
1108 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1110 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='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newnet' value='$fwhostsettings{'newnet'}'>";
1112 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'>";
1114 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'></td></tr></table></form>";
1115 &Header
::closebox
();
1121 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1122 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1124 <table border='0' width='100%'><form method='post' style='display:inline'>
1125 <tr><td>$Lang::tr{'name'}:</td><td width='35%'><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} ><script>document.getElementById('textbox1').focus()</script></td><td><select name='type'>
1127 if ($fwhostsettings{'type'} eq 'ip'){print "<option value='ip' selected >IP</option>";}else{print "<option value='ip' >IP</option>";}
1128 if ($fwhostsettings{'type'} eq 'mac'){print "<option value='mac' selected >MAC</option>";}else{print "<option value='mac' >MAC</option>";}
1130 </option></select></td><td align='right' width='15%'>IP/MAC:</td><td align='right'><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} ></td></tr>
1131 <tr><td>$Lang::tr{'remark'}:</td><td colspan='5'><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' size='64'></td></tr>
1132 <tr><td colspan='7'><br><br><b>$Lang::tr{'fwhost attention'}</b><br>$Lang::tr{'fwhost macwarn'}</td></tr>
1133 <tr><td colspan='7'><hr></hr></td></tr>
1136 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1139 print " <td colspan='6' align='right'><input type='submit' value='$Lang::tr{'update'}' style='min-width:100px;'/><input type='hidden' name='ACTION' value='updatehost'><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newhost' value='$fwhostsettings{'newhost'}'></form>";
1141 print " <td colspan='6' 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'>";
1143 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'></td></tr></table></form>";
1144 &Header
::closebox
();
1151 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1152 &General
::setup_default_networks
(\
%defaultNetworks);
1154 $checked{'check1'}{'off'} = '';
1155 $checked{'check1'}{'on'} = '';
1156 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1157 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1158 my $grp=$fwhostsettings{'grp_name'};
1159 my $rem=$fwhostsettings{'remark'};
1160 if ($fwhostsettings{'update'} eq ''){
1162 <table width='100%' border='0'><form method='post'>
1163 <tr><td>$Lang::tr{'fwhost addgrpname'}</td><td><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}'></td><td>$Lang::tr{'remark'}:</td><td width='1%'><input type='TEXT' name='remark' size='35' value='$fwhostsettings{'remark'}'></tr>
1164 <tr><td colspan='5'><hr></td></tr></table>
1168 <table width='100%' border='0'><form method='post' style='display:inline'>
1169 <tr><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' readonly ></td><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='newrem' size='35' value='$fwhostsettings{'remark'}'></td><td><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldrem' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='ACTION' value='changegrpremark' ></td></tr></table></form>
1173 if ($fwhostsettings{'update'} eq 'on'){
1175 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'><table width='100%' border='0'><tr><td width='1%'><input type='radio' name='grp2' value='std_net' checked></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost stdnet'}</td><td><select name='DEFAULT_SRC_ADR' style='min-width:185px;'>
1177 foreach my $network (sort keys %defaultNetworks)
1179 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1180 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1181 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1182 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1183 print ">$network</option>";
1186 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_net' $checked{'grp2'}{'ovpn_net'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='OVPN_CCD_NET' style='min-width:185px;'>
1188 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1189 foreach my $key (sort { uc($ccdnet{$a}[0]) cmp uc($ccdnet{$b}[0]) } keys %ccdnet)
1191 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1195 <tr><td><input type='radio' name='grp2' value='cust_net' $checked{'grp2'}{'cust_net'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='CUST_SRC_NET' style='min-width:185px;'>
1197 &General
::readhasharray
("$confignet", \
%customnetwork);
1198 foreach my $key (sort { uc($customnetwork{$a}[0]) cmp uc($customnetwork{$b}[0]) } keys %customnetwork) {
1199 print"<option>$customnetwork{$key}[0]</option>";
1202 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_host' $checked{'grp2'}{'ovpn_host'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='OVPN_CCD_HOST' style='min-width:185px;'>
1204 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1205 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1207 if ($ccdhost{$key}[33] ne ''){
1208 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1213 <tr><td valign='top'><input type='radio' name='grp2' value='cust_host' $checked{'grp2'}{'cust_host'}></td><td valign='top'>$Lang::tr{'fwhost cust addr'}</td><td><select name='CUST_SRC_HOST' style='min-width:185px;'>
1215 &General
::readhasharray
("$confighost", \
%customhost);
1216 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0]) } keys %customhost) {
1217 print"<option>$customhost{$key}[0]</option>";
1220 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_n2n' $checked{'grp2'}{'ovpn_n2n'}></td><td valign='top'>$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='OVPN_N2N' style='min-width:185px;'>
1222 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1223 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1224 if($ccdhost{$key}[3] eq 'net'){
1225 print"<option>$ccdhost{$key}[1]</option>";
1230 <tr><td colspan='3'></td><td valign='top'><input type='radio' name='grp2' value='ipsec_net' $checked{'grp2'}{'ipsec_net'}></td><td valign='top'>$Lang::tr{'fwhost ipsec net'}</td><td><select name='IPSEC_NET' style='min-width:185px;'>
1232 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1233 foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1234 if ($ipsecconf{$key}[3] eq 'net'){
1235 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1239 </select></td></tr></table>
1241 # <td colspan='3'></td><td valign='top'><input type='radio' name='grp2' value='ipsec_host' $checked{'grp2'}{'ipsec_host'}></td><td valign='top'>$Lang::tr{'fwhost ipsec host'}</td><td><select name='IPSEC_HOST' style='min-width:185px;'>
1243 # &General::readhasharray("$configipsec", \%ipsecconf);
1244 # foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1245 # if ($ipsecconf{$key}[3] eq 'host'){
1246 # print"<option>$ipsecconf{$key}[1]</option>";
1250 # </select></td></tr>
1252 print"<br><br><b>$Lang::tr{'fwhost attention'}:</b><br> $Lang::tr{'fwhost macwarn'}<br><hr>";
1254 print"<table border='0' width='100%'>";
1255 print"<tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /><input type='hidden' name='oldremark' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='update' value=$fwhostsettings{'update'} ><input type='hidden' name='ACTION' value='savegrp' ></form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value'reset'></td></td></table></form>";
1256 &Header
::closebox
();
1262 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservice'});
1263 if ($fwhostsettings{'updatesrv'} eq 'on')
1265 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1266 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1267 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1270 <table width='100%' border='0'><form method='post'>
1271 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost srv_name'}:</td><td width='1%' nowrap='nowrap'><input type='text' name='SRV_NAME' id='textbox1' value='$fwhostsettings{'SRV_NAME'}'><script>document.getElementById('textbox1').focus()</script></td><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT'>
1273 foreach ("TCP","UDP","ICMP")
1275 if ($_ eq $fwhostsettings{'PROT'})
1277 print"<option selected>$_</option>";
1279 print"<option>$_</option>";
1283 </select></td><td>$Lang::tr{'fwhost port'}:</td><td><input type='text' name='SRV_PORT' value='$fwhostsettings{'SRV_PORT'}' maxlength='11' size='9'></td></tr>
1284 <tr><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='4'><select name='ICMP_TYPES'>
1286 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1287 print"<option>All ICMP-Types</option>";
1288 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1289 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1294 <tr><td colspan='6'><hr></td></tr>
1295 <tr><td colspan='6' align='right'>
1297 if ($fwhostsettings{'updatesrv'} eq 'on')
1300 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1301 <input type='hidden' name='ACTION' value='updateservice'>
1302 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1303 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1304 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1308 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1311 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1316 &Header
::closebox
();
1324 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservicegrp'});
1325 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1326 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1328 <table width='100%' border='0'><form method='post'>
1329 <tr><td>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}'></td><td>$Lang::tr{'remark'}:</td><td width='1%'><input type='text' name='SRVGRP_REMARK' size='35' value='$fwhostsettings{'SRVGRP_REMARK'}'></td></tr>
1330 <tr><td colspan='4'><hr></td></td></tr>
1335 <table width='100%' border='0'><form method='post' style='display:inline'>
1336 <tr><td>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}' readonly ></td><td>$Lang::tr{'remark'}:</td><td width='1%'><input type='text' name='newsrvrem' size='35' value='$fwhostsettings{'SRVGRP_REMARK'}'></td><td><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldsrvrem' value='$fwhostsettings{'oldsrvgrpremark'}'><input type='hidden' name='ACTION' value='changesrvgrpremark' ></td></tr>
1337 <tr><td colspan='5'><hr></td></td></tr>
1341 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1343 <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%'>
1344 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1346 &General
::readhasharray
("$configsrv", \
%customservice);
1347 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
1349 print "<option>$customservice{$key}[0]</option>";
1353 <tr><td colspan='4'><br><br><br></td></tr>
1354 <tr><td colspan='4'><hr></td></tr>
1359 <table width='100%' border='0'>
1360 <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>
1363 &Header
::closebox
();
1368 if(! -z
$confignet){
1369 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1370 &General
::readhasharray
("$confignet", \
%customnetwork);
1371 if (!keys %customnetwork)
1373 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1376 <table border='0' width='100%'>
1377 <tr><td align='center'><b>$Lang::tr{'name'}</td><td align='center'><b>$Lang::tr{'fwhost netaddress'}</td><td align='center'><b>$Lang::tr{'netmask'}</td><td align='center'><b>$Lang::tr{'remark'}</td><td align='center'><b>$Lang::tr{'used'}</td><td></td><td width='3%'></td></tr>
1381 foreach my $key (sort {$a <=> $b} keys %customnetwork) {
1382 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1383 print" <tr bgcolor='${Header::colouryellow}'>";
1386 print" <tr bgcolor='$color{'color22'}'>";
1389 print" <tr bgcolor='$color{'color20'}'>";
1392 <td width='20%'><form method='post'>$customnetwork{$key}[0]</td><td width=15%'>$customnetwork{$key}[1]</td><td width='15%'>$customnetwork{$key}[2]</td><td width='40%'>$customnetwork{$key}[3]</td><td align='center'>$customnetwork{$key}[4]x</td>
1393 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1394 <input type='hidden' name='ACTION' value='editnet'>
1395 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1396 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1397 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1398 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1401 if($customnetwork{$key}[4] == '0')
1403 print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delnet' /><input type='hidden' name='key' value='$customnetwork{$key}[0]' /></td></form></tr>";
1405 print"<td></td></form></tr>";
1410 &Header
::closebox
();
1416 if (! -z
$confighost){
1417 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1418 &General
::readhasharray
("$confighost", \
%customhost);
1419 if (!keys %customhost)
1421 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1424 <table border='0' width='100%'>
1425 <tr><td align='center'><b>$Lang::tr{'name'}</td><td align='center'><b>$Lang::tr{'fwhost ip_mac'}</td><td align='center'><b>$Lang::tr{'remark'}</td><td align='center'><b>$Lang::tr{'used'}</td><td></td><td width='3%'></td></tr>
1429 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0])|| $a <=> $b } keys %customhost) {
1430 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1431 print" <tr bgcolor='${Header::colouryellow}'>";
1432 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1433 else{ print" <tr bgcolor='$color{'color20'}'>";}
1434 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1435 $customhost{$key}[4]=~s/\s+//g;
1437 <td width='20%'><form method='post'>$customhost{$key}[0]</td><td width='20%'>$ip</td><td width='50%'>$customhost{$key}[3]</td><td align='center'>$customhost{$key}[4]x</td>
1438 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1439 <input type='hidden' name='ACTION' value='edithost' />
1440 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1441 <input type='hidden' name='IP' value='$ip' />
1442 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1443 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1446 if($customhost{$key}[4] == '0')
1448 print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delhost' /><input type='hidden' name='key' value='$customhost{$key}[0]' /></td></form></tr>";
1450 print"<td width='1%'></td></tr>";
1455 &Header
::closebox
();
1460 if(! -z
"$configgrp"){
1461 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1462 &General
::readhasharray
("$configgrp", \
%customgrp);
1463 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1464 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1465 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1466 &General
::readhasharray
("$confighost", \
%customhost);
1467 &General
::readhasharray
("$confignet", \
%customnetwork);
1475 if (!keys %customgrp)
1477 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1479 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } sort { uc($customgrp{$a}[2]) cmp uc($customgrp{$b}[2]) } keys %customgrp){
1481 if ($helper ne $customgrp{$key}[0]){
1483 foreach my $key1 (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } sort { uc($customgrp{$a}[2]) cmp uc($customgrp{$b}[2]) } keys %customgrp){
1484 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1493 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost empty'};}
1494 $grpname=$customgrp{$key}[0];
1495 $remark="$customgrp{$key}[1]";
1496 if($count >=2){print"</table>";}
1497 print "<br><b><u>$grpname</u></b>    ";
1498 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1499 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1500 if($customgrp{$key}[4] == '0')
1502 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>";
1504 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>";
1505 print"<table width='100%' style='border: 1px solid #000000;' rules='none' ><tr><td align='center'><b>Name</b></td><td align='center'><b>$Lang::tr{'ip address'}</b></td><td align='center' width='25%'><b>$Lang::tr{'fwhost type'}</td></tr>";
1508 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1509 print" <tr bgcolor='${Header::colouryellow}'>";
1510 }elsif ($count %2 == 0){
1511 print"<tr bgcolor='$color{'color22'}'>";
1513 print"<tr bgcolor='$color{'color20'}'>";
1515 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1516 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1517 print "<td width='39%'>";
1518 if($customgrp{$key}[3] eq 'Standard Network'){
1519 print &get_name
($customgrp{$key}[2])."</td>";
1521 print "$customgrp{$key}[2]</td>";
1523 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost empty'}){
1524 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1526 print"<td>$ip</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1528 if ($delflag > '1' && $ip ne ''){
1529 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1531 print"<input type='hidden' name='ACTION' value='deletegrphost'><input type='hidden' name='grpcnt' value='$customgrp{$key}[4]'><input type='hidden' name='update' value='$fwhostsettings{'update'}'><input type='hidden' name='delhost' value='$grpname,$remark,$customgrp{$key}[2],$customgrp{$key}[3]'></form></td></tr>";
1533 $helper=$customgrp{$key}[0];
1539 &Header
::closebox
();
1543 sub viewtableservice
1546 if(! -z
"$configsrv")
1548 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1549 &General
::readhasharray
("$configsrv", \
%customservice);
1551 <table width='100%' border='0'>
1552 <tr><td align='center'><b>$Lang::tr{'fwhost srv_name'}</td><td align='center'><b>$Lang::tr{'fwhost prot'}</td><td align='center'><b>$Lang::tr{'fwhost port'}</td><td align='center'><b>ICMP</td><td align='center'><b>$Lang::tr{'fwhost used'}</td><td></td><td width='3%'></td></tr>
1554 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
1557 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1558 print" <tr bgcolor='${Header::colouryellow}'>";
1559 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1561 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1563 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1566 </td><td align='center'>$customservice{$key}[4]x</td>
1567 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} /><input type='hidden' name='ACTION' value='editservice' />
1568 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1569 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1570 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1572 if ($customservice{$key}[4] eq '0')
1574 print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delservice' /><input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]'></td></tr></form>";
1576 print"<td></td></tr>";
1580 &Header
::closebox
();
1583 sub viewtableservicegrp
1592 if (! -z
$configsrvgrp){
1593 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1594 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1595 &General
::readhasharray
("$configsrv", \
%customservice);
1596 my $number= keys %customservicegrp;
1597 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0])|| $a <=> $b } keys %customservicegrp){
1599 if ($helper ne $customservicegrp{$key}[0]){
1601 foreach my $key1 (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } sort { uc($customservicegrp{$a}[2]) cmp uc($customservicegrp{$b}[2]) } keys %customservicegrp){
1602 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1610 $grpname=$customservicegrp{$key}[0];
1611 if ($customservicegrp{$key}[2] eq "none"){
1612 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1616 $remark="$customservicegrp{$key}[1]";
1617 if($count >=2){print"</table>";}
1618 print "<br><b><u>$grpname</u></b>     ";
1619 print "<b>$Lang::tr{'remark'}:</b>  $remark " if ($remark ne '');
1620 print "  <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1621 if($customservicegrp{$key}[3] == '0')
1623 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>";
1625 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>";
1626 print"<table width='100%' style='border: 1px solid #000000;' rules='none' ><tr><td align='center'><b>Name</b></td><td align='center'><b>$Lang::tr{'port'}</b></td><td align='center' width='25%'><b>$Lang::tr{'fwhost prot'}</td></tr>";
1628 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1629 print" <tr bgcolor='${Header::colouryellow}'>";
1630 }elsif ($count %2 == 0){
1631 print"<tr bgcolor='$color{'color22'}'>";
1633 print"<tr bgcolor='$color{'color20'}'>";
1635 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1636 foreach my $srv (sort keys %customservice){
1637 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1638 $protocol=$customservice{$srv}[2];
1639 $port=$customservice{$srv}[1];
1643 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1644 if ($number gt '1'){
1645 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1647 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'><input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2],$customservicegrp{$key}[3]'></form></td></tr>";
1648 $helper=$customservicegrp{$key}[0];
1651 &Header
::closebox
();
1657 my %hash=%{(shift)};
1658 foreach my $key (keys %hash) {
1659 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1669 my %hash=%{(shift)};
1671 foreach my $key (keys %hash) {
1672 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1681 my %hash=%{(shift)};
1682 &General
::readhasharray
("$confignet", \
%hash);
1683 foreach my $key (keys %hash) {
1684 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1691 sub checkservicegroup
1693 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1697 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1699 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1700 return $errormessage;
1702 #check empty selectbox
1703 if (keys %customservice lt 1)
1705 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1707 #check if name already exists
1708 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1709 foreach my $key (keys %customservicegrp) {
1710 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1711 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1716 #check if service already exists in group
1717 foreach my $key (keys %customservicegrp) {
1718 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1719 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1722 return $errormessage;
1726 if ($errormessage) {
1727 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1728 print "<class name='base'>$errormessage\n";
1729 print " </class>\n";
1730 &Header
::closebox
();
1736 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1737 print "<class name='base'>$hint\n";
1738 print " </class>\n";
1739 &Header
::closebox
();
1745 &General
::setup_default_networks
(\
%defaultNetworks);
1746 foreach my $network (sort keys %defaultNetworks)
1748 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1756 &General
::readhasharray
("$config",\
%hash);
1757 foreach my $key (keys %hash) {
1758 $errormessage.="lese $hash{$key}[2] und $target<br>";
1759 if($hash{$key}[2] eq $target){
1762 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1765 &General
::writehasharray
("$config",\
%hash);
1772 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
1774 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1775 $fwhostsettings{'BLK_IP'}='readonly';
1776 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1777 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1779 #check if name collides with CCD Netname
1780 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1781 foreach my $key (keys %ccdnet) {
1782 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1783 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1784 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1785 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1789 #check if IP collides with CCD NetIP
1790 if ($fwhostsettings{'type'} ne 'mac'){
1791 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1792 foreach my $key (keys %ccdnet) {
1793 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1794 if($ccdnet{$key}[1] eq $test){
1795 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1796 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1797 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1798 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1803 #check if name collides with CCD Hostname
1804 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1805 foreach my $key (keys %ccdhost) {
1806 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1807 if($ip eq $fwhostsettings{'IP'}){
1808 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1809 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1813 #check if IP collides with CCD HostIP (only hosts)
1814 if ($edit eq 'edithost')
1816 foreach my $key (keys %ccdhost) {
1817 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1818 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1819 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1820 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1825 #check if network with this name already exists
1826 &General
::readhasharray
("$confignet", \
%customnetwork);
1827 if (!&checkname
(\
%customnetwork))
1829 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1830 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1831 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1833 #check if network ip already exists
1834 if (!&checkip
(\
%customnetwork,1))
1836 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1837 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1839 #check if host with this name already exists
1840 &General
::readhasharray
("$confighost", \
%customhost);
1841 if (!&checkname
(\
%customhost))
1843 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1844 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1845 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1847 #check if host with this ip already exists
1848 if (!&checkip
(\
%customhost,2))
1850 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1860 #get address from IPSEC NETWORK
1861 if ($type eq 'IpSec Network'){
1862 foreach my $key (keys %ipsecconf) {
1863 if ($ipsecconf{$key}[1] eq $name){
1864 return $ipsecconf{$key}[11];
1867 &deletefromgrp
($name,$configgrp);
1870 #get address from IPSEC HOST
1871 if ($type eq 'IpSec Host'){
1872 foreach my $key (keys %ipsecconf) {
1873 if ($ipsecconf{$key}[1] eq $name){
1874 return $ipsecconf{$key}[10];
1877 &deletefromgrp
($name,$configgrp);
1880 #get address from ovpn ccd Net-2-Net
1881 if ($type eq 'OpenVPN N-2-N'){
1882 foreach my $key (keys %ccdhost) {
1883 if($ccdhost{$key}[1] eq $name){
1884 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1885 $b=&General
::iporsubtodec
($b);
1889 &deletefromgrp
($name,$configgrp);
1892 #get address from ovpn ccd static host
1893 if ($type eq 'OpenVPN static host'){
1894 foreach my $key (keys %ccdhost) {
1895 if($ccdhost{$key}[1] eq $name){
1896 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1897 $b=&General
::iporsubtodec
($b);
1901 &deletefromgrp
($name,$configgrp);
1904 #get address from ovpn ccd static net
1905 if ($type eq 'OpenVPN static network'){
1906 foreach my $key (keys %ccdnet) {
1907 if ($ccdnet{$key}[0] eq $name){
1908 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1909 $b=&General
::iporsubtodec
($b);
1915 #check custom addresses
1916 if ($type eq 'Custom Host'){
1917 foreach my $key (keys %customhost) {
1918 if ($customhost{$key}[0] eq $name){
1919 return $customhost{$key}[2];
1924 ##check custom networks
1925 if ($type eq 'Custom Network'){
1926 foreach my $key (keys %customnetwork) {
1927 if($customnetwork{$key}[0] eq $name){
1928 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
1933 #check standard networks
1934 if ($type eq 'Standard Network'){
1935 if ($name =~ /OpenVPN/i){
1937 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
1938 return $ovpn{'DOVPN_SUBNET'};
1940 if ($name eq 'GREEN'){
1942 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1943 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
1945 if ($name eq 'BLUE'){
1947 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1948 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
1950 if ($name eq 'ORANGE'){
1952 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1953 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
1955 if ($name eq 'ALL'){
1956 return "0.0.0.0/0.0.0.0";
1958 if ($name =~ /IPsec/i){
1960 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
1961 return $hash{'RW_NET'};
1967 if (!-f
"${General::swroot}/fwhosts/reread"){
1968 system("touch ${General::swroot}/fwhosts/reread");
1969 system("touch ${General::swroot}/forward/reread");
1974 system ("/usr/local/bin/forwardfwctrl");
1975 if ( -f
"${General::swroot}/fwhosts/reread"){
1976 system("rm ${General::swroot}/fwhosts/reread");
1977 system("rm ${General::swroot}/forward/reread");
1984 &General
::readhasharray
("$confignet", \
%customnetwork);
1985 &General
::readhasharray
("$confighost", \
%customhost);
1986 foreach my $key (sort keys %customgrp ){
1987 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
1988 foreach my $key1 (sort keys %customnetwork){
1989 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
1990 $customnetwork{$key1}[3]=$customnetwork{$key1}[3]-1;
1996 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
1997 foreach my $key2 (sort keys %customhost){
1998 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
1999 $customhost{$key2}[3]=$customhost{$key2}[3]-1;
2006 &General
::writehasharray
("$confignet", \
%customnetwork);
2007 &General
::writehasharray
("$confighost", \
%customhost);
2012 &General
::readhasharray
("$configsrv", \
%customservice);
2013 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2015 foreach my $key (sort keys %customservicegrp){
2016 if ($customservicegrp{$key}[0] eq $grp ){
2017 foreach my $key2 (sort keys %customservice){
2018 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2019 $customservice{$key2}[4]--;
2024 &General
::writehasharray
("$configsrv", \
%customservice);
2030 my %hash=%{(shift)};
2032 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2033 $errormessage=$Lang::tr
{'fwhost err name1'};
2035 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2036 $errormessage=$Lang::tr
{'fwhost err port'};
2039 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2040 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2042 #change dashes with :
2043 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2045 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2046 $fwhostsettings{'SRV_PORT'} = "1:65535";
2048 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2049 $fwhostsettings{'SRV_PORT'} = "1:$2";
2051 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2052 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2054 if($fwhostsettings{'PROT'} ne 'ICMP'){
2055 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2057 # a new service has to have a different name
2058 foreach my $key (keys %hash){
2059 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2060 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2064 return $errormessage;
2068 # Checks a hostname against RFC1035
2069 my $hostname = $_[0];
2071 # Each part should be at least two characters in length
2072 # but no more than 63 characters
2073 if (length ($hostname) < 1 || length ($hostname) > 63) {
2075 # Only valid characters are a-z, A-Z, 0-9 and -
2076 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2078 # First character can only be a letter or a digit
2079 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2081 # Last character can only be a letter or a digit
2082 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2088 # Checks a hostname against RFC1035
2090 # Each part should be at least two characters in length
2091 # but no more than 63 characters
2092 if (length ($remark) < 1 || length ($remark) > 255) {
2094 # Only valid characters are a-z, A-Z, 0-9 and -
2095 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2097 # First character can only be a letter or a digit
2098 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2100 # Last character can only be a letter or a digit
2101 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2105 &Header
::closebigbox
();
2106 &Header
::closepage
();