Home / Class/ RedirectingTestDnsServer Class — netty Architecture

RedirectingTestDnsServer Class — netty Architecture

Architecture documentation for the RedirectingTestDnsServer class in DnsNameResolverTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  fab4cf20_fc88_094c_9fc4_e7a1811bd113["RedirectingTestDnsServer"]
  a522ba1b_7e05_723d_0457_5085cd62d3eb["DnsNameResolverTest.java"]
  fab4cf20_fc88_094c_9fc4_e7a1811bd113 -->|defined in| a522ba1b_7e05_723d_0457_5085cd62d3eb
  8b3fab7a_957c_c6ff_f404_987483f990ef["RedirectingTestDnsServer()"]
  fab4cf20_fc88_094c_9fc4_e7a1811bd113 -->|method| 8b3fab7a_957c_c6ff_f404_987483f990ef
  b0618a05_7496_c9dd_aea2_0dfca223a7ed["DnsMessage()"]
  fab4cf20_fc88_094c_9fc4_e7a1811bd113 -->|method| b0618a05_7496_c9dd_aea2_0dfca223a7ed

Relationship Graph

Source Code

resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java lines 2352–2387

    private static class RedirectingTestDnsServer extends TestDnsServer {

        private final String dnsAddress;
        private final String domain;

        RedirectingTestDnsServer(String domain, String dnsAddress) {
            super(Collections.singleton(domain));
            this.domain = domain;
            this.dnsAddress = dnsAddress;
        }

        @Override
        protected DnsMessage filterMessage(DnsMessage message) {
            // Clear the answers as we want to add our own stuff to test dns redirects.
            message.getAnswerRecords().clear();
            message.getAuthorityRecords().clear();
            message.getAdditionalRecords().clear();

            String name = domain;
            for (int i = 0 ;; i++) {
                int idx = name.indexOf('.');
                if (idx <= 0) {
                    break;
                }
                name = name.substring(idx + 1); // skip the '.' as well.
                String dnsName = "dns" + idx + '.' + domain;
                message.getAuthorityRecords().add(newNsRecord(name, dnsName));
                message.getAdditionalRecords().add(newARecord(dnsName, i == 0 ? dnsAddress : "1.2.3." + idx));

                // Add an unresolved NS record (with no additionals as well)
                message.getAuthorityRecords().add(newNsRecord(name, "unresolved." + dnsName));
            }

            return message;
        }
    }

Frequently Asked Questions

What is the RedirectingTestDnsServer class?
RedirectingTestDnsServer is a class in the netty codebase, defined in resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java.
Where is RedirectingTestDnsServer defined?
RedirectingTestDnsServer is defined in resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java at line 2352.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free