diff --git a/src/main/java/org/xbill/DNS/SVCBBase.java b/src/main/java/org/xbill/DNS/SVCBBase.java index e2aba92b..e3331c33 100644 --- a/src/main/java/org/xbill/DNS/SVCBBase.java +++ b/src/main/java/org/xbill/DNS/SVCBBase.java @@ -789,10 +789,6 @@ protected void rdataFromString(Tokenizer st, Name origin) throws IOException { } st.unget(); - if (svcPriority > 0 && svcParams.isEmpty()) { - throw new TextParseException( - "At least one parameter value must be specified for ServiceMode"); - } if (svcPriority == 0 && !svcParams.isEmpty()) { throw new TextParseException("No parameter values allowed for AliasMode"); } diff --git a/src/test/java/org/xbill/DNS/SVCBRecordTest.java b/src/test/java/org/xbill/DNS/SVCBRecordTest.java index 966c7a67..d2a8ec13 100644 --- a/src/test/java/org/xbill/DNS/SVCBRecordTest.java +++ b/src/test/java/org/xbill/DNS/SVCBRecordTest.java @@ -117,6 +117,15 @@ void aliasMode() throws IOException { assertEquals(str, wireToString(bytes)); } + @Test + void serviceModeWithoutParameters() throws IOException { + String str = "1 ."; + byte[] bytes = stringToWire(str); + byte[] expected = new byte[] {0, 1, 0}; + assertArrayEquals(expected, bytes); + assertEquals(str, wireToString(bytes)); + } + @Test void serviceModePort() throws IOException { String str = "1 . port=8443"; @@ -319,6 +328,7 @@ void masterFormatParsing() throws IOException { + "test.net. 86400 IN NS ns1.test.net.\n" + "test.net. 300 IN HTTPS 0 www.test.net.\n" + "test.net. 300 IN SVCB 1 . alpn=h2\n" + + "test.net. 300 IN HTTPS 1 .\n" + "www.test.net. 300 IN A 1.2.3.4\n"; Master m = new Master(new ByteArrayInputStream(str.getBytes())); @@ -333,6 +343,9 @@ void masterFormatParsing() throws IOException { assertEquals(Type.SVCB, r.getType()); assertEquals("1 . alpn=h2", r.rdataToString()); r = m.nextRecord(); + assertEquals(Type.HTTPS, r.getType()); + assertEquals("1 .", r.rdataToString()); + r = m.nextRecord(); assertEquals(Type.A, r.getType()); assertEquals("1.2.3.4", r.rdataToString()); r = m.nextRecord(); @@ -351,12 +364,6 @@ void extraQuotesInParamValues() { assertThrows(TextParseException.class, () -> stringToWire(str)); } - @Test - void serviceModeWithoutParameters() { - String str = "1 aliasmode.example.com."; - assertThrows(TextParseException.class, () -> stringToWire(str)); - } - @Test void aliasModeWithParameters() { String str = "0 . alpn=h3"; @@ -465,12 +472,6 @@ void emptyString() { assertThrows(TextParseException.class, () -> stringToWire(str)); } - @Test - void noParamValues() { - String str = "1 ."; - assertThrows(TextParseException.class, () -> stringToWire(str)); - } - @Test void svcPriorityTooHigh() { String str = "65536 . port=443";