Add more IP autoban info to watchdog log messages

Created on 1 May 2020, over 4 years ago
Updated 3 May 2024, 7 months ago

It would be nice to see all the information in the Watchdog

	$banned_ip = $item->hostname; $banned_ip_count = $item->hcount;
	if(!$host = gethostbyaddr($banned_ip)) { $host = NULL; }
	$provider = $banManagerData['ban_name'];
	/*Get subnet*/
		$mask = '255.255.255.0'; $wcmask = long2ip( ~ip2long($mask) );
		$subnet = long2ip( ip2long($banned_ip) & ip2long($mask) ); $bcast = long2ip( ip2long($banned_ip) | ip2long($wcmask) );
		$banned_ip_range = $subnet  . '…' . $bcast;
	$message_wt = 'Has been banned: '.$banned_ip . ' (' . $host . ') Rule: '. $rule . ' Count:'. $banned_ip_count . '; Provider: ' . $provider . ' Range:' . $banned_ip_range;
	\Drupal::logger('Autoban')->notice($message_wt); // WT Logs a notice
Feature request
Status

Active

Version

1.6

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇪🇨Ecuador jwilson3

    I totally agree, and would like to bump this issue.

    If you compare Autoban watchdog log messages with Perimeter Defense module's watchdog log messages, you see room for improvement.

    Some improvements I suggest be implemented here include:

    • Each IP gets its own log message, instead of a generic message stating a Total of 3 IPs were blocked. This is unhelpful information.
    • Explain which Rule was triggered for the ban action.
    • Provide any additional context and info like from the code snippet in the issue summary above.

  • 🇪🇨Ecuador jwilson3

    While we're at it, we should also fix capitalization consistently for Autoban. The best practice is to use lowercase. (Note that Perimeter module also doesnt follow this best practices, but at least they're consistent and use Uppercase everywhere).

Production build 0.71.5 2024