Commit f8431022 authored by Colin Shea's avatar Colin Shea

DKIM records generate a quoted TXT record

Before they weren't, so using the PowerDNS API caused complaints
parent f809ab1f
......@@ -155,7 +155,7 @@ class Zone
raise ArgumentError, "invalid port: #{port}" if port < 0 || port > 65535
raise ArgumentError, "invalid protocol: #{protocol}" if protocol.to_s !~ /^[a-z]+$/
raise ArgumentError, "no data given" unless data
raise ArgumentError, 'no data given' unless data
raise ArgumentError, "invalid usage: #{usage}" unless Integer === usage
raise ArgumentError, "invalid selector: #{selector}" unless Integer === selector
raise ArgumentError, "invalid matching_type: #{matching}" unless Integer === matching
......@@ -172,7 +172,7 @@ class Zone
raise ArgumentError, "invalid key type, only RSA supported: #{type}" if type != "rsa"
push :txt, "#{selector}._domainkey", ttl, text: "v=DKIM1; k=#{type}; p=#{pubkey}"
push :txt, "#{selector}._domainkey", ttl, text: "\"v=DKIM1; k=#{type}; p=#{pubkey}\""
end
# name in not-reversed order
......
......@@ -52,7 +52,7 @@ class ZoneGenerator
File.open(@tmp_named, 'w') do |f|
Dir.glob("#{@zones_dir}/**/*.rb").sort.each do |file|
domain = File.basename(file).sub(/\.rb$/, nil)
domain = File.basename(file).sub(/\.rb$/, '')
puts "Parsing zone for #{domain}"
generate_zone(file, domain)
......
......@@ -220,7 +220,6 @@ class Zonefile
hexadeimal = /([\sA-F0-9]*)/i
quoted = /(\"[^\"]*\")/i
data = {}
if line =~ /^\$ORIGIN\s*(#{valid_name})/ix then
@origin = $1
elsif line =~ /^(#{valid_name})? \s*
......@@ -230,20 +229,20 @@ class Zonefile
/ix then
(name, ttl, dclass, type, host) = [$1, $2, $3, $4, $5]
add_record($4, :name => $1, :ttl => $2, :class => $3, :host => $5)
elsif line=~/^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
AAAA \s
(#{valid_ip6})
/x then
add_record('aaaa', :name => $1, :ttl => $2, :class => $3, :host => $4)
elsif line=~/^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
MX \s
(\d+) \s
(#{valid_name})
/ix then
add_record('mx', :name => $1, :ttl => $2, :class => $3, :pri => $4.to_i, :host => $5)
elsif line=~/^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
SRV \s
(\d+) \s
......@@ -253,7 +252,7 @@ class Zonefile
/ix
add_record('srv', :name => $1, :ttl => $2, :class => $3, :pri => $4, :weight => $5,
:port => $6, :host => $7)
elsif line=~/^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
DS \s
(\d+) \s
......@@ -263,14 +262,14 @@ class Zonefile
/ix
add_record( 'ds', :name => $1, :ttl => $2, :class => $3, :key_tag => $4.to_i, :algorithm => $5,
:digest_type => $6.to_i, :digest => $7.gsub( /\s/,'') )
elsif line=~/^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
NSEC \s
(#{valid_name}) \s
([\s\w]*)
/ix
add_record( 'nsec', :name => $1, :ttl => $2, :class => $3, :next => $4, :types => $5.strip )
elsif line=~/^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
NSEC3 \s
(\d+) \s
......@@ -282,7 +281,7 @@ class Zonefile
/ix
add_record( 'nsec3', :name => $1, :ttl => $2, :class => $3, :algorithm => $4, :flags => $5,
:iterations => $6, :salt => $7, :next => $8.strip, :types => $9.strip )
elsif line=~/^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
NSEC3PARAM \s
(\d+) \s
......@@ -292,7 +291,7 @@ class Zonefile
/ix
add_record( 'nsec3param', :name => $1, :ttl => $2, :class => $3, :algorithm => $4, :flags => $5,
:iterations => $6, :salt => $7 )
elsif line=~/^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
DNSKEY \s
(\d+) \s
......@@ -302,7 +301,7 @@ class Zonefile
/ix
add_record( 'dnskey', :name => $1, :ttl => $2, :class => $3, :flag => $4.to_i, :protocol => $5.to_i,
:algorithm => $6, :public_key => $7.gsub( /\s/,'') )
elsif line=~/^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
RRSIG \s
(\w+) \s
......@@ -318,7 +317,7 @@ class Zonefile
add_record( 'rrsig', :name => $1, :ttl => $2, :class => $3, :type_covered => $4, :algorithm => $5,
:labels => $6.to_i, :original_ttl => $7.to_i, :expiration => $8.to_i, :inception => $9.to_i,
:key_tag => $10.to_i, :signer => $11, :signature => $12.gsub( /\s/,'') )
elsif line=~/^(#{valid_name}) \s*
elsif line =~ /^(#{valid_name}) \s*
#{ttl_cls}
TLSA \s
(\d+) \s
......@@ -328,7 +327,7 @@ class Zonefile
/ix
add_record( 'tlsa', :name => $1, :ttl => $2, :class => $3, :certificate_usage => $4.to_i,
:selector => $5.to_i, :matching_type => $6.to_i, :data => $7 )
elsif line=~/^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
NAPTR \s
(\d+) \s
......@@ -340,7 +339,7 @@ class Zonefile
/ix
add_record( 'naptr', :name => $1, :ttl => $2, :class => $3, :order => $4.to_i, :preference => $5.to_i,
:flags => $6, :service => $7, :regexp => $8, :replacement => $9 )
elsif line=~/^(#{valid_name}) \s+
elsif line =~ /^(#{valid_name}) \s+
#{ttl_cls}
SOA \s+
(#{valid_name}) \s+
......@@ -364,7 +363,7 @@ class Zonefile
@soa[:expire] = $9
@soa[:minimumTTL] = $10
elsif line=~ /^(#{valid_name})? \s*
elsif line =~ /^(#{valid_name})? \s*
#{ttl_cls}
PTR \s+
(#{valid_name})
......@@ -374,7 +373,7 @@ class Zonefile
add_record('txt', :name => $1, :ttl => $2, :class => $3, :text => $4.strip)
elsif line =~ /^(#{valid_name})? \s* #{ttl_cls} SPF \s+ (.*)$/ix
add_record('spf', :name => $1, :ttl => $2, :class => $3, :text => $4.strip)
elsif line=~/^(#{valid_name})? \s*
elsif line =~/^(#{valid_name})? \s*
#{ttl_cls}
SSHFP \s+
(\d+) \s+
......@@ -382,7 +381,7 @@ class Zonefile
#{hexadeimal}
/ix
add_record('sshfp', :name => $1, :ttl => $2, :class => $3, key_type: $4.to_i, fingerprint_type: $5.to_i, fingerprint: $6.strip)
elsif line=~/^(#{valid_name})? \s*
elsif line =~/^(#{valid_name})? \s*
#{ttl_cls}
CAA \s+
(\d+) \s+
......@@ -450,7 +449,8 @@ ENDH
out += "\n; Zone TXT Records\n" unless self.txt.empty?
self.txt.each do |tx|
out += "#{tx[:name]} #{tx[:ttl]} #{tx[:class]} TXT (#{tx[:text].chars.each_slice(255).map { |txt_part| "\"#{txt_part}\"" }.join(' ')})\n"
#out += "#{tx[:name]} #{tx[:ttl]} #{tx[:class]} TXT (#{tx[:text].chars.each_slice(255).map { |txt_part| "\"#{txt_part.join(nil)}\"" }.join(' ')})\n"
out += "#{tx[:name]} #{tx[:ttl]} #{tx[:class]} TXT #{tx[:text]}\n"
end
out += "\n; Zone SPF Records\n" unless self.spf.empty?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment