dns-zonefile 1.1.0 → 1.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2827522219ce8faf8c79547c65317965d5a628eb
4
- data.tar.gz: 9cb7a17d1ee296c80c68e682ee1b4d3a2384232e
2
+ SHA256:
3
+ metadata.gz: 4edd1610f1ecdf845654917cd1f3ea2aa83f1196a87be9bf97c59a34d10392ec
4
+ data.tar.gz: cf115e357d4763424d310592ebf0eb5d18366fff4a2bb451c61a80371317b62e
5
5
  SHA512:
6
- metadata.gz: 786c0b7a22598d0f27826ef8c3e7ea8e851e990fedd981f3d88dd112c98a8b483f1c7fd665eddf51a83f60a23360350a81a714699a0a5225c1f2a4482c037e8d
7
- data.tar.gz: 654452ea27aa6752a3d2a275e93634dee0283c3e3011a782254e83fe73e7fbaa9e88433bc2b0947d3200475aa6c4aca8c05faff34c68c928c8f45ffae3d2c5c1
6
+ metadata.gz: 3416c7cc446f189fe4c03e128f37c2b2b9b886c911a7a11345ade49c6ae6bc2a138cf95cc76f77721950ff820bd5817d1e874b9fc90420af42333f54572b4592
7
+ data.tar.gz: e0ee661f673016703e919225b9fc04b3e40ce59effbba2417c0f5489c9db6109f4c8aac23ffed06f2252fbb08c5d65f6c4f5860bd8caa4ccb384adbccc0d178b
data/.gitignore CHANGED
@@ -1,3 +1,10 @@
1
- *.gem
2
- .rvmrc
3
- Gemfile.lock
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /dns-zonefile-*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -1,4 +1,10 @@
1
1
  language: ruby
2
+
3
+ before_install:
4
+ - yes | gem update --system --force
5
+ - gem install bundler
6
+
2
7
  rvm:
