GeezerVison is showing github.com — Auto-port 4.1: codec-dns: Add SMIMEA, CDS, CDNSKEY, OPENPGPKEY, CSYNC… · netty/netty@6b72b06
File treeExpand file treeCollapse file tree Open diff view settings main/java/io/netty/handler/codec/dns test/java/io/netty/handler/codec/dns
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: codec-dns/src/main/java/io/netty/handler/codec/dns/DnsRecordType.java +48-3Lines changed: 48 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -228,12 +228,57 @@ public class DnsRecordType implements Comparable<DnsRecordType> { | 228 | 228 | */ | 229 | 229 | public static final DnsRecordType TLSA = new DnsRecordType(0x0034, "TLSA"); | 230 | 230 |
| | 231 | + /** | | 232 | + * S/MIME certificate association record. Uses the same RDATA format as {@link #TLSA}, but | | 233 | + * associates an S/MIME certificate with an email address. RFC 8162 is Experimental rather than | | 234 | + * standards-track, but the code point is assigned and the record is seen on the wire. | | 235 | + * See <a href="https://www.rfc-editor.org/rfc/rfc8162.html">RFC 8162</a>. | | 236 | + */ | | 237 | + public static final DnsRecordType SMIMEA = new DnsRecordType(0x0035, "SMIMEA"); | | 238 | + | 231 | 239 | /** | 232 | 240 | * Host Identity Protocol record RFC 5205 Method of separating the end-point | 233 | 241 | * identifier and locator roles of IP addresses. | 234 | 242 | */ | 235 | 243 | public static final DnsRecordType HIP = new DnsRecordType(0x0037, "HIP"); | 236 | 244 |
| | 245 | + /** | | 246 | + * Child DS record. Published in a child zone to signal the {@link #DS} record the child wishes | | 247 | + * its parent to publish, so that a delegation can be maintained without an out-of-band | | 248 | + * provisioning channel. | | 249 | + * See <a href="https://www.rfc-editor.org/rfc/rfc7344.html">RFC 7344</a>. | | 250 | + */ | | 251 | + public static final DnsRecordType CDS = new DnsRecordType(0x003b, "CDS"); | | 252 | + | | 253 | + /** | | 254 | + * Child DNSKEY record. The child-published counterpart of {@link #DNSKEY}, from which the | | 255 | + * parent may derive the delegation's {@link #DS} record. | | 256 | + * See <a href="https://www.rfc-editor.org/rfc/rfc7344.html">RFC 7344</a>. | | 257 | + */ | | 258 | + public static final DnsRecordType CDNSKEY = new DnsRecordType(0x003c, "CDNSKEY"); | | 259 | + | | 260 | + /** | | 261 | + * OpenPGP public key record. Associates an OpenPGP public key with an email address. RFC 7929 is | | 262 | + * Experimental rather than standards-track, but the code point is assigned and the record is seen | | 263 | + * on the wire. | | 264 | + * See <a href="https://www.rfc-editor.org/rfc/rfc7929.html">RFC 7929</a>. | | 265 | + */ | | 266 | + public static final DnsRecordType OPENPGPKEY = new DnsRecordType(0x003d, "OPENPGPKEY"); | | 267 | + | | 268 | + /** | | 269 | + * Child-to-parent synchronization record. Signals to a parent zone which records a child wishes | | 270 | + * the parent to keep in sync. | | 271 | + * See <a href="https://www.rfc-editor.org/rfc/rfc7477.html">RFC 7477</a>. | | 272 | + */ | | 273 | + public static final DnsRecordType CSYNC = new DnsRecordType(0x003e, "CSYNC"); | | 274 | + | | 275 | + /** | | 276 | + * Message digest for DNS zones. Carries a cryptographic digest over the zone's contents, so that | | 277 | + * a whole zone can be verified independently of the transport that delivered it. | | 278 | + * See <a href="https://www.rfc-editor.org/rfc/rfc8976.html">RFC 8976</a>. | | 279 | + */ | | 280 | + public static final DnsRecordType ZONEMD = new DnsRecordType(0x003f, "ZONEMD"); | | 281 | + | 237 | 282 | /** | 238 | 283 | * Sender Policy Framework record RFC 4408 Specified as part of the SPF | 239 | 284 | * protocol as an alternative to of storing SPF data in TXT records. Uses | @@ -320,11 +365,11 @@ public class DnsRecordType implements Comparable<DnsRecordType> { | 320 | 365 | static { | 321 | 366 | DnsRecordType[] all = { | 322 | 367 | A, NS, CNAME, SOA, PTR, MX, TXT, RP, AFSDB, SIG, KEY, AAAA, LOC, SRV, NAPTR, KX, CERT, DNAME, OPT, APL, | 323 | | - DS, SSHFP, IPSECKEY, RRSIG, NSEC, DNSKEY, DHCID, NSEC3, NSEC3PARAM, TLSA, HIP, SPF, TKEY, TSIG, IXFR, | 324 | | - AXFR, ANY, CAA, TA, DLV, SVCB, HTTPS | | 368 | + DS, SSHFP, IPSECKEY, RRSIG, NSEC, DNSKEY, DHCID, NSEC3, NSEC3PARAM, TLSA, SMIMEA, HIP, CDS, CDNSKEY, | | 369 | + OPENPGPKEY, CSYNC, ZONEMD, SPF, TKEY, TSIG, IXFR, AXFR, ANY, CAA, TA, DLV, SVCB, HTTPS | 325 | 370 | }; | 326 | 371 |
| 327 | | - final StringBuilder expected = new StringBuilder(512); | | 372 | + final StringBuilder expected = new StringBuilder(1024); | 328 | 373 |
| 329 | 374 | expected.append(" (expected: "); | 330 | 375 | for (DnsRecordType type: all) { | |
Collapse file Copy file name to clipboardExpand all lines: codec-dns/src/test/java/io/netty/handler/codec/dns/DnsRecordTypeTest.java +35Lines changed: 35 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -83,4 +83,39 @@ public void testFind() throws Exception { | 83 | 83 | assertSame(t, found, t.name()); | 84 | 84 | } | 85 | 85 | } | | 86 | + | | 87 | + /** | | 88 | + * Pins the code points against the IANA "Resource Record (RR) TYPEs" registry. {@link #testFind()} | | 89 | + * proves a constant is registered, but a transposed number would still round-trip through | | 90 | + * {@link DnsRecordType#valueOf(int)}, so the values themselves are asserted literally. | | 91 | + */ | | 92 | + @Test | | 93 | + public void testCodePointsMatchIanaRegistry() { | | 94 | + assertEquals(43, DnsRecordType.DS.intValue()); | | 95 | + assertEquals(46, DnsRecordType.RRSIG.intValue()); | | 96 | + assertEquals(47, DnsRecordType.NSEC.intValue()); | | 97 | + assertEquals(48, DnsRecordType.DNSKEY.intValue()); | | 98 | + assertEquals(50, DnsRecordType.NSEC3.intValue()); | | 99 | + assertEquals(51, DnsRecordType.NSEC3PARAM.intValue()); | | 100 | + assertEquals(52, DnsRecordType.TLSA.intValue()); | | 101 | + assertEquals(53, DnsRecordType.SMIMEA.intValue()); | | 102 | + assertEquals(59, DnsRecordType.CDS.intValue()); | | 103 | + assertEquals(60, DnsRecordType.CDNSKEY.intValue()); | | 104 | + assertEquals(61, DnsRecordType.OPENPGPKEY.intValue()); | | 105 | + assertEquals(62, DnsRecordType.CSYNC.intValue()); | | 106 | + assertEquals(63, DnsRecordType.ZONEMD.intValue()); | | 107 | + } | | 108 | + | | 109 | + /** | | 110 | + * An unregistered code point must still decode, as an unregistered instance rather than by throwing. | | 111 | + * See {@link DnsRecordType#valueOf(int)}. | | 112 | + */ | | 113 | + @Test | | 114 | + public void testUnregisteredCodePointDecodesAsUnknown() { | | 115 | + // 0xff00 is in the private-use range of the registry, so IANA will never assign it and this | | 116 | + // test cannot start failing when the registry grows. | | 117 | + DnsRecordType unassigned = DnsRecordType.valueOf(0xff00); | | 118 | + assertEquals(0xff00, unassigned.intValue()); | | 119 | + assertEquals("UNKNOWN", unassigned.name()); | | 120 | + } | 86 | 121 | } |
|