From 8b9932218ffa0e53b05cad5bc769f9317687e6da Mon Sep 17 00:00:00 2001 From: Bui Date: Mon, 6 Oct 2014 03:37:13 +0900 Subject: [PATCH 1/3] add forward-confirmed reverse DNS --- inc/config.php | 5 ++++- inc/functions.php | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/inc/config.php b/inc/config.php index 1a75cad0..bd5c5db3 100644 --- a/inc/config.php +++ b/inc/config.php @@ -66,7 +66,10 @@ // Use `host` via shell_exec() to lookup hostnames, avoiding query timeouts. May not work on your system. // Requires safe_mode to be disabled. $config['dns_system'] = false; - + + // Check validity of the reverse DNS of IP addresses. Highly recommended. + $config['fcrdns'] = true; + // When executing most command-line tools (such as `convert` for ImageMagick image processing), add this // to the environment path (seperated by :). $config['shell_path'] = '/usr/local/bin'; diff --git a/inc/functions.php b/inc/functions.php index 357666d6..8c5f46b9 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2265,6 +2265,7 @@ function rDNS($ip_addr) { if (!$config['dns_system']) { $host = gethostbyaddr($ip_addr); + $isip = filter_var($host, FILTER_VALIDATE_IP); } else { $resp = shell_exec_error('host -W 1 ' . $ip_addr); if (preg_match('/domain name pointer ([^\s]+)$/', $resp, $m)) @@ -2273,6 +2274,10 @@ function rDNS($ip_addr) { $host = $ip_addr; } + if ($config['fcrdns'] && !$isip && gethostbyname($host) != $ip_addr) { + $host = $ip_addr; + } + if ($config['cache']['enabled']) cache::set('rdns_' . $ip_addr, $host); From 1e95e588110516ed0d89ddb8546548a6324b3e1a Mon Sep 17 00:00:00 2001 From: Bui Date: Mon, 6 Oct 2014 04:08:10 +0900 Subject: [PATCH 2/3] don't break if dns_system is true --- inc/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index 8c5f46b9..f45e9055 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2265,7 +2265,6 @@ function rDNS($ip_addr) { if (!$config['dns_system']) { $host = gethostbyaddr($ip_addr); - $isip = filter_var($host, FILTER_VALIDATE_IP); } else { $resp = shell_exec_error('host -W 1 ' . $ip_addr); if (preg_match('/domain name pointer ([^\s]+)$/', $resp, $m)) @@ -2274,6 +2273,8 @@ function rDNS($ip_addr) { $host = $ip_addr; } + $isip = filter_var($host, FILTER_VALIDATE_IP); + if ($config['fcrdns'] && !$isip && gethostbyname($host) != $ip_addr) { $host = $ip_addr; } From aba8d27ace9b1b95bb7cc71ae0424f0bc8f20809 Mon Sep 17 00:00:00 2001 From: Bui Date: Mon, 6 Oct 2014 04:30:32 +0900 Subject: [PATCH 3/3] wasn't aware of DNS function --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index f45e9055..3802d19d 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2275,7 +2275,7 @@ function rDNS($ip_addr) { $isip = filter_var($host, FILTER_VALIDATE_IP); - if ($config['fcrdns'] && !$isip && gethostbyname($host) != $ip_addr) { + if ($config['fcrdns'] && !$isip && DNS($host) != $ip_addr) { $host = $ip_addr; }