MiniDNS/minidns

Cannot retrieve any DNS SRV adress after typing "."

Closed this issue · 7 comments

I've using this lib for retrieving SRV records on Android app.

Steps

  1. Get SRV records from "_mydomain._tcp.dev.local"
    ResolverResult result -> responseCode = NO_ERROR ------- works perfectly
  2. Try to get "_mydomain._tcp.dev.local."
    ResolverResult result -> responseCode = NX_DOMAIN -------- okay, works as expected
  3. Get SRV records from "_mydomain._tcp.dev.local"
    ResolverResult result -> responseCode = NX_DOMAIN ----------- what? why?
    The result of the following attempts will be the same until I restart the app

Why I retrieve responseCode = NX_DOMAIN in third step?

I'm sorry but your description is hard to follow. It would help tremendously if you showed some short and relevant code snippets. Or provide a minimal example which attempts to reproduce the behavior.

Given that my interpretation of your description is correct, my first intuition would be we are possibly dealing which erroneous caching behavior by MiniDNS here.

@Flowdalic thanks for quick response :)
I think you are right, problem is in caching, but how I can clear caching for miniDNS?

Code
Initialization
DNSClient.removeDNSServerLookupMechanism( AndroidUsingExec.INSTANCE ); DNSClient.addDnsServerLookupMechanism( new AndroidUsingLinkProperties( context ) );
........
DNSName dnsName = DNSName.from( domain ); ResolverResult<SRV> result = resolveWithFallback( dnsName, SRV.class );
.....................

private <D extends Data> ResolverResult<D> resolveWithFallback( DNSName dnsName, Class<D> type ) throws IOException { final Question question = new Question( dnsName, Record.TYPE.getType( type ) ); return ResolverApi.INSTANCE.resolve( question ); }
AndroidUsingLinkProperties class see here:
https://www.programcreek.com/java-api-examples/?code=syntafin/TenguChat/TenguChat-master/src/main/java/de/tengu/chat/utils/AndroidUsingLinkProperties.java#

@Flowdalic
If this will help you, this throws when I'm trying to query adress with "." in the end of adress and all time after this
image

@Flowdalic
JFYI: I've describe a workaround:
There is a method
public DNSMessage query(DNSMessage.Builder queryBuilder) throws IOException
in your DNSClient class.
This method include a "for" statement by dnsServerAdresses.
So when I try the correct DNS adress without "." in the end, then I send DatagramPacket to ipAdress "192.168.11.4" and receive correct SRV record. Okay. All is fine.
But if I try the incorrect DNS adress with a "." in the end of adress, then this behaviour occurs in the "for" statement

  1. Try to send to "192.168.11.4" - >
    NetworkDataSource class: DNSMessage queryUdp(DNSMessage message, InetAddress address, int port) throws IOException method: socket.send(packet); --- send successfuly ->
    DNSMessage.responseCode = FORMAT_ERR
  2. Try to send to "8.8.8.8"- > same behaviour as previous
  3. Try to send to "/2001:4860:4860:8888" -> socket.send(packet); -> throw SocketException
    and it detailedMessage is null

@Flowdalic
Hi :) Is any updates for this issue?

I'm unable to reproduce this with the latest MiniDNS master. That is

    public void testClient() throws IOException {
        DnsClient dnsClient = new DnsClient(new LruCache(1024));

        DnsQueryResult result1 = dnsClient.query("geekplace.eu", TYPE.A);
        
        DnsQueryResult result2 = dnsClient.query("geekplace.eu.", TYPE.A);
        
        DnsQueryResult result3 = dnsClient.query("geekplace.eu", TYPE.A);

    }

works as expected. Please provide a minimal code snipped which can be used to reproduce your issue and state the MiniDNS version you are using. I'm closing this until the code to reproduce this issue has been provided.