`Sc@sdZddlmZddlZddlZddlZddlZddlZddl Zddl Zddl Zddl Zddl ZddlZddlZyddlmZWn!ek rddlmZnXdejjfdYZdefdYZd efd YZd efd YZd efdYZdefdYZeejje eee!e dZ"eejje eee e dZ#ee e dZ$dS(s DNS Zones.i(t generatorsN(tStringIOtBadZonecBseZdZRS(sThe zone is malformed.(t__name__t __module__t__doc__(((s./usr/lib64/python2.7/site-packages/dns/zone.pyR'stNoSOAcBseZdZRS(s%The zone has no SOA RR at its origin.(RRR(((s./usr/lib64/python2.7/site-packages/dns/zone.pyR+stNoNScBseZdZRS(s'The zone has no NS RRset at its origin.(RRR(((s./usr/lib64/python2.7/site-packages/dns/zone.pyR/st UnknownOrigincBseZdZRS(sThe zone's origin is unknown.(RRR(((s./usr/lib64/python2.7/site-packages/dns/zone.pyR3stZonecBseZdZejjZddddgZejj e dZ dZ dZ dZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZedZedZdZejj edZ!ejj edZ"ejj dZ#dZ$ejj dZ%ejj dZ&ejj'ejj dZ(ejj'ejj dZ)e e d#d Z+e e d#d!Z,d"Z-RS($sZA DNS zone. A Zone is a mapping from names to nodes. The zone object may be treated like a Python dictionary, e.g. zone[name] will retrieve the node associated with that name. The I{name} may be a dns.name.Name object, or it may be a string. In the either case, if the name is relative it is treated as relative to the origin of the zone. @ivar rdclass: The zone's rdata class; the default is class IN. @type rdclass: int @ivar origin: The origin of the zone. @type origin: dns.name.Name object @ivar nodes: A dictionary mapping the names of nodes in the zone to the nodes themselves. @type nodes: dict @ivar relativize: should names in the zone be relativized? @type relativize: bool @cvar node_factory: the factory used to create a new node @type node_factory: class or callable trdclasstorigintnodest relativizecCs(||_||_i|_||_dS(sInitialize a zone object. @param origin: The origin of the zone. @type origin: dns.name.Name object @param rdclass: The zone's rdata class; the default is class IN. @type rdclass: intN(R R R R (tselfR R R ((s./usr/lib64/python2.7/site-packages/dns/zone.pyt__init__Rs   cCsQt|tstS|j|jksI|j|jksI|j|jkrMtStS(siTwo zones are equal if they have the same origin, class, and nodes. @rtype: bool (t isinstanceR tFalseR R R tTrue(Rtother((s./usr/lib64/python2.7/site-packages/dns/zone.pyt__eq___scCs|j| S(s6Are two zones not equal? @rtype: bool (R(RR((s./usr/lib64/python2.7/site-packages/dns/zone.pyt__ne__mscCst|ttfr-tjj|d}n$t|tjjsQtdn|j r|j |j s~tdn|j r|j |j }qn|S(Ns0name parameter must be convertable to a DNS names5name parameter must be a subdomain of the zone origin( Rtstrtunicodetdnstnamet from_texttNonetNametKeyErrort is_absolutet is_subdomainR R (RR((s./usr/lib64/python2.7/site-packages/dns/zone.pyt_validate_namets  cCs|j|}|j|S(N(R R (Rtkey((s./usr/lib64/python2.7/site-packages/dns/zone.pyt __getitem__scCs |j|}||j|           c!Cs=|jdkrtn|jj}yLtjj|j\}}}|jj}|j srtj j nWntj j nXy7|j}|jj}|j stj j nWntj j nXyCtj j|j}|jj}|j stj j nWn tj j k r;|j }nXyCtjj|j}|jj}|j s~tj j nWn5tj j k rtj j n|jj}nX||jjkrtj j dnyCtjj|j}|jj}|j s tj j nWn tj j d|jnXy |j} Wntj j nX|j|\} } } } }|j| \}}}}}xt||d|D]{}| dkr|t| }n| dkr|t| }n|dkr|t|}n|dkr<|t|}nt|jt| }t|jt|}|jd| |}| jd||}tjj||j|_|j}|j|jjs|jdS|jr|j|jj}n|jjj|}|dkrI|jj}||jj|'. @type filename: string @param allow_include: is $INCLUDE allowed? @type allow_include: bool @param check_origin: should sanity checks of the origin node be done? The default is True. @type check_origin: bool @raises dns.zone.NoSOA: No SOA RR was found at the zone origin @raises dns.zone.NoNS: No NS RRset was found at the zone origin @rtype: dns.zone.Zone object sRsRfN(RRRRRlRRp( ttextR R R RtRRsRfRmtreader((s./usr/lib64/python2.7/site-packages/dns/zone.pyRs"    c Cstjdkrt}d} n t}d} t||rf|dkrN|}nt|| }t} n|dkr{d}nt} z%t ||||||||} Wd| r|j nX| S(sRead a master file and build a zone object. @param f: file or string. If I{f} is a string, it is treated as the name of a file to open. @param origin: The origin of the zone; if not specified, the first $ORIGIN statement in the master file will determine the origin of the zone. @type origin: dns.name.Name object or string @param rdclass: The zone's rdata class; the default is class IN. @type rdclass: int @param relativize: should names be relativized? The default is True @type relativize: bool @param zone_factory: The zone factory to use @type zone_factory: function returning a Zone @param filename: The filename to emit when describing where an error occurred; the default is '', or the value of I{f} if I{f} is a string. @type filename: string @param allow_include: is $INCLUDE allowed? @type allow_include: bool @param check_origin: should sanity checks of the origin node be done? The default is True. @type check_origin: bool @raises dns.zone.NoSOA: No SOA RR was found at the zone origin @raises dns.zone.NoNS: No NS RRset was found at the zone origin @rtype: dns.zone.Zone object itrURsN( RNRORPRRRRQRRRRU( RVR R R RtRRsRfRYRZR[tz((s./usr/lib64/python2.7/site-packages/dns/zone.pyt from_files&      c Cs4d}x|D] }|dkri|r1|j}n|jdj}|jdj}|||d|}nx|jD]}|jj|j} | s|j} | |j|js@             g  )  6