Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Apply blocklist.de to shorewall, intended for use as a cron script
<?php
$url = 'http://api.blocklist.de/getlast.php?time=';
$cachefile = '/tmp/blocklist.de.cache';
$cachetime = 0 + @filemtime($cachefile);
$url = $url . $cachetime;
$result = file_get_contents($url);
if (is_string($result)) {
file_put_contents($cachefile, $result, FILE_APPEND);
$arr = explode("\n", $result);
foreach ($arr as $ip) {
if(strlen($ip)) {
echo "Blocking ${ip}\n";
shell_exec("shorewall drop ".escapeshellarg($ip));
}
}
} else {
echo "Failed to update blocklist";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment