]>
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
30 use CGI
::Carp
'fatalsToBrowser';
31 no warnings
'uninitialized';
32 require '/var/ipfire/general-functions.pl';
33 require "${General::swroot}/lang.pl";
34 require "${General::swroot}/header.pl";
36 my %fwhostsettings=();
41 my %customservicegrp=();
47 my %defaultNetworks=();
57 my $confignet = "${General::swroot}/fwhosts/customnetworks";
58 my $confighost = "${General::swroot}/fwhosts/customhosts";
59 my $configgrp = "${General::swroot}/fwhosts/customgroups";
60 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
61 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
62 my $configipsec = "${General::swroot}/vpn/config";
63 my $configsrv = "${General::swroot}/fwhosts/customservices";
64 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
65 my $fwconfigfwd = "${General::swroot}/forward/config";
66 my $fwconfiginp = "${General::swroot}/forward/input";
68 unless (-e
$confignet) { system("touch $confignet"); }
69 unless (-e
$confighost) { system("touch $confighost"); }
70 unless (-e
$configgrp) { system("touch $configgrp"); }
71 unless (-e
$configsrv) { system("touch $configsrv"); }
72 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
74 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
75 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
76 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
77 &Header
::getcgihash
(\
%fwhostsettings);
79 &Header
::showhttpheaders
();
80 &Header
::openpage
($Lang::tr
{'fwhost hosts'}, 1, '');
81 &Header
::openbigbox
('100%', 'center');
86 \$(document).ready(function() {
87 // Automatically select radio buttons when corresponding
88 // dropdown menu changes.
89 \$("select").change(function() {
90 var id = \$(this).attr("name");
91 //When using SNAT or DNAT, check "USE NAT" Checkbox
92 if ( id === 'snat' || id === 'dnat') {
93 \$('#USE_NAT').prop('checked', true);
95 \$('#' + id).prop("checked", true);
102 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
108 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
110 &General
::readhasharray
("$confignet", \
%customnetwork);
111 foreach my $key (keys %customnetwork)
113 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
115 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
116 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
117 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
118 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
119 $fwhostsettings{'count'} = $customnetwork{$key}[4];
120 delete $customnetwork{$key};
124 &General
::writehasharray
("$confignet", \
%customnetwork);
125 $fwhostsettings{'actualize'} = 'on';
126 $fwhostsettings{'ACTION'} = 'savenet';
128 if ($fwhostsettings{'ACTION'} eq 'updatehost')
131 &General
::readhasharray
("$confighost", \
%customhost);
132 foreach my $key (keys %customhost)
134 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
136 if ($customhost{$key}[1] eq 'ip'){
137 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
139 $ip = $customhost{$key}[2];
141 $fwhostsettings{'orgip'} = $ip;
142 $fwhostsettings{'count'} = $customhost{$key}[4];
143 delete $customhost{$key};
144 &General
::writehasharray
("$confighost", \
%customhost);
147 $fwhostsettings{'actualize'} = 'on';
148 if($fwhostsettings{'orgip'}){
149 $fwhostsettings{'ACTION'} = 'savehost';
151 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
154 if ($fwhostsettings{'ACTION'} eq 'updateservice')
158 $errormessage=&checkports
(\
%customservice);
160 &General
::readhasharray
("$configsrv", \
%customservice);
161 foreach my $key (keys %customservice)
163 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
165 $count=$customservice{$key}[4];
166 delete $customservice{$key};
167 &General
::writehasharray
("$configsrv", \
%customservice);
171 if ($fwhostsettings{'PROT'} ne 'ICMP'){
172 $fwhostsettings{'ICMP_TYPES'}='BLANK';
174 my $key1 = &General
::findhasharraykey
(\
%customservice);
175 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
176 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
177 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
178 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
179 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
180 $customservice{$key1}[4] = $count;
181 &General
::writehasharray
("$configsrv", \
%customservice);
182 #check if we need to update firewallrules
183 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
184 if ( ! -z
$fwconfigfwd ){
185 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
186 foreach my $key (sort keys %fwfwd){
187 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
188 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
191 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
193 if ( ! -z
$fwconfiginp ){
194 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
195 foreach my $line (sort keys %fwinp){
196 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
197 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
200 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
202 #check if we need to update groups
203 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
204 foreach my $key (sort keys %customservicegrp){
205 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
206 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
209 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
212 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
215 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
218 $fwhostsettings{'SRV_NAME'} = '';
219 $fwhostsettings{'SRV_PORT'} = '';
220 $fwhostsettings{'PROT'} = '';
222 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
223 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
224 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
225 $fwhostsettings{'updatesrv'}= 'on';
227 if($needrules eq 'on'){
233 if ($fwhostsettings{'ACTION'} eq 'savenet' )
237 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
238 #check if all fields are set
239 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
241 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
246 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
248 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
249 $fwhostsettings{'BLK_HOST'} ='readonly';
250 $fwhostsettings{'NOCHECK'} ='false';
251 $fwhostsettings{'error'} ='on';
254 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
255 $errormessage=$Lang::tr
{'fwhost err remark'};
256 $fwhostsettings{'error'} ='on';
258 #check if subnet is sigle host
259 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
261 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
263 if($fwhostsettings{'error'} ne 'on'){
264 #check if we use one of ipfire's networks (green,orange,blue)
265 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
267 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
268 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
269 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
271 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
273 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
274 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
275 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
277 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
279 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
280 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
281 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
283 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
285 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
286 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
287 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
290 #only check plausi when no error till now
292 &plausicheck
("editnet");
294 #check if network ip is part of an already used one
295 if(&checksubnet
(\
%customnetwork))
297 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
298 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
300 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
302 $fwhostsettings{'actualize'} = '';
303 my $key = &General
::findhasharraykey
(\
%customnetwork);
304 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
305 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
306 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
307 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
308 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
309 $customnetwork{$key}[4] = $fwhostsettings{'count'};
310 &General
::writehasharray
("$confignet", \
%customnetwork);
311 undef %customnetwork;
315 &General
::readhasharray
("$confignet", \
%customnetwork);
316 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
317 if ($fwhostsettings{'update'} == '0'){
318 foreach my $key (keys %customnetwork) {
319 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
320 $count=$customnetwork{$key}[4];
321 delete $customnetwork{$key};
327 #get count if actualize is 'on'
328 if($fwhostsettings{'actualize'} eq 'on'){
329 $fwhostsettings{'actualize'} = '';
330 $count=$fwhostsettings{'count'};
331 #check if we need to reload rules
332 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
335 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
336 #check if we need to update groups
337 &General
::readhasharray
("$configgrp", \
%customgrp);
338 foreach my $key (sort keys %customgrp){
339 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
340 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
344 &General
::writehasharray
("$configgrp", \
%customgrp);
345 #check if we need to update firewallrules
346 if ( ! -z
$fwconfigfwd ){
347 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
348 foreach my $line (sort keys %fwfwd){
349 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
350 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
352 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
353 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
356 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
358 if ( ! -z
$fwconfiginp ){
359 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
360 foreach my $line (sort keys %fwinp){
361 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
362 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
365 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
369 my $key = &General
::findhasharraykey
(\
%customnetwork);
370 foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";}
371 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
372 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
373 #convert ip when leading '0' in byte
374 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
375 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
376 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
377 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
378 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
379 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
380 $customnetwork{$key}[4] = $count;
381 &General
::writehasharray
("$confignet", \
%customnetwork);
382 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
383 undef %customnetwork;
384 $fwhostsettings{'HOSTNAME'}='';
385 $fwhostsettings{'IP'}='';
386 $fwhostsettings{'SUBNET'}='';
387 $fwhostsettings{'NETREMARK'}='';
388 #check if an edited net affected groups and need to reload rules
389 if ($needrules eq 'on'){
400 if ($fwhostsettings{'ACTION'} eq 'savehost')
404 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
405 $fwhostsettings{'SUBNET'}='32';
406 #check if all fields are set
407 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
409 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
410 $fwhostsettings{'ACTION'} = 'edithost';
412 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
413 $fwhostsettings{'type'} = 'mac';
414 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
415 $fwhostsettings{'type'} = 'ip';
417 $fwhostsettings{'type'} = '';
418 $errormessage=$Lang::tr
{'fwhost err ipmac'};
421 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
422 $errormessage=$Lang::tr
{'fwhost err remark'};
425 if ($fwhostsettings{'type'} eq 'ip'){
427 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
428 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
430 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
431 $fwhostsettings{'error'}='on';
433 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
434 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
435 $fwhostsettings{'error'}='on';
437 #check if net or broadcast
438 my @tmp= split (/\./,$fwhostsettings{'IP'});
439 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
440 $errormessage=$Lang::tr
{'fwhost err hostip'};
443 #only check plausi when no error till now
445 &plausicheck
("edithost");
447 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
448 $fwhostsettings{'actualize'} = '';
449 my $key = &General
::findhasharraykey
(\
%customhost);
450 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
451 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
452 $customhost{$key}[1] = $fwhostsettings{'type'} ;
453 if($customhost{$key}[1] eq 'ip'){
454 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
456 $customhost{$key}[2] = $fwhostsettings{'orgip'};
458 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
459 $customhost{$key}[4] = $fwhostsettings{'count'};
460 &General
::writehasharray
("$confighost", \
%customhost);
464 #get count if host was edited
465 if($fwhostsettings{'actualize'} eq 'on'){
466 $count=$fwhostsettings{'count'};
467 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
470 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
471 #check if we need to update groups
472 &General
::readhasharray
("$configgrp", \
%customgrp);
473 foreach my $key (sort keys %customgrp){
474 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
475 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
478 &General
::writehasharray
("$configgrp", \
%customgrp);
479 #check if we need to update firewallrules
480 if ( ! -z
$fwconfigfwd ){
481 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
482 foreach my $line (sort keys %fwfwd){
483 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
484 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
486 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
487 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
490 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
492 if ( ! -z
$fwconfiginp ){
493 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
494 foreach my $line (sort keys %fwinp){
495 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
496 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
499 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
503 my $key = &General
::findhasharraykey
(\
%customhost);
504 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
505 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
506 $customhost{$key}[1] = $fwhostsettings{'type'} ;
507 if ($fwhostsettings{'type'} eq 'ip'){
508 #convert ip when leading '0' in byte
509 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
510 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
511 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
513 $customhost{$key}[2] = $fwhostsettings{'IP'};
515 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
516 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
517 $customhost{$key}[4] =$count;
518 &General
::writehasharray
("$confighost", \
%customhost);
520 $fwhostsettings{'HOSTNAME'}='';
521 $fwhostsettings{'IP'}='';
522 $fwhostsettings{'type'}='';
523 $fwhostsettings{'HOSTREMARK'}='';
524 #check if we need to update rules while host was edited
525 if($needrules eq 'on'){
536 if ($fwhostsettings{'ACTION'} eq 'savegrp')
538 my $grp=$fwhostsettings{'grp_name'};;
539 my $rem=$fwhostsettings{'remark'};
542 my $updcounter='off';
545 &General
::readhasharray
("$configgrp", \
%customgrp);
546 &General
::readhasharray
("$confignet", \
%customnetwork);
547 &General
::readhasharray
("$confighost", \
%customhost);
549 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
551 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
552 $errormessage.=$Lang::tr
{'fwhost err remark'};
554 if ($fwhostsettings{'update'} eq 'on'){
555 #check standard networks
556 if ($fwhostsettings{'grp2'} eq 'std_net'){
557 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
558 $type='Standard Network';
560 #check custom networks
561 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
562 @target=$fwhostsettings{'CUST_SRC_NET'};
564 $type='Custom Network';
565 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
566 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
567 $fwhostsettings{'grp_name'}='';
568 $fwhostsettings{'remark'}='';
570 #check custom addresses
571 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
572 @target=$fwhostsettings{'CUST_SRC_HOST'};
575 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
576 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
577 $fwhostsettings{'grp_name'}='';
578 $fwhostsettings{'remark'}='';
580 #get address from ovpn ccd static net
581 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
582 @target=$fwhostsettings{'OVPN_CCD_NET'};
583 $type='OpenVPN static network';
584 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
585 $errormessage=$Lang::tr
{'fwhost err groupempty'};
586 $fwhostsettings{'grp_name'}='';
587 $fwhostsettings{'remark'}='';
589 #get address from ovpn ccd static host
590 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
591 @target=$fwhostsettings{'OVPN_CCD_HOST'};
592 $type='OpenVPN static host';
593 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
594 $errormessage=$Lang::tr
{'fwhost err groupempty'};
596 #get address from ovpn ccd Net-2-Net
597 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
598 @target=$fwhostsettings{'OVPN_N2N'};
599 $type='OpenVPN N-2-N';
600 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
601 $errormessage=$Lang::tr
{'fwhost err groupempty'};
602 $fwhostsettings{'grp_name'}='';
603 $fwhostsettings{'remark'}='';
605 #get address from IPSEC HOST
606 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
607 @target=$fwhostsettings{'IPSEC_HOST'};
609 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
610 $errormessage=$Lang::tr
{'fwhost err groupempty'};
611 $fwhostsettings{'grp_name'}='';
612 $fwhostsettings{'remark'}='';
614 #get address from IPSEC NETWORK
615 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
616 @target=$fwhostsettings{'IPSEC_NET'};
617 $type='IpSec Network';
618 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
619 $errormessage=$Lang::tr
{'fwhost err groupempty'};
620 $fwhostsettings{'grp_name'}='';
621 $fwhostsettings{'remark'}='';
623 #check if host/net exists in grp
625 my $test="$grp,$fwhostsettings{'oldremark'},@target";
626 foreach my $key (keys %customgrp) {
627 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
628 if ($test1 eq $test){
629 $errormessage=$Lang::tr
{'fwhost err isingrp'};
630 $fwhostsettings{'update'} = 'on';
636 #on first save, we have an empty @target, so fill it with nothing
637 my $targetvalues=@target;
638 if ($targetvalues == '0'){
641 #on update, we have to delete the dummy entry
642 foreach my $key (keys %customgrp){
643 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
644 delete $customgrp{$key};
648 &General
::writehasharray
("$configgrp", \
%customgrp);
649 &General
::readhasharray
("$configgrp", \
%customgrp);
651 foreach my $key (keys %customgrp)
653 if($customgrp{$key}[0] eq $grp)
655 $count=$customgrp{$key}[4];
659 if ($count eq '' ){$count='0';}
661 #create array with new lines
662 foreach my $line (@target){
663 push (@newgrp,"$grp,$rem,$line");
666 my $key = &General
::findhasharraykey
(\
%customgrp);
667 foreach my $line (@newgrp){
668 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
669 my ($a,$b,$c,$d) = split (",",$line);
670 $customgrp{$key}[0] = $a;
671 $customgrp{$key}[1] = $b;
672 $customgrp{$key}[2] = $c;
673 $customgrp{$key}[3] = $type;
674 $customgrp{$key}[4] = $count;
676 &General
::writehasharray
("$configgrp", \
%customgrp);
677 #update counter in Host/Net
678 if($updcounter eq 'net'){
679 foreach my $key (keys %customnetwork) {
680 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
681 $customnetwork{$key}[4] = $customnetwork{$key}[4]+1;
685 &General
::writehasharray
("$confignet", \
%customnetwork);
686 }elsif($updcounter eq 'host'){
687 foreach my $key (keys %customhost) {
688 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
689 $customhost{$key}[4]=$customhost{$key}[4]+1;
692 &General
::writehasharray
("$confighost", \
%customhost);
694 $fwhostsettings{'update'}='on';
696 #check if ruleupdate is needed
704 if ($fwhostsettings{'ACTION'} eq 'saveservice')
707 &General
::readhasharray
("$configsrv", \
%customservice );
708 $errormessage=&checkports
(\
%customservice);
709 if ($fwhostsettings{'PROT'} eq 'ICMP'){
710 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
711 foreach my $key (keys %icmptypes){
712 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
713 $ICMP=$icmptypes{$key}[0];
717 if($ICMP eq ''){$ICMP='BLANK';}
719 my $key = &General
::findhasharraykey
(\
%customservice);
720 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
721 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
722 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
723 $customservice{$key}[2] = $fwhostsettings{'PROT'};
724 $customservice{$key}[3] = $ICMP;
725 $customservice{$key}[4] = 0;
726 &General
::writehasharray
("$configsrv", \
%customservice );
728 $fwhostsettings{'SRV_NAME'}='';
729 $fwhostsettings{'SRV_PORT'}='';
730 $fwhostsettings{'PROT'}='';
731 $fwhostsettings{'ICMP_TYPES'}='';
735 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
740 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
741 &General
::readhasharray
("$configsrv", \
%customservice );
742 $errormessage=&checkservicegroup
;
744 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
745 $errormessage=$Lang::tr
{'fwhost err remark'};
748 #on first save, we have to enter a dummy value
749 if ($fwhostsettings{'CUST_SRV'} eq ''){
750 $fwhostsettings{'CUST_SRV'}='none';
752 #on update, we have to delete the dummy entry
753 foreach my $key (keys %customservicegrp){
754 if ($customservicegrp{$key}[2] eq 'none'){
755 delete $customservicegrp{$key};
759 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
760 #check if remark has also changed
761 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
763 foreach my $key (keys %customservicegrp)
765 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
767 $customservicegrp{$key}[1]='';
768 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
773 foreach my $key (keys %customservicegrp)
775 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
777 $count=$customservicegrp{$key}[3];
781 if ($count eq '' ){$count='0';}
783 foreach my $key (sort keys %customservice){
784 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
785 $port=$customservice{$key}[1];
786 $prot=$customservice{$key}[2];
787 $customservice{$key}[4]++;
790 &General
::writehasharray
("$configsrv", \
%customservice );
791 my $key = &General
::findhasharraykey
(\
%customservicegrp);
792 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
793 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
794 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
795 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
796 $customservicegrp{$key}[3] = $count;
797 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
798 $fwhostsettings{'updatesrvgrp'}='on';
804 &viewtableservicegrp
;
807 if ($fwhostsettings{'ACTION'} eq 'editnet')
812 if ($fwhostsettings{'ACTION'} eq 'edithost')
817 if ($fwhostsettings{'ACTION'} eq 'editgrp')
819 $fwhostsettings{'update'}='on';
823 if ($fwhostsettings{'ACTION'} eq 'editservice')
825 $fwhostsettings{'updatesrv'}='on';
828 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
830 $fwhostsettings{'updatesrvgrp'} = 'on';
832 &viewtableservicegrp
;
835 if ($fwhostsettings{'ACTION'} eq 'resetnet')
837 $fwhostsettings{'HOSTNAME'} ="";
838 $fwhostsettings{'IP'} ="";
839 $fwhostsettings{'SUBNET'} ="";
842 if ($fwhostsettings{'ACTION'} eq 'resethost')
844 $fwhostsettings{'HOSTNAME'} ="";
845 $fwhostsettings{'IP'} ="";
846 $fwhostsettings{'type'} ="";
850 if ($fwhostsettings{'ACTION'} eq 'delnet')
852 &General
::readhasharray
("$confignet", \
%customnetwork);
853 foreach my $key (keys %customnetwork) {
854 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
855 delete $customnetwork{$key};
856 &General
::writehasharray
("$confignet", \
%customnetwork);
863 if ($fwhostsettings{'ACTION'} eq 'delhost')
865 &General
::readhasharray
("$confighost", \
%customhost);
866 foreach my $key (keys %customhost) {
867 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
868 delete $customhost{$key};
869 &General
::writehasharray
("$confighost", \
%customhost);
876 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
880 &General
::readhasharray
("$configgrp", \
%customgrp);
881 foreach my $key (keys %customgrp){
882 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
883 #decrease count from source host/net
884 if ($customgrp{$key}[3] eq 'Custom Network'){
885 &General
::readhasharray
("$confignet", \
%customnetwork);
886 foreach my $key1 (keys %customnetwork){
887 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
888 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
892 &General
::writehasharray
("$confignet", \
%customnetwork);
894 if ($customgrp{$key}[3] eq 'Custom Host'){
895 &General
::readhasharray
("$confighost", \
%customhost);
896 foreach my $key1 (keys %customhost){
897 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
898 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
902 &General
::writehasharray
("$confighost", \
%customhost);
904 $grpname=$customgrp{$key}[0];
905 $grpremark=$customgrp{$key}[1];
906 delete $customgrp{$key};
909 &General
::writehasharray
("$configgrp", \
%customgrp);
910 if ($fwhostsettings{'grpcnt'} > 0){&rules
;}
911 if ($fwhostsettings{'update'} eq 'on'){
912 $fwhostsettings{'remark'}= $grpremark;
913 $fwhostsettings{'grp_name'}=$grpname;
918 if ($fwhostsettings{'ACTION'} eq 'delgrp')
920 &General
::readhasharray
("$configgrp", \
%customgrp);
921 &decrease
($fwhostsettings{'grp_name'});
922 foreach my $key (sort keys %customgrp)
924 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
926 delete $customgrp{$key};
929 &General
::writehasharray
("$configgrp", \
%customgrp);
930 $fwhostsettings{'grp_name'}='';
934 if ($fwhostsettings{'ACTION'} eq 'delservice')
936 &General
::readhasharray
("$configsrv", \
%customservice);
937 foreach my $key (keys %customservice) {
938 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
939 #&deletefromgrp($customhost{$key}[0],$configgrp);
940 delete $customservice{$key};
941 &General
::writehasharray
("$configsrv", \
%customservice);
945 $fwhostsettings{'SRV_NAME'}='';
946 $fwhostsettings{'SRV_PORT'}='';
947 $fwhostsettings{'PROT'}='';
950 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
952 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
953 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
954 foreach my $key (sort keys %customservicegrp)
956 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
958 delete $customservicegrp{$key};
961 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
962 $fwhostsettings{'SRVGRP_NAME'}='';
964 &viewtableservicegrp
;
966 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
970 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
971 &General
::readhasharray
("$configsrv", \
%customservice);
972 foreach my $key (keys %customservicegrp){
973 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
975 #decrease count from source service
976 foreach my $key1 (sort keys %customservice){
977 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
978 $customservice{$key1}[4]--;
982 &General
::writehasharray
("$configsrv", \
%customservice);
983 $grpname=$customservicegrp{$key}[0];
984 $grpremark=$customservicegrp{$key}[1];
985 delete $customservicegrp{$key};
988 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
990 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
991 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
992 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
995 &viewtableservicegrp
;
998 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1003 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1008 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1013 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1017 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1020 &viewtableservicegrp
;
1022 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1024 &General
::readhasharray
("$configgrp", \
%customgrp);
1025 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1026 foreach my $key (sort keys %customgrp)
1028 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1030 $customgrp{$key}[1]='';
1031 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1034 &General
::writehasharray
("$configgrp", \
%customgrp);
1035 $fwhostsettings{'update'}='on';
1036 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1038 $errormessage=$Lang::tr
{'fwhost err remark'};
1039 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1040 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1041 $fwhostsettings{'update'} = 'on';
1043 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1047 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1049 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1050 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1051 foreach my $key (sort keys %customservicegrp)
1053 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1055 $customservicegrp{$key}[1]='';
1056 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1059 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1060 $fwhostsettings{'updatesrvgrp'}='on';
1061 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1063 $errormessage=$Lang::tr
{'fwhost err remark'};
1064 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1065 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1066 $fwhostsettings{'updatesrvgrp'} = 'on';
1068 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1070 &viewtableservicegrp
;
1073 if($fwhostsettings{'ACTION'} eq '')
1080 if (-f
"${General::swroot}/forward/reread"){
1081 print "<table border='1' rules='groups' bgcolor='lightgreen' width='100%'><form method='post'><td><div style='font-size:11pt; font-weight: bold;vertical-align: middle; '><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: green; font-weight: bold; font-size: 14pt;'>    $Lang::tr{'fwhost reread'}</td></tr></table></form><br>";
1083 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1084 print "$Lang::tr{'fwhost welcome'}";
1086 <br><br><table border='0' width='100%'>
1087 <tr><td><form method='post'><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newnet'}' ><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newhost'}' ><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newgrp'}' ></form></td>
1088 <td align='right'><form method='post'><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservice'}' ><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservicegrp'}' ></form></td></tr>
1089 <tr><td colspan='6'><hr></td></tr></table>
1091 &Header
::closebox
();
1099 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1100 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1101 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1103 <table border='0' width='100%'>
1104 <tr><td width='15%'>$Lang::tr{'name'}:</td><td><form method='post'><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} size='20'><script>document.getElementById('textbox1').focus()</script></td></tr>
1105 <tr><td>$Lang::tr{'fwhost netaddress'}:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1106 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1107 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1108 <tr><td colspan='6'><br><hr></td></tr><tr>
1110 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1112 print "<td colspan='6' align='right' ><input type='submit' value='$Lang::tr{'update'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='updatenet'><input type='hidden' name='orgnetremark' value='$fwhostsettings{'orgnetremark'}' ><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newnet' value='$fwhostsettings{'newnet'}'></td>";
1114 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'>";
1116 print "</form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;' ><input type='hidden' name='ACTION' value='resetnet'></form></td></tr></table>";
1117 &Header
::closebox
();
1123 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1124 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1125 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1127 <table border='0' width='100%'>
1128 <tr><td>$Lang::tr{'name'}:</td><td><form method='post' style='display:inline;'><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} size='20'><script>document.getElementById('textbox1').focus()</script></td></tr>
1129 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1130 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1131 <tr><td colspan='5'><hr></td></tr><tr>
1134 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1137 print " <td colspan='4' align='right'><input type='submit' value='$Lang::tr{'update'}' style='min-width:100px;'/><input type='hidden' name='ACTION' value='updatehost'><input type='hidden' name='orgremark' value='$fwhostsettings{'orgremark'}' ><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newhost' value='$fwhostsettings{'newhost'}'></form>";
1139 print " <td colspan='4' align='right'><input type='submit' name='savehost' value='$Lang::tr{'save'}' style='min-width:100px;' /><input type='hidden' name='ACTION' value='savehost' /><input type='hidden' name='newhost' value='on'>";
1141 print " </form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;' ><input type='hidden' name='ACTION' value='resethost'></form></td></tr></table>";
1142 &Header
::closebox
();
1149 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1150 &General
::setup_default_networks
(\
%defaultNetworks);
1151 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1152 &General
::readhasharray
("$confignet", \
%customnetwork);
1153 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1154 &General
::readhasharray
("$confighost", \
%customhost);
1155 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1159 $checked{'check1'}{'off'} = '';
1160 $checked{'check1'}{'on'} = '';
1161 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1162 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1163 my $grp=$fwhostsettings{'grp_name'};
1164 my $rem=$fwhostsettings{'remark'};
1165 if ($fwhostsettings{'update'} eq ''){
1167 <table width='100%' border='0'>
1168 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='20'></td></tr>
1169 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1170 <tr><td colspan='2'><br><hr></td></tr></table>
1174 <table width='100%' border='0'><form method='post' style='display:inline'>
1175 <tr><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' readonly ></td><td></td></tr>
1176 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='newrem' size='45' value='$fwhostsettings{'remark'}' style='width:98%'></td><td align='right'><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>
1180 if ($fwhostsettings{'update'} eq 'on'){
1182 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1183 <table width='100%' border='0'>
1184 <tr><td width=50% valign='top'>
1185 <table width='100%' border='0'>
1186 <tr><td width='1%'><input type='radio' name='grp2' value='std_net' id='DEFAULT_SRC_ADR' checked></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost stdnet'}</td><td><select name='DEFAULT_SRC_ADR' style='min-width:185px;'>
1188 foreach my $network (sort keys %defaultNetworks)
1190 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1191 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1192 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1193 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1194 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1195 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1196 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1197 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1198 if ($ownnet{$defnet}){
1199 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1201 print ">$network</option>";
1204 print"</select></td></tr>";
1205 if (! -z
$confignet){
1206 print"<tr><td><input type='radio' name='grp2' id='CUST_SRC_NET' 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;'>";
1207 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1208 print"<option>$customnetwork{$key}[0]</option>";
1210 print"</select></td></tr>";
1212 if (! -z
$confighost){
1213 print"<tr><td valign='top'><input type='radio' name='grp2' id='CUST_SRC_HOST' 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;'>";
1214 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1215 print"<option>$customhost{$key}[0]</option>";
1217 print"</select></td></tr>";
1221 print"</td><td valign='top'><table width='100%' border='0'>";
1223 if (! -z
$configccdnet){
1224 print"<td width='1%'><input type='radio' name='grp2' id='OVPN_CCD_NET' 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;'>";
1225 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1227 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1229 print"</select></td></tr>";
1232 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1234 if ($ccdhost{$key}[33] ne ''){
1235 print"<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;'>" if ($show eq '');
1237 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1240 if ($show eq '1'){$show='';print"</select></td></tr>";}
1242 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1243 if($ccdhost{$key}[3] eq 'net'){
1244 print"<td width='1%'><input type='radio' name='grp2' id='OVPN_N2N' 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;'>" if ($show eq '');
1246 print"<option>$ccdhost{$key}[1]</option>";
1249 if ($show eq '1'){$show='';print"</select></td></tr>";}
1251 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1252 if ($ipsecconf{$key}[3] eq 'net'){
1253 print"<td valign='top'><input type='radio' name='grp2' id='IPSEC_NET' 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;'>" if ($show eq '');
1255 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1258 if ($show eq '1'){$show='';print"</select></td></tr>";}
1260 print"</td></tr></table>";
1261 print"<br><br><b>$Lang::tr{'fwhost attention'}:</b><br> $Lang::tr{'fwhost macwarn'}<br><hr>";
1263 print"<table border='0' width='100%'>";
1264 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'></form></td></table>";
1265 &Header
::closebox
();
1271 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1272 if ($fwhostsettings{'updatesrv'} eq 'on')
1274 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1275 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1276 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1279 <table width='100%' border='0'><form method='post'>
1280 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost srv_name'}:</td><td><input type='text' name='SRV_NAME' id='textbox1' value='$fwhostsettings{'SRV_NAME'}' size='24'><script>document.getElementById('textbox1').focus()</script></td></tr>
1281 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT'>
1283 foreach ("TCP","UDP","ICMP")
1285 if ($_ eq $fwhostsettings{'PROT'})
1287 print"<option selected>$_</option>";
1289 print"<option>$_</option>";
1294 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td><select name='ICMP_TYPES'>
1296 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1297 print"<option>All ICMP-Types</option>";
1298 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1299 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1304 <tr><td width='10%'>$Lang::tr{'fwhost port'}:</td><td><input type='text' name='SRV_PORT' value='$fwhostsettings{'SRV_PORT'}' maxlength='11' size='24'></td></tr>
1305 <tr><td colspan='6'><br><hr></td></tr>
1306 <tr><td colspan='6' align='right'>
1308 if ($fwhostsettings{'updatesrv'} eq 'on')
1311 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1312 <input type='hidden' name='ACTION' value='updateservice'>
1313 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1314 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1315 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1319 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1322 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1327 &Header
::closebox
();
1335 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1336 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1337 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1339 <table width='100%' border='0'><form method='post'>
1340 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1341 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1342 <tr><td colspan='2'><br><hr></tr>
1347 <table width='100%' border='0'><form method='post' style='display:inline'>
1348 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}' readonly size='14'></td><td width='3%'></td></tr>
1349 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='newsrvrem' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width:98%;'></td><td align='right'><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>
1350 <tr><td colspan='3'><br><hr></td></td></tr>
1354 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1356 <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%'>
1357 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1359 &General
::readhasharray
("$configsrv", \
%customservice);
1360 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1362 print "<option>$customservice{$key}[0]</option>";
1366 <tr><td colspan='4'><br><br></td></tr>
1367 <tr><td colspan='4'><hr></td></tr>
1372 <table width='100%' border='0'>
1373 <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>
1376 &Header
::closebox
();
1381 if(! -z
$confignet){
1382 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1383 &General
::readhasharray
("$confignet", \
%customnetwork);
1384 if (!keys %customnetwork)
1386 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1389 <table border='0' width='100%' cellspacing='0'>
1390 <tr><td align='center'><b>$Lang::tr{'name'}</b></td><td align='center'><b>$Lang::tr{'fwhost netaddress'}</b></td><td align='center'><b>$Lang::tr{'remark'}</b></td><td align='center'><b>$Lang::tr{'used'}</b></td><td></td><td width='3%'></td></tr>
1394 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1395 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1396 print" <tr bgcolor='${Header::colouryellow}'>";
1399 print" <tr bgcolor='$color{'color22'}'>";
1402 print" <tr bgcolor='$color{'color20'}'>";
1404 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1405 print"<td width='20%'><form method='post'>$customnetwork{$key}[0]</td><td width='15%' align='center'>".&Header
::colorize
($colnet)."</td><td width='40%'>$customnetwork{$key}[3]</td><td align='center'>$customnetwork{$key}[4]x</td>";
1407 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1408 <input type='hidden' name='ACTION' value='editnet'>
1409 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1410 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1411 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1412 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1415 if($customnetwork{$key}[4] == '0')
1417 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>";
1419 print"<td></td></tr>";
1424 &Header
::closebox
();
1430 if (! -z
$confighost){
1431 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1432 &General
::readhasharray
("$confighost", \
%customhost);
1433 if (!keys %customhost)
1435 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1438 <table border='0' width='100%' cellspacing='0'>
1439 <tr><td align='center'><b>$Lang::tr{'name'}</b></td><td align='center'><b>$Lang::tr{'fwhost ip_mac'}</b></td><td align='center'><b>$Lang::tr{'remark'}</b></td><td align='center'><b>$Lang::tr{'used'}</b></td><td></td><td width='3%'></td></tr>
1443 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1444 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1445 print" <tr bgcolor='${Header::colouryellow}'>";
1446 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1447 else{ print" <tr bgcolor='$color{'color20'}'>";}
1448 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1449 $customhost{$key}[4]=~s/\s+//g;
1450 print"<td width='20%'>$customhost{$key}[0]</td><td width='20%' align='center'>".&Header
::colorize
($ip)."</td><td width='50%' align='left'>$customhost{$key}[3]</td><td align='center'>$customhost{$key}[4]x</td>";
1452 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1453 <input type='hidden' name='ACTION' value='edithost' />
1454 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1455 <input type='hidden' name='IP' value='$ip' />
1456 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1457 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1460 if($customhost{$key}[4] == '0')
1462 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>";
1464 print"<td width='1%'></td></tr>";
1469 &Header
::closebox
();
1474 if(! -z
"$configgrp"){
1475 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1476 &General
::readhasharray
("$configgrp", \
%customgrp);
1477 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1478 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1479 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1480 &General
::readhasharray
("$confighost", \
%customhost);
1481 &General
::readhasharray
("$confignet", \
%customnetwork);
1489 if (!keys %customgrp)
1491 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1493 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1495 if ($helper ne $customgrp{$key}[0]){
1497 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1498 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1507 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost empty'};}
1508 $grpname=$customgrp{$key}[0];
1509 $remark="$customgrp{$key}[1]";
1510 if($count gt 2){ print"</table>";}
1511 print "<br><b><u>$grpname</u></b> ";
1512 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1513 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1514 if($customgrp{$key}[4] == '0')
1516 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>";
1518 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>";
1519 print"<table width='100%' style='border: 1px solid #CCCCCC;' rules='none' cellspacing='0'><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><td></td></tr>";
1522 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1523 print" <tr bgcolor='${Header::colouryellow}'>";
1524 }elsif ($count %2 == 0){
1525 print"<tr bgcolor='$color{'color22'}'>";
1527 print"<tr bgcolor='$color{'color20'}'>";
1529 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1530 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1531 print "<td width='39%' align='left'>";
1532 if($customgrp{$key}[3] eq 'Standard Network'){
1533 print &get_name
($customgrp{$key}[2])."</td>";
1535 print "$customgrp{$key}[2]</td>";
1537 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost empty'}){
1538 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1540 my ($colip,$colsub) = split("/",$ip);
1541 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1542 print"<td align='center'>".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1544 if ($delflag > '1' && $ip ne ''){
1545 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1547 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>";
1549 $helper=$customgrp{$key}[0];
1555 &Header
::closebox
();
1559 sub viewtableservice
1562 if(! -z
"$configsrv")
1564 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1565 &General
::readhasharray
("$configsrv", \
%customservice);
1567 <table width='100%' border='0' cellspacing='0'>
1568 <tr><td align='center'><b>$Lang::tr{'fwhost srv_name'}</b></td><td align='center'><b>$Lang::tr{'fwhost prot'}</b></td><td align='center'><b>$Lang::tr{'fwhost port'}</b></td><td align='center'><b>ICMP</b></td><td align='center'><b>$Lang::tr{'fwhost used'}</b></td><td></td><td width='3%'></td></tr>
1570 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1573 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1574 print" <tr bgcolor='${Header::colouryellow}'>";
1575 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1577 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1579 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1582 </td><td align='center'>$customservice{$key}[4]x</td>
1583 <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' />
1584 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1585 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1586 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1588 if ($customservice{$key}[4] eq '0')
1590 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>";
1592 print"<td></td></tr>";
1596 &Header
::closebox
();
1599 sub viewtableservicegrp
1608 if (! -z
$configsrvgrp){
1609 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1610 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1611 &General
::readhasharray
("$configsrv", \
%customservice);
1612 my $number= keys %customservicegrp;
1613 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1615 if ($helper ne $customservicegrp{$key}[0]){
1617 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1618 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1626 $grpname=$customservicegrp{$key}[0];
1627 if ($customservicegrp{$key}[2] eq "none"){
1628 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1632 $remark="$customservicegrp{$key}[1]";
1633 if($count >=2){print"</table>";}
1634 print "<br><b><u>$grpname</u></b> ";
1635 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1636 print " <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1637 if($customservicegrp{$key}[3] == '0')
1639 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>";
1641 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>";
1642 print"<table width='100%' style='border: 1px solid #CCCCCC;' rules='none' cellspacing='0'><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><td></td></tr>";
1644 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1645 print" <tr bgcolor='${Header::colouryellow}'>";
1646 }elsif ($count %2 == 0){
1647 print"<tr bgcolor='$color{'color22'}'>";
1649 print"<tr bgcolor='$color{'color20'}'>";
1651 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1652 foreach my $srv (sort keys %customservice){
1653 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1654 $protocol=$customservice{$srv}[2];
1655 $port=$customservice{$srv}[1];
1659 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1660 if ($number gt '1'){
1661 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1663 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>";
1664 $helper=$customservicegrp{$key}[0];
1667 &Header
::closebox
();
1673 my %hash=%{(shift)};
1674 foreach my $key (keys %hash) {
1675 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1685 my %hash=%{(shift)};
1687 foreach my $key (keys %hash) {
1688 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1696 my %hash=%{(shift)};
1697 &General
::readhasharray
("$confignet", \
%hash);
1698 foreach my $key (keys %hash) {
1699 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1706 sub checkservicegroup
1708 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1712 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1714 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1715 return $errormessage;
1717 #check empty selectbox
1718 if (keys %customservice lt 1)
1720 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1722 #check if name already exists
1723 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1724 foreach my $key (keys %customservicegrp) {
1725 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1726 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1731 #check if service already exists in group
1732 foreach my $key (keys %customservicegrp) {
1733 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1734 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1737 return $errormessage;
1741 if ($errormessage) {
1742 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1743 print "<class name='base'>$errormessage\n";
1744 print " </class>\n";
1745 &Header
::closebox
();
1751 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1752 print "<class name='base'>$hint\n";
1753 print " </class>\n";
1754 &Header
::closebox
();
1760 &General
::setup_default_networks
(\
%defaultNetworks);
1761 foreach my $network (sort keys %defaultNetworks)
1763 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1771 &General
::readhasharray
("$config",\
%hash);
1772 foreach my $key (keys %hash) {
1773 $errormessage.="lese $hash{$key}[2] und $target<br>";
1774 if($hash{$key}[2] eq $target){
1777 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1780 &General
::writehasharray
("$config",\
%hash);
1787 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
1789 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1790 $fwhostsettings{'BLK_IP'}='readonly';
1791 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1792 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1794 #check if name collides with CCD Netname
1795 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1796 foreach my $key (keys %ccdnet) {
1797 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1798 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1799 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1800 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1804 #check if IP collides with CCD NetIP
1805 if ($fwhostsettings{'type'} ne 'mac'){
1806 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1807 foreach my $key (keys %ccdnet) {
1808 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1809 if($ccdnet{$key}[1] eq $test){
1810 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1811 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1812 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1813 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1818 #check if name collides with CCD Hostname
1819 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1820 foreach my $key (keys %ccdhost) {
1821 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1822 if($ip eq $fwhostsettings{'IP'}){
1823 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1824 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1828 #check if IP collides with CCD HostIP (only hosts)
1829 if ($edit eq 'edithost')
1831 foreach my $key (keys %ccdhost) {
1832 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1833 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1834 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1835 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1840 #check if network with this name already exists
1841 &General
::readhasharray
("$confignet", \
%customnetwork);
1842 if (!&checkname
(\
%customnetwork))
1844 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1845 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1846 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1848 #check if network ip already exists
1849 if (!&checkip
(\
%customnetwork,1))
1851 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1852 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1854 #check if host with this name already exists
1855 &General
::readhasharray
("$confighost", \
%customhost);
1856 if (!&checkname
(\
%customhost))
1858 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1859 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1860 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1862 #check if host with this ip already exists
1863 if (!&checkip
(\
%customhost,2))
1865 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1875 #get address from IPSEC NETWORK
1876 if ($type eq 'IpSec Network'){
1877 foreach my $key (keys %ipsecconf) {
1878 if ($ipsecconf{$key}[1] eq $name){
1879 return $ipsecconf{$key}[11];
1882 &deletefromgrp
($name,$configgrp);
1885 #get address from IPSEC HOST
1886 if ($type eq 'IpSec Host'){
1887 foreach my $key (keys %ipsecconf) {
1888 if ($ipsecconf{$key}[1] eq $name){
1889 return $ipsecconf{$key}[10];
1892 &deletefromgrp
($name,$configgrp);
1895 #get address from ovpn ccd Net-2-Net
1896 if ($type eq 'OpenVPN N-2-N'){
1897 foreach my $key (keys %ccdhost) {
1898 if($ccdhost{$key}[1] eq $name){
1899 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1900 $b=&General
::iporsubtodec
($b);
1904 &deletefromgrp
($name,$configgrp);
1907 #get address from ovpn ccd static host
1908 if ($type eq 'OpenVPN static host'){
1909 foreach my $key (keys %ccdhost) {
1910 if($ccdhost{$key}[1] eq $name){
1911 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1912 $b=&General
::iporsubtodec
($b);
1916 &deletefromgrp
($name,$configgrp);
1919 #get address from ovpn ccd static net
1920 if ($type eq 'OpenVPN static network'){
1921 foreach my $key (keys %ccdnet) {
1922 if ($ccdnet{$key}[0] eq $name){
1923 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1924 $b=&General
::iporsubtodec
($b);
1930 #check custom addresses
1931 if ($type eq 'Custom Host'){
1932 foreach my $key (keys %customhost) {
1933 if ($customhost{$key}[0] eq $name){
1934 my ($ip,$sub) = split("/",$customhost{$key}[2]);
1940 ##check custom networks
1941 if ($type eq 'Custom Network'){
1942 foreach my $key (keys %customnetwork) {
1943 if($customnetwork{$key}[0] eq $name){
1944 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
1949 #check standard networks
1950 if ($type eq 'Standard Network'){
1951 if ($name =~ /OpenVPN/i){
1953 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
1954 return $ovpn{'DOVPN_SUBNET'};
1956 if ($name eq 'GREEN'){
1958 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1959 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
1961 if ($name eq 'BLUE'){
1963 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1964 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
1966 if ($name eq 'ORANGE'){
1968 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1969 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
1971 if ($name eq 'ALL'){
1972 return "0.0.0.0/0.0.0.0";
1974 if ($name =~ /IPsec/i){
1976 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
1977 return $hash{'RW_NET'};
1983 if (!-f
"${General::swroot}/fwhosts/reread"){
1984 system("touch ${General::swroot}/fwhosts/reread");
1985 system("touch ${General::swroot}/forward/reread");
1990 system ("/usr/local/bin/forwardfwctrl");
1991 if ( -f
"${General::swroot}/fwhosts/reread"){
1992 system("rm ${General::swroot}/fwhosts/reread");
1993 system("rm ${General::swroot}/forward/reread");
2000 &General
::readhasharray
("$confignet", \
%customnetwork);
2001 &General
::readhasharray
("$confighost", \
%customhost);
2002 foreach my $key (sort keys %customgrp ){
2003 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2004 foreach my $key1 (sort keys %customnetwork){
2005 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2006 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2012 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2013 foreach my $key2 (sort keys %customhost){
2014 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2015 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2022 &General
::writehasharray
("$confignet", \
%customnetwork);
2023 &General
::writehasharray
("$confighost", \
%customhost);
2028 &General
::readhasharray
("$configsrv", \
%customservice);
2029 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2031 foreach my $key (sort keys %customservicegrp){
2032 if ($customservicegrp{$key}[0] eq $grp ){
2033 foreach my $key2 (sort keys %customservice){
2034 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2035 $customservice{$key2}[4]--;
2040 &General
::writehasharray
("$configsrv", \
%customservice);
2046 my %hash=%{(shift)};
2048 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2049 $errormessage=$Lang::tr
{'fwhost err name1'};
2051 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2052 $errormessage=$Lang::tr
{'fwhost err port'};
2055 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2056 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2058 #change dashes with :
2059 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2061 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2062 $fwhostsettings{'SRV_PORT'} = "1:65535";
2064 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2065 $fwhostsettings{'SRV_PORT'} = "1:$2";
2067 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2068 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2070 if($fwhostsettings{'PROT'} ne 'ICMP'){
2071 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2073 # a new service has to have a different name
2074 foreach my $key (keys %hash){
2075 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2076 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2080 return $errormessage;
2084 # Checks a hostname against RFC1035
2085 my $hostname = $_[0];
2087 # Each part should be at least two characters in length
2088 # but no more than 63 characters
2089 if (length ($hostname) < 1 || length ($hostname) > 63) {
2091 # Only valid characters are a-z, A-Z, 0-9 and -
2092 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2094 # First character can only be a letter or a digit
2095 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2097 # Last character can only be a letter or a digit
2098 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2104 # Checks a hostname against RFC1035
2106 # Each part should be at least two characters in length
2107 # but no more than 63 characters
2108 if (length ($remark) < 1 || length ($remark) > 255) {
2110 # Only valid characters are a-z, A-Z, 0-9 and -
2111 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2113 # First character can only be a letter or a digit
2114 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2116 # Last character can only be a letter or a digit
2117 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2121 &Header
::closebigbox
();
2122 &Header
::closepage
();