3
- - ruby-head
4
- - 2.3.0
8
+ - 2.5
9
+ - 2.6
10
+ - 2.7
@@ -0,0 +1,36 @@
1
+ # Contributing to dns-zonefile
2
+
3
+ ## Getting started
4
+
5
+ Clone the repository and move into it:
6
+
7
+ ```
8
+ $ git clone git@github.com:craigw/dns-zonefile.git
9
+ $ cd dns-zonefile
10
+ ```
11
+
12
+ Install the dependencies using [Bundler](http://bundler.io/):
13
+
14
+ ```
15
+ $ bundle
16
+ ```
17
+
18
+ [Run the test suite](#testing) to check everything works as expected.
19
+
20
+
21
+ ## Testing
22
+
23
+ To run the test suite:
24
+
25
+ ```
26
+ $ rake
27
+ ```
28
+
29
+
30
+ ## Tests
31
+
32
+ Submit unit tests for your changes. You can test your changes on your machine by [running the test suite](#testing).
33
+
34
+ ## Publishing
35
+
36
+ Once a PR is merged into master, bump the version in `lib/dns/zonefile/version.rb` and commit that change. Next, add a new tag with that version number and push the tag to GitHub. Finally, if you are a maintainer with access rights for rubygems.org, run `gem build dnsimple-zonefile.gemspec` followed by `gem push dnsimple-zonefile-x.x.x.gem` where x.x.x is the version number you just set.
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.2.2
1
+ FROM ruby:2.3
2
2
 
3
3
  RUN mkdir -p /u/app
4
4
  WORKDIR /u/app
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in dns-zonefile.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -11,21 +11,14 @@ some canonical form.
11
11
 
12
12
  ## Getting setup
13
13
 
14
- Well, you'll need the treetop and polyglot gems installed. They do all
15
- the hard work. Thanks!
14
+ Add `gem dns-zonefile` to your Gemfile
16
15
 
17
- sudo gem install treetop polyglot
16
+ or
18
17
 
19
- Now you'll need to generate the Treetop parser from the Zonefile grammar
20
- that I've hacked together.
21
-
22
- rake generate_grammar
18
+ `gem install dns-zonefile`
23
19
 
24
20
  Okay, you're ready to move onto the examples now.
25
21
 
26
- The above steps should not be necessary if you install the gem via rubygems.
27
-
28
-
29
22
  ## Examples
30
23
 
31
24
  Using raw data from the parser. Note that "@" isn't translated in this mode.
@@ -54,19 +47,22 @@ handled in this mode.
54
47
  # get all MX records
55
48
  puts zone.records_of(DNS::Zonefile::MX)
56
49
 
50
+ Open the examples in the `./examples` directory to see more examples.
57
51
 
58
52
  ## Authors
59
53
 
60
- Original code and concept:
54
+ ### Original code and concept:
55
+
61
56
  Craig R Webster <http://barkingiguana.com/>
62
57
 
63
- Additions:
64
- t.e.morgan <http://zerigo.com/>
58
+ ### Additions:
59
+
60
+ - t.e.morgan <http://zerigo.com/>
61
+ - Anthony Eden <https://dnsimple.com/>
65
62
 
66
63
 
67
64
  ## Contributing
68
65
 
69
- See the TODO. Send me patches or pull request either by email or on
70
- GitHub.
66
+ See the TODO. Read CONTRIBUTING.md for more details on how to contribute to this project.
71
67
 
72
68
  [![Build Status](https://secure.travis-ci.org/craigw/dns-zonefile.png)](http://travis-ci.org/craigw/dns-zonefile)
data/Rakefile CHANGED
@@ -1,11 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
2
3
 
3
- require 'rake'
4
- require 'rspec/core/rake_task'
5
4
  RSpec::Core::RakeTask.new(:spec)
6
5
 
7
- task :default => [ :spec ]
8
-
9
- task :build do
10
- puts %x[gem build dns-zonefile.gemspec]
11
- end
6
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dns/zonefile"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ dependencies:
2
+ pre:
3
+ - gem install bundler --version 1.11
4
+ machine:
5
+ ruby:
6
+ version: 2.3.0
@@ -1,31 +1,41 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require "dns/zonefile/version"
4
4
 
5
- Gem::Specification.new do |s|
6
- s.name = "dns-zonefile"
7
- s.version = DNS::Zonefile::VERSION
8
- s.authors = ["Craig R Webster"]
9
- s.email = ["craig@barkingiguana.com"]
10
- s.homepage = ""
11
- s.summary = %q{Work with zonefiles (RFC 1035 section 5 and RFC 1034 section 3.6.1)}
12
- s.description = %q{The format of a DNS Zonefile is defined in RFC 1035 section 5 and RFC
13
- 1034 section 3.6.1. To anyone who's using BIND they'll look very
14
- familiar.
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "dns-zonefile"
7
+ spec.version = DNS::Zonefile::VERSION
8
+ spec.authors = ["Craig R Webster", "Anthony Eden"]
9
+ spec.email = ["craig@barkingiguana.com", "anthonyeden@gmail.com"]
15
10
 
16
- This is an attempt to use Ruby parse them into an object graph which can
17
- be investigated programatically, manipulated, validated or printed into
18
- some canonical form.}
11
+ spec.summary = "Work with zonefiles (RFC 1035 section 5 and RFC 1034 section 3.6.1)"
12
+ spec.description = <<~EOD
13
+ The format of a DNS Zonefile is defined in RFC 1035 section 5 and RFC
14
+ 1034 section 3.6.1. To anyone who's using BIND they'll look very
15
+ familiar.
16
+
17
+ This is an attempt to use Ruby parse them into an object graph which can
18
+ be investigated programatically, manipulated, validated or printed into
19
+ some canonical form.
20
+ EOD
21
+ spec.homepage = "https://github.com/craigw/dns-zonefile"
19
22
 
20
- s.rubyforge_project = "dns-zonefile"
23
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
24
+ # delete this section to allow pushing this gem to any host.
25
+ if spec.respond_to?(:metadata)
26
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
27
+ else
28
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
29
+ end
21
30
 
22
- s.files = `git ls-files`.split("\n")
23
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
- s.require_paths = ["lib"]
31
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
26
35
 
27
- s.add_development_dependency "rspec"
28
- s.add_development_dependency "rake"
29
- s.add_runtime_dependency "treetop"
30
- s.add_runtime_dependency "polyglot"
36
+ spec.add_dependency "treetop", "~> 1.6"
37
+ spec.add_dependency "polyglot", "~> 0.3"
38
+ spec.add_development_dependency "bundler", "~> 2.1"
39
+ spec.add_development_dependency "rake", "~> 13.0"
40
+ spec.add_development_dependency "rspec", "~> 3.0"
31
41
  end
@@ -0,0 +1,12 @@
1
+ # First make sure you have installed the `dns-zonefile` gem.
2
+ #
3
+ # Run this script with `ruby basic.rb`
4
+
5
+ require "dns/zonefile"
6
+
7
+ zonefile = "example.com.zonefile"
8
+ zone = DNS::Zonefile.parse(File.read(zonefile))
9
+
10
+ puts zone.soa.origin.to_s
11
+ puts zone.soa.ns.to_s
12
+ puts zone.rr[0].to_s
@@ -0,0 +1,15 @@
1
+ # First make sure you have installed the `dns-zonefile` gem.
2
+ #
3
+ # Run this script with `ruby basic.rb`
4
+
5
+ require "dns/zonefile"
6
+
7
+ zonefile = "example.com.zonefile"
8
+ zone = DNS::Zonefile.load(File.read(zonefile), "example.com.")
9
+
10
+ puts zone.soa.origin
11
+ puts zone.soa.nameserver
12
+ # get all MX records
13
+ zone.records_of(DNS::Zonefile::MX).each do |rec|
14
+ puts "#{rec.host} #{rec.klass} #{rec.ttl} #{rec.priority} #{rec.domainname}"
15
+ end
@@ -0,0 +1,16 @@
1
+ $TTL 1h ; default expiration time of all resource records without their own TTL value
2
+ example.com. IN SOA ns.example.com. username.example.com. ( 2007120710 1d 2h 4w 1h )
3
+ example.com. IN NS ns ; ns.example.com is a nameserver for example.com
4
+ example.com. IN NS ns.somewhere.example. ; ns.somewhere.example is a backup nameserver for example.com
5
+ example.com. IN MX 10 mail.example.com. ; mail.example.com is the mailserver for example.com
6
+ @ IN MX 20 mail2.example.com. ; equivalent to above line, "@" represents zone origin
7
+ @ IN MX 50 mail3 ; equivalent to above line, but using a relative host name
8
+ example.com. IN A 192.0.2.1 ; IPv4 address for example.com
9
+ IN AAAA 2001:db8:10::1 ; IPv6 address for example.com
10
+ ns IN A 192.0.2.2 ; IPv4 address for ns.example.com
11
+ IN AAAA 2001:db8:10::2 ; IPv6 address for ns.example.com
12
+ www IN CNAME example.com. ; www.example.com is an alias for example.com
13
+ wwwtest IN CNAME www ; wwwtest.example.com is another alias for www.example.com
14
+ mail IN A 192.0.2.3 ; IPv4 address for mail.example.com
15
+ mail2 IN A 192.0.2.4 ; IPv4 address for mail2.example.com
16
+ mail3 IN A 192.0.2.5 ; IPv4 address for mail3.example.com
@@ -0,0 +1,17 @@
1
+ $ORIGIN example.com. ; designates the start of this zone file in the namespace
2
+ $TTL 1h ; default expiration time of all resource records without their own TTL value
3
+ example.com. IN SOA ns.example.com. username.example.com. ( 2007120710 1d 2h 4w 1h )
4
+ example.com. IN NS ns ; ns.example.com is a nameserver for example.com
5
+ example.com. IN NS ns.somewhere.example. ; ns.somewhere.example is a backup nameserver for example.com
6
+ example.com. IN MX 10 mail.example.com. ; mail.example.com is the mailserver for example.com
7
+ @ IN MX 20 mail2.example.com. ; equivalent to above line, "@" represents zone origin
8
+ @ IN MX 50 mail3 ; equivalent to above line, but using a relative host name
9
+ example.com. IN A 192.0.2.1 ; IPv4 address for example.com
10
+ IN AAAA 2001:db8:10::1 ; IPv6 address for example.com
11
+ ns IN A 192.0.2.2 ; IPv4 address for ns.example.com
12
+ IN AAAA 2001:db8:10::2 ; IPv6 address for ns.example.com
13
+ www IN CNAME example.com. ; www.example.com is an alias for example.com
14
+ wwwtest IN CNAME www ; wwwtest.example.com is another alias for www.example.com
15
+ mail IN A 192.0.2.3 ; IPv4 address for mail.example.com
16
+ mail2 IN A 192.0.2.4 ; IPv4 address for mail2.example.com
17
+ mail3 IN A 192.0.2.5 ; IPv4 address for mail3.example.com
@@ -1,113 +1,84 @@
1
- require 'dns/zonefile/version'
2
- require 'treetop'
3
- Treetop.load 'lib/dns/zonefile'
1
+ require "dns/zonefile/version"
2
+ require "treetop"
3
+ Treetop.load File.expand_path("../zonefile", __FILE__)
4
4
 
5
5
  module DNS
6
6
  module Zonefile
7
7
  class << self
8
8
  def parse(zone_string)
9
- parser = ZonefileParser.new
10
- if result = parser.parse(zone_string)
11
- result
12
- else
13
- raise ParsingError, parser.failure_reason
14
- end
9
+ parser = ZonefileParser.new
10
+ result = parser.parse(zone_string)
11
+ return result if result
12
+ raise ParsingError, parser.failure_reason
15
13
  end
16
14
 
17
- def load(zone_string, alternate_origin=nil)
18
- Zone.new(parse(zone_string).entries, alternate_origin)
15
+ def load(zone_string, alternate_origin = nil)
16
+ Zone.new(parse(zone_string).entries, alternate_origin)
19
17
  end
20
18
  end
21
19
 
22
- class ParsingError < RuntimeError ; end
23
- class UnknownRecordType < RuntimeError ; end
20
+ class ParsingError < RuntimeError; end
21
+ class UnknownRecordType < RuntimeError; end
24
22
  class Zone
25
- attr_reader :origin, :soa
23
+ attr_reader :origin
26
24
  attr_reader :records
27
25
 
28
- def initialize(entries, alternate_origin=nil)
29
- alternate_origin ||= '.'
30
- @records = []
31
- @vars = {'origin'=>alternate_origin, :last_host=>'.'}
32
- entries.each do |e|
33
- case e.parse_type
34
- when :variable
35
- case key = e.name.text_value.downcase
36
- when 'ttl'
37
- @vars[key] = e.value.text_value.to_i
38
- else
39
- @vars[key] = e.value.text_value
40
- end
41
- when :soa
42
- @records << SOA.new(@vars, e)
43
- when :record
44
- case e.record_type
45
- when 'A' then @records << A.new(@vars, e)
46
- when 'AAAA' then @records << AAAA.new(@vars, e)
47
- when 'CNAME' then @records << CNAME.new(@vars, e)
48
- when 'MX' then @records << MX.new(@vars, e)
49
- when 'NAPTR' then @records << NAPTR.new(@vars, e)
50
- when 'NS' then @records << NS.new(@vars, e)
51
- when 'PTR' then @records << PTR.new(@vars, e)
52
- when 'SRV' then @records << SRV.new(@vars, e)
53
- when 'SPF' then @records << SPF.new(@vars, e)
54
- when 'TXT' then @records << TXT.new(@vars, e)
55
- when 'SOA' then ;
56
- else
57
- raise UnknownRecordType, "Unknown record type: #{e.record_type}"
58
- end
59
- end
60
- end
26
+ def initialize(entries, alternate_origin = nil)
27
+ alternate_origin ||= "."
28
+ @records = []
29
+ @vars = {"origin" => alternate_origin, :last_host => "."}
30
+ entries.each do |e|
31
+ case e.parse_type
32
+ when :variable
33
+ key = e.name.text_value.downcase
34
+ @vars[key] = case key
35
+ when "ttl"
36
+ e.value.text_value.to_i
37
+ else
38
+ e.value.text_value
39
+ end
40
+ when :soa
41
+ @records << SOA.new(@vars, e)
42
+ when :record
43
+ case e.record_type
44
+ when "A" then @records << A.new(@vars, e)
45
+ when "AAAA" then @records << AAAA.new(@vars, e)
46
+ when "CAA" then @records << CAA.new(@vars, e)
47
+ when "CNAME" then @records << CNAME.new(@vars, e)
48
+ when "MX" then @records << MX.new(@vars, e)
49
+ when "NAPTR" then @records << NAPTR.new(@vars, e)
50
+ when "NS" then @records << NS.new(@vars, e)
51
+ when "PTR" then @records << PTR.new(@vars, e)
52
+ when "SRV" then @records << SRV.new(@vars, e)
53
+ when "SPF" then @records << SPF.new(@vars, e)
54
+ when "SSHFP" then @records << SSHFP.new(@vars, e)
55
+ when "TXT" then @records << TXT.new(@vars, e)
56
+ when "SOA" then
57
+ # No-op
58
+ else
59
+ raise UnknownRecordType, "Unknown record type: #{e.record_type}"
60
+ end
61
+ end
62
+ end
61
63
  end
62
64
 
63
65
  def soa
64
- records_of(SOA).first
66
+ records_of(SOA).first
65
67
  end
66
68
 
67
69
  def records_of(kl)
68
- @records.select{|r| r.instance_of? kl}
70
+ @records.select { |r| r.instance_of? kl }
69
71
  end
70
72
  end
71
73
 
72
74
  class Record
73
- # assign, with handling for '@'
74
- def self.writer_for_at(*attribs)
75
- attribs.each do |attrib|
76
- c = <<-MTH
77
- def #{attrib}=(val)
78
- @#{attrib} = val.gsub('@', @vars['origin'])
79
- end
80
- MTH
81
- class_eval c, __FILE__, __LINE__
82
- end
83
- end
84
-
85
- # assign, with handling for '@', with inheritance
86
- def self.inheriting_writer_for_at(*attribs)
87
- attribs.each do |attrib|
88
- c = <<-MTH
89
- def #{attrib}=(val)
90
- if val.strip.empty?
91
- @#{attrib} = @vars[:last_host]
92
- else
93
- @#{attrib} = val.gsub('@', @vars['origin'])
94
- end
95
- end
96
- MTH
97
- class_eval c, __FILE__, __LINE__
98
- end
99
- end
100
-
101
75
  # assign, with handling for global TTL
102
76
  def self.writer_for_ttl(*attribs)
103
- attribs.each do |attrib|
104
- c = <<-MTH
105
- def #{attrib}=(val)
106
- @#{attrib} = val || @vars['ttl']
107
- end
108
- MTH
109
- class_eval c, __FILE__, __LINE__
110
- end
77
+ attribs.each do |attrib|
78
+ define_method "#{attrib}=" do |val|
79
+ instance_variable_set("@#{attrib}", val || @vars["ttl"])
80
+ end
81
+ end
111
82
  end
112
83
 
113
84
  attr_reader :ttl
@@ -115,192 +86,218 @@ module DNS
115
86
  writer_for_ttl :ttl
116
87
 
117
88
  def klass
118
- @klass = nil if @klass == ''
119
- @klass ||= 'IN'
89
+ @klass = nil if @klass == ""
90
+ @klass ||= "IN"
120
91
  end
121
92
 
93
+ private
94
+
95
+ def qualify_host(host)
96
+ origin = vars["origin"]
97
+ host = vars[:last_host] if /^\s*$/.match?(host)
98
+ host = host.gsub(/@/, origin)
99
+ if /\.$/.match?(host)
100
+ host
101
+ elsif /^\./.match?(origin)
102
+ host + origin
103
+ else
104
+ host + "." + origin
105
+ end
106
+ end
107
+ attr_accessor :vars
122
108
  end
123
109
 
124
110
  class SOA < Record
125
111
  attr_accessor :origin, :nameserver, :responsible_party, :serial, :refresh_time, :retry_time, :expiry_time, :nxttl
126
112
 
127
- writer_for_at :origin, :nameserver, :responsible_party
128
-
129
- def initialize(vars, zonefile_soa=nil)
130
- @vars = vars
131
- if zonefile_soa
132
- self.origin = zonefile_soa.origin.to_s
133
- @vars[:last_host] = self.origin
134
- self.ttl = zonefile_soa.ttl.to_i
135
- self.klass = zonefile_soa.klass.to_s
136
- self.nameserver = zonefile_soa.ns.to_s
137
- self.responsible_party = zonefile_soa.rp.to_s
138
- self.serial = zonefile_soa.serial.to_i
139
- self.refresh_time = zonefile_soa.refresh.to_i
140
- self.retry_time = zonefile_soa.reretry.to_i
141
- self.expiry_time = zonefile_soa.expiry.to_i
142
- self.nxttl = zonefile_soa.nxttl.to_i
143
- end
113
+ def initialize(vars, zonefile_soa = nil)
114
+ @vars = vars
115
+ if zonefile_soa
116
+ self.origin = qualify_host(zonefile_soa.origin.to_s)
117
+ @vars[:last_host] = origin
118
+ self.ttl = zonefile_soa.ttl.to_i
119
+ self.klass = zonefile_soa.klass.to_s
120
+ self.nameserver = qualify_host(zonefile_soa.ns.to_s)
121
+ self.responsible_party = qualify_host(zonefile_soa.rp.to_s)
122
+ self.serial = zonefile_soa.serial.to_i
123
+ self.refresh_time = zonefile_soa.refresh.to_i
124
+ self.retry_time = zonefile_soa.reretry.to_i
125
+ self.expiry_time = zonefile_soa.expiry.to_i
126
+ self.nxttl = zonefile_soa.nxttl.to_i
127
+ end
144
128
  end
145
129
  end
146
130
 
147
131
  class A < Record
148
132
  attr_accessor :host, :address
149
133
 
150
- inheriting_writer_for_at :host
151
-
152
134
  def initialize(vars, zonefile_record)
153
- @vars = vars
154
- if zonefile_record
155
- self.host = zonefile_record.host.to_s
156
- @vars[:last_host] = self.host
157
- self.ttl = zonefile_record.ttl.to_i
158
- self.klass = zonefile_record.klass.to_s
159
- self.address = zonefile_record.ip_address.to_s
160
- end
135
+ @vars = vars
136
+ if zonefile_record
137
+ self.host = qualify_host(zonefile_record.host.to_s)
138
+ @vars[:last_host] = host
139
+ self.ttl = zonefile_record.ttl.to_i
140
+ self.klass = zonefile_record.klass.to_s
141
+ self.address = zonefile_record.ip_address.to_s
142
+ end
161
143
  end
162
144
  end
163
145
 
164
146
  class AAAA < A
165
147
  end
166
148
 
149
+ class CAA < Record
150
+ attr_accessor :host, :flags, :tag, :value
151
+
152
+ def initialize(vars, zonefile_record)
153
+ @vars = vars
154
+ if zonefile_record
155
+ self.host = qualify_host(zonefile_record.host.to_s)
156
+ @vars[:last_host] = host
157
+ self.ttl = zonefile_record.ttl.to_i
158
+ self.klass = zonefile_record.klass.to_s
159
+ self.flags = zonefile_record.flags.to_i
160
+ self.tag = zonefile_record.tag.to_s
161
+ self.value = zonefile_record.value.to_s
162
+ end
163
+ end
164
+ end
165
+
167
166
  class CNAME < Record
168
167
  attr_accessor :host, :domainname
169
168
 
170
- inheriting_writer_for_at :host
171
- writer_for_at :domainname
172
-
173
169
  def initialize(vars, zonefile_record)
174
- @vars = vars
175
- if zonefile_record
176
- self.host = zonefile_record.host.to_s
177
- @vars[:last_host] = self.host
178
- self.ttl = zonefile_record.ttl.to_i
179
- self.klass = zonefile_record.klass.to_s
180
- self.domainname = zonefile_record.target.to_s
181
- end
170
+ @vars = vars
171
+ if zonefile_record
172
+ self.host = qualify_host(zonefile_record.host.to_s)
173
+ @vars[:last_host] = host
174
+ self.ttl = zonefile_record.ttl.to_i
175
+ self.klass = zonefile_record.klass.to_s
176
+ self.domainname = qualify_host(zonefile_record.target.to_s)
177
+ end
182
178
  end
183
179
 
184
- alias :target :domainname
185
- alias :alias :host
180
+ alias target domainname
181
+ alias alias host
186
182
  end
187
183
 
188
184
  class MX < Record
189
185
  attr_accessor :host, :priority, :domainname
190
186
 
191
- inheriting_writer_for_at :host
192
- writer_for_at :domainname
193
-
194
187
  def initialize(vars, zonefile_record)
195
- @vars = vars
196
- if zonefile_record
197
- self.host = zonefile_record.host.to_s
198
- @vars[:last_host] = self.host
199
- self.ttl = zonefile_record.ttl.to_i
200
- self.klass = zonefile_record.klass.to_s
201
- self.priority = zonefile_record.priority.to_i
202
- self.domainname = zonefile_record.exchanger.to_s
203
- end
188
+ @vars = vars
189
+ if zonefile_record
190
+ self.host = qualify_host(zonefile_record.host.to_s)
191
+ @vars[:last_host] = host
192
+ self.ttl = zonefile_record.ttl.to_i
193
+ self.klass = zonefile_record.klass.to_s
194
+ self.priority = zonefile_record.priority.to_i
195
+ self.domainname = qualify_host(zonefile_record.exchanger.to_s)
196
+ end
204
197
  end
205
198
 
206
- alias :exchange :domainname
207
- alias :exchanger :domainname
199
+ alias exchange domainname
200
+ alias exchanger domainname
208
201
  end
209
202
 
210
203
  class NAPTR < Record
211
204
  attr_accessor :host, :data
212
205
 
213
- inheriting_writer_for_at :host
214
-
215
206
  def initialize(vars, zonefile_record)
216
- @vars = vars
217
- if zonefile_record
218
- self.host = zonefile_record.host.to_s
219
- @vars[:last_host] = self.host
220
- self.ttl = zonefile_record.ttl.to_i
221
- self.klass = zonefile_record.klass.to_s
222
- self.data = zonefile_record.data.to_s
223
- end
207
+ @vars = vars
208
+ if zonefile_record
209
+ self.host = qualify_host(zonefile_record.host.to_s)
210
+ @vars[:last_host] = host
211
+ self.ttl = zonefile_record.ttl.to_i
212
+ self.klass = zonefile_record.klass.to_s
213
+ self.data = zonefile_record.data.to_s
214
+ end
224
215
  end
225
216
  end
226
217
 
227
218
  class NS < Record
228
219
  attr_accessor :host, :domainname
229
220
 
230
- inheriting_writer_for_at :host
231
- writer_for_at :domainname
232
-
233
221
  def initialize(vars, zonefile_record)
234
- @vars = vars
235
- if zonefile_record
236
- self.host = zonefile_record.host.to_s
237
- @vars[:last_host] = self.host
238
- self.ttl = zonefile_record.ttl.to_i
239
- self.klass = zonefile_record.klass.to_s
240
- self.domainname = zonefile_record.nameserver.to_s
241
- end
222
+ @vars = vars
223
+ if zonefile_record
224
+ self.host = qualify_host(zonefile_record.host.to_s)
225
+ @vars[:last_host] = host
226
+ self.ttl = zonefile_record.ttl.to_i
227
+ self.klass = zonefile_record.klass.to_s
228
+ self.domainname = qualify_host(zonefile_record.nameserver.to_s)
229
+ end
242
230
  end
243
231
 
244
- alias :nameserver :domainname
232
+ alias nameserver domainname
245
233
  end
246
234
 
247
235
  class PTR < Record
248
236
  attr_accessor :host, :domainname
249
237
 
250
- inheriting_writer_for_at :host
251
- writer_for_at :domainname
252
-
253
238
  def initialize(vars, zonefile_record)
254
- @vars = vars
255
- if zonefile_record
256
- self.host = zonefile_record.host.to_s
257
- @vars[:last_host] = self.host
258
- self.ttl = zonefile_record.ttl.to_i
259
- self.klass = zonefile_record.klass.to_s
260
- self.domainname = zonefile_record.target.to_s
261
- end
239
+ @vars = vars
240
+ if zonefile_record
241
+ self.host = qualify_host(zonefile_record.host.to_s)
242
+ @vars[:last_host] = host
243
+ self.ttl = zonefile_record.ttl.to_i
244
+ self.klass = zonefile_record.klass.to_s
245
+ self.domainname = qualify_host(zonefile_record.target.to_s)
246
+ end
262
247
  end
263
248
 
264
- alias :target :domainname
249
+ alias target domainname
265
250
  end
266
251
 
267
252
  class SRV < Record
268
253
  attr_accessor :host, :priority, :weight, :port, :domainname
269
254
 
270
- inheriting_writer_for_at :host
271
- writer_for_at :domainname
272
-
273
255
  def initialize(vars, zonefile_record)
274
- @vars = vars
275
- if zonefile_record
276
- self.host = zonefile_record.host.to_s
277
- @vars[:last_host] = self.host
278
- self.ttl = zonefile_record.ttl.to_i
279
- self.klass = zonefile_record.klass.to_s
280
- self.priority = zonefile_record.priority.to_i
281
- self.weight = zonefile_record.weight.to_i
282
- self.port = zonefile_record.port.to_i
283
- self.domainname = zonefile_record.target.to_s
284
- end
256
+ @vars = vars
257
+ if zonefile_record
258
+ self.host = qualify_host(zonefile_record.host.to_s)
259
+ @vars[:last_host] = host
260
+ self.ttl = zonefile_record.ttl.to_i
261
+ self.klass = zonefile_record.klass.to_s
262
+ self.priority = zonefile_record.priority.to_i
263
+ self.weight = zonefile_record.weight.to_i
264
+ self.port = zonefile_record.port.to_i
265
+ self.domainname = qualify_host(zonefile_record.target.to_s)
266
+ end
285
267
  end
286
268
 
287
- alias :target :domainname
269
+ alias target domainname
270
+ end
271
+
272
+ class SSHFP < Record
273
+ attr_accessor :host, :alg, :fptype, :fp
274
+
275
+ def initialize(vars, zonefile_record)
276
+ @vars = vars
277
+ if zonefile_record
278
+ self.host = qualify_host(zonefile_record.host.to_s)
279
+ @vars[:last_host] = host
280
+ self.ttl = zonefile_record.ttl.to_i
281
+ self.klass = zonefile_record.klass.to_s
282
+ self.alg = zonefile_record.alg.to_i
283
+ self.fptype = zonefile_record.fptype.to_i
284
+ self.fp = zonefile_record.fp.to_s
285
+ end
286
+ end
288
287
  end
289
288
 
290
289
  class TXT < Record
291
290
  attr_accessor :host, :data
292
291
 
293
- inheriting_writer_for_at :host
294
-
295
292
  def initialize(vars, zonefile_record)
296
- @vars = vars
297
- if zonefile_record
298
- self.host = zonefile_record.host.to_s
299
- @vars[:last_host] = self.host
300
- self.ttl = zonefile_record.ttl.to_i
301
- self.klass = zonefile_record.klass.to_s
302
- self.data = zonefile_record.data.to_s
303
- end
293
+ @vars = vars
294
+ if zonefile_record
295
+ self.host = qualify_host(zonefile_record.host.to_s)
296
+ @vars[:last_host] = host
297
+ self.ttl = zonefile_record.ttl.to_i
298
+ self.klass = zonefile_record.klass.to_s
299
+ self.data = zonefile_record.data.to_s
300
+ end
304
301
  end
305
302
  end
306
303