mirror of https://github.com/fail2ban/fail2ban
added fallback using tr and sed (jq is optional now)
parent
1c1b671c74
commit
01e92ce4a6
|
@ -5,7 +5,7 @@
|
||||||
#
|
#
|
||||||
# Please set jail.local's permission to 640 because it contains your CF API key.
|
# Please set jail.local's permission to 640 because it contains your CF API key.
|
||||||
#
|
#
|
||||||
# This action depends on curl and jq.
|
# 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
|
# 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
|
# To get your CloudFlare API Key: https://www.cloudflare.com/a/account/my-account
|
||||||
|
@ -60,7 +60,7 @@ actionban = curl -s -o /dev/null -X POST <_cf_api_prms> \
|
||||||
# API v4
|
# API v4
|
||||||
actionunban = id=$(curl -s -X GET <_cf_api_prms> \
|
actionunban = id=$(curl -s -X GET <_cf_api_prms> \
|
||||||
"<_cf_api_url>?mode=block&configuration_target=ip&configuration_value=<ip>&page=1&per_page=1¬es=Fail2Ban%%20<name>" \
|
"<_cf_api_url>?mode=block&configuration_target=ip&configuration_value=<ip>&page=1&per_page=1¬es=Fail2Ban%%20<name>" \
|
||||||
| jq -r '.result[0].id')
|
| { jq -r '.result[0].id' 2>/dev/null || tr -d '\n' | sed -nE 's/^.*"result"\s*:\s*\[\s*\{\s*"id"\s*:\s*"([^"]+)".*$/\1/p'; })
|
||||||
if [ -z "$id" ]; then echo "<name>: id for <ip> cannot be found"; exit 0; fi;
|
if [ -z "$id" ]; then echo "<name>: id for <ip> cannot be found"; exit 0; fi;
|
||||||
curl -s -o /dev/null -X DELETE <_cf_api_prms> "<_cf_api_url>/$id"
|
curl -s -o /dev/null -X DELETE <_cf_api_prms> "<_cf_api_url>/$id"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue