Fix for banned ips update

This commit is contained in:
Kyle Drake 2022-12-03 22:34:13 +00:00
parent a2098a300e
commit 2be4fbbde8

View file

@ -53,13 +53,17 @@ end
desc 'Update banned IPs list' desc 'Update banned IPs list'
task :update_blocked_ips => [:environment] do task :update_blocked_ips => [:environment] do
IO.copy_stream( filename = 'listed_ip_365_ipv46'
open('https://www.stopforumspam.com/downloads/listed_ip_90.zip'),
'/tmp/listed_ip_90.zip'
)
Zip::Archive.open('/tmp/listed_ip_90.zip') do |ar| File.open("/tmp/#{filename}.zip", 'wb') do |file|
ar.fopen('listed_ip_90.txt') do |f| response = HTTP.get "https://www.stopforumspam.com/downloads/#{filename}.zip"
response.body.each do |chunk|
file.write chunk
end
end
Zip::Archive.open("/tmp/#{filename}.zip") do |ar|
ar.fopen("#{filename}.txt") do |f|
ips = f.read ips = f.read
insert_hashes = [] insert_hashes = []
ips.each_line {|ip| insert_hashes << {ip: ip.strip, created_at: Time.now}} ips.each_line {|ip| insert_hashes << {ip: ip.strip, created_at: Time.now}}
@ -71,6 +75,8 @@ task :update_blocked_ips => [:environment] do
end end
end end
end end
FileUtils.rm "/tmp/#{filename}.zip"
end end
desc 'parse tor exits' desc 'parse tor exits'