diff --git a/inc/config.php b/inc/config.php index ac4069da..c96e9e4e 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 f9c09085..5960d65d 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2259,6 +2259,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)) @@ -2267,6 +2268,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);