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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.xbill.DNS.Name;
import org.xbill.DNS.RRset;
import org.xbill.DNS.Rcode;
import org.xbill.DNS.Resolver;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;
import org.xbill.DNS.Update;
Expand All @@ -58,7 +59,7 @@
* A DnsWriter that implements the DNS UPDATE protocol as specified in <a
* href="https://tools.ietf.org/html/rfc2136">RFC 2136</a>. Publishes changes in the domain-registry
* to a (capable) external DNS server, sometimes called a "hidden master". DNS UPDATE messages are
* sent via a supplied "transport" class.
* sent via a supplied {@link Resolver}.
*
* <p>On call to {@link #commit()}, a single UPDATE message is created containing the records
* required to "synchronize" the DNS with the current (at the time of processing) state of the
Expand Down Expand Up @@ -89,7 +90,7 @@ public class DnsUpdateWriter extends BaseDnsWriter {
private final Duration dnsDefaultATtl;
private final Duration dnsDefaultNsTtl;
private final Duration dnsDefaultDsTtl;
private final DnsMessageTransport transport;
private final Resolver resolver;
private final Clock clock;
private final Update update;
private final String zoneName;
Expand All @@ -100,7 +101,7 @@ public class DnsUpdateWriter extends BaseDnsWriter {
* @param dnsDefaultATtl TTL used for any created resource records
* @param dnsDefaultNsTtl TTL used for any created nameserver records
* @param dnsDefaultDsTtl TTL used for any created DS records
* @param transport the transport used to send/receive the UPDATE messages
* @param resolver the resolver used to send/receive the UPDATE messages
* @param clock a source of time
*/
@Inject
Expand All @@ -109,14 +110,14 @@ public DnsUpdateWriter(
@Config("dnsDefaultATtl") Duration dnsDefaultATtl,
@Config("dnsDefaultNsTtl") Duration dnsDefaultNsTtl,
@Config("dnsDefaultDsTtl") Duration dnsDefaultDsTtl,
DnsMessageTransport transport,
Resolver resolver,
Clock clock) {
this.zoneName = zoneName;
this.update = new Update(toAbsoluteName(zoneName));
this.dnsDefaultATtl = dnsDefaultATtl;
this.dnsDefaultNsTtl = dnsDefaultNsTtl;
this.dnsDefaultDsTtl = dnsDefaultDsTtl;
this.transport = transport;
this.resolver = resolver;
this.clock = clock;
}

Expand Down Expand Up @@ -175,7 +176,7 @@ public void publishHost(String hostName) {
@Override
protected void commitUnchecked() {
try {
Message response = transport.send(update);
Message response = resolver.send(update);
verify(
response.getRcode() == Rcode.NOERROR,
"DNS server failed domain update for '%s' rcode: %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,30 @@
import dagger.multibindings.IntoMap;
import dagger.multibindings.IntoSet;
import dagger.multibindings.StringKey;
import google.registry.config.RegistryConfig.Config;
import google.registry.dns.writer.DnsWriter;
import jakarta.inject.Named;
import javax.net.SocketFactory;
import java.net.UnknownHostException;
import java.time.Duration;
import org.xbill.DNS.Resolver;
import org.xbill.DNS.SimpleResolver;

/** Dagger module that provides a DnsUpdateWriter. */
@Module
public abstract class DnsUpdateWriterModule {

@Provides
static SocketFactory provideSocketFactory() {
return SocketFactory.getDefault();
static Resolver provideResolver(
@Config("dnsUpdateHost") String updateHost,
@Config("dnsUpdateTimeout") Duration updateTimeout) {
try {
SimpleResolver resolver = new SimpleResolver(updateHost);
resolver.setTCP(true);
resolver.setTimeout(updateTimeout);
return resolver;
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
}

@Binds
Expand Down
Loading
Loading