Milter.dns.Session Class Reference
Inheritance diagram for Milter.dns.Session:

## Public Member Functions

def | __init__ (self)
def | dns (self, name, qtype, cnames=None)
| Cached DNS lookup. More...
def | dns_txt (self, domainname, enc='ascii')

## Public Attributes

| cache

## Static Public Attributes

| SAFE2CACHE
| Additional DNS RRs we can safely cache. More...

## Detailed Description

    A Session object has a simple cache with no TTL that is valid
     for a single "session", for example an SMTP conversation.

## Member Function Documentation

## dns()

def Milter.dns.Session.dns | ( |  | self,
|  |  | name,
|  |  | qtype,
|  |  | cnames = `None`
| ) |  |

Cached DNS lookup.

Parameters

  name | the DNS label to query
  qtype | the query type, e.g. 'A'
  cnames | tracks CNAMES already followed in recursive calls

    DNS query.

    If the result is in cache, return that.  Otherwise pull the
    result from DNS, and cache ALL answers, so additional info
    is available for further queries later.

    CNAMEs are followed.

    If there is no data, [] is returned.

    pre: qtype in ['A', 'AAAA', 'MX', 'PTR', 'TXT', 'SPF']
    post: isinstance(__return__, types.ListType)

References Milter.cache.AddrCache.cache, Milter.dns.Session.cache, Milter.dns.Session.dns(), and Milter.dns.DNSLookup().

Referenced by Milter.dns.Session.dns().

## Member Data Documentation

## SAFE2CACHE

Milter.dns.Session.SAFE2CACHE

static

Initial value:
= frozenset((
('MX','MX'), ('MX','A'),
('CNAME','CNAME'), ('CNAME','A'),
('A','A'),
('AAAA','AAAA'),
('PTR','PTR'),
('NS','NS'), ('NS','A'),
('TXT','TXT'),
('SPF','SPF')
))

Additional DNS RRs we can safely cache.

We have to be careful which additional DNS RRs we cache. For instance, PTR records are controlled by the connecting IP, and they could poison our local cache with bogus A and MX records.
Each entry is a tuple of (query_type,rr_type). So for instance, the entry ('MX','A') says it is safe (for milter purposes) to cache any 'A' RRs found in an 'MX' query.

The documentation for this class was generated from the following file:

- Milter/dns.py