From eddff747d68412ae3074f01838ca5a645fc21698 Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 26 Oct 2021 23:58:23 -0500 Subject: [PATCH] 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. --- app/logical/ip_lookup.rb | 1 + test/unit/ip_geolocation_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/logical/ip_lookup.rb b/app/logical/ip_lookup.rb index 13085b009..2d5cbf9ef 100644 --- a/app/logical/ip_lookup.rb +++ b/app/logical/ip_lookup.rb @@ -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 diff --git a/test/unit/ip_geolocation_test.rb b/test/unit/ip_geolocation_test.rb index b71470512..df2988b94 100644 --- a/test/unit/ip_geolocation_test.rb +++ b/test/unit/ip_geolocation_test.rb @@ -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