Sha256: c3bcdc57f8eec800f0089273b40956c4b355fb71b41b4f2856f990efc5e20ef6

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

# original author: Kent 'picat' Gruber

module Shodan
  module Clients
    class Host < Base
      # Returns all services that have been found on the given host IP.
      # @param ip [String]
      # @option params [Hash]
      # @return [Hash]
      def get_by_ip(ip, **params)
        get("/shodan/host/#{ip}", **params)
      end

      # This method behaves identical to "/shodan/host/search" with the only
      # difference that this method does not return any host results, it only
      # returns the total number of results that matched the query and any
      # facet information that was requested. As a result this method does
      # not consume query credits.
      def count(query = "", facets: {}, **params)
        params[:query] = query
        converted_params = turn_into_query(params)
        facets = turn_into_facets(facets)
        get("/shodan/host/count", **converted_params.merge(facets))
      end

      # Search Shodan using the same query syntax as the website and use facets
      # to get summary information for different properties.
      def search(query = "", facets: {}, page: 1, minify: true, **params)
        params[:query] = query
        params = turn_into_query(params)
        facets = turn_into_facets(facets)
        params[:page] = page
        params[:minify] = minify
        get("/shodan/host/search", **params.merge(facets))
      end

      # This method lets you determine which filters are being used by
      # the query string and what parameters were provided to the filters.
      def tokens(query = "", **params)
        params[:query] = query
        params = turn_into_query(params)
        get("/shodan/host/search/tokens", **params)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shodanx-0.2.1 lib/shodan/clients/host.rb