spf-discuss
[Top] [All Lists]

Re: CNAME limit

2005-07-21 19:20:49
On Thu, 21 Jul 2005, wayne wrote:

These chains actually aren't that bad because the authoratative name
server sends out all appropriate CNAMEs in one packet, so this is only
a little more CPU intensive than just having a single A record.  Ok,
the single UDP DNS packet is also a little larger.

So the analogous limits would be PTR and MX.  I have limited CNAME
chains to 10 each, just like PTR and MX records.

        def dns(self, name, qtype, cnames=None):
                """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)
                """
                result = self.cache.get( (name, qtype) )
                cname = None
                if not result:
                        for k,v in DNSLookup(name,qtype):
                            if k == (name, 'CNAME'):
                                cname = v
                            self.cache.setdefault(k, []).append(v)
                        result = self.cache.get( (name, qtype), [])
                if not result and cname:
                        if not cnames:
                          cnames = {}
                        elif len(cnames) >= MAX_CNAME:
                          raise PermError(
                            'Length of CNAME chain exceeds %d' % MAX_CNAME)
                        cnames[name] = cname
                        if cname in cnames:
                          raise PermError,'CNAME loop'
                        result = self.dns(cname, qtype, cnames=cnames)
                return result


-- 
              Stuart D. Gathman <stuart(_at_)bmsi(_dot_)com>
    Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.


<Prev in Thread] Current Thread [Next in Thread>