bot_detection 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/bot_detection/instance_methods.rb +6 -3
- data/lib/bot_detection/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 734ee8ae0a3565c70058e067166600e919ed2046
|
4
|
+
data.tar.gz: 14cec0cae15256ed72bb42cf0b373b8894a08660
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d0c195f9fd461e1cbc3eb639f40ea309547940b3f7a0586a8ca23ae0fa7dab77c1b969a8137be6dffe89c3c82c6f10efc5b6bed3bd15c24ca8bf3b51232a6b6
|
7
|
+
data.tar.gz: 07fdf6125c9af23a8d9fc7a3482c9efc9ff262892b13d8d416fde3f8021592272c0ac6e42ab31de0819a990a3e0411dced675b9cba7fd11d39cea9293e6ec0bd
|
data/CHANGELOG.md
CHANGED
@@ -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)
|
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
|