Class: Seer::DNS

Inherits:
Object
  • Object
show all
Defined in:
lib/seer/dns.rb

Overview

DNS API controller

Instance Method Summary collapse

Constructor Details

#initialize(token: '', version: '2.0', host: '') ⇒ DNS

Initialize a DNS object

Parameters:

  • token (string) (defaults to: '')

    API token

  • version (string) (defaults to: '2.0')

    API version you want use (defaut 1)

  • host (string) (defaults to: '')

    API host



8
9
10
11
12
13
14
15
# File 'lib/seer/dns.rb', line 8

def initialize(token: '', version: '2.0', host: '')
  @host = host + '/dns'
  @header = {
      content_type: 'application/json',
      x_seer_token: token,
      x_seer_version: version
  }
end

Instance Method Details

#domain(domain) ⇒ Hash

Get ip from domain

Parameters:

  • domain (string)

Returns:

  • (Hash)

    Result



20
21
22
23
24
# File 'lib/seer/dns.rb', line 20

def domain(domain)
  body = { domain: domain }
  url = @host + '/domain'
  Seer.request(url, body, @header)
end

#ip(ip) ⇒ Hash

Get domain by ip

Parameters:

  • ip (String)

Returns:

  • (Hash)

    Result



38
39
40
41
42
# File 'lib/seer/dns.rb', line 38

def ip(ip)
  body = { ip: ip }
  url = @host + '/ip'
  Seer.request(url, body, @header)
end

#search(type, key) ⇒ Hash

Advance search

Parameters:

  • type (string)

    DNS type

  • key (string)

    Key

Returns:

  • (Hash)

    Result



48
49
50
51
52
53
54
55
# File 'lib/seer/dns.rb', line 48

def search(type, key)
  body = {
      type: type,
      key: key
  }
  url = @host + '/search'
  Seer.request(url, body, @header)
end

#subdomain(subdomain) ⇒ Hash

Get sub domain from domain

Parameters:

  • subdomain (string)

Returns:

  • (Hash)

    Result



29
30
31
32
33
# File 'lib/seer/dns.rb', line 29

def subdomain(subdomain)
  body = { domain: subdomain }
  url = @host + '/subdomain'
  Seer.request(url, body, @header)
end