bot_detection 1.0.7 → 1.0.8
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/bot_detection/instance_methods.rb +9 -9
- data/lib/bot_detection/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ba34f3960eac21e99b508be65a2d83887d638e5
|
|
4
|
+
data.tar.gz: 5ec50864e018bc31c19463b82d3d25ab9a602dbe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95f902fae54db98d1f7b43265844ac93921b447f80fff6334b39a71b833c832ca2738736fc675db739673843d9c50921fa4c34f2d64fc008a74269239a5dc9a1
|
|
7
|
+
data.tar.gz: 19884845b25d0c8198d5c68cc6bfd06c843d5f561fa463e61cf1c66593f6a54a1f200efabdeaf3efaa891651ee16aecbbb5a81c30acf291bbcdb690f445f2d1c
|
data/CHANGELOG.md
CHANGED
|
@@ -3,19 +3,19 @@ require_relative 'google_user_agents.rb'
|
|
|
3
3
|
require_relative 'bot_user_agents.rb'
|
|
4
4
|
require_relative 'search_engine_user_agents.rb'
|
|
5
5
|
|
|
6
|
-
module BotDetection::InstanceMethods
|
|
6
|
+
module BotDetection::InstanceMethods
|
|
7
7
|
def is_known_crawler?
|
|
8
8
|
BotDetection::BotUserAgents.include?(user_agent) || is_search_engine_crawler?(reverse_lookup: false)
|
|
9
9
|
end
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
def is_search_engine_crawler? options = {}
|
|
12
12
|
remote_ip = options.delete(:ip) || options.delete(:ip_address) || request.remote_ip
|
|
13
13
|
return false if remote_ip.blank?
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
reverse_lookup = options.delete(:reverse_lookup)
|
|
16
16
|
reverse_lookup = true if reverse_lookup.nil?
|
|
17
|
-
|
|
18
|
-
return false unless is_known_search_engine_crawler?
|
|
17
|
+
|
|
18
|
+
return false unless is_known_search_engine_crawler?
|
|
19
19
|
return true unless reverse_lookup
|
|
20
20
|
return true if options.delete(:development)
|
|
21
21
|
|
|
@@ -23,11 +23,11 @@ module BotDetection::InstanceMethods
|
|
|
23
23
|
return false if host.nil?
|
|
24
24
|
domain = PublicSuffix.parse(host) rescue nil
|
|
25
25
|
return false if domain.nil?
|
|
26
|
-
|
|
26
|
+
|
|
27
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)
|
|
28
28
|
host_ip = get_hostip(host)
|
|
29
29
|
return false if host_ip.nil?
|
|
30
|
-
host_ip
|
|
30
|
+
host_ip == remote_ip
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def is_google?
|
|
@@ -38,11 +38,11 @@ protected
|
|
|
38
38
|
def is_known_search_engine_crawler?
|
|
39
39
|
is_google? || BotDetection::SearchEngineUserAgents.include?(user_agent)
|
|
40
40
|
end
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
def get_hostname(ip_address)
|
|
43
43
|
Socket.gethostbyaddr(ip_address.split(".").map(&:to_i).pack("CCCC")).first rescue nil
|
|
44
44
|
end
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
def get_hostip(host)
|
|
47
47
|
Socket.gethostbyname(host).last.unpack("C*").join(".") rescue nil
|
|
48
48
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bot_detection
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nils Berenbold
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-01-
|
|
11
|
+
date: 2015-01-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: public_suffix
|