diff --git a/cfapi.conf b/cfapi.conf deleted file mode 100644 index 0240919..0000000 --- a/cfapi.conf +++ /dev/null @@ -1,18 +0,0 @@ -[Definition] - -actionstart = - -actionstop = - -actioncheck = - -actionban = curl -s -X POST https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules \ - -H "X-Auth-Email: " -H "X-Auth-Key: " -H "Content-Type: application/json" \ - --data '{"mode":"block","configuration":{"target":"ip","value":""},"notes":"Banned by Fail2Ban"}' - -actionunban = curl -s -X GET -H "X-Auth-Email: " -H "X-Auth-Key: " -H "Content-Type: application/json" \ - "https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules?page=1&per_page=5&mode=block&configuration.target=ip&configuration.value=¬es=Banned by Fail2Ban&match=all&order=configuration.value&direction=desc" | \ - python -c "import sys, json; print json.load(sys.stdin)['result'][0]['id'];" | \ - xargs -I@@ curl -s -X DELETE -H "X-Auth-Email: " -H "X-Auth-Key: " -H "Content-Type: application/json" https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules/@@ - -[Init] diff --git a/cloudflare.conf b/cloudflare.conf new file mode 100644 index 0000000..633bb83 --- /dev/null +++ b/cloudflare.conf @@ -0,0 +1,88 @@ +# +# Author: Mike Rushton +# +# IMPORTANT +# +# Please set jail.local's permission to 640 because it contains your CF API key. +# +# This action depends on curl (and optionally jq). +# Referenced from http://www.normyee.net/blog/2012/02/02/adding-cloudflare-support-to-fail2ban by NORM YEE +# +# To get your CloudFlare API Key: https://www.cloudflare.com/a/account/my-account +# +# CloudFlare API error codes: https://www.cloudflare.com/docs/host-api.html#s4.2 + +[Definition] + +# Option: actionstart +# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). +# Values: CMD +# +actionstart = + +# Option: actionstop +# Notes.: command executed at the stop of jail (or at the end of Fail2Ban) +# Values: CMD +# +actionstop = + +# Option: actioncheck +# Notes.: command executed once before each actionban command +# Values: CMD +# +actioncheck = + +# Option: actionban +# Notes.: command executed when banning an IP. Take care that the +# command is executed with Fail2Ban user rights. +# Tags: IP address +# number of failures +#