mirror of
https://github.com/google/nomulus.git
synced 2025-07-20 09:46:03 +02:00
Make dnsupdate go back to using dnsjava 2.x
Currently the build breaks due to a surprise migration to dnsjava 1.6.4, which is not available in Maven. dnsjava 2.x is available internally, but it jarjar's the package name. So we'll need to deal with that the same way we deal with the Objectify package rename. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=122447929
This commit is contained in:
parent
707e22f2d2
commit
13f5106070
4 changed files with 17 additions and 25 deletions
|
@ -25,7 +25,6 @@ import google.registry.config.ConfigModule.Config;
|
|||
import org.joda.time.Duration;
|
||||
import org.xbill.DNS.Message;
|
||||
import org.xbill.DNS.Opcode;
|
||||
import org.xbill.DNS.SimpleResolver;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -34,7 +33,6 @@ import java.io.OutputStream;
|
|||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.net.SocketFactory;
|
||||
|
@ -42,8 +40,8 @@ import javax.net.SocketFactory;
|
|||
/**
|
||||
* A transport for DNS messages. Sends/receives DNS messages over TCP using old-style {@link Socket}
|
||||
* s and the message framing defined in <a href="https://tools.ietf.org/html/rfc1035">RFC 1035</a>.
|
||||
* We would like use the dnsjava library's {@link SimpleResolver} class for this, but it requires
|
||||
* {@link SocketChannel} which is not supported on AppEngine.
|
||||
* We would like use the dnsjava library's {@link org.xbill.DNS.SimpleResolver} class for this, but
|
||||
* it requires {@link java.nio.channels.SocketChannel} which is not supported on AppEngine.
|
||||
*/
|
||||
public class DnsMessageTransport {
|
||||
|
||||
|
|
|
@ -195,16 +195,13 @@ public class DnsUpdateWriter implements DnsWriter {
|
|||
}
|
||||
|
||||
private RRset makeV6AddressSet(String hostName, Iterable<InetAddress> addresses)
|
||||
throws TextParseException, IOException {
|
||||
throws TextParseException {
|
||||
RRset addressSet = new RRset();
|
||||
for (InetAddress address : addresses) {
|
||||
if (address instanceof Inet6Address) {
|
||||
AAAARecord record =
|
||||
new AAAARecord(
|
||||
toAbsoluteName(hostName),
|
||||
DClass.IN,
|
||||
dnsTimeToLive.getStandardSeconds(),
|
||||
new org.xbill.DNS.Inet6Address(address.getAddress()));
|
||||
toAbsoluteName(hostName), DClass.IN, dnsTimeToLive.getStandardSeconds(), address);
|
||||
addressSet.addRR(record);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.dns.writer.dnsupdate;
|
||||
|
||||
import static com.google.common.io.BaseEncoding.base16;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -41,7 +42,6 @@ import org.xbill.DNS.Rcode;
|
|||
import org.xbill.DNS.Record;
|
||||
import org.xbill.DNS.Type;
|
||||
import org.xbill.DNS.Update;
|
||||
import org.xbill.DNS.utils.base16;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -99,7 +99,7 @@ public class DnsMessageTransportTest {
|
|||
byte[] messageData = new byte[messageLength];
|
||||
sentMessage.get(messageData);
|
||||
assertThat(messageLength).isEqualTo(simpleQuery.toWire().length);
|
||||
assertThat(base16.toString(messageData)).isEqualTo(base16.toString(simpleQuery.toWire()));
|
||||
assertThat(base16().encode(messageData)).isEqualTo(base16().encode(simpleQuery.toWire()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -111,8 +111,8 @@ public class DnsMessageTransportTest {
|
|||
|
||||
Message actualResponse = resolver.send(simpleQuery);
|
||||
|
||||
assertThat(base16.toString(actualResponse.toWire()))
|
||||
.isEqualTo(base16.toString(expectedResponse.toWire()));
|
||||
assertThat(base16().encode(actualResponse.toWire()))
|
||||
.isEqualTo(base16().encode(expectedResponse.toWire()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.dns.writer.dnsupdate;
|
|||
|
||||
import static com.google.common.io.BaseEncoding.base16;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
|
@ -44,8 +45,6 @@ import google.registry.testing.ExceptionRule;
|
|||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectRule;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.Before;
|
||||
|
@ -83,14 +82,14 @@ public class DnsUpdateWriterTest {
|
|||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("1971-01-01TZ"));
|
||||
|
||||
@Mock
|
||||
private DnsMessageTransport mockResolver;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<Update> updateCaptor;
|
||||
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("1971-01-01TZ"));
|
||||
|
||||
private DnsUpdateWriter writer;
|
||||
|
||||
@Before
|
||||
|
@ -188,7 +187,7 @@ public class DnsUpdateWriterTest {
|
|||
ImmutableSet.of(
|
||||
InetAddresses.forString("10.0.0.1"),
|
||||
InetAddresses.forString("10.1.0.1"),
|
||||
InetAddresses.forString("fd0e:a5c8:6dfb:6a5e::1")))
|
||||
InetAddresses.forString("fd0e:a5c8:6dfb:6a5e:0:0:0:1")))
|
||||
.build();
|
||||
persistResource(host);
|
||||
|
||||
|
@ -199,7 +198,7 @@ public class DnsUpdateWriterTest {
|
|||
assertThatUpdatedZoneIs(update, "tld.");
|
||||
assertThatUpdateDeletes(update, "ns1.example.tld.", Type.ANY);
|
||||
assertThatUpdateAdds(update, "ns1.example.tld.", Type.A, "10.0.0.1", "10.1.0.1");
|
||||
assertThatUpdateAdds(update, "ns1.example.tld.", Type.AAAA, "fd0e:a5c8:6dfb:6a5e::1");
|
||||
assertThatUpdateAdds(update, "ns1.example.tld.", Type.AAAA, "fd0e:a5c8:6dfb:6a5e:0:0:0:1");
|
||||
assertThatTotalUpdateSetsIs(update, 3); // The delete, the A, and AAAA sets
|
||||
}
|
||||
|
||||
|
@ -281,12 +280,10 @@ public class DnsUpdateWriterTest {
|
|||
return fixIterator(Record.class, set.rrs());
|
||||
}
|
||||
}
|
||||
throw new AssertionFailedError(
|
||||
"no record set found for resource '"
|
||||
+ resourceName
|
||||
+ "', type '"
|
||||
+ Type.string(recordType)
|
||||
+ "'");
|
||||
assert_().fail(
|
||||
"No record set found for resource '%s' type '%s'",
|
||||
resourceName, Type.string(recordType));
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "unused"})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue