config: remove banned_ip_for_download? option.
* Remove `banned_ip_for_download?` config option. This isn't something that usually needs to be configured. * Replace the `ipaddress` gem with `ipaddress_2`. The `ipaddress` gem has several methods we need (`link_local?`, etc) that are only available in master because the gem hasn't had an official release in several years. `ipaddress_2` is a fork that is more actively maintained.
This commit is contained in:
@@ -392,39 +392,6 @@ module Danbooru
|
||||
"zDMSATq0W3hmA5p3rKTgD"
|
||||
end
|
||||
|
||||
# For downloads, if the host matches any of these IPs, block it
|
||||
def banned_ip_for_download?(ip_addr)
|
||||
raise ArgumentError unless ip_addr.is_a?(IPAddr)
|
||||
|
||||
if ip_addr.ipv4?
|
||||
if IPAddr.new("127.0.0.1") == ip_addr
|
||||
true
|
||||
elsif IPAddr.new("169.254.0.0/16").include?(ip_addr)
|
||||
true
|
||||
elsif IPAddr.new("10.0.0.0/8").include?(ip_addr)
|
||||
true
|
||||
elsif IPAddr.new("172.16.0.0/12").include?(ip_addr)
|
||||
true
|
||||
elsif IPAddr.new("192.168.0.0/16").include?(ip_addr)
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
elsif ip_addr.ipv6?
|
||||
if IPAddr.new("::1") == ip_addr
|
||||
true
|
||||
elsif IPAddr.new("fe80::/10").include?(ip_addr)
|
||||
true
|
||||
elsif IPAddr.new("fd00::/8").include?(ip_addr)
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
# The url of the Discord server associated with this site.
|
||||
def discord_server_url
|
||||
nil
|
||||
|
||||
Reference in New Issue
Block a user