config/danbooru_default_config.rb
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
# For downloads, if the host matches any of these IPs, block it
For downloads, if the host matches any of these IPs, block it
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
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
For downloads, if the host matches any of these IPs, block it
For downloads if the host matches any of these IPs block it
ip_addr