Class: Ryo::Plugin::Shodan
- Inherits:
-
Object
- Object
- Ryo::Plugin::Shodan
- Defined in:
- lib/ryo/plugin/shodan.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
- #discover(ip) ⇒ Object
-
#initialize ⇒ Shodan
constructor
A new instance of Shodan.
Constructor Details
#initialize ⇒ Shodan
Returns a new instance of Shodan.
9 10 11 12 |
# File 'lib/ryo/plugin/shodan.rb', line 9 def initialize raise ArgumentError, "Please set your Shodan API key via ENV['SHODAN_API_KEY']" unless ENV["SHODAN_API_KEY"] @client = Shodanz.client.new end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/ryo/plugin/shodan.rb', line 8 def client @client end |
Class Method Details
.discover(ip) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/ryo/plugin/shodan.rb', line 18 def self.discover(ip) new.discover(ip) rescue ArgumentError => e { error: e.to_s } rescue StandardError => e { error: e.to_s } end |
Instance Method Details
#discover(ip) ⇒ Object
14 15 16 |
# File 'lib/ryo/plugin/shodan.rb', line 14 def discover(ip) ip == "N/A" ? { error: "Invalid IP" } : client.rest_api.host(ip) end |