dns-catalog_zone 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +13 -0
- data/.rspec +1 -0
- data/.travis.yml +11 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.jp.md +115 -0
- data/README.md +113 -0
- data/Rakefile +8 -0
- data/bin/catz +33 -0
- data/certs/mimuret.pem +21 -0
- data/dns-catalog_zone.gemspec +33 -0
- data/lib/dns/catalog_zone.rb +40 -0
- data/lib/dns/catalog_zone/catalog_zone.rb +125 -0
- data/lib/dns/catalog_zone/cli.rb +88 -0
- data/lib/dns/catalog_zone/config.rb +83 -0
- data/lib/dns/catalog_zone/errors.rb +32 -0
- data/lib/dns/catalog_zone/helper.rb +98 -0
- data/lib/dns/catalog_zone/master.rb +47 -0
- data/lib/dns/catalog_zone/output.rb +44 -0
- data/lib/dns/catalog_zone/output/base.rb +42 -0
- data/lib/dns/catalog_zone/output/file.rb +57 -0
- data/lib/dns/catalog_zone/output/stdout.rb +41 -0
- data/lib/dns/catalog_zone/prefixes.rb +45 -0
- data/lib/dns/catalog_zone/provider.rb +46 -0
- data/lib/dns/catalog_zone/provider/base.rb +66 -0
- data/lib/dns/catalog_zone/provider/knot.rb +278 -0
- data/lib/dns/catalog_zone/provider/nsd.rb +106 -0
- data/lib/dns/catalog_zone/provider/yadifa.rb +139 -0
- data/lib/dns/catalog_zone/source.rb +47 -0
- data/lib/dns/catalog_zone/source/axfr.rb +54 -0
- data/lib/dns/catalog_zone/source/base.rb +59 -0
- data/lib/dns/catalog_zone/source/file.rb +49 -0
- data/lib/dns/catalog_zone/version.rb +27 -0
- data/lib/dns/catalog_zone/zone.rb +39 -0
- data/share/CatalogZone +24 -0
- data/share/knotd-catalog.sh +32 -0
- data/share/nsd-catalog.sh +37 -0
- data/share/yadifad-catalog.sh +34 -0
- metadata +183 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Manabu Sonoda
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'ipaddr'
|
24
|
+
|
25
|
+
module Dns
|
26
|
+
module CatalogZone
|
27
|
+
module Provider
|
28
|
+
class Nsd < Base
|
29
|
+
def make(catalog_zone)
|
30
|
+
@output = ''
|
31
|
+
global_config(catalog_zone)
|
32
|
+
zones_config(catalog_zone)
|
33
|
+
end
|
34
|
+
def reconfig
|
35
|
+
system("#{control} reconfig")
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def control
|
40
|
+
@setting['control'] || "nsd-control"
|
41
|
+
end
|
42
|
+
|
43
|
+
def global_config(catalog_zone)
|
44
|
+
output "pattern:\n"
|
45
|
+
output "\tname: \"CatalogZone\"\n"
|
46
|
+
catalog_zone.masters.each_pair do |label, master|
|
47
|
+
output output_master(master, "#{label}.masters")
|
48
|
+
end
|
49
|
+
catalog_zone.notifies.each_pair do |label, notify|
|
50
|
+
output output_notify(notify, "#{label}.notifies")
|
51
|
+
end
|
52
|
+
catalog_zone.allow_transfers.each_pair do |_label, prefixes|
|
53
|
+
output output_prefixes(prefixes)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def output_master(master, label = 'global')
|
58
|
+
request_xfr = []
|
59
|
+
allow_notify = []
|
60
|
+
master.addresses.each do |addr|
|
61
|
+
ipa = IPAddr.new(addr)
|
62
|
+
plen = ipa.ipv4? ? 32 : 128
|
63
|
+
tsig = master.tsig || 'NOKEY'
|
64
|
+
request_xfr << "\trequest-xfr: #{addr}@#{master.port} #{tsig}\n"
|
65
|
+
allow_notify << "\tallow-notify: #{addr}/#{plen}@#{master.port} #{tsig}\n"
|
66
|
+
end
|
67
|
+
output = request_xfr.join + allow_notify.join
|
68
|
+
return "\t# #{label}\n#{output}" unless output.empty?
|
69
|
+
end
|
70
|
+
|
71
|
+
def output_notify(notify, label = 'global')
|
72
|
+
notifies = []
|
73
|
+
provide_xfr = []
|
74
|
+
notify.addresses.each do |addr|
|
75
|
+
ipa = IPAddr.new(addr)
|
76
|
+
plen = ipa.ipv4? ? 32 : 128
|
77
|
+
tsig = notify.tsig || 'NOKEY'
|
78
|
+
notifies << "\tnotify: #{addr}@#{notify.port} #{tsig}\n"
|
79
|
+
provide_xfr << "\tprovide-xfr: #{addr}/#{plen}@#{notify.port} #{tsig}\n"
|
80
|
+
end
|
81
|
+
output = notifies.join + provide_xfr.join
|
82
|
+
return "\t# #{label}\n#{output}" unless output.empty?
|
83
|
+
end
|
84
|
+
|
85
|
+
def output_prefixes(_prefixes)
|
86
|
+
''
|
87
|
+
end
|
88
|
+
|
89
|
+
def zones_config(catalog_zone)
|
90
|
+
catalog_zone.zones.each_pair do |_hash, zone|
|
91
|
+
output "zone:\n"
|
92
|
+
output "\tinclude-pattern: \"CatalogZone\"\n"
|
93
|
+
output "\tname: \"#{zone.zonename}\"\n"
|
94
|
+
output "\tzonefile: \"#{zonepath(zone)}\"\n"
|
95
|
+
zone.masters.each_pair do |label, master|
|
96
|
+
output output_master(master, "#{label}.masters")
|
97
|
+
end
|
98
|
+
zone.notifies.each_pair do |label, notify|
|
99
|
+
output output_notify(notify, "#{label}.notifies")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Manabu Sonoda
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
module Dns
|
24
|
+
module CatalogZone
|
25
|
+
module Provider
|
26
|
+
class Yadifa < Base
|
27
|
+
def initialize(setting)
|
28
|
+
@setting = setting
|
29
|
+
end
|
30
|
+
|
31
|
+
def make(catalog_zone)
|
32
|
+
@output = ''
|
33
|
+
@type = 'master'
|
34
|
+
@templates = []
|
35
|
+
@acls = []
|
36
|
+
@remotes = []
|
37
|
+
@zones = []
|
38
|
+
@masters = []
|
39
|
+
@notifies = []
|
40
|
+
global_config(catalog_zone)
|
41
|
+
zones_config(catalog_zone)
|
42
|
+
end
|
43
|
+
|
44
|
+
def reconfig
|
45
|
+
system("#{control} cfgreload")
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def control
|
50
|
+
@setting['control'] || "yadifa"
|
51
|
+
end
|
52
|
+
|
53
|
+
def global_config(catalog_zone)
|
54
|
+
allow_transfers = []
|
55
|
+
|
56
|
+
catalog_zone.masters.each_pair do |_label, master|
|
57
|
+
add_master(master, @masters)
|
58
|
+
end
|
59
|
+
catalog_zone.notifies.each_pair do |_label, notify|
|
60
|
+
add_notify(notify, @notifies)
|
61
|
+
end
|
62
|
+
catalog_zone.allow_transfers.each_pair do |_label, prefixes|
|
63
|
+
add_prefixes(prefixes, allow_transfers)
|
64
|
+
end
|
65
|
+
|
66
|
+
output_r '<main>'
|
67
|
+
# for master
|
68
|
+
unless @masters.empty?
|
69
|
+
output_r "\tallow-notify\t#{@masters.join(';')}"
|
70
|
+
end
|
71
|
+
|
72
|
+
# for allow-transfer
|
73
|
+
unless allow_transfers.empty?
|
74
|
+
output_r "\tallow-transfer\t#{allow_transfers.join(';')}"
|
75
|
+
end
|
76
|
+
output_r '</main>'
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_master(master, masters)
|
80
|
+
return if master.addresses.empty?
|
81
|
+
@type = 'slave'
|
82
|
+
masters.push(master.addresses)
|
83
|
+
end
|
84
|
+
|
85
|
+
def add_notify(notify, notifies)
|
86
|
+
return if notify.addresses.empty?
|
87
|
+
notifies.push(notify.addresses)
|
88
|
+
end
|
89
|
+
|
90
|
+
def add_prefixes(prefixes, allow_transfers)
|
91
|
+
prefixes.prefixes.each do |prefix|
|
92
|
+
allow_transfers.push("#{prefix.address}/#{prefix.prefix_length}")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def zones_config(catalog_zone)
|
97
|
+
catalog_zone.zones.each_pair do |_hash, zone|
|
98
|
+
masters = @masters.clone
|
99
|
+
notifies = @notifies.clone
|
100
|
+
allow_transfers = []
|
101
|
+
|
102
|
+
zone.masters.each_pair do |_label, master|
|
103
|
+
add_master(master, masters)
|
104
|
+
end
|
105
|
+
zone.notifies.each_pair do |_label, notify|
|
106
|
+
add_notify(notify, notifies)
|
107
|
+
end
|
108
|
+
zone.allow_transfers.each_pair do |_label, prefixes|
|
109
|
+
add_prefixes(prefixes, allow_transfers)
|
110
|
+
end
|
111
|
+
|
112
|
+
output_r '<zone>'
|
113
|
+
output_r "\ttype\t#{@type}"
|
114
|
+
output_r "\tdomain\t#{zone.zonename}"
|
115
|
+
output_r "\tfile\t#{zonepath(zone)}"
|
116
|
+
# for master
|
117
|
+
unless masters.empty?
|
118
|
+
output_r "\tallow-notify\t#{masters.join(';')}"
|
119
|
+
output_r "\tmasters\t#{masters.join(',')}"
|
120
|
+
output_r "\ttrue-multimaster\tyes" if masters.count > 1
|
121
|
+
end
|
122
|
+
|
123
|
+
# for notify
|
124
|
+
unless notifies.empty?
|
125
|
+
output_r "\talso-notify\t#{notifies.join(',')}"
|
126
|
+
allow_transfers = notifies
|
127
|
+
end
|
128
|
+
|
129
|
+
# for allow-transfer
|
130
|
+
unless allow_transfers.empty?
|
131
|
+
output_r "\tallow-transfer\t#{allow_transfers.join(';')}"
|
132
|
+
end
|
133
|
+
output_r '</zone>'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Manabu Sonoda
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'dns/catalog_zone/source/base'
|
24
|
+
|
25
|
+
module Dns
|
26
|
+
module CatalogZone
|
27
|
+
# source module
|
28
|
+
module Source
|
29
|
+
class << self
|
30
|
+
def create(setting)
|
31
|
+
type = setting.source
|
32
|
+
class_name = "Dns::CatalogZone::Source::#{type.ucc}"
|
33
|
+
begin
|
34
|
+
require "dns/catalog_zone/source/#{type}"
|
35
|
+
source = Object.const_get(class_name).new(setting)
|
36
|
+
rescue LoadError
|
37
|
+
raise Dns::CatalogZone::ValidateError, "can't find #{class_name}"
|
38
|
+
rescue NameError
|
39
|
+
raise Dns::CatalogZone::ValidateError, "can't find #{class_name}"
|
40
|
+
end
|
41
|
+
source
|
42
|
+
end
|
43
|
+
end
|
44
|
+
class SourceValidateError < RuntimeError; end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Manabu Sonoda
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'timeout'
|
24
|
+
|
25
|
+
module Dns
|
26
|
+
module CatalogZone
|
27
|
+
module Source
|
28
|
+
class Axfr < Base
|
29
|
+
def get
|
30
|
+
zt = Dnsruby::ZoneTransfer.new
|
31
|
+
zt.server = @setting.server
|
32
|
+
zt.port = @setting.port
|
33
|
+
zt.tsig = @setting.tsig if @setting.tsig
|
34
|
+
zt.src_address = @setting.src_address if @setting.src_address
|
35
|
+
rrsets = []
|
36
|
+
timeout(@setting.timeout.to_i, Dns::CatalogZone::TimeoutError) do
|
37
|
+
begin
|
38
|
+
rrsets = zt.transfer(@setting.zonename)
|
39
|
+
rescue
|
40
|
+
raise Dns::CatalogZone::AxfrError
|
41
|
+
end
|
42
|
+
end
|
43
|
+
rrsets
|
44
|
+
end
|
45
|
+
|
46
|
+
def validate
|
47
|
+
raise SourceValidateError,
|
48
|
+
"[#{@setting.name}] require server param." unless @setting.server
|
49
|
+
super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Manabu Sonoda
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
module Dns
|
24
|
+
module CatalogZone
|
25
|
+
module Source
|
26
|
+
class Base
|
27
|
+
attr_reader :rrsets
|
28
|
+
def initialize(setting)
|
29
|
+
@setting = setting
|
30
|
+
@rrsets = []
|
31
|
+
end
|
32
|
+
|
33
|
+
# get rrsets
|
34
|
+
#
|
35
|
+
# === Returns
|
36
|
+
# rrsets<Array[Dnsruby::RR]>
|
37
|
+
def get
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
|
41
|
+
# get rrsets
|
42
|
+
#
|
43
|
+
# === Raise
|
44
|
+
# SourceValidateError>
|
45
|
+
# === Returns
|
46
|
+
# true<TrueClass>
|
47
|
+
def validate
|
48
|
+
begin
|
49
|
+
Dnsruby::Name.create(@setting.zonename)
|
50
|
+
rescue
|
51
|
+
raise SourceValidateError,
|
52
|
+
"[#{@setting.name}] zonename is not valid domain name."
|
53
|
+
end
|
54
|
+
true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Manabu Sonoda
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
module Dns
|
24
|
+
module CatalogZone
|
25
|
+
module Source
|
26
|
+
class File < Base
|
27
|
+
def get
|
28
|
+
rrsets = []
|
29
|
+
begin
|
30
|
+
reader = Dnsruby::ZoneReader.new(@setting.zonename)
|
31
|
+
rrsets = reader.process_file(@setting.zonefile)
|
32
|
+
rescue
|
33
|
+
raise ZonePraseError
|
34
|
+
end
|
35
|
+
rrsets
|
36
|
+
end
|
37
|
+
|
38
|
+
def validate
|
39
|
+
if @setting.zonefile.class != String ||
|
40
|
+
!::File.exist?(@setting.zonefile)
|
41
|
+
raise Dns::CatalogZone::ValidateError,
|
42
|
+
"[#{@setting.name}] zonefile not found"
|
43
|
+
end
|
44
|
+
super
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|