Coopeh / Cloudflare-Blacklist-Whitelist-Bulk

Blacklist, whitelist and unlist IPs in bulk using Cloudflare's API
5 stars 0 forks source link

issue parsing txt file #1

Open inspiredearth opened 8 years ago

inspiredearth commented 8 years ago

Hi there, Thanks for making this available. I have tried to use it to whitelist the IPs from here: https://uptimerobot.com/inc/files/ips/IPv4.txt

But it comes back with an error:

Line break detected 69.162.124.226 is not valid. 69.162.124.227 is not valid. 69.162.124.228 is not valid. 69.162.124.229 is not valid. 69.162.124.230 is not valid. 69.162.124.231 is not valid. 69.162.124.232 is not valid. 69.162.124.233 is not valid. 69.162.124.234 is not valid. 69.162.124.235 is not valid. 69.162.124.236 is not valid. 69.162.124.237 is not valid. 69.162.124.238 is not valid. 46.137.190.132 is not valid. 122.248.234.23 is not valid. 188.226.183.141 is not valid. 178.62.52.237 is not valid. 54.79.28.129 is not valid. 54.94.142.218 is not valid. 104.131.107.63 is not valid. 54.67.10.127 is not valid. 54.64.67.106 is not valid. is not valid. 0 IPs detected. Whitelisting with Cloudflare now... 
Notice: Undefined property: stdClass::$response in /home/jonathan/public_html/cloudflare.php on line 145

Notice: Trying to get property of non-object in /home/jonathan/public_html/cloudflare.php on line 145

Notice: Trying to get property of non-object in /home/jonathan/public_html/cloudflare.php on line 145
- Error 

etc. It is not clear to me why these valid IPv4 addresses are generating errors.

Any suggestions on how the code can be improved in order to resolve this issue?

Coopeh commented 8 years ago

Hi,

No problem. I've had a very quick look but not overly sure why it won't accept the uptimerobot txt file, I'll try get round to fixing it this weekend. In the meantime, if you just paste the IPs into the array then that works fine.

"69.162.124.226","69.162.124.227","69.162.124.228","69.162.124.229","69.162.124.230","69.162.124.231","69.162.124.232","69.162.124.233","69.162.124.234","69.162.124.235","69.162.124.236","69.162.124.237","69.162.124.238","46.137.190.132","122.248.234.23","188.226.183.141","178.62.52.237","54.79.28.129","54.94.142.218","104.131.107.63","54.67.10.127","54.64.67.106"

Cheers, Ed

inspiredearth commented 8 years ago

Thanks Ed. Much appreciated. Pasting as an array is what I ended up doing, and that worked fine. Very glad you made this script available. When Cloudflare provided zero means to import a large list of IPs into their firewall, except via the API, I thought I was going to be stuck entering them all by hand. I’ve got about 60 more to add. Will use your script for them too.

Cheers, Jonathan