1995-03-17 16:07:09 +00:00
|
|
|
\section{Built-in Module \sectcode{macdnr}}
|
1997-07-17 16:34:52 +00:00
|
|
|
\label{module-macdnr}
|
1995-03-02 14:41:55 +00:00
|
|
|
\bimodindex{macdnr}
|
|
|
|
|
|
|
|
This module provides an interface to the Macintosh Domain Name
|
1995-04-10 11:34:00 +00:00
|
|
|
Resolver. It is usually used in conjunction with the \var{mactcp}
|
|
|
|
module, to map hostnames to IP-addresses. It may not be available in
|
|
|
|
all Mac Python versions.
|
1995-03-02 14:41:55 +00:00
|
|
|
|
|
|
|
The \code{macdnr} module defines the following functions:
|
|
|
|
|
|
|
|
\renewcommand{\indexsubitem}{(in module macdnr)}
|
|
|
|
|
|
|
|
\begin{funcdesc}{Open}{\optional{filename}}
|
1995-04-10 11:34:00 +00:00
|
|
|
Open the domain name resolver extension. If \var{filename} is given it
|
1995-03-02 14:41:55 +00:00
|
|
|
should be the pathname of the extension, otherwise a default is
|
1995-04-10 11:34:00 +00:00
|
|
|
used. Normally, this call is not needed since the other calls will
|
1995-03-02 14:41:55 +00:00
|
|
|
open the extension automatically.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{Close}{}
|
1995-04-10 11:34:00 +00:00
|
|
|
Close the resolver extension. Again, not needed for normal use.
|
1995-03-02 14:41:55 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{StrToAddr}{hostname}
|
1995-04-10 11:34:00 +00:00
|
|
|
Look up the IP address for \var{hostname}. This call returns a dnr
|
1995-03-02 14:41:55 +00:00
|
|
|
result object of the ``address'' variation.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{AddrToName}{addr}
|
|
|
|
Do a reverse lookup on the 32-bit integer IP-address
|
1995-04-10 11:34:00 +00:00
|
|
|
\var{addr}. Returns a dnr result object of the ``address'' variation.
|
1995-03-02 14:41:55 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{AddrToStr}{addr}
|
|
|
|
Convert the 32-bit integer IP-address \var{addr} to a dotted-decimal
|
1995-04-10 11:34:00 +00:00
|
|
|
string. Returns the string.
|
1995-03-02 14:41:55 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{HInfo}{hostname}
|
|
|
|
Query the nameservers for a \code{HInfo} record for host
|
1995-04-10 11:34:00 +00:00
|
|
|
\var{hostname}. These records contain hardware and software
|
1995-03-02 14:41:55 +00:00
|
|
|
information about the machine in question (if they are available in
|
1995-04-10 11:34:00 +00:00
|
|
|
the first place). Returns a dnr result object of the ``hinfo''
|
1995-03-02 14:41:55 +00:00
|
|
|
variety.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{MXInfo}{domain}
|
1995-04-10 11:34:00 +00:00
|
|
|
Query the nameservers for a mail exchanger for \var{domain}. This is
|
1995-03-02 14:41:55 +00:00
|
|
|
the hostname of a host willing to accept SMTP mail for the given
|
1995-04-10 11:34:00 +00:00
|
|
|
domain. Returns a dnr result object of the ``mx'' variety.
|
1995-03-02 14:41:55 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\subsection{dnr result object}
|
|
|
|
|
|
|
|
Since the DNR calls all execute asynchronously you do not get the
|
1995-04-10 11:34:00 +00:00
|
|
|
results back immediately. Instead, you get a dnr result object. You
|
1995-03-02 14:41:55 +00:00
|
|
|
can check this object to see whether the query is complete, and access
|
|
|
|
its attributes to obtain the information when it is.
|
|
|
|
|
|
|
|
Alternatively, you can also reference the result attributes directly,
|
|
|
|
this will result in an implicit wait for the query to complete.
|
|
|
|
|
|
|
|
The \var{rtnCode} and \var{cname} attributes are always available, the
|
|
|
|
others depend on the type of query (address, hinfo or mx).
|
|
|
|
|
|
|
|
\renewcommand{\indexsubitem}{(dnr result object method)}
|
|
|
|
|
|
|
|
% Add args, as in {arg1\, arg2 \optional{\, arg3}}
|
|
|
|
\begin{funcdesc}{wait}{}
|
|
|
|
Wait for the query to complete.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
% Add args, as in {arg1\, arg2 \optional{\, arg3}}
|
|
|
|
\begin{funcdesc}{isdone}{}
|
|
|
|
Return 1 if the query is complete.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1995-03-17 16:07:09 +00:00
|
|
|
\renewcommand{\indexsubitem}{(dnr result object attribute)}
|
|
|
|
|
1995-03-02 14:41:55 +00:00
|
|
|
\begin{datadesc}{rtnCode}
|
|
|
|
The error code returned by the query.
|
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{cname}
|
|
|
|
The canonical name of the host that was queried.
|
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{ip0}
|
|
|
|
\dataline{ip1}
|
|
|
|
\dataline{ip2}
|
|
|
|
\dataline{ip3}
|
1995-04-10 11:34:00 +00:00
|
|
|
At most four integer IP addresses for this host. Unused entries are
|
|
|
|
zero. Valid only for address queries.
|
1995-03-02 14:41:55 +00:00
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{cpuType}
|
|
|
|
\dataline{osType}
|
1995-04-10 11:34:00 +00:00
|
|
|
Textual strings giving the machine type an OS name. Valid for hinfo
|
1995-03-02 14:41:55 +00:00
|
|
|
queries.
|
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{exchange}
|
1995-04-10 11:34:00 +00:00
|
|
|
The name of a mail-exchanger host. Valid for mx queries.
|
1995-03-02 14:41:55 +00:00
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{preference}
|
1995-04-10 11:34:00 +00:00
|
|
|
The preference of this mx record. Not too useful, since the Macintosh
|
|
|
|
will only return a single mx record. Mx queries only.
|
1995-03-02 14:41:55 +00:00
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
The simplest way to use the module to convert names to dotted-decimal
|
|
|
|
strings, without worrying about idle time, etc:
|
1997-07-17 16:34:52 +00:00
|
|
|
\bcode\begin{verbatim}
|
1995-03-02 14:41:55 +00:00
|
|
|
>>> def gethostname(name):
|
|
|
|
... import macdnr
|
|
|
|
... dnrr = macdnr.StrToAddr(name)
|
|
|
|
... return macdnr.AddrToStr(dnrr.ip0)
|
1997-07-17 16:34:52 +00:00
|
|
|
\end{verbatim}\ecode
|