]>
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) 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{'count'} = $customnetwork{$key}[3];
100 delete $customnetwork{$key};
104 &General
::writehasharray
("$confignet", \
%customnetwork);
105 $fwhostsettings{'actualize'} = 'on';
106 $fwhostsettings{'ACTION'} = 'savenet';
108 if ($fwhostsettings{'ACTION'} eq 'updatehost')
111 &General
::readhasharray
("$confighost", \
%customhost);
112 foreach my $key (keys %customhost)
114 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
116 if ($customhost{$key}[1] eq 'ip'){
117 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
119 $ip = $customhost{$key}[2];
121 $fwhostsettings{'orgip'} = $ip;
122 $fwhostsettings{'count'} = $customhost{$key}[3];
123 delete $customhost{$key};
124 &General
::writehasharray
("$confighost", \
%customhost);
127 $fwhostsettings{'actualize'} = 'on';
128 if($fwhostsettings{'orgip'}){
129 $fwhostsettings{'ACTION'} = 'savehost';
131 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
134 if ($fwhostsettings{'ACTION'} eq 'updateservice')
138 $errormessage=&checkports
(\
%customservice);
140 &General
::readhasharray
("$configsrv", \
%customservice);
141 foreach my $key (keys %customservice)
143 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
145 $count=$customservice{$key}[4];
146 delete $customservice{$key};
147 &General
::writehasharray
("$configsrv", \
%customservice);
151 if ($fwhostsettings{'PROT'} ne 'ICMP'){
152 $fwhostsettings{'ICMP_TYPES'}='BLANK';
154 my $key1 = &General
::findhasharraykey
(\
%customservice);
155 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
156 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
157 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
158 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
159 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
160 $customservice{$key1}[4] = $count;
161 &General
::writehasharray
("$configsrv", \
%customservice);
162 #check if we need to update firewallrules
163 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
164 if ( ! -z
$fwconfigfwd ){
165 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
166 foreach my $key (sort keys %fwfwd){
167 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
168 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
171 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
173 if ( ! -z
$fwconfiginp ){
174 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
175 foreach my $line (sort keys %fwinp){
176 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
177 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
180 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
182 #check if we need to update groups
183 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
184 foreach my $key (sort keys %customservicegrp){
185 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
186 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
189 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
192 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
195 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
198 $fwhostsettings{'SRV_NAME'} = '';
199 $fwhostsettings{'SRV_PORT'} = '';
200 $fwhostsettings{'PROT'} = '';
202 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
203 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
204 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
205 $fwhostsettings{'updatesrv'}= 'on';
207 if($needrules eq 'on'){
213 if ($fwhostsettings{'ACTION'} eq 'savenet' )
217 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
218 #check if all fields are set
219 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
221 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
226 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
228 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
229 $fwhostsettings{'BLK_HOST'} ='readonly';
230 $fwhostsettings{'NOCHECK'} ='false';
231 $fwhostsettings{'error'} ='on';
233 #check if subnet is sigle host
234 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
236 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
238 if($fwhostsettings{'error'} ne 'on'){
239 #check if we use one of ipfire's networks (green,orange,blue)
240 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
242 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
243 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
244 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
246 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
248 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
249 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
250 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
252 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
254 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
255 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
256 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
258 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
260 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
261 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
262 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
265 #only check plausi when no error till now
267 &plausicheck
("editnet");
269 #check if network ip is part of an already used one
270 if(&checksubnet
(\
%customnetwork))
272 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
273 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
275 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
277 $fwhostsettings{'actualize'} = '';
278 my $key = &General
::findhasharraykey
(\
%customnetwork);
279 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
280 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
281 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
282 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
283 $customnetwork{$key}[3] = $fwhostsettings{'count'};
284 &General
::writehasharray
("$confignet", \
%customnetwork);
285 undef %customnetwork;
288 &General
::readhasharray
("$confignet", \
%customnetwork);
289 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
290 if ($fwhostsettings{'update'} == '0'){
291 foreach my $key (keys %customnetwork) {
292 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
293 $count=$customnetwork{$key}[3];
294 delete $customnetwork{$key};
300 #get count if actualize is 'on'
301 if($fwhostsettings{'actualize'} eq 'on'){
302 $fwhostsettings{'actualize'} = '';
303 $count=$fwhostsettings{'count'};
304 #check if we need to reload rules
305 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
308 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
309 #check if we need to update groups
310 &General
::readhasharray
("$configgrp", \
%customgrp);
311 foreach my $key (sort keys %customgrp){
312 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
313 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
317 &General
::writehasharray
("$configgrp", \
%customgrp);
318 #check if we need to update firewallrules
319 if ( ! -z
$fwconfigfwd ){
320 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
321 foreach my $line (sort keys %fwfwd){
322 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
323 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
325 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
326 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
329 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
331 if ( ! -z
$fwconfiginp ){
332 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
333 foreach my $line (sort keys %fwinp){
334 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
335 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
338 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
342 my $key = &General
::findhasharraykey
(\
%customnetwork);
343 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
344 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
345 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
346 #convert ip when leading '0' in byte
347 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
348 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
349 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
350 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
351 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
352 $customnetwork{$key}[3] = $count;
353 &General
::writehasharray
("$confignet", \
%customnetwork);
354 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
355 undef %customnetwork;
356 $fwhostsettings{'HOSTNAME'}='';
357 $fwhostsettings{'IP'}='';
358 $fwhostsettings{'SUBNET'}='';
359 #check if an edited net affected groups and need to reload rules
360 if ($needrules eq 'on'){
372 if ($fwhostsettings{'ACTION'} eq 'savehost')
376 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
377 $fwhostsettings{'SUBNET'}='32';
378 #check if all fields are set
379 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
381 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
382 $fwhostsettings{'ACTION'} = 'edithost';
384 if($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
385 $fwhostsettings{'type'} = 'mac';
386 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
387 $fwhostsettings{'type'} = 'ip';
388 }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
389 $fwhostsettings{'type'} = 'mac';
390 }elsif($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
391 $fwhostsettings{'type'} = 'ip';
393 $fwhostsettings{'type'} = '';
394 $errormessage=$Lang::tr
{'fwhost err ipmac'};
396 if($fwhostsettings{'type'} eq 'mac' )
398 if ($fwhostsettings{'IP'}!~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/ )
400 $errormessage=$Lang::tr
{'fwhost err mac'};
404 if ($fwhostsettings{'type'} eq 'ip'){
406 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
407 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
409 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
410 $fwhostsettings{'error'}='on';
412 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
413 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
414 $fwhostsettings{'error'}='on';
416 #check if net or broadcast
417 my @tmp= split (/\./,$fwhostsettings{'IP'});
418 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
419 $errormessage=$Lang::tr
{'fwhost err hostip'};
422 #only check plausi when no error till now
424 &plausicheck
("edithost");
426 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
427 $fwhostsettings{'actualize'} = '';
428 my $key = &General
::findhasharraykey
(\
%customhost);
429 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
430 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
431 $customhost{$key}[1] = $fwhostsettings{'type'} ;
432 if($customhost{$key}[1] eq 'ip'){
433 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
435 $customhost{$key}[2] = $fwhostsettings{'orgip'};
437 $customhost{$key}[3] = $fwhostsettings{'count'};
438 &General
::writehasharray
("$confighost", \
%customhost);
442 #get count if host was edited
443 if($fwhostsettings{'actualize'} eq 'on'){
444 $count=$fwhostsettings{'count'};
445 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
448 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
449 #check if we need to update groups
450 &General
::readhasharray
("$configgrp", \
%customgrp);
451 foreach my $key (sort keys %customgrp){
452 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
453 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
457 &General
::writehasharray
("$configgrp", \
%customgrp);
458 #check if we need to update firewallrules
459 if ( ! -z
$fwconfigfwd ){
460 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
461 foreach my $line (sort keys %fwfwd){
462 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
463 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
465 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
466 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
469 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
471 if ( ! -z
$fwconfiginp ){
472 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
473 foreach my $line (sort keys %fwinp){
474 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
475 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
478 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
482 my $key = &General
::findhasharraykey
(\
%customhost);
483 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
484 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
485 $customhost{$key}[1] = $fwhostsettings{'type'} ;
486 if ($fwhostsettings{'type'} eq 'ip'){
487 #convert ip when leading '0' in byte
488 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
489 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
490 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
492 $customhost{$key}[2] = $fwhostsettings{'IP'};
494 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
495 $customhost{$key}[3] = $count;
496 &General
::writehasharray
("$confighost", \
%customhost);
498 $fwhostsettings{'HOSTNAME'}='';
499 $fwhostsettings{'IP'}='';
500 $fwhostsettings{'type'}='';
501 #check if we need to update rules while host was edited
502 if($needrules eq 'on'){
513 if ($fwhostsettings{'ACTION'} eq 'savegrp')
515 my $grp=$fwhostsettings{'grp_name'};;
516 my $rem=$fwhostsettings{'remark'};
519 my $updcounter='off';
522 &General
::readhasharray
("$configgrp", \
%customgrp);
523 &General
::readhasharray
("$confignet", \
%customnetwork);
524 &General
::readhasharray
("$confighost", \
%customhost);
526 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
528 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
529 $errormessage.=$Lang::tr
{'fwhost err remark'};
530 $fwhostsettings{'update'} = 'on';
531 $fwhostsettings{'remark'}=$fwhostsettings{'oldremark'};
535 if ($fwhostsettings{'update'} eq 'on'){
536 #check standard networks
537 if ($fwhostsettings{'grp2'} eq 'std_net'){
538 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
539 $type='Standard Network';
541 #check custom networks
542 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
543 @target=$fwhostsettings{'CUST_SRC_NET'};
545 $type='Custom Network';
546 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
547 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
548 $fwhostsettings{'grp_name'}='';
549 $fwhostsettings{'remark'}='';
551 #check custom addresses
552 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
553 @target=$fwhostsettings{'CUST_SRC_HOST'};
556 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
557 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
558 $fwhostsettings{'grp_name'}='';
559 $fwhostsettings{'remark'}='';
561 #get address from ovpn ccd static net
562 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
563 @target=$fwhostsettings{'OVPN_CCD_NET'};
564 $type='OpenVPN static network';
565 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
566 $errormessage=$Lang::tr
{'fwhost err groupempty'};
567 $fwhostsettings{'grp_name'}='';
568 $fwhostsettings{'remark'}='';
570 #get address from ovpn ccd static host
571 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
572 @target=$fwhostsettings{'OVPN_CCD_HOST'};
573 $type='OpenVPN static host';
574 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
575 $errormessage=$Lang::tr
{'fwhost err groupempty'};
577 #get address from ovpn ccd Net-2-Net
578 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
579 @target=$fwhostsettings{'OVPN_N2N'};
580 $type='OpenVPN N-2-N';
581 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
582 $errormessage=$Lang::tr
{'fwhost err groupempty'};
583 $fwhostsettings{'grp_name'}='';
584 $fwhostsettings{'remark'}='';
586 #get address from IPSEC HOST
587 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
588 @target=$fwhostsettings{'IPSEC_HOST'};
590 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
591 $errormessage=$Lang::tr
{'fwhost err groupempty'};
592 $fwhostsettings{'grp_name'}='';
593 $fwhostsettings{'remark'}='';
595 #get address from IPSEC NETWORK
596 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
597 @target=$fwhostsettings{'IPSEC_NET'};
598 $type='IpSec Network';
599 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
600 $errormessage=$Lang::tr
{'fwhost err groupempty'};
601 $fwhostsettings{'grp_name'}='';
602 $fwhostsettings{'remark'}='';
604 #check if host/net exists in grp
606 my $test="$grp,$fwhostsettings{'oldremark'},@target";
607 foreach my $key (keys %customgrp) {
608 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
609 if ($test1 eq $test){
610 $errormessage=$Lang::tr
{'fwhost err isingrp'};
611 $fwhostsettings{'update'} = 'on';
617 #on first save, we have an empty @target, so fill it with nothing
618 my $targetvalues=@target;
619 if ($targetvalues == '0'){
622 #on update, we have to delete the dummy entry
623 foreach my $key (keys %customgrp){
624 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
625 delete $customgrp{$key};
629 &General
::writehasharray
("$configgrp", \
%customgrp);
630 &General
::readhasharray
("$configgrp", \
%customgrp);
632 foreach my $key (keys %customgrp)
634 if($customgrp{$key}[0] eq $grp)
636 $count=$customgrp{$key}[4];
640 if ($count eq '' ){$count='0';}
642 #create array with new lines
643 foreach my $line (@target){
644 push (@newgrp,"$grp,$rem,$line");
647 my $key = &General
::findhasharraykey
(\
%customgrp);
648 foreach my $line (@newgrp){
649 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
650 my ($a,$b,$c,$d) = split (",",$line);
651 $customgrp{$key}[0] = $a;
652 $customgrp{$key}[1] = $b;
653 $customgrp{$key}[2] = $c;
654 $customgrp{$key}[3] = $type;
655 $customgrp{$key}[4] = $count;
657 &General
::writehasharray
("$configgrp", \
%customgrp);
658 #update counter in Host/Net
659 if($updcounter eq 'net'){
660 foreach my $key (keys %customnetwork) {
661 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
662 $customnetwork{$key}[3] = $customnetwork{$key}[3]+1;
666 &General
::writehasharray
("$confignet", \
%customnetwork);
667 }elsif($updcounter eq 'host'){
668 foreach my $key (keys %customhost) {
669 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
670 $customhost{$key}[3]=$customhost{$key}[3]+1;
673 &General
::writehasharray
("$confighost", \
%customhost);
675 $fwhostsettings{'update'}='on';
677 #check if ruleupdate is needed
685 if ($fwhostsettings{'ACTION'} eq 'saveservice')
688 &General
::readhasharray
("$configsrv", \
%customservice );
689 $errormessage=&checkports
(\
%customservice);
690 if ($fwhostsettings{'PROT'} eq 'ICMP'){
691 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
692 foreach my $key (keys %icmptypes){
693 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
694 $ICMP=$icmptypes{$key}[0];
698 if($ICMP eq ''){$ICMP='BLANK';}
700 my $key = &General
::findhasharraykey
(\
%customservice);
701 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
702 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
703 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
704 $customservice{$key}[2] = $fwhostsettings{'PROT'};
705 $customservice{$key}[3] = $ICMP;
706 $customservice{$key}[4] = 0;
707 &General
::writehasharray
("$configsrv", \
%customservice );
709 $fwhostsettings{'SRV_NAME'}='';
710 $fwhostsettings{'SRV_PORT'}='';
711 $fwhostsettings{'PROT'}='';
712 $fwhostsettings{'ICMP_TYPES'}='';
716 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
721 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
722 &General
::readhasharray
("$configsrv", \
%customservice );
723 $errormessage=&checkservicegroup
;
725 #on first save, we have to enter a dummy value
726 if ($fwhostsettings{'CUST_SRV'} eq ''){
727 $fwhostsettings{'CUST_SRV'}='none';
729 #on update, we have to delete the dummy entry
730 foreach my $key (keys %customservicegrp){
731 if ($customservicegrp{$key}[2] eq 'none'){
732 delete $customservicegrp{$key};
736 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
737 #check if remark has also changed
738 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
740 foreach my $key (keys %customservicegrp)
742 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
744 $customservicegrp{$key}[1]='';
745 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
750 foreach my $key (keys %customservicegrp)
752 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
754 $count=$customservicegrp{$key}[3];
758 if ($count eq '' ){$count='0';}
760 foreach my $key (sort keys %customservice){
761 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
762 $port=$customservice{$key}[1];
763 $prot=$customservice{$key}[2];
764 $customservice{$key}[4]++;
767 &General
::writehasharray
("$configsrv", \
%customservice );
768 my $key = &General
::findhasharraykey
(\
%customservicegrp);
769 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
770 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
771 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
772 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
773 $customservicegrp{$key}[3] = $count;
774 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
775 $fwhostsettings{'updatesrvgrp'}='on';
781 &viewtableservicegrp
;
784 if ($fwhostsettings{'ACTION'} eq 'editnet')
789 if ($fwhostsettings{'ACTION'} eq 'edithost')
794 if ($fwhostsettings{'ACTION'} eq 'editgrp')
796 $fwhostsettings{'update'}='on';
800 if ($fwhostsettings{'ACTION'} eq 'editservice')
802 $fwhostsettings{'updatesrv'}='on';
805 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
807 $fwhostsettings{'updatesrvgrp'} = 'on';
809 &viewtableservicegrp
;
812 if ($fwhostsettings{'ACTION'} eq 'resetnet')
814 $fwhostsettings{'HOSTNAME'} ="";
815 $fwhostsettings{'IP'} ="";
816 $fwhostsettings{'SUBNET'} ="";
819 if ($fwhostsettings{'ACTION'} eq 'resethost')
821 $fwhostsettings{'HOSTNAME'} ="";
822 $fwhostsettings{'IP'} ="";
823 $fwhostsettings{'type'} ="";
827 if ($fwhostsettings{'ACTION'} eq 'delnet')
829 &General
::readhasharray
("$confignet", \
%customnetwork);
830 foreach my $key (keys %customnetwork) {
831 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
832 delete $customnetwork{$key};
833 &General
::writehasharray
("$confignet", \
%customnetwork);
840 if ($fwhostsettings{'ACTION'} eq 'delhost')
842 &General
::readhasharray
("$confighost", \
%customhost);
843 foreach my $key (keys %customhost) {
844 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
845 delete $customhost{$key};
846 &General
::writehasharray
("$confighost", \
%customhost);
853 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
857 &General
::readhasharray
("$configgrp", \
%customgrp);
858 foreach my $key (keys %customgrp){
859 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
860 #decrease count from source host/net
861 if ($customgrp{$key}[3] eq 'Custom Network'){
862 &General
::readhasharray
("$confignet", \
%customnetwork);
863 foreach my $key1 (keys %customnetwork){
864 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
865 $customnetwork{$key1}[3] = $customnetwork{$key1}[3]-1;
869 &General
::writehasharray
("$confignet", \
%customnetwork);
871 if ($customgrp{$key}[3] eq 'Custom Host'){
872 &General
::readhasharray
("$confighost", \
%customhost);
873 foreach my $key1 (keys %customhost){
874 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
875 $customhost{$key1}[3] = $customhost{$key1}[3]-1;
879 &General
::writehasharray
("$confighost", \
%customhost);
881 $grpname=$customgrp{$key}[0];
882 $grpremark=$customgrp{$key}[1];
883 delete $customgrp{$key};
886 &General
::writehasharray
("$configgrp", \
%customgrp);
888 if ($fwhostsettings{'update'} eq 'on'){
889 $fwhostsettings{'remark'}= $grpremark;
890 $fwhostsettings{'grp_name'}=$grpname;
895 if ($fwhostsettings{'ACTION'} eq 'delgrp')
897 &General
::readhasharray
("$configgrp", \
%customgrp);
898 &decrease
($fwhostsettings{'grp_name'});
899 foreach my $key (sort keys %customgrp)
901 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
903 delete $customgrp{$key};
906 &General
::writehasharray
("$configgrp", \
%customgrp);
907 $fwhostsettings{'grp_name'}='';
911 if ($fwhostsettings{'ACTION'} eq 'delservice')
913 &General
::readhasharray
("$configsrv", \
%customservice);
914 foreach my $key (keys %customservice) {
915 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
916 #&deletefromgrp($customhost{$key}[0],$configgrp);
917 delete $customservice{$key};
918 &General
::writehasharray
("$configsrv", \
%customservice);
922 $fwhostsettings{'SRV_NAME'}='';
923 $fwhostsettings{'SRV_PORT'}='';
924 $fwhostsettings{'PROT'}='';
927 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
929 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
930 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
931 foreach my $key (sort keys %customservicegrp)
933 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
935 delete $customservicegrp{$key};
938 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
939 $fwhostsettings{'SRVGRP_NAME'}='';
941 &viewtableservicegrp
;
943 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
947 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
948 &General
::readhasharray
("$configsrv", \
%customservice);
949 foreach my $key (keys %customservicegrp){
950 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
952 #decrease count from source service
953 foreach my $key1 (sort keys %customservice){
954 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
955 $customservice{$key1}[4]--;
959 &General
::writehasharray
("$configsrv", \
%customservice);
960 $grpname=$customservicegrp{$key}[0];
961 $grpremark=$customservicegrp{$key}[1];
962 delete $customservicegrp{$key};
965 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
967 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
968 #$fwhostsettings{'updatesrvgrp'}='on';
969 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
970 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
973 &viewtableservicegrp
;
976 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
981 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
986 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
991 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
995 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
998 &viewtableservicegrp
;
1000 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1002 &General
::readhasharray
("$configgrp", \
%customgrp);
1003 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && &validremark
($fwhostsettings{'newrem'})){
1004 foreach my $key (sort keys %customgrp)
1006 #$customgrp{$key}[1]=~ s/\|/,/g;
1007 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1009 #$fwhostsettings{'newrem'}=~ s/,/\|/g;
1010 $customgrp{$key}[1]='';
1011 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1014 &General
::writehasharray
("$configgrp", \
%customgrp);
1015 $fwhostsettings{'update'}='on';
1016 #$fwhostsettings{'newrem'}=~ s/\|/,/g;
1017 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1019 $errormessage=$Lang::tr
{'fwhost err remark'};
1020 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1021 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1022 $fwhostsettings{'update'} = 'on';
1024 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1028 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1030 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1031 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && &validremark
($fwhostsettings{'newsrvrem'})){
1032 foreach my $key (sort keys %customservicegrp)
1034 #$customservicegrp{$key}[1]=~ s/\|/,/g;
1035 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1037 #$fwhostsettings{'newsrvrem'}=~ s/,/|/g;
1038 $customservicegrp{$key}[1]='';
1039 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1042 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1043 $fwhostsettings{'updatesrvgrp'}='on';
1044 #$fwhostsettings{'newsrvrem'}=~ s/\|/,/g;
1045 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1047 $errormessage=$Lang::tr
{'fwhost err remark'};
1048 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1049 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1050 $fwhostsettings{'updatesrvgrp'} = 'on';
1052 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1054 &viewtableservicegrp
;
1057 if($fwhostsettings{'ACTION'} eq '')
1065 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1067 <table border='0' width='100%'><form method='post'>
1068 <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>
1069 <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>
1070 <tr><td colspan='6'><hr></hr></td>
1074 if (-f
"${General::swroot}/fwhosts/reread"){
1075 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>";
1077 print"</tr></table></form>";
1079 &Header
::closebox
();
1087 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1088 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1090 <table border='0' width='100%'><form method='post' style='display:inline' >
1091 <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>
1092 <tr><td colspan='6'><hr></hr></td></tr><tr>
1094 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1096 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'}'>";
1098 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'>";
1100 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>";
1101 &Header
::closebox
();
1107 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1108 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1110 <table border='0' width='100%'><form method='post' style='display:inline'>
1111 <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'>
1113 if ($fwhostsettings{'type'} eq 'ip'){print "<option value='ip' selected >IP</option>";}else{print "<option value='ip' >IP</option>";}
1114 if ($fwhostsettings{'type'} eq 'mac'){print "<option value='mac' selected >MAC</option>";}else{print "<option value='mac' >MAC</option>";}
1116 </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>
1117 <tr><td colspan='7'><br><br><b>$Lang::tr{'fwhost attention'}</b><br>$Lang::tr{'fwhost macwarn'}</td></tr>
1118 <tr><td colspan='7'><hr></hr></td></tr>
1121 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1124 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>";
1126 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'>";
1128 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>";
1129 &Header
::closebox
();
1136 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1137 &General
::setup_default_networks
(\
%defaultNetworks);
1139 $checked{'check1'}{'off'} = '';
1140 $checked{'check1'}{'on'} = '';
1141 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1142 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1143 my $grp=$fwhostsettings{'grp_name'};
1144 my $rem=$fwhostsettings{'remark'};
1145 if ($fwhostsettings{'update'} eq ''){
1147 <table width='100%' border='0'><form method='post'>
1148 <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>
1149 <tr><td colspan='5'><hr></td></tr></table>
1153 <table width='100%' border='0'><form method='post' style='display:inline'>
1154 <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>
1158 if ($fwhostsettings{'update'} eq 'on'){
1160 <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;'>
1162 foreach my $network (sort keys %defaultNetworks)
1164 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1165 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1166 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1167 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1168 print ">$network</option>";
1171 </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;'>
1173 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1174 foreach my $key (sort { uc($ccdnet{$a}[0]) cmp uc($ccdnet{$b}[0]) } keys %ccdnet)
1176 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1180 <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;'>
1182 &General
::readhasharray
("$confignet", \
%customnetwork);
1183 foreach my $key (sort { uc($customnetwork{$a}[0]) cmp uc($customnetwork{$b}[0]) } keys %customnetwork) {
1184 print"<option>$customnetwork{$key}[0]</option>";
1187 </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;'>
1189 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1190 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1192 if ($ccdhost{$key}[33] ne ''){
1193 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1198 <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;'>
1200 &General
::readhasharray
("$confighost", \
%customhost);
1201 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0]) } keys %customhost) {
1202 print"<option>$customhost{$key}[0]</option>";
1205 </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;'>
1207 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1208 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1209 if($ccdhost{$key}[3] eq 'net'){
1210 print"<option>$ccdhost{$key}[1]</option>";
1215 <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;'>
1217 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1218 foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1219 if ($ipsecconf{$key}[3] eq 'net'){
1220 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1224 </select></td></tr></table>
1226 # <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;'>
1228 # &General::readhasharray("$configipsec", \%ipsecconf);
1229 # foreach my $key (sort { uc($ipsecconf{$a}[0]) cmp uc($ipsecconf{$b}[0]) } keys %ipsecconf) {
1230 # if ($ipsecconf{$key}[3] eq 'host'){
1231 # print"<option>$ipsecconf{$key}[1]</option>";
1235 # </select></td></tr>
1237 print"<br><br><b>$Lang::tr{'fwhost attention'}:</b><br> $Lang::tr{'fwhost macwarn'}<br><hr>";
1239 print"<table border='0' width='100%'>";
1240 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>";
1241 &Header
::closebox
();
1247 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservice'});
1248 if ($fwhostsettings{'updatesrv'} eq 'on')
1250 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1251 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1252 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1255 <table width='100%' border='0'><form method='post'>
1256 <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'>
1258 foreach ("TCP","UDP","ICMP")
1260 if ($_ eq $fwhostsettings{'PROT'})
1262 print"<option selected>$_</option>";
1264 print"<option>$_</option>";
1268 </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>
1269 <tr><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='4'><select name='ICMP_TYPES'>
1271 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1272 print"<option>All ICMP-Types</option>";
1273 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1274 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1279 <tr><td colspan='6'><hr></td></tr>
1280 <tr><td colspan='6' align='right'>
1282 if ($fwhostsettings{'updatesrv'} eq 'on')
1285 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1286 <input type='hidden' name='ACTION' value='updateservice'>
1287 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1288 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1289 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1293 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1296 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1301 &Header
::closebox
();
1309 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost newservicegrp'});
1310 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1311 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1313 <table width='100%' border='0'><form method='post'>
1314 <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>
1315 <tr><td colspan='4'><hr></td></td></tr>
1320 <table width='100%' border='0'><form method='post' style='display:inline'>
1321 <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>
1322 <tr><td colspan='5'><hr></td></td></tr>
1326 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1328 <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%'>
1329 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1331 &General
::readhasharray
("$configsrv", \
%customservice);
1332 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
1334 print "<option>$customservice{$key}[0]</option>";
1338 <tr><td colspan='4'><br><br><br></td></tr>
1339 <tr><td colspan='4'><hr></td></tr>
1344 <table width='100%' border='0'>
1345 <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>
1348 &Header
::closebox
();
1353 if(! -z
$confignet){
1354 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1355 &General
::readhasharray
("$confignet", \
%customnetwork);
1356 if (!keys %customnetwork)
1358 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1361 <table border='0' width='100%'>
1362 <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{'used'}</td><td></td><td width='3%'></td></tr>
1366 foreach my $key (sort {$a <=> $b} keys %customnetwork) {
1367 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1368 print" <tr bgcolor='${Header::colouryellow}'>";
1371 print" <tr bgcolor='$color{'color22'}'>";
1374 print" <tr bgcolor='$color{'color20'}'>";
1377 <td width='40%'><form method='post'>$customnetwork{$key}[0]</td><td width=25%'>$customnetwork{$key}[1]</td><td width='25%'>$customnetwork{$key}[2]</td><td align='center'>$customnetwork{$key}[3]x</td>
1378 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1379 <input type='hidden' name='ACTION' value='editnet'>
1380 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1381 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1382 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1385 if($customnetwork{$key}[3] == '0')
1387 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>";
1389 print"<td></td></form></tr>";
1394 &Header
::closebox
();
1400 if (! -z
$confighost){
1401 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1402 &General
::readhasharray
("$confighost", \
%customhost);
1403 if (!keys %customhost)
1405 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1408 <table border='0' width='100%'>
1409 <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{'used'}</td><td></td><td width='3%'></td></tr>
1413 foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0])|| $a <=> $b } keys %customhost) {
1414 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1415 print" <tr bgcolor='${Header::colouryellow}'>";
1416 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1417 else{ print" <tr bgcolor='$color{'color20'}'>";}
1418 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1419 $customhost{$key}[3]=~s/\s+//g;
1421 <td width='40%'><form method='post'>$customhost{$key}[0]</td><td width='50%'>$ip</td><td align='center'>$customhost{$key}[3]x</td>
1422 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1423 <input type='hidden' name='ACTION' value='edithost' />
1424 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1425 <input type='hidden' name='IP' value='$ip' />
1426 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1429 if($customhost{$key}[3] == '0')
1431 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>";
1433 print"<td width='1%'></td></tr>";
1438 &Header
::closebox
();
1443 if(! -z
"$configgrp"){
1444 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1445 &General
::readhasharray
("$configgrp", \
%customgrp);
1446 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1447 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1448 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1449 &General
::readhasharray
("$confighost", \
%customhost);
1450 &General
::readhasharray
("$confignet", \
%customnetwork);
1458 if (!keys %customgrp)
1460 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1462 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){
1464 if ($helper ne $customgrp{$key}[0]){
1466 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){
1467 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1476 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost empty'};}
1477 $grpname=$customgrp{$key}[0];
1478 $remark="$customgrp{$key}[1]";
1479 if($count >=2){print"</table>";}
1480 print "<br><b><u>$grpname</u></b>    ";
1481 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1482 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1483 if($customgrp{$key}[4] == '0')
1485 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>";
1487 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>";
1488 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>";
1491 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1492 print" <tr bgcolor='${Header::colouryellow}'>";
1493 }elsif ($count %2 == 0){
1494 print"<tr bgcolor='$color{'color22'}'>";
1496 print"<tr bgcolor='$color{'color20'}'>";
1498 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1499 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1500 print "<td width='39%'>";
1501 if($customgrp{$key}[3] eq 'Standard Network'){
1502 print &get_name
($customgrp{$key}[2])."</td>";
1504 print "$customgrp{$key}[2]</td>";
1506 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost empty'}){
1507 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1509 print"<td>$ip</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1511 if ($delflag > '1' && $ip ne ''){
1512 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1514 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>";
1516 $helper=$customgrp{$key}[0];
1522 &Header
::closebox
();
1526 sub viewtableservice
1529 if(! -z
"$configsrv")
1531 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1532 &General
::readhasharray
("$configsrv", \
%customservice);
1534 <table width='100%' border='0'>
1535 <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>
1537 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
1540 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1541 print" <tr bgcolor='${Header::colouryellow}'>";
1542 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1544 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1546 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1549 </td><td align='center'>$customservice{$key}[4]x</td>
1550 <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' />
1551 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1552 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1553 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1555 if ($customservice{$key}[4] eq '0')
1557 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>";
1559 print"<td></td></tr>";
1563 &Header
::closebox
();
1566 sub viewtableservicegrp
1575 if (! -z
$configsrvgrp){
1576 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1577 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1578 &General
::readhasharray
("$configsrv", \
%customservice);
1579 my $number= keys %customservicegrp;
1580 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0])|| $a <=> $b } keys %customservicegrp){
1582 if ($helper ne $customservicegrp{$key}[0]){
1584 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){
1585 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1593 $grpname=$customservicegrp{$key}[0];
1594 if ($customservicegrp{$key}[2] eq "none"){
1595 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1597 $remark="$customservicegrp{$key}[1]";
1598 if($count >=2){print"</table>";}
1599 print "<br><b><u>$grpname</u></b>     ";
1600 print "<b>$Lang::tr{'remark'}:</b>  $remark " if ($remark ne '');
1601 print "  <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1602 if($customservicegrp{$key}[3] == '0')
1604 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>";
1606 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>";
1607 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>";
1609 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1610 print" <tr bgcolor='${Header::colouryellow}'>";
1611 }elsif ($count %2 == 0){
1612 print"<tr bgcolor='$color{'color22'}'>";
1614 print"<tr bgcolor='$color{'color20'}'>";
1616 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1617 foreach my $srv (sort keys %customservice){
1618 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1619 $protocol=$customservice{$srv}[2];
1620 $port=$customservice{$srv}[1];
1624 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1625 if ($number gt '1'){
1626 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1628 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>";
1629 $helper=$customservicegrp{$key}[0];
1632 &Header
::closebox
();
1638 my %hash=%{(shift)};
1639 foreach my $key (keys %hash) {
1640 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1650 my %hash=%{(shift)};
1652 foreach my $key (keys %hash) {
1653 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1662 my %hash=%{(shift)};
1663 &General
::readhasharray
("$confignet", \
%hash);
1664 foreach my $key (keys %hash) {
1665 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1672 sub checkservicegroup
1674 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1678 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1680 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1681 return $errormessage;
1683 #check empty selectbox
1684 if (keys %customservice lt 1)
1686 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1688 #check if name already exists
1689 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1690 foreach my $key (keys %customservicegrp) {
1691 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1692 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1697 #check if service already exists in group
1698 foreach my $key (keys %customservicegrp) {
1699 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1700 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1703 return $errormessage;
1707 if ($errormessage) {
1708 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1709 print "<class name='base'>$errormessage\n";
1710 print " </class>\n";
1711 &Header
::closebox
();
1717 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1718 print "<class name='base'>$hint\n";
1719 print " </class>\n";
1720 &Header
::closebox
();
1726 &General
::setup_default_networks
(\
%defaultNetworks);
1727 foreach my $network (sort keys %defaultNetworks)
1729 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1737 &General
::readhasharray
("$config",\
%hash);
1738 foreach my $key (keys %hash) {
1739 $errormessage.="lese $hash{$key}[2] und $target<br>";
1740 if($hash{$key}[2] eq $target){
1743 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1746 &General
::writehasharray
("$config",\
%hash);
1754 if (!&General
::validhostname
($fwhostsettings{'HOSTNAME'}))
1756 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1757 $fwhostsettings{'BLK_IP'}='readonly';
1758 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1759 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1761 #check if name collides with CCD Netname
1763 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1764 foreach my $key (keys %ccdnet) {
1765 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1766 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1767 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1768 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1773 #check if IP collides with CCD NetIP
1774 if ($fwhostsettings{'type'} ne 'mac'){
1775 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1776 foreach my $key (keys %ccdnet) {
1777 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1778 if($ccdnet{$key}[1] eq $test){
1779 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1780 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1781 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1782 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1790 #check if name collides with CCD Hostname
1791 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1792 foreach my $key (keys %ccdhost) {
1793 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1794 if($ip eq $fwhostsettings{'IP'}){
1795 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1796 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1800 #check if IP collides with CCD HostIP (only hosts)
1801 if ($edit eq 'edithost')
1803 foreach my $key (keys %ccdhost) {
1804 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1805 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1806 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1807 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1812 #check if network with this name already exists
1813 &General
::readhasharray
("$confignet", \
%customnetwork);
1814 if (!&checkname
(\
%customnetwork))
1816 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1817 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1818 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1820 #check if network ip already exists
1821 if (!&checkip
(\
%customnetwork,1))
1823 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1824 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1826 #check if host with this name already exists
1827 &General
::readhasharray
("$confighost", \
%customhost);
1828 if (!&checkname
(\
%customhost))
1830 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1831 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1832 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1834 #check if host with this ip already exists
1835 if (!&checkip
(\
%customhost,2))
1837 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1849 #get address from IPSEC NETWORK
1850 if ($type eq 'IpSec Network'){
1851 foreach my $key (keys %ipsecconf) {
1852 if ($ipsecconf{$key}[1] eq $name){
1853 return $ipsecconf{$key}[11];
1856 &deletefromgrp
($name,$configgrp);
1859 #get address from IPSEC HOST
1860 if ($type eq 'IpSec Host'){
1861 foreach my $key (keys %ipsecconf) {
1862 if ($ipsecconf{$key}[1] eq $name){
1863 return $ipsecconf{$key}[10];
1866 &deletefromgrp
($name,$configgrp);
1869 #get address from ovpn ccd Net-2-Net
1870 if ($type eq 'OpenVPN N-2-N'){
1871 foreach my $key (keys %ccdhost) {
1872 if($ccdhost{$key}[1] eq $name){
1873 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1874 $b=&General
::iporsubtodec
($b);
1878 &deletefromgrp
($name,$configgrp);
1881 #get address from ovpn ccd static host
1882 if ($type eq 'OpenVPN static host'){
1883 foreach my $key (keys %ccdhost) {
1884 if($ccdhost{$key}[1] eq $name){
1885 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1886 $b=&General
::iporsubtodec
($b);
1890 &deletefromgrp
($name,$configgrp);
1893 #get address from ovpn ccd static net
1894 if ($type eq 'OpenVPN static network'){
1895 foreach my $key (keys %ccdnet) {
1896 if ($ccdnet{$key}[0] eq $name){
1897 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1898 $b=&General
::iporsubtodec
($b);
1904 #check custom addresses
1905 if ($type eq 'Custom Host'){
1906 foreach my $key (keys %customhost) {
1907 if ($customhost{$key}[0] eq $name){
1908 return $customhost{$key}[2];
1913 ##check custom networks
1914 if ($type eq 'Custom Network'){
1915 foreach my $key (keys %customnetwork) {
1916 if($customnetwork{$key}[0] eq $name){
1917 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
1922 #check standard networks
1923 if ($type eq 'Standard Network'){
1924 if ($name =~ /OpenVPN/i){
1926 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
1927 return $ovpn{'DOVPN_SUBNET'};
1929 if ($name eq 'GREEN'){
1931 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1932 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
1934 if ($name eq 'BLUE'){
1936 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1937 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
1939 if ($name eq 'ORANGE'){
1941 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1942 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
1944 if ($name eq 'ALL'){
1945 return "0.0.0.0/0.0.0.0";
1947 if ($name =~ /IPsec/i){
1949 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
1950 return $hash{'RW_NET'};
1956 if (!-f
"${General::swroot}/fwhosts/reread"){
1957 system("touch ${General::swroot}/fwhosts/reread");
1962 system ("/usr/local/bin/forwardfwctrl");
1963 if ( -f
"${General::swroot}/fwhosts/reread"){
1964 system("rm ${General::swroot}/fwhosts/reread");
1971 &General
::readhasharray
("$confignet", \
%customnetwork);
1972 &General
::readhasharray
("$confighost", \
%customhost);
1973 foreach my $key (sort keys %customgrp ){
1974 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
1975 foreach my $key1 (sort keys %customnetwork){
1976 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
1977 $customnetwork{$key1}[3]=$customnetwork{$key1}[3]-1;
1983 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
1984 foreach my $key2 (sort keys %customhost){
1985 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
1986 $customhost{$key2}[3]=$customhost{$key2}[3]-1;
1993 &General
::writehasharray
("$confignet", \
%customnetwork);
1994 &General
::writehasharray
("$confighost", \
%customhost);
1999 &General
::readhasharray
("$configsrv", \
%customservice);
2000 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2002 foreach my $key (sort keys %customservicegrp){
2003 if ($customservicegrp{$key}[0] eq $grp ){
2004 foreach my $key2 (sort keys %customservice){
2005 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2006 $customservice{$key2}[4]--;
2011 &General
::writehasharray
("$configsrv", \
%customservice);
2017 my %hash=%{(shift)};
2019 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2020 $errormessage=$Lang::tr
{'fwhost err name1'};
2022 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2023 $errormessage=$Lang::tr
{'fwhost err port'};
2026 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2027 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2029 #change dashes with :
2030 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2032 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2033 $fwhostsettings{'SRV_PORT'} = "1:65535";
2035 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2036 $fwhostsettings{'SRV_PORT'} = "1:$2";
2038 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2039 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2041 if($fwhostsettings{'PROT'} ne 'ICMP'){
2042 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2044 # a new service has to have a different name
2045 foreach my $key (keys %hash){
2046 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2047 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2051 return $errormessage;
2055 # Checks a hostname against RFC1035
2056 my $hostname = $_[0];
2058 # Each part should be at least two characters in length
2059 # but no more than 63 characters
2060 if (length ($hostname) < 1 || length ($hostname) > 63) {
2062 # Only valid characters are a-z, A-Z, 0-9 and -
2063 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_()\/\s
]*$/) {
2065 # First character can only be a letter or a digit
2066 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2068 # Last character can only be a letter or a digit
2069 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2075 # Checks a hostname against RFC1035
2077 # Each part should be at least two characters in length
2078 # but no more than 63 characters
2079 if (length ($remark) < 1 || length ($remark) > 255) {
2081 # Only valid characters are a-z, A-Z, 0-9 and -
2082 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;_\/\s
]*$/) {
2084 # First character can only be a letter or a digit
2085 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2087 # Last character can only be a letter or a digit
2088 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
2092 &Header
::closebigbox
();
2093 &Header
::closepage
();