From 3caae2dee2f2e31b73006d6c237af5aecce6d41b Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Sun, 22 May 2016 10:28:58 +0200 Subject: [PATCH] Add fail2ban filter --- dynastie/views.py | 5 ++++- misc/apache-dynastie.conf | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 misc/apache-dynastie.conf diff --git a/dynastie/views.py b/dynastie/views.py index c83d8c5..d6e0500 100755 --- a/dynastie/views.py +++ b/dynastie/views.py @@ -806,7 +806,10 @@ def add_comment(request, post_id, parent_id): # Anti robot !! if request.POST['email'] != '': - print 'fucking robot' + if 'HTTP_X_REAL_IP' in request.META: + print 'Dynastie : fucking robot %s' % (request.META['HTTP_X_REAL_IP']) + else: + print 'Dynastie : fucking robot %s' % (request.META['REMOTE_ADDR']) return HttpResponseRedirect(ref) post = Post.objects.get(pk=post_id) diff --git a/misc/apache-dynastie.conf b/misc/apache-dynastie.conf new file mode 100644 index 0000000..cba5991 --- /dev/null +++ b/misc/apache-dynastie.conf @@ -0,0 +1,18 @@ +# Fail2Ban apache-dynastie filter +# + +[INCLUDES] + +# Read common prefixes. If any customizations available -- read them from +# apache-common.local +before = apache-common.conf + +[Definition] + +failregex = ^\[[^]]*\] \[wsgi\:error\] \[pid [0-9]+\] Dynastie : fucking robot $ + +ignoreregex = + +# http://indefero.soutade.fr/p/dynastie +# [Sun May 22 10:10:33.804242 2016] [wsgi:error] [pid 10514] Dynastie : fucking robot 192.168.1.1 +# Author: Grégory Soutadé