Created
November 6, 2014 08:42
-
-
Save kiote/1462e08cc5e9f5926be5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From adc62760f101717507e67fcc71f1b24731084963 Mon Sep 17 00:00:00 2001 | |
From: Ekaterina Krivich <[email protected]> | |
Date: Thu, 6 Nov 2014 11:37:15 +0300 | |
Subject: [PATCH] checking for SSL error | |
also previos version does not check errors at all | |
errors raised not at the moment object crated, | |
but when we have first usage: | |
not here service = ::Plugins::IPDBAtScraper.new(ip_address) | |
but here isp = service.isp | |
related to #119 | |
--- | |
app/jobs/reviews/isp_and_org_lookup.rb | 12 +++++++----- | |
1 file changed, 7 insertions(+), 5 deletions(-) | |
diff --git a/app/jobs/reviews/isp_and_org_lookup.rb b/app/jobs/reviews/isp_and_org_lookup.rb | |
index b816335..1073ccb 100644 | |
--- a/app/jobs/reviews/isp_and_org_lookup.rb | |
+++ b/app/jobs/reviews/isp_and_org_lookup.rb | |
@@ -12,13 +12,15 @@ module Reviews | |
Delayed::Worker.logger.debug("### #{self.class.name} ###") | |
ip_address = review_metadata.client_ipaddress | |
Delayed::Worker.logger.debug("Looking up IP address: #{ip_address}") | |
- service = begin | |
- ::Plugins::IPDBAtScraper.new(ip_address) | |
- rescue OpenURI::HTTPError | |
+ begin | |
+ service = ::Plugins::IPDBAtScraper.new(ip_address) | |
+ isp, organization = service.isp, service.organization | |
+ rescue OpenURI::HTTPError, OpenSSL::SSL::SSLError | |
Delayed::Worker.logger.debug('IPdb failed, trying Maxmind...') | |
- ::Plugins::IspMaxmind.new(ip_address) | |
+ service = ::Plugins::IspMaxmind.new(ip_address) | |
+ isp, organization = service.isp, service.organization | |
end | |
- isp, organization = service.isp, service.organization | |
+ | |
Delayed::Worker.logger.debug("ISP found: #{isp}") | |
Delayed::Worker.logger.debug("Organization found: #{organization}") | |
if isp || organization | |
-- | |
1.9.3 (Apple Git-50) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment