Subversion Repositories configs

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
192 - 1
#
2
# Author: Mike Rushton
3
#
4
# IMPORTANT
5
#
6
# Please set jail.local's permission to 640 because it contains your CF API key.
7
#
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
12
#
13
# CloudFlare API error codes: https://www.cloudflare.com/docs/host-api.html#s4.2
14
 
15
[Definition]
16
 
17
# Option:  actionstart
18
# Notes.:  command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false).
19
# Values:  CMD
20
#
21
actionstart =
22
 
23
# Option:  actionstop
24
# Notes.:  command executed at the stop of jail (or 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
#
43
# API v1
44
#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>'
45
# API v4
46
actionban = curl -s -o /dev/null -X POST -H 'X-Auth-Email: <cfuser>' -H 'X-Auth-Key: <cftoken>' \
47
            -H 'Content-Type: application/json' -d '{ "mode": "block", "configuration": { "target": "ip", "value": "<ip>" } }' \
48
            https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules
49
 
50
# Option:  actionunban
51
# Notes.:  command executed when unbanning an IP. Take care that the
52
#          command is executed with Fail2Ban user rights.
53
# Tags:    <ip>  IP address
54
#          <failures>  number of failures
55
#          <time>  unix timestamp of the ban time
56
# Values:  CMD
57
#
58
# API v1
59
#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>'
60
# API v4
61
actionunban = curl -s -o /dev/null -X DELETE -H 'X-Auth-Email: <cfuser>' -H 'X-Auth-Key: <cftoken>' \
62
              https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules/$(curl -s -X GET -H 'X-Auth-Email: <cfuser>' -H 'X-Auth-Key: <cftoken>' \
63
              'https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules?mode=block&configuration_target=ip&configuration_value=<ip>&page=1&per_page=1' | cut -d'"' -f6)
64
 
65
[Init]
66
 
67
# If you like to use this action with mailing whois lines, you could use the composite action
68
# action_cf_mwl predefined in jail.conf, just define in your jail:
69
#
70
# action = %(action_cf_mwl)s
71
# # Your CF account e-mail
72
# cfemail  =
73
# # Your CF API Key
74
# cfapikey =
75
 
76
cftoken =
77
 
78
cfuser =