mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-10 02:55:55 +02:00
Forward Firewall: fixed converterbug and added ruleposition to new rules in forwardfw.cgi
This commit is contained in:
committed by
Michael Tremer
parent
e3afaf8890
commit
70d38e5089
@@ -54,7 +54,6 @@ sub process_groups
|
||||
$ip =~ s/\s//gi;
|
||||
print LOG "Check IP $ip from Group $group ";
|
||||
my $val=&check_ip($ip);
|
||||
print "ALARM IP ist nun: $val"; ############################
|
||||
if($val){
|
||||
push(@hostarray,$val.",ip");
|
||||
print LOG "-> OK\n";
|
||||
@@ -102,16 +101,12 @@ sub check_ip
|
||||
{
|
||||
my $adr=shift;
|
||||
my $a;
|
||||
|
||||
print "habe bekommen: $adr\n";#########################################
|
||||
#ip with subnet in decimal
|
||||
if($adr =~ m/^(\d\d?\d?).(\d\d?\d?).(\d\d?\d?).(\d\d?\d?)\/(\d{1,2})$/){
|
||||
print "Bin drin, erkannt: cidr\n";################################
|
||||
$adr=int($1).".".int($2).".".int($3).".".int($4);
|
||||
my $b = &General::iporsubtodec($5);
|
||||
$a=$adr."/".$b;
|
||||
}elsif($adr =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
|
||||
print "Hm erkannt ip ohne subnetz, ersetze es\n";#################
|
||||
$adr=int($1).".".int($2).".".int($3).".".int($4);
|
||||
if(&General::validip($adr)){
|
||||
$a=$adr."/255.255.255.255";
|
||||
@@ -209,7 +204,7 @@ sub new_hostgrp
|
||||
&General::writehasharray($confighosts,\%hosts);
|
||||
&General::writehasharray($configgroups,\%groups);
|
||||
&General::writehasharray($confignets,\%nets);
|
||||
|
||||
|
||||
}
|
||||
sub check_host
|
||||
{
|
||||
@@ -291,7 +286,7 @@ sub process_rules
|
||||
}else{
|
||||
push(@prot,$configline[3]);
|
||||
}
|
||||
|
||||
|
||||
if($configline[4] ne ''){
|
||||
$configline[4] =~ s/,/;/g;
|
||||
$remark = $configline[4];
|
||||
@@ -557,5 +552,5 @@ sub build_ovpn_grp
|
||||
sub process_p2p
|
||||
{
|
||||
copy("/var/ipfire/outgoing/p2protocols","/var/ipfire/forward/p2protocols");
|
||||
chmod oct(0777), '/var/ipfire/forward/p2protocols';
|
||||
chmod oct('0777'), '/var/ipfire/forward/p2protocols';
|
||||
}
|
||||
|
||||
@@ -134,8 +134,9 @@ if ($fwdfwsettings{'ACTION'} eq 'saverule')
|
||||
#INPUT part
|
||||
if($fwdfwsettings{'grp2'} eq 'ipfire'){
|
||||
$fwdfwsettings{'chain'} = 'INPUTFW';
|
||||
my $maxkey=&General::findhasharraykey(\%configinputfw);
|
||||
#check if we have an identical rule already
|
||||
if($fwdfwsettings{'oldrulenumer'} eq $fwdfwsettings{'rulepos'}){
|
||||
if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
|
||||
foreach my $key (sort keys %configinputfw){
|
||||
if ("$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
|
||||
eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27]"){
|
||||
@@ -151,6 +152,16 @@ if ($fwdfwsettings{'ACTION'} eq 'saverule')
|
||||
}
|
||||
}
|
||||
}
|
||||
#check Rulepos on new Rule
|
||||
if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
|
||||
$fwdfwsettings{'oldrulenumber'}=$maxkey;
|
||||
foreach my $key (sort keys %configinputfw){
|
||||
if ("$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
|
||||
eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27]"){
|
||||
$errormessage.=$Lang::tr{'fwdfw err ruleexists'};
|
||||
}
|
||||
}
|
||||
}
|
||||
#check if we just close a rule
|
||||
if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} ) {
|
||||
if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
|
||||
@@ -196,6 +207,7 @@ if ($fwdfwsettings{'ACTION'} eq 'saverule')
|
||||
}else{
|
||||
#FORWARD PART
|
||||
$fwdfwsettings{'chain'} = 'FORWARDFW';
|
||||
my $maxkey=&General::findhasharraykey(\%configfwdfw);
|
||||
if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
|
||||
#check if we have an identical rule already
|
||||
foreach my $key (sort keys %configfwdfw){
|
||||
@@ -213,6 +225,16 @@ if ($fwdfwsettings{'ACTION'} eq 'saverule')
|
||||
}
|
||||
}
|
||||
}
|
||||
#check Rulepos on new Rule
|
||||
if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
|
||||
$fwdfwsettings{'oldrulenumber'}=$maxkey;
|
||||
foreach my $key (sort keys %configfwdfw){
|
||||
if ("$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
|
||||
eq "$configfwdfw{$key}[0],$configfwdfw{$key}[2],$configfwdfw{$key}[3],$configfwdfw{$key}[4],$configfwdfw{$key}[5],$configfwdfw{$key}[6],$configfwdfw{$key}[7],$configfwdfw{$key}[8],$configfwdfw{$key}[9],$configfwdfw{$key}[10],$configfwdfw{$key}[11],$configfwdfw{$key}[12],$configfwdfw{$key}[13],$configfwdfw{$key}[14],$configfwdfw{$key}[15],$configfwdfw{$key}[17],$configfwdfw{$key}[18],$configfwdfw{$key}[19],$configfwdfw{$key}[20],$configfwdfw{$key}[21],$configfwdfw{$key}[22],$configfwdfw{$key}[23],$configfwdfw{$key}[24],$configfwdfw{$key}[25],$configfwdfw{$key}[26],$configfwdfw{$key}[27]"){
|
||||
$errormessage.=$Lang::tr{'fwdfw err ruleexists'};
|
||||
}
|
||||
}
|
||||
}
|
||||
#check if we just close a rule
|
||||
if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} ) {
|
||||
if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
|
||||
@@ -989,7 +1011,7 @@ sub newrule
|
||||
foreach my $key (sort keys %hash){
|
||||
$sum++;
|
||||
if ($key eq $fwdfwsettings{'key'}){
|
||||
$fwdfwsettings{'oldrulenumber'} = $key;
|
||||
$fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
|
||||
$fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
|
||||
$fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
|
||||
$fwdfwsettings{'grp1'} = $hash{$key}[3];
|
||||
@@ -1080,7 +1102,6 @@ END
|
||||
|
||||
&Header::closebox();
|
||||
&Header::openbox('100%', 'left', $Lang::tr{'fwdfw source'});
|
||||
|
||||
#------SOURCE-------------------------------------------------------
|
||||
print<<END;
|
||||
<table width='100%' border='0'>
|
||||
@@ -1373,6 +1394,8 @@ END
|
||||
print">$count</option>";
|
||||
}
|
||||
print"</select></td></tr>";
|
||||
}else{
|
||||
print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
|
||||
}
|
||||
|
||||
print<<END;
|
||||
@@ -1438,7 +1461,8 @@ END
|
||||
<table border='0' width='100%'>
|
||||
<tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
|
||||
<input type='hidden' name='config' value='$config' >
|
||||
<input type='hidden' name='ACTION' value='saverule' ></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>
|
||||
<input type='hidden' name='ACTION' value='saverule' >
|
||||
</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>
|
||||
END
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user