Class: Enricher::BGPRanking

Inherits:
Object
  • Object
show all
Defined in:
lib/enricher/bgpranking.rb

Overview

BGP dynamic ASN ranking checks provided by circl.lu.

Results cached locally for 12hr.

> r = RestClient.post “bgpranking.circl.lu/json”, { ‘method’ => ‘cached_daily_rank’, ‘asn’ => 198540, ‘date’ => ‘2014-02-23’ }.to_json, :content_type => :json, :accept => :json

> “[198540, ”ELAN-AS Przedsiebiorstwo Uslug Specjalistycznych ELAN mgr inz. Andrzej Niechcial“, ”2014-02-23“, ”global“, 1.0496093750000002]”

>> r = RestClient.post “bgpranking.circl.lu/json”, { ‘method’ => ‘cached_daily_rank’, ‘asn’ => 198540, ‘date’ => ‘2014-02-24’ }.to_json, :content_type => :json, :accept => :json

> “[198540, ”ELAN-AS Przedsiebiorstwo Uslug Specjalistycznych ELAN mgr inz. Andrzej Niechcial“, ”2014-02-24“, ”global“, 1.09609375]”

>> a = JSON.parse®

Constant Summary collapse

BGP_RANK_URL =
"http://bgpranking.circl.lu/json"

Class Method Summary collapse

Class Method Details

.cacheObject



27
28
29
# File 'lib/enricher/bgpranking.rb', line 27

def self.cache
  @@cache
end

.rank?(addr) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
# File 'lib/enricher/bgpranking.rb', line 16

def self.rank?(addr)
  asn = addr.strip[/[0-9]+/]  
  if asn =~ /[0-9]+/
    @@cache ||= Vash.new 
    # Voliate Cache store for 43200 (12hr)
    @@cache["asn#{asn}".to_sym] ||= self.onlinerank?(asn)
  else
    return "0.0"
  end
end