Skip to content

Commit

Permalink
Fix. Common. Helper::dnsResolve() method fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glomberg committed Dec 28, 2024
1 parent 7416d13 commit 192e51a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Cleantalk/ApbctWP/Firewall/SFW.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,9 @@ public static function updateWriteToDbExclusions($db, $db__table__data, $exclusi
if (Server::get('HTTP_HOST')) {
// Do not add exceptions for local hosts
if (defined('APBCT_IS_LOCALHOST') && !APBCT_IS_LOCALHOST) {
$exclusions[] = Helper::dnsResolve(Server::get('HTTP_HOST'));
if ( $current_host_ip = Helper::dnsResolve(Server::get('HTTP_HOST')) ) {
$exclusions[] = $current_host_ip;
}
$exclusions[] = '127.0.0.1';
// And delete all 127.0.0.1 entries for local hosts
} else {
Expand Down
5 changes: 5 additions & 0 deletions lib/Cleantalk/Common/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,11 @@ public static function ipResolve($ip)
*/
public static function dnsResolve($host, $out = false)
{
// Check if the $url is set and it is an url
if ( ! $host || ! filter_var($host, FILTER_VALIDATE_URL)) {
return $out;
}

// Get DNS records about URL
if (function_exists('dns_get_record')) {
$records = dns_get_record($host, DNS_A);
Expand Down

0 comments on commit 192e51a

Please sign in to comment.