class RedZone::Arpa
Arpa
definition
Attributes
name[R]
Reverse DNS name @return [String] dns name
network[R]
Network @return [IPAddr]
records[R]
Get the list of PTR records @return [Array<Record>] PTR records
Public Class Methods
new(opt)
click to toggle source
Constructs a new MailExchange
entry @param [Hash<String, SOA>] opt @option opt [String] :name Arpa
DNS name (Required) @option opt [String] :network IP address with network mask (Required) @option opt [SOA,String] :soa SOA
record (Required)
# File lib/redzone/arpa.rb, line 23 def initialize(opt) raise ArgumentError, ':name is required' unless opt.has_key?(:name) raise ArgumentError, ':network is required' unless opt.has_key?(:network) raise ArgumentError, ':soa is required' unless opt.has_key?(:soa) @name = opt[:name] @network = IPAddr.new(opt[:network]) @soa = opt[:soa] @records = [] end
Public Instance Methods
add(machine,domain)
click to toggle source
Adds a machine to the arpa network for reverse-address lookup only if the machine is in this network. @param [Machine] machine @param [String] domain name
# File lib/redzone/arpa.rb, line 47 def add(machine,domain) fqdn = "#{machine.name}.#{domain}." substr = ".#{@name}" if @network.ipv4? and machine.ipv4? and @network.include?(machine.ipv4) ip = machine.ipv4.reverse ip.slice!(substr) records << Record.new(:name => ip, :type => "PTR", :data => fqdn, :comment => "Machine #{machine.name}") end if @network.ipv6? and machine.ipv6? and @network.include?(machine.ipv6) ip = machine.ipv6.ip6_arpa ip.slice!(substr) records << Record.new(:name => ip, :type => "PTR", :data => fqdn, :comment => "Machine #{machine.name}") end end
add_record(record)
click to toggle source
# File lib/redzone/arpa.rb, line 62 def add_record(record) records << record end
write(io)
click to toggle source
Writes the Arpa
to the given IO stream @param [IO] io IO Stream
# File lib/redzone/arpa.rb, line 35 def write(io) io << @soa @records.each do |r| io << r end io << "\n" end