Commit e9b66fb3 authored by Julian Kornberger's avatar Julian Kornberger

Support for TLSA records

parent 3dfbe38a
source 'https://rubygems.org'
gem 'zonefile'
gem 'zonefile', '~> 1.5', github: 'digineo/zonefile', branch: 'tlsa'
GIT
remote: git://github.com/digineo/zonefile.git
revision: 59f007e8dc0d9f25a6d586b63f74a96fb56bd0f4
branch: tlsa
specs:
zonefile (1.05)
GEM
remote: https://rubygems.org/
specs:
zonefile (1.04)
PLATFORMS
ruby
DEPENDENCIES
zonefile
zonefile (~> 1.5)!
......@@ -22,6 +22,9 @@ txt "google-site-verification=vEj1ZcGtXeM_UEjnCqQEhxPSqkS9IQ4PBFuh48FP8o4"
# SRV records
srv :sip, :tcp, "sipserver.example.net.", 5060
# TLSA record
tlsa 443, :tcp, "@", 0, 0, 1, "e36d9e402c6308273375b68297f7ae207521238f0cd812622672f0f2ce67eb1c"
# Wildcard records
a "*.user", "192.168.1.100"
mx "*.user", "mail"
......@@ -116,6 +116,28 @@ class Zone
push :txt, name, ttl, text: text
end
def tlsa(*args)
ttl = extract_ttl! args
name = args.shift if String===args[0]
name = (name=="@" || !name) ? '' : "." << name
port = args.shift
protocol = args.shift
usage = args.shift
selector = args.shift
matching = args.shift
data = args.shift
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, "invalid usage: #{usage}" unless Fixnum === usage
raise ArgumentError, "invalid selector: #{selector}" unless Fixnum === selector
raise ArgumentError, "invalid matching_type: #{matching}" unless Fixnum === matching
push :tlsa, "_#{port}._#{protocol}#{name}", ttl,
certificate_usage: usage, selector: selector, matching_type: matching, data: data
end
# name in not-reversed order
def ptr(name, host, ttl=nil)
......@@ -151,4 +173,4 @@ class Zone
args.pop if args.last.is_a?(Fixnum)
end
end
\ No newline at end of file
end
......@@ -139,4 +139,24 @@ describe Zone do
end
end
end
\ No newline at end of file
describe "tlsa record" do
it "should create tlsa record" do
subject.tlsa "www", 443, :tcp, 3, 0, 1, 'e31d9e402c6308273375b68297f7af207521238f0cd812622672f0f2ce67eb1c'
subject.zonefile.tlsa.must_equal [{:class=>"IN", :name=>"_443._tcp.www", :ttl=>nil, :certificate_usage=>3, :selector=>0, :matching_type=>1, :data=>"e31d9e402c6308273375b68297f7af207521238f0cd812622672f0f2ce67eb1c"}]
end
it "should create tlsa record without subdomain" do
subject.tlsa 443, :tcp, 3, 0, 1, 'e31d9e402c6308273375b68297f7af207521238f0cd812622672f0f2ce67eb1c', 3600
subject.zonefile.tlsa.must_equal [{:class=>"IN", :name=>"_443._tcp", :ttl=>3600, :certificate_usage=>3, :selector=>0, :matching_type=>1, :data=>"e31d9e402c6308273375b68297f7af207521238f0cd812622672f0f2ce67eb1c"}]
end
it "with invalid port" do
assert_raises ArgumentError do
subject.tlsa "www", 123456, :tcp, 3, 0, 1, 'e31d9e402c6308273375b68297f7af207521238f0cd812622672f0f2ce67eb1c'
end
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