Sha256: edb795d8c5d93b79b6f63dab25bad7e83bc970da00f07af37858778233144a81

Contents?: true

Size: 906 Bytes

Versions: 2

Compression:

Stored size: 906 Bytes

Contents

module Dyndnsd
  module Generator
    class Bind
      def initialize(domain, config)
        @domain = domain
        @ttl = config['ttl']
        @dns = config['dns']
        @email_addr = config['email_addr']
        @additional_zone_content = config['additional_zone_content']
      end

      def generate(zone)
        out = []
        out << "$TTL #{@ttl}"
        out << "$ORIGIN #{@domain}."
        out << ""
        out << "@ IN SOA #{@dns} #{@email_addr} ( #{zone['serial']} 3h 5m 1w 1h )"
        out << "@ IN NS #{@dns}"
        out << ""
        zone['hosts'].each do |hostname,ip|
          ip = IPAddr.new(ip).native
          type = ip.ipv6? ? "AAAA" : "A"
          name = hostname.chomp('.' + @domain)
          out << "#{name} IN #{type} #{ip}"
        end
        out << ""
        out << @additional_zone_content
        out << ""
        out.join("\n")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dyndnsd-1.5.0 lib/dyndnsd/generator/bind.rb
dyndnsd-1.4.0 lib/dyndnsd/generator/bind.rb