12/7/2023 0 Comments Unblock ip cloudflare![]() $r holds a boolean value - which is unprintable convert $response to an associative array and place into $r Uncomment the following line to see $response A given cURL operation should only take We setup a http POST, and provide %postdataĬurl_setopt($ch, CURLOPT_POSTFIELDS, $postdata) 'notes'=>'This is a block rule created by API4' the following line converts the json response into an associative array if you wish to process the output further, Tell cURL to return the response output as a string.Ĭurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) A given cURL operation should only take 5 seconds max. trying to connect to the URL in question.Ĭurl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5) Tell cURL that it should only spend 5 seconds We setup a http GET by the CURLOPT_URL option and provide an URLĬurl_setopt($ch, CURLOPT_URL, $apiurl."?".$qrydata) Ĭurl_setopt($ch, CURLOPT_HTTPHEADER, $httphead) Simply amend the $authemail and $authkey in each script and run them in php. cf_unblockip.php – unblock an ip by supplying an ip address as argument.cf_blockip.php – block an ip by supplying an ip address as argument.This is good for checking your firewall or for debugging cf_getaccesslist.php – dump the firewall access list in json format.On CF there are also Account and Organization level rule so you may need to amend the URL to suit your need. Please note I am using “User Level” rules. I also added some connection time-out and error checkings. I’ve gone a bit further – I added a search where by supplying an IP address and the script can locate the object ID and delete it from the Firewall access list. He has created the backbones of the php scripts. Thanks to andrieslouw at github I didn’t have to reinvent the wheel. ![]() Using curl directly is a bit cumbersome, so I created a few php helper scripts. I want to use the new APIs to block IP addresses using fail2ban. ![]() Cloudflare has upgraded their API to version 4 some while ago.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |