Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ The following is a (non-exhaustive) list of features :

- Implemented RRs : A, AAAA, AFSDB, ANY, CAA, CERT, CNAME, DNAME,
GPOS, HINFO, ISDN, LOC, MB, MG, MINFO, MR, MX, NAPTR, NS, NSAP,
NXT, OPT, PTR, PX, RP, RT, SOA, SPF, SRV, TKEY, TSIG, TXT,
WKS, X25, DNSKEY, RRSIG, NSEC, NSEC3, NSEC3PARAM, DS, DLV
NXT, OPT, PTR, PX, RP, RT, SOA, SPF, SRV, SVCB, HTTPS, TKEY,
TSIG, TXT, WKS, X25, DNSKEY, RRSIG, NSEC, NSEC3, NSEC3PARAM, DS, DLV

- Generic RR types supported (RFC3597)

Expand Down
9 changes: 9 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Release Notes

## Unreleased

* Add support for SVCB (type 64) and HTTPS (type 65) resource records - RFC 9460, including zone file parsing with TargetName origin resolution
* Recognises the registered SvcParamKey mnemonics `mandatory`, `alpn`, `no-default-alpn`, `port`, `ipv4hint`, `ipv6hint` (RFC 9460), `ech` (RFC 9848), `dohpath` (RFC 9461), `ohttp` (RFC 9540) and `docpath` (RFC 9953). Any other key reads and writes as `keyNNNNN`
* **Breaking (text output only)** - `Dnsruby::IPv6#to_s` and `#inspect` now emit the RFC 5952 canonical form: lowercase hex, no leading zeros, and `::` for the longest run of all-zero fields (never a single field)
* Affects `AAAA`, `IPSECKEY` and `APL` records and log output; code that string-compares the old uppercase form needs updating. Parsing and wire format are unchanged
* `::ffff:0:0/96` now uses the mixed notation (`::ffff:192.0.2.1`); the deprecated IPv4-compatible `::/96` range keeps the hexadecimal form, unlike `IPAddr#to_s` and `inet_ntop`
* Fix `Dnsruby::ZoneReader` splitting an unquoted character-string in two at a backslash-escaped quote - RFC 1035 Section 5.1 makes `\"` a literal quote, so `TXT \"escaped` is one string and was previously read as `"", "\"escaped"`

## v1.74.0

* Resolve all configured nameservers in parallel
Expand Down
2 changes: 2 additions & 0 deletions lib/dnsruby/code_mappers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ class Types < CodeMapper
HIP = 55 # RFC 5205
CDS = 59 # RFC 7344
CDNSKEY = 60 # RFC 7344
SVCB = 64 # RFC 9460
HTTPS = 65 # RFC 9460
SPF = 99 # RFC 4408
UINFO = 100 # non-standard
UID = 101 # non-standard
Expand Down
38 changes: 33 additions & 5 deletions lib/dnsruby/ipv6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,40 @@ def initialize(address) #:nodoc:
# The raw IPv6 address as a String
attr_reader :address

# The RFC 5952 canonical text representation of the address
def to_s
address = sprintf("%X:%X:%X:%X:%X:%X:%X:%X", *@address.unpack("nnnnnnnn"))
unless address.sub!(/(^|:)0(:0)+(:|$)/, '::')
address.sub!(/(^|:)0(:|$)/, '::')
fields = @address.unpack("n8")

# RFC 5952 section 5: an address carrying an embedded IPv4 address
# under the well-known ::ffff:0:0/96 prefix is written in the mixed
# hexadecimal / dotted decimal notation.
if fields[0, 5].all?(&:zero?) && fields[5] == 0xffff
return "::ffff:" + fields[6, 2].pack("n2").unpack("C4").join(".")
end

# RFC 5952 section 4.2.3: "::" replaces the longest run of consecutive
# all-zero fields, and the first such run when several are equally long.
# Section 4.2.2: a run of a single all-zero field is never replaced.
run_start = nil
best_start, best_length = nil, 1
fields.each_with_index do |field, i|
if field == 0
run_start ||= i
length = i - run_start + 1
best_start, best_length = run_start, length if length > best_length
else
run_start = nil
end
end

# RFC 5952 sections 4.1 and 4.3: no leading zeros, and lowercase hex
strings = fields.map {|field| field.to_s(16)}
if best_start
strings[best_start, best_length] = ['']
strings.unshift('') if best_start == 0
strings.push('') if best_start + best_length == fields.length
end
return address
return strings.join(':')
end

def inspect #:nodoc:
Expand Down Expand Up @@ -141,4 +169,4 @@ def hash
return @address.hash
end
end
end
end
16 changes: 16 additions & 0 deletions lib/dnsruby/resource/HTTPS.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'dnsruby/resource/SVCB'

module Dnsruby
class RR
# Class for DNS HTTPS resource records.
#
# RFC 9460 sec 9
#
# The HTTPS-specific instantiation of the SVCB record, sharing its wire and
# presentation formats, for the "https" and "http" URI schemes.
class HTTPS < SVCB
ClassValue = nil #:nodoc: all
TypeValue = Types::HTTPS #:nodoc: all
end
end
end
2 changes: 2 additions & 0 deletions lib/dnsruby/resource/IN.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class RR
Types::GPOS => GPOS,
Types::NXT => NXT,
Types::CAA => CAA,
Types::SVCB => SVCB,
Types::HTTPS => HTTPS,
} #:nodoc: all

# module IN contains ARPA Internet specific RRs
Expand Down
Loading
Loading