watch the httpd access log rather than the mysql database
This commit is contained in:
parent
3fc9117bff
commit
ef85d6281f
@ -6,10 +6,8 @@ stopforumspam API](https://www.stopforumspam.com/usage) and
|
|||||||
To deploy:
|
To deploy:
|
||||||
|
|
||||||
* modify the configuration variables in the scripts
|
* modify the configuration variables in the scripts
|
||||||
* copy the scripts to /usr/local/bin
|
* copy the scripts to `/usr/local/bin`
|
||||||
* add a line like `0 0 * * * /usr/local/bin/q2a_usercheck.sh` to root's
|
* register `q2a_usercheck.sh` as a systemd unit or rc script
|
||||||
crontab. Alternatively, you can add `q2a_usercheck.sh` to /etc/cron.daily/
|
|
||||||
if it exists (for example, on debian).
|
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
* add support for pf
|
* add support for pf
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
mysql_user='q2a_user'
|
logf='/var/log/nginx/access.log'
|
||||||
mysql_pass='q2a_pass'
|
cache='/tmp/forumspam_cache'
|
||||||
mysql_db='q2a_db'
|
|
||||||
|
|
||||||
tmpf=`mktemp`
|
install -m 600 /dev/null $cache
|
||||||
yesterday=`date -d yesterday '+%Y-%m-%d %H:%M:%S'`
|
|
||||||
|
|
||||||
mysql -u $mysql_user "--password=$mysql_pass" $mysql_db -e \
|
tail -F $logf | while read line ; do
|
||||||
"SELECT INET_NTOA(CONV(HEX(createip),16,10))
|
case $line in (*"POST"*)
|
||||||
FROM qa_users WHERE created >= '$yesterday';
|
ip=`echo $line | awk '{print $1}'`
|
||||||
" | sed '1d' | sort | uniq > $tmpf
|
if ! grep -q $ip $cache; then
|
||||||
|
echo $ip >> $cache
|
||||||
while read ip ; do
|
|
||||||
/usr/local/bin/forumspam.sh "$ip"
|
/usr/local/bin/forumspam.sh "$ip"
|
||||||
done < $tmpf
|
fi
|
||||||
|
esac
|
||||||
rm $tmpf
|
done
|
||||||
|
Reference in New Issue
Block a user