bot_detection 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e95e799dda05201285a7785ebcdbd4bfac871278
4
- data.tar.gz: a33bfd5449247970885c9687a3b7d9fbd7c14d0e
3
+ metadata.gz: 734ee8ae0a3565c70058e067166600e919ed2046
4
+ data.tar.gz: 14cec0cae15256ed72bb42cf0b373b8894a08660
5
5
  SHA512:
6
- metadata.gz: d6fb0bbbc3591a8cc295286b7cc2534fe38130cb9a6e422542aecf3aecbe642bb426a2fc222fd4a15e45ab6e72c6dc9ef10da2d9da4d44cbb512eeee79ba84bd
7
- data.tar.gz: 89aeb6ec92cc70e203e390ceea71cb49d3edd523e11fb0f3fbd0a65a82e8e6ef28bc082772966c1deacfc62b6ceed720e8e05090fc12383499ebc088ac2e40d6
6
+ metadata.gz: 0d0c195f9fd461e1cbc3eb639f40ea309547940b3f7a0586a8ca23ae0fa7dab77c1b969a8137be6dffe89c3c82c6f10efc5b6bed3bd15c24ca8bf3b51232a6b6
7
+ data.tar.gz: 07fdf6125c9af23a8d9fc7a3482c9efc9ff262892b13d8d416fde3f8021592272c0ac6e42ab31de0819a990a3e0411dced675b9cba7fd11d39cea9293e6ec0bd
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  #### Release 1.0.2
4
4
 
5
+ - fixed a bug causing the lookup to throw an exception if the reverse lookup fails
6
+
7
+ #### Release 1.0.2
8
+
5
9
  - added some new user agents to the list of known bots
6
10
 
7
11
  #### Release 1.0.1
@@ -20,11 +20,14 @@ module BotDetection::InstanceMethods
20
20
  return true if options.delete(:development)
21
21
 
22
22
  host = get_hostname(remote_ip)
23
+ return false if host.nil?
23
24
  domain = PublicSuffix.parse(host) rescue nil
24
25
  return false if domain.nil?
25
26
 
26
27
  return false unless ["crawl.yahoo.net", "googlebot.com", "google.com", "search.msn.com", "ask.com", "yandex.net", "yandex.com", "yandex.ru", "baidu.com", "baidu.jp"].include?(domain.domain.downcase)
27
- get_hostip(host) == remote_ip
28
+ host_ip = get_hostip(host)
29
+ return false if host_ip.nil?
30
+ host_ip = remote_ip
28
31
  end
29
32
 
30
33
  def is_google?
@@ -37,11 +40,11 @@ protected
37
40
  end
38
41
 
39
42
  def get_hostname(ip_address)
40
- Socket.gethostbyaddr(ip_address.split(".").map(&:to_i).pack("CCCC")).first
43
+ Socket.gethostbyaddr(ip_address.split(".").map(&:to_i).pack("CCCC")).first rescue nil
41
44
  end
42
45
 
43
46
  def get_hostip(host)
44
- Socket.gethostbyname(host).last.unpack("C*").join(".")
47
+ Socket.gethostbyname(host).last.unpack("C*").join(".") rescue nil
45
48
  end
46
49
 
47
50
  def user_agent
@@ -1,3 +1,3 @@
1
1
  module BotDetection
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bot_detection
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nils Berenbold