Home / Function/ add() — netty Function Reference

add() — netty Function Reference

Architecture documentation for the add() function in DnsResolveContext.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  161fe130_19c1_016b_ea22_8d91937c6452["add()"]
  a63c5319_f927_6bfc_6318_415aecf6068e["AuthoritativeNameServerList"]
  161fe130_19c1_016b_ea22_8d91937c6452 -->|defined in| a63c5319_f927_6bfc_6318_415aecf6068e
  07f53a31_718c_c4a3_04b0_19d21f5a6af4["query()"]
  07f53a31_718c_c4a3_04b0_19d21f5a6af4 -->|calls| 161fe130_19c1_016b_ea22_8d91937c6452
  804ea022_5b6c_6eb0_3048_d20c3d4093fb["queryUnresolvedNameServer()"]
  804ea022_5b6c_6eb0_3048_d20c3d4093fb -->|calls| 161fe130_19c1_016b_ea22_8d91937c6452
  9f785e45_60a1_a069_4e9a_3b5e73cfe534["AuthoritativeNameServerList()"]
  9f785e45_60a1_a069_4e9a_3b5e73cfe534 -->|calls| 161fe130_19c1_016b_ea22_8d91937c6452
  1ff8f220_55f4_0cc5_b454_65682e36be5e["onExpectedResponse()"]
  1ff8f220_55f4_0cc5_b454_65682e36be5e -->|calls| 161fe130_19c1_016b_ea22_8d91937c6452
  6074b900_3b4a_a781_3f13_d319edfe2ce0["InetSocketAddress()"]
  6074b900_3b4a_a781_3f13_d319edfe2ce0 -->|calls| 161fe130_19c1_016b_ea22_8d91937c6452
  2b098af8_5694_2a00_1f74_a3149167f056["addressList()"]
  2b098af8_5694_2a00_1f74_a3149167f056 -->|calls| 161fe130_19c1_016b_ea22_8d91937c6452
  5167f7c9_01dd_bfa6_4519_865cd0886ae5["AuthoritativeNameServer()"]
  161fe130_19c1_016b_ea22_8d91937c6452 -->|calls| 5167f7c9_01dd_bfa6_4519_865cd0886ae5
  style 161fe130_19c1_016b_ea22_8d91937c6452 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

resolver-dns/src/main/java/io/netty/resolver/dns/DnsResolveContext.java lines 1263–1311

        void add(DnsRecord r) {
            if (r.type() != DnsRecordType.NS || !(r instanceof DnsRawRecord)) {
                return;
            }

            // Only include servers that serve the correct domain.
            if (questionName.length() <  r.name().length()) {
                return;
            }

            String recordName = r.name().toLowerCase(Locale.US);

            int dots = 0;
            for (int a = recordName.length() - 1, b = questionName.length() - 1; a >= 0; a--, b--) {
                char c = recordName.charAt(a);
                if (questionName.charAt(b) != c) {
                    return;
                }
                if (c == '.') {
                    dots++;
                }
            }

            if (head != null && head.dots > dots) {
                // We already have a closer match so ignore this one, no need to parse the domainName etc.
                return;
            }

            final ByteBuf recordContent = ((ByteBufHolder) r).content();
            final String domainName = decodeDomainName(recordContent);
            if (domainName == null) {
                // Could not be parsed, ignore.
                return;
            }

            // We are only interested in preserving the nameservers which are the closest to our qName, so ensure
            // we drop servers that have a smaller dots count.
            if (head == null || head.dots < dots) {
                nameServerCount = 1;
                head = new AuthoritativeNameServer(dots, r.timeToLive(), recordName, domainName);
            } else if (head.dots == dots) {
                AuthoritativeNameServer serverName = head;
                while (serverName.next != null) {
                    serverName = serverName.next;
                }
                serverName.next = new AuthoritativeNameServer(dots, r.timeToLive(), recordName, domainName);
                nameServerCount++;
            }
        }

Subdomains

Frequently Asked Questions

What does add() do?
add() is a function in the netty codebase, defined in resolver-dns/src/main/java/io/netty/resolver/dns/DnsResolveContext.java.
Where is add() defined?
add() is defined in resolver-dns/src/main/java/io/netty/resolver/dns/DnsResolveContext.java at line 1263.
What does add() call?
add() calls 1 function(s): AuthoritativeNameServer.
What calls add()?
add() is called by 6 function(s): AuthoritativeNameServerList, InetSocketAddress, addressList, onExpectedResponse, query, queryUnresolvedNameServer.

Analyze Your Own Codebase

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

Try Supermodel Free