34 |
- |
1 |
#
|
|
|
2 |
# Author: Mike Rushton
|
|
|
3 |
#
|
39 |
- |
4 |
# IMPORTANT
|
34 |
- |
5 |
#
|
39 |
- |
6 |
# Please set jail.local's permission to 640 because it contains your CF API key.
|
34 |
- |
7 |
#
|
39 |
- |
8 |
# This action depends on curl.
|
|
|
9 |
# Referenced from http://www.normyee.net/blog/2012/02/02/adding-cloudflare-support-to-fail2ban by NORM YEE
|
|
|
10 |
#
|
|
|
11 |
# To get your CloudFlare API Key: https://www.cloudflare.com/a/account/my-account
|
71 |
- |
12 |
#
|
|
|
13 |
# CloudFlare API error codes: https://www.cloudflare.com/docs/host-api.html#s4.2
|
34 |
- |
14 |
|
|
|
15 |
[Definition]
|
|
|
16 |
|
|
|
17 |
# Option: actionstart
|
|
|
18 |
# Notes.: command executed once at the start of Fail2Ban.
|
|
|
19 |
# Values: CMD
|
|
|
20 |
#
|
|
|
21 |
actionstart =
|
|
|
22 |
|
|
|
23 |
# Option: actionstop
|
|
|
24 |
# Notes.: command executed once at the end of Fail2Ban
|
|
|
25 |
# Values: CMD
|
|
|
26 |
#
|
|
|
27 |
actionstop =
|
|
|
28 |
|
|
|
29 |
# Option: actioncheck
|
|
|
30 |
# Notes.: command executed once before each actionban command
|
|
|
31 |
# Values: CMD
|
|
|
32 |
#
|
|
|
33 |
actioncheck =
|
|
|
34 |
|
|
|
35 |
# Option: actionban
|
|
|
36 |
# Notes.: command executed when banning an IP. Take care that the
|
|
|
37 |
# command is executed with Fail2Ban user rights.
|
|
|
38 |
# Tags: <ip> IP address
|
|
|
39 |
# <failures> number of failures
|
|
|
40 |
# <time> unix timestamp of the ban time
|
|
|
41 |
# Values: CMD
|
|
|
42 |
#
|
39 |
- |
43 |
actionban = curl -s -o /dev/null https://www.cloudflare.com/api_json.html -d 'a=ban' -d 'tkn=<cftoken>' -d 'email=<cfuser>' -d 'key=<ip>'
|
|
|
44 |
|
34 |
- |
45 |
# Option: actionunban
|
|
|
46 |
# Notes.: command executed when unbanning an IP. Take care that the
|
|
|
47 |
# command is executed with Fail2Ban user rights.
|
|
|
48 |
# Tags: <ip> IP address
|
|
|
49 |
# <failures> number of failures
|
|
|
50 |
# <time> unix timestamp of the ban time
|
|
|
51 |
# Values: CMD
|
|
|
52 |
#
|
39 |
- |
53 |
actionunban = curl -s -o /dev/null https://www.cloudflare.com/api_json.html -d 'a=nul' -d 'tkn=<cftoken>' -d 'email=<cfuser>' -d 'key=<ip>'
|
34 |
- |
54 |
|
|
|
55 |
[Init]
|
|
|
56 |
|
39 |
- |
57 |
# If you like to use this action with mailing whois lines, you could use the composite action
|
|
|
58 |
# action_cf_mwl predefined in jail.conf, just define in your jail:
|
|
|
59 |
#
|
|
|
60 |
# action = %(action_cf_mwl)s
|
|
|
61 |
# # Your CF account e-mail
|
|
|
62 |
# cfemail =
|
|
|
63 |
# # Your CF API Key
|
|
|
64 |
# cfapikey =
|
34 |
- |
65 |
|
39 |
- |
66 |
cftoken =
|
|
|
67 |
|
|
|
68 |
cfuser =
|