Class: Proxy::Dns::Dnsmasq::Record

Inherits:
Record
  • Object
show all
Includes:
Log
Defined in:
lib/smart_proxy_dns_dnsmasq/dns_dnsmasq_main.rb

Direct Known Subclasses

Default, Openwrt

Instance Method Summary collapse

Constructor Details

#initialize(dns_ttl) ⇒ Record

Returns a new instance of Record.



8
9
10
# File 'lib/smart_proxy_dns_dnsmasq/dns_dnsmasq_main.rb', line 8

def initialize(dns_ttl)
  super('localhost', dns_ttl)
end

Instance Method Details

#do_create(name, value, type) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/smart_proxy_dns_dnsmasq/dns_dnsmasq_main.rb', line 12

def do_create(name, value, type)
  case type
  when 'A', 'AAAA'
    add_entry(type, name, value)
  when 'PTR'
    add_entry(type, value, ptr_to_ip(name))
  when 'CNAME'
    add_cname(name, value)
  else
    raise Proxy::Dns::Error, "Can't create entries of type #{type}"
  end

  update!
end

#do_remove(name, type) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/smart_proxy_dns_dnsmasq/dns_dnsmasq_main.rb', line 27

def do_remove(name, type)
  case type
  when 'A', 'AAAA'
    remove_entry(type, name)
  when 'PTR'
    remove_entry(type, nil, ptr_to_ip(name))
  when 'CNAME'
    remove_cname(name)
  else
    raise Proxy::Dns::Error, "Can't remove entries of type #{type}"
  end

  update!
end