use Sort::Naturally;
use utf8;
use feature 'unicode_strings';
+use experimental 'smartmatch';
no warnings 'uninitialized';
require '/var/ipfire/network-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
-require "${General::swroot}/geoip-functions.pl";
+require "${General::swroot}/location-functions.pl";
require "/usr/lib/firewall/firewall-lib.pl";
-unless (-d "${General::swroot}/firewall") { system("mkdir ${General::swroot}/firewall"); }
-unless (-e "${General::swroot}/firewall/settings") { system("touch ${General::swroot}/firewall/settings"); }
-unless (-e "${General::swroot}/firewall/config") { system("touch ${General::swroot}/firewall/config"); }
-unless (-e "${General::swroot}/firewall/input") { system("touch ${General::swroot}/firewall/input"); }
-unless (-e "${General::swroot}/firewall/outgoing") { system("touch ${General::swroot}/firewall/outgoing"); }
+unless (-d "${General::swroot}/firewall") { &General::system("mkdir", "${General::swroot}/firewall"); }
+unless (-e "${General::swroot}/firewall/settings") { &General::system("touch", "${General::swroot}/firewall/settings"); }
+unless (-e "${General::swroot}/firewall/config") { &General::system("touch", "${General::swroot}/firewall/config"); }
+unless (-e "${General::swroot}/firewall/input") { &General::system("touch", "${General::swroot}/firewall/input"); }
+unless (-e "${General::swroot}/firewall/outgoing") { &General::system("touch", "${General::swroot}/firewall/outgoing"); }
my %fwdfwsettings=();
my %selected=() ;
my %netsettings=();
my %customhost=();
my %customgrp=();
-my %customgeoipgrp=();
+my %customlocationgrp=();
my %customnetworks=();
my %customservice=();
my %customservicegrp=();
my $confignet = "${General::swroot}/fwhosts/customnetworks";
my $confighost = "${General::swroot}/fwhosts/customhosts";
my $configgrp = "${General::swroot}/fwhosts/customgroups";
-my $configgeoipgrp = "${General::swroot}/fwhosts/customgeoipgrp";
+my $configlocationgrp = "${General::swroot}/fwhosts/customlocationgrp";
my $configsrv = "${General::swroot}/fwhosts/customservices";
my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
my @protocols;
&General::readhash("${General::swroot}/firewall/settings", \%fwdfwsettings);
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
&General::readhash($fwoptions, \%optionsfw);
&General::readhash($ifacesettings, \%ifaces);
&General::readhash("$configovpn", \%ovpnsettings);
$errormessage=$Lang::tr{'fwdfw err same'};
}
# INPUT part
- if ($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
+ if ($fwdfwsettings{'grp2'} eq 'ipfire') {
$fwdfwsettings{'config'}=$configinput;
$fwdfwsettings{'chain'} = 'INPUTFW';
$maxkey=&General::findhasharraykey(\%configinputfw);
my $grp=shift;
my $helper='';
my $show='';
+
+ my %checked = ();
+ my %selected = ();
+
$checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
$checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
$checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
$checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
$selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
$selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
- $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
- $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
print<<END;
<table width='100%' border='0'>
<tr><td width='50%' valign='top'>
{
next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
print "<option value='$defaultNetworks{$network}{'NAME'}'";
- print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
+
+ # Check if the the key handles a standard network.
+ if ( grep(/std_net_/, $fwdfwsettings{$grp}) ) {
+ print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
+ }
+
my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
my $defsub1=&General::subtocidr($ifaces{$defsub});
}
print"</select></td>";
}
- # geoip locations / groups.
- my @geoip_locations = &fwlib::get_geoip_locations();
+ # Locations / groups.
+ my @locations = &fwlib::get_locations();
print "<tr>\n";
- print "<td valign='top'><input type='radio' name='$grp' id='cust_geoip_$srctgt' value='cust_geoip_$srctgt' $checked{$grp}{'cust_geoip_'.$srctgt}></td>\n";
- print "<td>$Lang::tr{'geoip'}</td>\n";
- print "<td align='right'><select name='cust_geoip_$srctgt' style='width:200px;'>\n";
-
- # Add GeoIP groups to dropdown.
- if (!-z $configgeoipgrp) {
- print "<optgroup label='$Lang::tr{'fwhost cust geoipgroup'}'>\n";
- foreach my $key (sort { ncmp($customgeoipgrp{$a}[0],$customgeoipgrp{$b}[0]) } keys %customgeoipgrp) {
+ print "<td valign='top'><input type='radio' name='$grp' id='cust_location_$srctgt' value='cust_location_$srctgt' $checked{$grp}{'cust_location_'.$srctgt}></td>\n";
+ print "<td>$Lang::tr{'location'}</td>\n";
+ print "<td align='right'><select name='cust_location_$srctgt' style='width:200px;'>\n";
+
+ # Add Location groups to dropdown.
+ if (!-z $configlocationgrp) {
+ print "<optgroup label='$Lang::tr{'fwhost cust locationgroup'}'>\n";
+ foreach my $key (sort { ncmp($customlocationgrp{$a}[0],$customlocationgrp{$b}[0]) } keys %customlocationgrp) {
my $selected;
# Generate stored value for select detection.
- my $stored = join(':', "group",$customgeoipgrp{$key}[0]);
+ my $stored = join(':', "group",$customlocationgrp{$key}[0]);
# Only show a group once and group with elements.
- if($helper ne $customgeoipgrp{$key}[0] && $customgeoipgrp{$key}[2] ne 'none') {
+ if($helper ne $customlocationgrp{$key}[0] && $customlocationgrp{$key}[2] ne 'none') {
# Mark current entry as selected.
if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $stored) {
$selected = "selected='selected'";
}
- print"<option $selected value='group:$customgeoipgrp{$key}[0]'>$customgeoipgrp{$key}[0]</option>\n";
+ print"<option $selected value='group:$customlocationgrp{$key}[0]'>$customlocationgrp{$key}[0]</option>\n";
}
- $helper=$customgeoipgrp{$key}[0];
+ $helper=$customlocationgrp{$key}[0];
}
print "</optgroup>\n";
}
# Add locations.
- print "<optgroup label='$Lang::tr{'fwhost cust geoiplocation'}'>\n";
- foreach my $location (@geoip_locations) {
+ print "<optgroup label='$Lang::tr{'fwhost cust location'}'>\n";
+ foreach my $location (@locations) {
# Get country name.
- my $country_name = &GeoIP::get_full_country_name($location);
+ my $country_name = &Location::Functions::get_full_country_name($location);
# Mark current entry as selected.
my $selected;
}
print "</optgroup>\n";
- # Close GeoIP dropdown.
+ # Close Locations dropdown.
print "</select></td>\n";
#End left table. start right table (vpn)
&General::readhasharray("$confighost", \%customhost);
&General::readhasharray("$configccdhost", \%ccdhost);
&General::readhasharray("$configgrp", \%customgrp);
- &General::readhasharray("$configgeoipgrp", \%customgeoipgrp);
+ &General::readhasharray("$configlocationgrp", \%customlocationgrp);
&General::readhasharray("$configipsec", \%ipsecconf);
&General::get_aliases(\%aliases);
- my %checked=();
+
+ my %checked = ();
+ my %selected = ();
+
my $helper;
my $sum=0;
if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
$checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
$selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
$selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
- $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
- $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
+ $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} = 'selected' if ($fwdfwsettings{'grp2'} eq "ipfire");
+ $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} = 'selected' if ($fwdfwsettings{'grp1'} eq "ipfire_src");
#check if update and get values
if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
&General::readhasharray("$config", \%hash);
$fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
$fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
$fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
+ #Fix BUG 12479
+ #When copying a DNAT Rule, the sourceport has to be empty at this point.
+ if($hash{$key}[14] eq 'cust_srv' and $hash{$key}[31] eq 'dnat'){
+ $hash{$key}[30] = '';
+ }
$fwdfwsettings{'dnatport'} = $hash{$key}[30];
$fwdfwsettings{'LIMIT_CON_CON'} = $hash{$key}[32];
$fwdfwsettings{'concon'} = $hash{$key}[33];
$checked{'RATE_LIMIT'}{$fwdfwsettings{'RATE_LIMIT'}} = 'CHECKED';
$selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
$selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
- $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
- $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
+ $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} = 'selected' if ($fwdfwsettings{'grp2'} eq "ipfire");
+ $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} = 'selected' if ($fwdfwsettings{'grp1'} eq "ipfire_src");
$selected{'dnat'}{$fwdfwsettings{'dnat'}} ='selected';
$selected{'snat'}{$fwdfwsettings{'snat'}} ='selected';
$selected{'RATETIME'}{$fwdfwsettings{'RATETIME'}} ='selected';
}else{
print $$hash{$key}[4];
}
- }elsif ($$hash{$key}[3] eq 'cust_geoip_src') {
+ }elsif ($$hash{$key}[3] eq 'cust_location_src') {
my ($split1,$split2) = split(":", $$hash{$key}[4]);
if ($split2) {
print "$split2\n";
}else{
- print "$Lang::tr{'geoip'}: $$hash{$key}[4]\n";
+ print "$Lang::tr{'location'}: $$hash{$key}[4]\n";
}
}elsif ($$hash{$key}[4] eq 'RED1'){
print "$ipfireiface $Lang::tr{'fwdfw red'}";
}else{
print $$hash{$key}[6];
}
- }elsif ($$hash{$key}[5] eq 'cust_geoip_tgt') {
+ }elsif ($$hash{$key}[5] eq 'cust_location_tgt') {
my ($split1,$split2) = split(":", $$hash{$key}[6]);
if ($split2) {
print "$split2\n";
}else{
- print "$Lang::tr{'geoip'}: $$hash{$key}[6]\n";
+ print "$Lang::tr{'location'}: $$hash{$key}[6]\n";
}
}elsif ($$hash{$key}[5] eq 'tgt_addr'){
my ($split1,$split2) = split("/",$$hash{$key}[6]);