fixes for ip block updater

This commit is contained in:
Kyle Drake 2015-01-01 10:45:04 -06:00
parent 2368ec2b89
commit e7fc76a938

View file

@ -53,7 +53,6 @@ end
desc 'Update banned IPs list'
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, 'wb')
blocked_ips_zip.binmode
@ -64,8 +63,9 @@ task :update_blocked_ips => [:environment] do
blocked_ips_zip.flush
end
Zip::File.open(blocked_ips_zip.path) do |zip_file|
ips = zip_file.glob('listed_ip_90.txt').first.get_input_stream.read
Zip::Archive.open(blocked_ips_zip.path) do |ar|
ar.fopen('listed_ip_90.txt') do |f|
ips = f.read
insert_hashes = []
ips.each_line {|ip| insert_hashes << {ip: ip.strip, created_at: Time.now}}
ips = nil
@ -76,6 +76,7 @@ task :update_blocked_ips => [:environment] do
end
end
end
end
desc 'Compile domain map for nginx'
task :compile_domain_map => [:environment] do