Sha256: 9b5bed1f9df6b11195dcc4093c7a9a96a8ec666fde7d4993f2e01671bfa6fa35
Contents?: true
Size: 746 Bytes
Versions: 1
Compression:
Stored size: 746 Bytes
Contents
require 'segment_tree' require 'irrc' require 'concurrent' module Legitbot # https://developers.facebook.com/docs/sharing/webmasters/crawler class Facebook < BotMatch AS = 'AS32934' ValidIPs = Concurrent::Delay.new do client = Irrc::Client.new client.query :radb, 'AS32934' results = client.perform Hash[%i(ipv4 ipv6).map { |k| [k, SegmentTree.new(results[AS][k][AS].map { |cidr| [IPAddr.new(cidr).to_range, true] })] }] end def valid? ip = IPAddr.new(@ip) if ip.ipv4? ValidIPs.value[:ipv4].find(ip) else ValidIPs.value[:ipv6].find(ip) end end end rule Legitbot::Facebook, %w(facebookhit facebookexternalhit) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
legitbot-0.1.0 | lib/legitbot/facebook.rb |