Fix for blocked ip update script

This commit is contained in:
Kyle Drake 2018-12-20 05:07:07 +00:00
parent ee3516829f
commit a733a3b742

View file

@ -47,17 +47,13 @@ end
desc 'Update banned IPs list' desc 'Update banned IPs list'
task :update_blocked_ips => [:environment] do task :update_blocked_ips => [:environment] do
uri = URI.parse('http://www.stopforumspam.com/downloads/listed_ip_90.zip')
blocked_ips_zip = Tempfile.new('blockedipszip', Dir.tmpdir)
blocked_ips_zip.binmode
Net::HTTP.start(uri.host, uri.port) do |http| IO.copy_stream(
resp = http.get(uri.path) open('http://www.stopforumspam.com/downloads/listed_ip_90.zip'),
blocked_ips_zip.write(resp.body) '/tmp/listed_ip_90.zip'
blocked_ips_zip.flush )
end
Zip::Archive.open(blocked_ips_zip.path) do |ar| Zip::Archive.open('/tmp/listed_ip_90.zip') do |ar|
ar.fopen('listed_ip_90.txt') do |f| ar.fopen('listed_ip_90.txt') do |f|
ips = f.read ips = f.read
insert_hashes = [] insert_hashes = []