mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
fixes for ip block updater
This commit is contained in:
parent
2368ec2b89
commit
e7fc76a938
1 changed files with 10 additions and 9 deletions
7
Rakefile
7
Rakefile
|
@ -53,7 +53,6 @@ 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')
|
uri = URI.parse('http://www.stopforumspam.com/downloads/listed_ip_90.zip')
|
||||||
blocked_ips_zip = Tempfile.new('blockedipszip', Dir.tmpdir, 'wb')
|
blocked_ips_zip = Tempfile.new('blockedipszip', Dir.tmpdir, 'wb')
|
||||||
blocked_ips_zip.binmode
|
blocked_ips_zip.binmode
|
||||||
|
@ -64,8 +63,9 @@ task :update_blocked_ips => [:environment] do
|
||||||
blocked_ips_zip.flush
|
blocked_ips_zip.flush
|
||||||
end
|
end
|
||||||
|
|
||||||
Zip::File.open(blocked_ips_zip.path) do |zip_file|
|
Zip::Archive.open(blocked_ips_zip.path) do |ar|
|
||||||
ips = zip_file.glob('listed_ip_90.txt').first.get_input_stream.read
|
ar.fopen('listed_ip_90.txt') do |f|
|
||||||
|
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}}
|
||||||
ips = nil
|
ips = nil
|
||||||
|
@ -75,6 +75,7 @@ task :update_blocked_ips => [:environment] do
|
||||||
DB[:blocked_ips].multi_insert insert_hashes
|
DB[:blocked_ips].multi_insert insert_hashes
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Compile domain map for nginx'
|
desc 'Compile domain map for nginx'
|
||||||
|
|
Loading…
Add table
Reference in a new issue