add forward-confirmed reverse DNS

This commit is contained in:
Bui 2014-10-06 03:37:13 +09:00 committed by czaks
parent 6804a2ede0
commit 8b9932218f
2 changed files with 9 additions and 1 deletions

View File

@ -67,6 +67,9 @@
// Requires safe_mode to be disabled. // Requires safe_mode to be disabled.
$config['dns_system'] = false; $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 // When executing most command-line tools (such as `convert` for ImageMagick image processing), add this
// to the environment path (seperated by :). // to the environment path (seperated by :).
$config['shell_path'] = '/usr/local/bin'; $config['shell_path'] = '/usr/local/bin';

View File

@ -2265,6 +2265,7 @@ function rDNS($ip_addr) {
if (!$config['dns_system']) { if (!$config['dns_system']) {
$host = gethostbyaddr($ip_addr); $host = gethostbyaddr($ip_addr);
$isip = filter_var($host, FILTER_VALIDATE_IP);
} else { } else {
$resp = shell_exec_error('host -W 1 ' . $ip_addr); $resp = shell_exec_error('host -W 1 ' . $ip_addr);
if (preg_match('/domain name pointer ([^\s]+)$/', $resp, $m)) if (preg_match('/domain name pointer ([^\s]+)$/', $resp, $m))
@ -2273,6 +2274,10 @@ function rDNS($ip_addr) {
$host = $ip_addr; $host = $ip_addr;
} }
if ($config['fcrdns'] && !$isip && gethostbyname($host) != $ip_addr) {
$host = $ip_addr;
}
if ($config['cache']['enabled']) if ($config['cache']['enabled'])
cache::set('rdns_' . $ip_addr, $host); cache::set('rdns_' . $ip_addr, $host);