Exemple #1
0
 def __init__(self, hosts, server=None):
     """
     <method maturity="stable">
       <summary>
         Constructor to initialize an instance of the DNSMatcher class.
       </summary>
       <description>
         <para>
           This constructor initializes an instance of the DNSMatcher class.
         </para>
       </description>
       <metainfo>
         <arguments>
           <argument maturity="stable">
             <name>hosts</name>
             <type>
               <list>
                 <string/>
               </list>
             </type>
             <description>Hostnames to resolve.</description>
           </argument>
           <argument maturity="stable">
             <name>server</name>
             <type>
               <string/>
             </type>
             <default>None</default>
             <description>IP address of the DNS server to query. Defaults to the servers set in
             the <filename>resolv.conf</filename> file.</description>
           </argument>
         </arguments>
       </metainfo>
     </method>
     """
     self.cache = ResolverCache(DNSResolver(server=server))
     if isinstance(hosts, str):
         self.cache.addHost(hosts)
     elif isinstance(hosts, collections.Iterable):
         for host in hosts:
             self.cache.addHost(host)
     else:
         raise ValueError('hosts has type %s, must be str or iterable')
Exemple #2
0
 def __init__(self, hosts, server=None):
     """
     <method maturity="stable">
       <summary>
         Constructor to initialize an instance of the DNSMatcher class.
       </summary>
       <description>
         <para>
           This constructor initializes an instance of the DNSMatcher class.
         </para>
       </description>
       <metainfo>
         <arguments>
           <argument maturity="stable">
             <name>hosts</name>
             <type>
               <list>
                 <string/>
               </list>
             </type>
             <description>Hostnames to resolve.</description>
           </argument>
           <argument maturity="stable">
             <name>server</name>
             <type>
               <string/>
             </type>
             <default>None</default>
             <description>IP address of the DNS server to query. Defaults to the servers set in
             the <filename>resolv.conf</filename> file.</description>
           </argument>
         </arguments>
       </metainfo>
     </method>
     """
     self.cache = ResolverCache(DNSResolver())