The DNS module provides DNS lookup functionality. It can operate in a synchronous or asynchronous manner (async not working). The development of pyDNS happens here. The main work horse of this module is the class DnsRequest.
| License: | This module is covered by the standard Python License. |
|---|
This page contains the main API overview. More information on specific topics can be found on the following pages:
Retrieve the system name servers and sets them as default values for the DnsRequest server parameter. This value will be taken as default value for all future DnsRequest instances and as default in DnsRequest.req() if the server parameter is not explicitely given. Calling this once per module lifetime suffices if your DNS servers have not changed in the meanwhile.
| Returns: | None |
|---|
Convenience routine for doing a reverse lookup of an address. This will only return one of any records returned.
| Returns: | DnsRequest(b, qtype = ‘ptr’).req().answers[0][‘data’] |
|---|
Takes an IPv6 textual address (rfc 2373 2.2 presentation format (subpart 3, ::i.p.v.4 is explicitly NOT supported).
return q.answers[0][‘data’]
| Returns: | a name (only one if more than one presented). |
|---|
Convenience routine for doing an MX lookup of a name.
| Returns: | List mail exchanger records sorted by preference. |
|---|
DnsRequest represents a specific request with a high-level user interface. Call DiscoverNameServers() in order to fill in the default values with the system DNS servers.
| Parameters: |
|
|---|---|
| Return type: | the initialized DNSRequest instance |
Perform a DNS request.
This method should usually be used to perform DNS requests. Parameters given here, will replace those that have been used to initialize the DnsRequest. All function parameters are identical to the DnsRequest(). Specifying an invalid qtype argument will raise DNSError ‘unknown query type’.
| Returns: | A DnsResult instance (also bound to the DnsRequest.response attribute) or None (for async calls) |
|---|---|
| Exception: | DNSError in case of errors. |
Note
This function would usually be called by the user to perform a DNS query.
Actually perform a TCP Request with the paramters that have previously been set up with the DNSRequest initialization or the parameters passed to req(). This function would usually not be called directly by the user but is invoked from req().
| Parameter: | server (string or list of strings) – DNS server hostname(s) as string or list of strings |
|---|
Actually perform a UDP Request with the paramters that have previously been set up with the DNSRequest initialization or the parameters passed to req(). This function would usually not be called directly by the user but is invoked from req().
| Parameter: | server (string or list of strings) – DNS server hostname(s) as string or list of strings |
|---|
An instance of this class is created by the DnsRequest and contains the results of a request.
| Parameters: |
|---|
Print()s out the DNS reply.
| Returns: | None |
|---|
| Parameter: | u (FIXME: a RRunpacker) – FIXME |
|---|
Returns a dict with the following keys:
mname = ‘get%sdata’ % r[‘typename’] if hasattr(u, mname):r[‘data’]=getattr(u, mname)() else:r[‘data’]=u.getbytes(r[‘rdlength’])
| Returns: | a dict containing the above keys. |
|---|