public static function HttpblEvaluator::makeHosts in http:BL 8
Quickly make up to 255 evaluated hosts of a certain status and expire time.
@internal $count ---------------------------------------------------------------------------
Example uses: Execute in devel/php to make dummy hosts.
Also executable in drush as "drush mho".
use Drupal\httpbl\Utility\Makehosts; Makehosts::makeHosts(); // Use defaults and create 255 safe hosts that will expire in 5 minutes. Useful for testing Cron.
use Drupal\httpbl\Utility\Makehosts; Makehosts::makeHosts(50,2, 60, '129.0.1.'); Make some grey-listed and edit them.
use Drupal\httpbl\Utility\Makehosts; Makehosts::makeHosts(1,0, 120, '127.0.0.' ); Make a localhost that lasts 2 minutes. Then delete it (it will come right back, from Project Honeypot!)
Parameters
int $max The number of hosts to be generated.:
int $status The status (0=safe, 1=blackisted, 2=grey-listed):
int $offset The time from now the host should expire.:
string $pattern The pattern used for IP addresses.:
File
- src/
HttpblEvaluator.php, line 620
Class
- HttpblEvaluator
- HttpblEvaluator evaluates visitor/host page requests.
Namespace
Drupal\httpblCode
public static function makeHosts($max = 255, $status = 0, $offset = 300, $pattern = '127.0.1.') {
$limit = 255;
$max <= $limit ?: ($max = $limit);
$count = 1;
$max = $max + 1;
while ($count < $max) {
$ip = $pattern . $count;
$host = Host::create([
'host_ip' => $ip,
'host_status' => $status,
'expire' => \Drupal::time()
->getRequestTime() + $offset,
'source' => t(HTTPBL_DRUSH_CREATED),
]);
$host
->save();
$logTrapper = \Drupal::service('httpbl.logtrapper');
$logTrapper
->trapDebug('@ip test host created with makeHosts().', [
'@ip' => $ip,
]);
$count++;
}
}