Class: OpenDNS::DNSDB

Inherits:
Object
  • Object
show all
Includes:
ByIP, ByName, Label, Related, Response, Traffic
Defined in:
lib/opendns-dnsdb/dnsdb.rb,
lib/opendns-dnsdb/version.rb,
lib/opendns-dnsdb/dnsdb/by_ip.rb,
lib/opendns-dnsdb/dnsdb/label.rb,
lib/opendns-dnsdb/dnsdb/by_name.rb,
lib/opendns-dnsdb/dnsdb/related.rb,
lib/opendns-dnsdb/dnsdb/rrutils.rb,
lib/opendns-dnsdb/dnsdb/traffic.rb,
lib/opendns-dnsdb/dnsdb/response.rb

Defined Under Namespace

Modules: ByIP, ByName, Label, RRUtils, Related, Response, Traffic

Constant Summary collapse

DEFAULT_TIMEOUT =
15
DEFAULT_MAX_CONCURRENCY =
10
SGRAPH_API_BASE_URL =
'https://sgraph.umbrella.com'
VERSION =
'0.3.0'

Constants included from Traffic

Traffic::DEFAULT_DAYS_BACK

Constants included from Label

Label::CACHE_KEY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Traffic

#daily_traffic_by_name, #high_pass_filter, #relative_standard_deviation

Methods included from Related

#distinct_related_names, #related_names, #related_names_with_score

Methods included from RRUtils

#distinct_rrs

Methods included from Label

#benign_names, #distinct_labels, #distinct_labels_by_name, #include_benign?, #include_suspicious?, #include_unknown?, #is_benign?, #is_suspicious?, #is_unknown?, #labels_by_name, #not_benign_names, #not_suspicious_names, #not_unknown_names, #suspicious_names, #unknown_names

Methods included from ByName

#cnames_by_name, #cnames_history_by_name, #distinct_cnames_by_name, #distinct_ips_by_name, #distinct_mxs_by_name, #distinct_nameservers_ips_by_name, #history_by_name, #ips_by_name, #ips_history_by_name, #mxs_by_name, #mxs_history_by_name, #nameservers_ips_by_name, #nameservers_ips_history_by_name, #rr_only_for_names

Methods included from ByIP

#distinct_names_by_ip, #distinct_names_by_nameserver_ip, #history_by_ip, #names_by_ip, #names_by_nameserver_ip, #names_history_by_ip, #names_history_by_nameserver_ip, #rr_only_for_ips

Constructor Details

#initialize(params = { }) ⇒ DNSDB

Returns a new instance of DNSDB.

Raises:

  • (UsageError)


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/opendns-dnsdb/dnsdb.rb', line 33

def initialize(params = { })
  raise UsageError, 'Missing certificate file' unless params[:sslcert]
  @sslcert = params[:sslcert]
  @timeout = DEFAULT_TIMEOUT
  @timeout = params[:timeout].to_f if params[:timeout]
  @max_concurrency = DEFAULT_MAX_CONCURRENCY
  @max_concurrency = params[:max_concurrency].to_i if params[:max_concurrency]
  @sslcerttype = params[:sslcerttype] || 'pem'
  @sslcertpasswd = params[:sslcertpasswd] || 'opendns'
  @options = {
    followlocation: true,
    timeout: @timeout,
    sslcert: @sslcert,
    sslcerttype: @sslcerttype,
    sslcertpasswd: @sslcertpasswd
  }
end

Instance Attribute Details

#max_concurrencyObject (readonly)

Returns the value of attribute max_concurrency.



31
32
33
# File 'lib/opendns-dnsdb/dnsdb.rb', line 31

def max_concurrency
  @max_concurrency
end

#sslcertObject (readonly)

Returns the value of attribute sslcert.



28
29
30
# File 'lib/opendns-dnsdb/dnsdb.rb', line 28

def sslcert
  @sslcert
end

#sslcertpasswdObject (readonly)

Returns the value of attribute sslcertpasswd.



30
31
32
# File 'lib/opendns-dnsdb/dnsdb.rb', line 30

def sslcertpasswd
  @sslcertpasswd
end

#sslcerttypeObject (readonly)

Returns the value of attribute sslcerttype.



29
30
31
# File 'lib/opendns-dnsdb/dnsdb.rb', line 29

def sslcerttype
  @sslcerttype
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



27
28
29
# File 'lib/opendns-dnsdb/dnsdb.rb', line 27

def timeout
  @timeout
end

Instance Method Details

#query_handler(endpoint, method = :get, options = { }) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/opendns-dnsdb/dnsdb.rb', line 55

def query_handler(endpoint, method = :get, options = { })
  url = SGRAPH_API_BASE_URL + endpoint
  options = options.merge(@options)
  options.merge!(method: method)
  query = Typhoeus::Request.new(url,
    @options.merge(options).merge(method: method))
  query
end

#query_multiObject



51
52
53
# File 'lib/opendns-dnsdb/dnsdb.rb', line 51

def query_multi
  Typhoeus::Hydra.new(max_concurrency: @max_concurrency)
end