forked from leftypol/leftypol
Merge pull request 'Add IPv6 support for DNSBL' (#48) from ipv6-dnsbl into config
Reviewed-on: https://git.leftypol.org/leftypol/leftypol/pulls/48
This commit is contained in:
commit
aa9341c51d
2 changed files with 16 additions and 8 deletions
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require 'inc/lib/IP/Lifo/IP/IP.php';
|
require_once 'inc/lib/IP/Lifo/IP/IP.php';
|
||||||
require 'inc/lib/IP/Lifo/IP/BC.php';
|
require_once 'inc/lib/IP/Lifo/IP/BC.php';
|
||||||
require 'inc/lib/IP/Lifo/IP/CIDR.php';
|
require_once 'inc/lib/IP/Lifo/IP/CIDR.php';
|
||||||
|
|
||||||
use Lifo\IP\CIDR;
|
use Lifo\IP\CIDR;
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,13 @@ require_once 'inc/mod/auth.php';
|
||||||
require_once 'inc/lock.php';
|
require_once 'inc/lock.php';
|
||||||
require_once 'inc/queue.php';
|
require_once 'inc/queue.php';
|
||||||
require_once 'inc/polyfill.php';
|
require_once 'inc/polyfill.php';
|
||||||
|
require_once 'inc/lib/IP/Lifo/IP/IP.php';
|
||||||
@include_once 'inc/lib/parsedown/Parsedown.php'; // fail silently, this isn't a critical piece of code
|
@include_once 'inc/lib/parsedown/Parsedown.php'; // fail silently, this isn't a critical piece of code
|
||||||
|
|
||||||
require_once 'inc/anti-bot.php'; // DELETE ME THIS IS FOR print_err function only!
|
require_once 'inc/anti-bot.php'; // DELETE ME THIS IS FOR print_err function only!
|
||||||
|
|
||||||
|
use Lifo\IP\IP; // for expanding IPv6 address in DNSBL()
|
||||||
|
|
||||||
if (!extension_loaded('gettext')) {
|
if (!extension_loaded('gettext')) {
|
||||||
require_once 'inc/lib/gettext/gettext.inc';
|
require_once 'inc/lib/gettext/gettext.inc';
|
||||||
}
|
}
|
||||||
|
@ -1753,9 +1756,6 @@ function buildJavascript() {
|
||||||
function checkDNSBL() {
|
function checkDNSBL() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (isIPv6())
|
|
||||||
return; // No IPv6 support yet.
|
|
||||||
|
|
||||||
if (!isset($_SERVER['REMOTE_ADDR']))
|
if (!isset($_SERVER['REMOTE_ADDR']))
|
||||||
return; // Fix your web server configuration
|
return; // Fix your web server configuration
|
||||||
|
|
||||||
|
@ -1765,7 +1765,11 @@ function checkDNSBL() {
|
||||||
if (in_array($_SERVER['REMOTE_ADDR'], $config['dnsbl_exceptions']))
|
if (in_array($_SERVER['REMOTE_ADDR'], $config['dnsbl_exceptions']))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$ipaddr = ReverseIPOctets($_SERVER['REMOTE_ADDR']);
|
if (isIPv6()) {
|
||||||
|
$ipaddr = ReverseIPv6Octets($_SERVER['REMOTE_ADDR']);
|
||||||
|
} else {
|
||||||
|
$ipaddr = ReverseIPv4Octets($_SERVER['REMOTE_ADDR']);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($config['dnsbl'] as $blacklist) {
|
foreach ($config['dnsbl'] as $blacklist) {
|
||||||
if (!is_array($blacklist))
|
if (!is_array($blacklist))
|
||||||
|
@ -1801,10 +1805,14 @@ function isIPv6() {
|
||||||
return strstr($_SERVER['REMOTE_ADDR'], ':') !== false;
|
return strstr($_SERVER['REMOTE_ADDR'], ':') !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ReverseIPOctets($ip) {
|
function ReverseIPv4Octets($ip) {
|
||||||
return implode('.', array_reverse(explode('.', $ip)));
|
return implode('.', array_reverse(explode('.', $ip)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ReverseIPv6Octets($ip) {
|
||||||
|
return strrev(implode(".", str_split(str_replace(':', '', IP::inet_expand($ip)))));
|
||||||
|
}
|
||||||
|
|
||||||
function wordfilters(&$body) {
|
function wordfilters(&$body) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue