11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/bot_detection/instance_methods.rb', line 11
def is_search_engine_crawler? options = {}
remote_ip = options.delete(:ip) || options.delete(:ip_address) || request.remote_ip
return false if remote_ip.blank?
reverse_lookup = options.delete(:reverse_lookup)
reverse_lookup = true if reverse_lookup.nil?
return false unless is_known_search_engine_crawler?
return true unless reverse_lookup
return true if options.delete(:development)
host = get_hostname(remote_ip)
return false if host.nil?
domain = PublicSuffix.parse(host) rescue nil
return false if domain.nil?
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)
host_ip = get_hostip(host)
return false if host_ip.nil?
host_ip == remote_ip
end
|