Class: BgpTools::AS
- Inherits:
-
Object
- Object
- BgpTools::AS
- Defined in:
- lib/bgp_tools/as.rb
Instance Attribute Summary collapse
-
#as_path_length ⇒ Object
readonly
Returns the value of attribute as_path_length.
-
#bgp_peer_list ⇒ Object
readonly
Returns the value of attribute bgp_peer_list.
-
#country_of_origin ⇒ Object
readonly
Returns the value of attribute country_of_origin.
-
#ips_originated ⇒ Object
readonly
Returns the value of attribute ips_originated.
-
#prefix_list ⇒ Object
readonly
Returns the value of attribute prefix_list.
Instance Method Summary collapse
- #contains?(ip) ⇒ Boolean
-
#initialize(as) ⇒ AS
constructor
A new instance of AS.
Constructor Details
#initialize(as) ⇒ AS
Returns a new instance of AS.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bgp_tools/as.rb', line 5 def initialize(as) url = "http://bgp.he.net/AS#{as}" result = RestClient.get url, user_agent: USER_AGENT self.doc = Nokogiri::HTML(result) set_country_of_origin set_prefix_list set_as_path_length set_ips_originated set_bgp_peer_list end |
Instance Attribute Details
#as_path_length ⇒ Object
Returns the value of attribute as_path_length.
3 4 5 |
# File 'lib/bgp_tools/as.rb', line 3 def as_path_length @as_path_length end |
#bgp_peer_list ⇒ Object
Returns the value of attribute bgp_peer_list.
3 4 5 |
# File 'lib/bgp_tools/as.rb', line 3 def bgp_peer_list @bgp_peer_list end |
#country_of_origin ⇒ Object
Returns the value of attribute country_of_origin.
3 4 5 |
# File 'lib/bgp_tools/as.rb', line 3 def country_of_origin @country_of_origin end |
#ips_originated ⇒ Object
Returns the value of attribute ips_originated.
3 4 5 |
# File 'lib/bgp_tools/as.rb', line 3 def ips_originated @ips_originated end |
#prefix_list ⇒ Object
Returns the value of attribute prefix_list.
3 4 5 |
# File 'lib/bgp_tools/as.rb', line 3 def prefix_list @prefix_list end |
Instance Method Details
#contains?(ip) ⇒ Boolean
17 18 19 20 |
# File 'lib/bgp_tools/as.rb', line 17 def contains?(ip) ipaddr = IPAddr.new(ip) prefix_list.select {|x| x.ip_addr.include? ipaddr }.count > 0 end |