| 
									
										
										
										
											1998-08-10 18:40:22 +00:00
										 |  |  | \section{\module{macdnr} --- | 
					
						
							| 
									
										
										
										
											1999-03-02 16:37:17 +00:00
										 |  |  |          Interface to the Macintosh Domain Name Resolver} | 
					
						
							| 
									
										
										
										
											1998-07-23 17:55:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-03-02 16:37:17 +00:00
										 |  |  | \declaremodule{builtin}{macdnr} | 
					
						
							|  |  |  |   \platform{Mac} | 
					
						
							| 
									
										
										
										
											1998-07-23 17:55:31 +00:00
										 |  |  | \modulesynopsis{Interfaces to the Macintosh Domain Name Resolver.} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | This module provides an interface to the Macintosh Domain Name | 
					
						
							| 
									
										
										
										
											1999-03-02 16:37:17 +00:00
										 |  |  | Resolver.  It is usually used in conjunction with the \refmodule{mactcp} | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | module, to map hostnames to IP addresses.  It may not be available in | 
					
						
							| 
									
										
										
										
											1995-04-10 11:34:00 +00:00
										 |  |  | all Mac Python versions. | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \index{Macintosh Domain Name Resolver} | 
					
						
							|  |  |  | \index{Domain Name Resolver, Macintosh} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-17 02:02:51 +00:00
										 |  |  | The \module{macdnr} module defines the following functions: | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \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 | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | the hostname of a host willing to accept SMTP\index{SMTP} mail for the | 
					
						
							|  |  |  | given domain.  Returns a dnr result object of the ``mx'' variety. | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | \end{funcdesc} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-03-02 16:37:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | \subsection{DNR Result Objects \label{dnr-result-object}} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-17 02:02:51 +00:00
										 |  |  | The \member{rtnCode} and \member{cname} attributes are always | 
					
						
							|  |  |  | available, the others depend on the type of query (address, hinfo or | 
					
						
							|  |  |  | mx). | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-17 02:02:51 +00:00
										 |  |  | % Add args, as in {arg1, arg2 \optional{, arg3}}
 | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \begin{methoddesc}[dnr result]{wait}{} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | Wait for the query to complete. | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-17 02:02:51 +00:00
										 |  |  | % Add args, as in {arg1, arg2 \optional{, arg3}}
 | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \begin{methoddesc}[dnr result]{isdone}{} | 
					
						
							| 
									
										
										
										
											1998-03-17 02:02:51 +00:00
										 |  |  | Return \code{1} if the query is complete. | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \end{methoddesc} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-03-17 16:07:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \begin{memberdesc}[dnr result]{rtnCode} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | The error code returned by the query. | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \end{memberdesc} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \begin{memberdesc}[dnr result]{cname} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | The canonical name of the host that was queried. | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \end{memberdesc} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \begin{memberdesc}[dnr result]{ip0} | 
					
						
							| 
									
										
										
										
											1998-11-25 20:15:52 +00:00
										 |  |  | \memberline{ip1} | 
					
						
							|  |  |  | \memberline{ip2} | 
					
						
							|  |  |  | \memberline{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. | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \end{memberdesc} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \begin{memberdesc}[dnr result]{cpuType} | 
					
						
							| 
									
										
										
										
											1998-11-25 20:15:52 +00:00
										 |  |  | \memberline{osType} | 
					
						
							| 
									
										
										
										
											1998-03-17 02:02:51 +00:00
										 |  |  | Textual strings giving the machine type an OS name.  Valid for ``hinfo'' | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | queries. | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \end{memberdesc} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \begin{memberdesc}[dnr result]{exchange} | 
					
						
							| 
									
										
										
										
											1998-03-17 02:02:51 +00:00
										 |  |  | The name of a mail-exchanger host.  Valid for ``mx'' queries. | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \end{memberdesc} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \begin{memberdesc}[dnr result]{preference} | 
					
						
							| 
									
										
										
										
											1995-04-10 11:34:00 +00:00
										 |  |  | The preference of this mx record.  Not too useful, since the Macintosh | 
					
						
							| 
									
										
										
										
											1998-03-17 02:02:51 +00:00
										 |  |  | will only return a single mx record.  Valid for ``mx'' queries only. | 
					
						
							| 
									
										
										
										
											1998-04-04 06:23:02 +00:00
										 |  |  | \end{memberdesc} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The simplest way to use the module to convert names to dotted-decimal | 
					
						
							|  |  |  | strings, without worrying about idle time, etc: | 
					
						
							| 
									
										
										
										
											1999-03-02 16:37:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-02-13 06:58:54 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											1995-03-02 14:41:55 +00:00
										 |  |  | >>> def gethostname(name): | 
					
						
							|  |  |  | ...     import macdnr | 
					
						
							|  |  |  | ...     dnrr = macdnr.StrToAddr(name) | 
					
						
							|  |  |  | ...     return macdnr.AddrToStr(dnrr.ip0) | 
					
						
							| 
									
										
										
										
											1998-02-13 06:58:54 +00:00
										 |  |  | \end{verbatim} |