aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorMarcello Coutinho <marcellocoutinho@gmail.com>2012-10-15 06:58:37 -0700
committerMarcello Coutinho <marcellocoutinho@gmail.com>2012-10-15 06:58:37 -0700
commitaec5874f3721280b7426fb1fed1919357ed8cfc6 (patch)
tree920a95a0538b9068c6f2b76dff12d6c2474d5502 /config
parent73c2f873521460dcdf0dbad6b7699c33e7934e9f (diff)
parent0d249b9d1b59555bb97491b48743d8455ff3039f (diff)
downloadpfsense-packages-aec5874f3721280b7426fb1fed1919357ed8cfc6.tar.gz
pfsense-packages-aec5874f3721280b7426fb1fed1919357ed8cfc6.tar.bz2
pfsense-packages-aec5874f3721280b7426fb1fed1919357ed8cfc6.zip
Merge pull request #329 from darkain/patch-1
Fixed two issues with IP Ranges
Diffstat (limited to 'config')
-rwxr-xr-xconfig/pf-blocker/pfblocker.inc24
1 files changed, 12 insertions, 12 deletions
diff --git a/config/pf-blocker/pfblocker.inc b/config/pf-blocker/pfblocker.inc
index 1c107dc4..58b93bb5 100755
--- a/config/pf-blocker/pfblocker.inc
+++ b/config/pf-blocker/pfblocker.inc
@@ -70,9 +70,9 @@ function pfblocker_Range2CIDR($ip_min, $ip_max) {
if ($bits < 0)
return "";
#identify first ip on range network
- $network=long2ip(bindec(substr(decbin($ip_min_long),0,$bits).preg_replace("/\d/","0",substr(decbin($ip_min_long),0,(32-$bits)))));
+ $network=long2ip( $ip_min_long & ((1<<32)-(1<<(32-$bits))-1) );
#print decbin($ip_min_long)."\n".$network."\n";
- return $network . "/". (32 -strlen(decbin($ip_max_long - $ip_min_long)));
+ return $network . "/". $bits;
}
function sync_package_pfblocker($cron="") {
@@ -288,16 +288,6 @@ function sync_package_pfblocker($cron="") {
$new_file="";
if (is_array($url_list)){
foreach ($url_list as $line){
- # CIDR format 192.168.0.0/16
- if (preg_match("/(\d+\.\d+\.\d+\.\d+\/\d+)/",$line,$matches)){
- ${$alias}.= $matches[1]."\n";
- $new_file.= $matches[1]."\n";
- }
- # Single ip addresses
- if (preg_match("/(\d+\.\d+\.\d+\.\d+)\s+/",$line,$matches)){
- ${$alias}.= $matches[1]."/32\n";
- $new_file.= $matches[1]."/32\n";
- }
# Network range 192.168.0.0-192.168.0.254
if (preg_match("/(\d+\.\d+\.\d+\.\d+)-(\d+\.\d+\.\d+\.\d+)/",$line,$matches)){
$cidr= pfblocker_Range2CIDR($matches[1],$matches[2]);
@@ -306,6 +296,16 @@ function sync_package_pfblocker($cron="") {
$new_file.= $cidr."\n";
}
}
+ # CIDR format 192.168.0.0/16
+ else if (preg_match("/(\d+\.\d+\.\d+\.\d+\/\d+)/",$line,$matches)){
+ ${$alias}.= $matches[1]."\n";
+ $new_file.= $matches[1]."\n";
+ }
+ # Single ip addresses
+ else if (preg_match("/(\d+\.\d+\.\d+\.\d+)\s+/",$line,$matches)){
+ ${$alias}.= $matches[1]."/32\n";
+ $new_file.= $matches[1]."/32\n";
+ }
}
}
if ($new_file != ""){