3
Date: October 1st, 2005
4
Author: Justin Karneges <justin@affinix.com>
6
JDNS is a simple DNS implementation that can perform normal DNS queries
7
of any record type (notably SRV), as well as Multicast DNS queries and
8
advertising. Multicast support is based on Jeremie Miller's "mdnsd"
11
For maximum flexibility, JDNS is written in C with no direct dependencies,
12
and is licensed under the MIT license. Your application must supply
13
functionality to JDNS, such as UDP sending/receiving, via callbacks.
15
For Qt users there is a wrapper available called QJDns. jdns.pri can
16
be used to include everything into a qmake project. jdns.pro will build
17
the sample Qt-based commandline tool 'jdns'.
20
* DNS client "stub" resolver
21
* Can fetch any record type, but provides handy decoding for many
22
known types: A, AAAA, SRV, MX, TXT, etc.
23
* Performs retries, caching/expiration, and CNAME following
24
* Algorithm logic adapted from Q3Dns
26
* Multicast advertising
29
* Trolltech is phasing out the Qt DNS implementation, which in Qt 4 has
30
been relegated to the Qt3Support module. A replacement was desired.
32
* While there are many DNS libraries available, at the time of this
33
writing it was (and still may be) hard to find one that satisfies
34
three essential conditions: cross-platform friendliness (and this
35
includes Windows 9x!), the ability to integrate into existing
36
eventloops, sensible licensing (ie, not GPL).
39
* Prepare callbacks and call jdns_session_new()
40
* Call jdns_init_unicast() or jdns_init_multicast(), depending on
41
if you want regular or multicast DNS. If you want both kinds, you
42
can always make two sessions.
43
* Make queries and have fun
44
* Call jdns_step() at the right times to advance JDNS processing
46
#### What is left to you:
47
* The callback functions, obviously.
48
* Querying for several "qualified" names. Here is what Q3Dns does:
49
Query for name as provided
50
Query for name + '.domain' (for every domain the computer is in)
51
* Detecting for '.local' in a name to be queried, and using that
52
to decide whether to query via Multicast or normal DNS.
53
* Recognition of IP addresses. If you want an IP address to resolve
54
to itself, then do that yourself. Passing an IP address as a DNS
55
name to JDNS won't work (especially since it wouldn't make any
56
sense in some contexts, like SRV).
57
* Recognition of known hosts. If you want this, compare inputs against
58
jdns_system_dnsparams().
59
* For zeroconf/Bonjour, keep in mind that JDNS only provides Multicast
60
DNS capability. DNS-SD and any higher layers would be your job.
62
Using a custom DNS implementation has the drawback that it is difficult
63
to take advantage of platform-specific features (for example, an OS-wide
64
DNS cache or LDAP integration).
66
An application strategy for normal DNS should probably be:
67
* If an A or AAAA record is desired, use a native lookup.
68
* Else, if the platform has advanced DNS features already (ie,
69
res_query), use those.
72
However, it may not be a bad idea at first to use JDNS for all occasions,
73
so that it can be debugged.
75
For Multicast DNS, awareness of the platform is doubly important. There
76
should only be one Multicast DNS "Responder" per computer, and using JDNS
77
at the same time could result in a conflict.
79
An application strategy for Multicast DNS should be:
80
* If the platform has a Multicast DNS daemon installed already, use