Commit 6a9a3724 authored by Colin Shea's avatar Colin Shea

SSHFP record type

parent 86c2af1b
......@@ -38,3 +38,6 @@ mx "*.user", "mail"
domainkey "google", "rsa", "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8it8iFFspQzey9IbqmjcmuYe9ScVCxnYKqdI+qCBIGy9rV+EqHqW6acjPcoIcodcJ4XQxIOUQ5XrC0ZNL68k7Vi6p0lwCgBpsIrHYDyujL2NHm11plVcCFCJKbWdu9v7eiWOeUCtPNX/QIaGLUDjGM0twXYaMuwvyd3RA8AXJ2QIDAQAB"
domainkey "google2", "rsa", "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8it8iFFspQzey9IbqmjcmuYe9ScVCxnYKqdI+qCBIGy9rV+EqHqW6acjPcoIcodcJ4XQxIOUQ5XrC0ZNL68k7Vi6p0lwCgBpsIrHYDyujL2NHm11plVcCFCJKbWdu9v7eiWOeUCtPNX/QIaGLUDjGM0twXYaMuwvyd3RA8AXJ2QIDAQAB", 2400
sshfp "@", 3, 1, "6ebd5d0a92eb1639ce59702da4afa29b8fa09a49"
sshfp "@", 3, 2, "ba7c07e606affd64fa4c782a11f552ba3138266fd51a7aaac7bc370c8fa2c112"
......@@ -185,6 +185,10 @@ class Zone
ptr name.split(":").map{|b| b.rjust(4,"0") }.join.reverse.split("").join("."), *args
end
def sshfp(name, key_type, fingerprint_type, fingerprint, ttl=nil)
push :sshfp, name, ttl, key_type: key_type, fingerprint_type: fingerprint_type, fingerprint: fingerprint
end
protected
# evaluates a file
......
......@@ -102,7 +102,7 @@
class Zonefile
RECORDS = %w{ mx a aaaa ns cname txt ptr srv soa ds dnskey rrsig nsec nsec3 nsec3param tlsa naptr spf }
RECORDS = %w{ mx a aaaa ns cname txt ptr srv soa ds dnskey rrsig nsec nsec3 nsec3param tlsa naptr spf sshfp }
attr :records
attr :soa
attr :data
......@@ -369,6 +369,8 @@ 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* #{ttl_cls} SSHFP (\d) (\d) (.*)$/ix
add_record('sshfp', :name => $1, :ttl => $2, :class => $3, key_type: $4, fingerprint_type: $5, fingerprint: $6.strip)
elsif line =~ /\$TTL\s+(#{rr_ttl})/i
@ttl = $1
end
......@@ -484,6 +486,11 @@ ENDH
out << "#{naptr[:name]} #{naptr[:ttl]} #{naptr[:class]} NAPTR #{naptr[:order]} #{naptr[:preference]} #{naptr[:flags]} #{naptr[:service]} #{naptr[:regexp]} #{naptr[:replacement]}\n"
end
out << "\n; Zone SSHFP Records\n" unless self.sshfp.empty?
self.sshfp.each do |sshfp|
out << "#{sshfp[:name]} #{sshfp[:ttl]} #{sshfp[:class]} SSHFP #{sshfp[:key_type]} #{sshfp[:fingerprint_type]} #{sshfp[:fingerprint]}"
end
out
end
......
......@@ -169,9 +169,13 @@ describe Zone do
it "should create a DKIM TXT record" do
subject.domainkey "google", "rsa", "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8it8iFFspQzey9IbqmjcmuYe9ScVCxnYKqdI+qCBIGy9rV+EqHqW6acjPcoIcodcJ4XQxIOUQ5XrC0ZNL68k7Vi6p0lwCgBpsIrHYDyujL2NHm11plVcCFCJKbWdu9v7eiWOeUCtPNX/QIaGLUDjGM0twXYaMuwvyd3RA8AXJ2QIDAQAB"
subject.zonefile.txt.must_equal [{:class=>"IN", :name=>"google._domainkey", :ttl=>nil, :text=>"v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8it8iFFspQzey9IbqmjcmuYe9ScVCxnYKqdI+qCBIGy9rV+EqHqW6acjPcoIcodcJ4XQxIOUQ5XrC0ZNL68k7Vi6p0lwCgBpsIrHYDyujL2NHm11plVcCFCJKbWdu9v7eiWOeUCtPNX/QIaGLUDjGM0twXYaMuwvyd3RA8AXJ2QIDAQAB"}]
#
end
end
describe "sshfp record" do
it "should create a sshfp record" do
subject.sshfp "@", 3, 1, "6ebd5d0a92eb1639ce59702da4afa29b8fa09a49"
subject.zonefile.sshfp.must_equal [{:class=>"IN", :name=>"@", :ttl=>nil, :key_type=>3, :fingerprint_type=>1, :fingerprint=>"6ebd5d0a92eb1639ce59702da4afa29b8fa09a49"}]
end
end
end
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