On 05/02/18 13:33, Dominik DL6ER wrote: > Hey Michael and Simon, > > Thanks. I already have added a cache lookup myself using dnsmasq's > cache_find_by_addr(). However, this is unsuitable for getting the host > names of the forward servers or if you are not the DHCP server. > > How could I trigger a PTR request from within dnsmasq? This will add the > host name to the cache where it will then be available afterwards. I > already use some pthreads for things that should not block so I wouldn't > mind to run the PTRs from therein, where it wouldn't be blocking anything.
It's not that simple: you can't block because attempting to process another query will result in the one you were handling being overwritten in the buffers. Even if you forward the answer first, you still need to retain enough information to create the log entry once you have the answer to the PTR record. Something like: In the forwarding path, where the logging happens, store the query type and domain in the forwarding record. Now create a new PTR query and a new forwarding record which is used to handle the reply. Link the two together so that when the answer comes in, you can go back to the original forwarding record and generate the log entry. Worry about if the answer to the original query returns before the answer to the PTR query, and frees the forwarding record before you've logged it. Worry about no answer to the PTR query arriving and garbage collecting the forwarding record, (and doing a fallback, without domain name, log line). Cheers, Simon. > > Best regards, > Dominik > > > On 05.02.2018 14:03, Michael Stiemke wrote: >> >> I have modified cache.c to do this. >> >> >> >> Output in the log now looks like this: >> >> >> >> query[A] v20.vortex-win.data.microsoft.com from 192.168.5.118 = >> cpu-video (dhcp) >> >> >> >> or >> >> >> >> query[AAAA] download.opensuse.org from 192.168.5.10 = emu-deve.xxxx.eu >> (static) >> >> >> >> If there is interest, I will post the changes. >> >> >> >> The modification just loops through the cache table and gets the names >> from there - local query originators only of course, these being >> either static or dhcp assigned, can be found in there. >> >> >> >> best regards, >> Michael Stiemke (mailto:m...@ansynova.com) >> >> ** >> >> >> >> _______________________________________________ >> Dnsmasq-discuss mailing list >> Dnsmasq-discuss@lists.thekelleys.org.uk >> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss > > > _______________________________________________ > Dnsmasq-discuss mailing list > Dnsmasq-discuss@lists.thekelleys.org.uk > http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss > _______________________________________________ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss