$fwhostsettings{'netremark'} = $customnetwork{$key}[3];
$fwhostsettings{'count'} = $customnetwork{$key}[4];
delete $customnetwork{$key};
-
+
}
}
&General::writehasharray("$confignet", \%customnetwork);
#convert ip if leading '0' exists
$fwhostsettings{'IP'} = &Network::ip_remove_zero($fwhostsettings{'IP'});
- #check valid ip
+ #check valid ip
if (!&General::validipandmask($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
{
$errormessage=$errormessage.$Lang::tr{'fwhost err addr'};
}
}
#only check plausi when no error till now
- if (!$errormessage){
+ if (!$errormessage){
&plausicheck("edithost");
}
if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
$customhost{$key}[3] = $fwhostsettings{'orgremark'};
&General::writehasharray("$confighost", \%customhost);
undef %customhost;
- }
+ }
if (!$errormessage){
#get count if host was edited
if($fwhostsettings{'actualize'} eq 'on'){
#check standard networks
if ($fwhostsettings{'grp2'} eq 'std_net'){
@target=$fwhostsettings{'DEFAULT_SRC_ADR'};
- $type='Standard Network';
+ $type='Standard Network';
}
#check custom networks
if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
$fwhostsettings{'remark'}='';
}
#check if host/net exists in grp
-
+
my $test="$grp,$fwhostsettings{'oldremark'},@target,$type";
foreach my $key (keys %customgrp) {
my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2],$customgrp{$key}[3]";
}
}
}
-
+
if (!$errormessage){
#on first save, we have an empty @target, so fill it with nothing
my $targetvalues=@target;
&General::readhasharray("$fwconfiginp", \%fwinp);
&General::readhasharray("$fwconfigout", \%fwout);
+ # Check name
+ if (!&validhostname($grp)){$errormessage.=$Lang::tr{'fwhost err name'};}
+
# Check for existing group name.
if (!&checkgroup($grp) && $fwhostsettings{'update'} ne 'on'){
$errormessage = $Lang::tr{'fwhost err grpexist'};
}
}
}
- if ($tcpcounter > 14){
+
+ # Loop through the hash of configured services.
+ foreach my $key (keys %customservice) {
+ # Assign nice human-readable values.
+ my $service_name = $customservice{$key}[0];
+ my $service_port = $customservice{$key}[1];
+ my $service_proto = $customservice{$key}[2];
+
+ # Skip services unless the processed one has found.
+ next unless $service_name eq $fwhostsettings{'CUST_SRV'};
+
+ # Increase the counters.
+ $tcpcounter++ if $service_proto eq 'TCP';
+ $tcpcounter++ if $service_proto eq 'TCP' && $service_port =~ m/:/i;
+ $udpcounter++ if $service_proto eq 'UDP';
+ $udpcounter++ if $service_proto eq 'UDP' && $service_port =~ m/:/i;
+ }
+
+ if ($tcpcounter > 15) {
$errormessage=$Lang::tr{'fwhost err maxservicetcp'};
}
- if ($udpcounter > 14){
+ if ($udpcounter > 15) {
$errormessage=$Lang::tr{'fwhost err maxserviceudp'};
}
$tcpcounter=0;
{
$customgrp{$key}[1]='';
$customgrp{$key}[1]=$fwhostsettings{'newrem'};
- }
+ }
}
&General::writehasharray("$configgrp", \%customgrp);
$fwhostsettings{'update'}='on';
{
$customservicegrp{$key}[1]='';
$customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
- }
+ }
}
&General::writehasharray("$configsrvgrp", \%customservicegrp);
$fwhostsettings{'updatesrvgrp'}='on';
<tr><td colspan='6'></td></tr></table>
END
&Header::closebox();
-
+
}
# Add
sub addnet
if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
{
-
+
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>";
}else{
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'>";
- }
+ }
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>";
&Header::closebox();
}
$fwhostsettings{'oldgrpname'}=$fwhostsettings{'grp_name'};
my $grp=$fwhostsettings{'grp_name'};
my $rem=$fwhostsettings{'remark'};
- if ($fwhostsettings{'update'} eq ''){
+ if ($fwhostsettings{'update'} eq ''){
print<<END;
<table width='100%' border='0'>
<tr>
&General::readhasharray("$fwconfiginp", \%fwinp);
&General::readhasharray("$fwconfigout", \%fwout);
- if (!keys %customnetwork)
- {
- print "<center><b>$Lang::tr{'fwhost empty'}</b>";
+ if (!keys %customnetwork)
+ {
+ print "<center><b>$Lang::tr{'fwhost empty'}</b>";
}else{
print<<END;
<table width='100%' cellspacing='0' class='tbl'>
print" <tr>";
$col="bgcolor='${Header::colouryellow}'";
}elsif ($count % 2)
- {
+ {
$col="bgcolor='$color{'color20'}'";
print" <tr>";
}else
}
print"</table>";
&Header::closebox();
- }
+ }
}
sub getcolor
&General::readhasharray("$fwconfiginp", \%fwinp);
&General::readhasharray("$fwconfigout", \%fwout);
&General::readhasharray("$configgrp", \%customgrp);
- if (!keys %customhost)
- {
- print "<center><b>$Lang::tr{'fwhost empty'}</b>";
+ if (!keys %customhost)
+ {
+ print "<center><b>$Lang::tr{'fwhost empty'}</b>";
}else{
print<<END;
<table width='100%' cellspacing='0' class='tbl'>
my $delflag;
my @counter;
my %hash;
- if (!keys %customgrp)
+ if (!keys %customgrp)
{
print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
}else{
print"<tr>";
$col="bgcolor='$color{'color22'}'";
}
- my $ip=&getipforgroup($customgrp{$key}[2],$customgrp{$key}[3]);
+ my $ip=&getipforgroup($customgrp{$key}[2],$customgrp{$key}[3]);
if ($ip eq ''){
print"<tr>";
$col="bgcolor='${Header::colouryellow}'";
}
}
return 1;
-
+
}
sub checkgroup
{
}
sub checkip
{
-
+
my %hash=%{(shift)};
my $a=shift;
foreach my $key (keys %hash) {
foreach my $key (keys %customservicegrp) {
if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
$errormessage.=$Lang::tr{'fwhost err grpexist'}."<br>";
-
+
}
}
}
foreach my $network (sort keys %defaultNetworks)
{
return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
- }
+ }
}
sub gethostcount
{
}
}
&General::writehasharray("$config",\%hash);
-
+
}
sub plausicheck
{
$errormessage=$errormessage."<br>".$Lang::tr{'fwhost err netexist'};
$fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
- }
- #check if network ip already exists
+ }
+ #check if network ip already exists
if (!&checkip(\%customnetwork,1))
{
$errormessage=$errormessage."<br>".$Lang::tr{'fwhost err net'};
if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
- }
+ }
#check if host with this name already exists
&General::readhasharray("$confighost", \%customhost);
if (!&checkname(\%customhost))
my $name=$_[0],
my $type=$_[1];
my $value;
-
+
#get address from IPSEC NETWORK
if ($type eq 'IpSec Network'){
foreach my $key (keys %ipsecconf) {
}
&deletefromgrp($name,$configgrp);
}
-
+
#get address from IPSEC HOST
if ($type eq 'IpSec Host'){
foreach my $key (keys %ipsecconf) {
}
&deletefromgrp($name,$configgrp);
}
-
+
#get address from ovpn ccd Net-2-Net
if ($type eq 'OpenVPN N-2-N'){
foreach my $key (keys %ccdhost) {
}
&deletefromgrp($name,$configgrp);
}
-
+
#get address from ovpn ccd static host
if ($type eq 'OpenVPN static host'){
foreach my $key (keys %ccdhost) {
}
&deletefromgrp($name,$configgrp);
}
-
+
#get address from ovpn ccd static net
if ($type eq 'OpenVPN static network'){
foreach my $key (keys %ccdnet) {
}
}
}
-
+
#check custom addresses
if ($type eq 'Custom Host'){
foreach my $key (keys %customhost) {
}
}
}
-
+
##check custom networks
if ($type eq 'Custom Network'){
foreach my $key (keys %customnetwork) {
}
}
}
-
+
#check standard networks
if ($type eq 'Standard Network'){
if ($name =~ /OpenVPN/i){
}
}
}
-
+
if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
foreach my $key2 (sort keys %customhost){
if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
last;
}
}
-
+
}
}
&General::writehasharray("$confignet", \%customnetwork);
my $grp=$_[0];
&General::readhasharray("$configsrv", \%customservice);
&General::readhasharray("$configsrvgrp", \%customservicegrp);
-
+
foreach my $key (sort keys %customservicegrp){
if ($customservicegrp{$key}[0] eq $grp ){
foreach my $key2 (sort keys %customservice){
}
}
&General::writehasharray("$configsrv", \%customservice);
-
+
}
sub changenameinfw
{
}
sub checkports
{
-
+
my %hash=%{(shift)};
#check empty fields
if ($fwhostsettings{'SRV_NAME'} eq '' ){
}
#change dashes with :
$fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
-
+
if ($fwhostsettings{'SRV_PORT'} eq "*") {
$fwhostsettings{'SRV_PORT'} = "1:65535";
}