Skip to content

Commit e33ef67

Browse files
committed
refactor(project honeypot): resolves #344, added additional check & debug info for ip type support
1 parent 7bc5a9d commit e33ef67

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

core/class-user.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public static function get_ip() {
3636
$ip = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) );
3737
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED'] ) ) {
3838
$ip = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED'] ) );
39+
} elseif ( isset( $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'] ) ) {
40+
$ip = sanitize_text_field( wp_unslash( $_SERVER['HTTP_XHTTP_X_CLUSTER_CLIENT_IP_FORWARDED'] ) );
3941
} elseif ( ! empty( $_SERVER['HTTP_FORWARDED_FOR'] ) ) {
4042
$ip = sanitize_text_field( wp_unslash( $_SERVER['HTTP_FORWARDED_FOR'] ) );
4143
} elseif ( ! empty( $_SERVER['HTTP_FORWARDED'] ) ) {

modules/class-projecthoneypot.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,16 @@ public function query( $ip ) {
9595
krsort( $octets );
9696

9797
$reversed_ip = implode( '.', $octets );
98+
if ( strlen( $reversed_ip ) > 16) {
99+
\ZeroSpam\Core\Utilities::log( 'Project Honeypot Warning: IPv6 ip addresses not supported: ' . $ip );
100+
return false;
101+
}
98102

99103
$endpoint = $settings['project_honeypot_access_key']['value'] . '.' . $reversed_ip . '.dnsbl.httpbl.org';
100104
$dns_array = dns_get_record( $endpoint, DNS_A );
101105

102106
if ( ! isset( $dns_array[0]['ip'] ) ) {
103-
\ZeroSpam\Core\Utilities::log( 'Project Honeypot Error: could not query the IP' );
107+
\ZeroSpam\Core\Utilities::log( 'Project Honeypot Error: could not get DNS information for ' . $endpoint . ': ' . wp_json_encode( $dns_array ) );
104108
return false;
105109
}
106110

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ If hosting with Pantheon, see their [known issues page](https://pantheon.io/docs
109109

110110
= v5.4.4 =
111111

112+
* refactor(project honeypot): resolves #344, added additional check & debug info for ip type support
112113
* fix(wpforms): resolves #343, fix for jquery dependency
113114
* fix(registration): resolves #342, fix for failed registration output
114115
* fix(php8): resolves #341, fix for php8+ compatibility issue

0 commit comments

Comments
 (0)