Fix certain IPs not being recognized as proxies.

Fix certain IPs (namely Digital Ocean IPs) no longer being recognized as
proxy IPs by the Ipregistry.co API. Caused by some sudden change in the
API.
This commit is contained in:
evazion
2021-10-26 23:58:23 -05:00
parent 082544ab03
commit eddff747d6
2 changed files with 3 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ class IpLookup
def is_proxy?
return true if ip_addr.is_tor?
return true if response.dig(:connection, :type) == "hosting"
response[:security].present? && response[:security].values.any?
end

View File

@@ -57,13 +57,13 @@ class IpGeolocationTest < ActiveSupport::TestCase
should "work for a proxy IP" do
@ip = IpGeolocation.create_or_update!("31.214.184.59")
assert_equal("Soluciones Corporativas IP SL", @ip.organization)
assert_equal("Soluciones Corporativas IP (SCIP)", @ip.organization)
assert_equal(true, @ip.is_proxy?)
end
should "work for a cloud hosting IP" do
@ip = IpGeolocation.create_or_update!("157.230.244.215")
assert_equal("DigitalOcean LLC", @ip.organization)
assert_equal("DigitalOcean, LLC", @ip.organization)
assert_equal(true, @ip.is_proxy?)
end