8889841có `«¥Sc@sÆdZddlmZddlZddlZddlZddlZddlZddl Zddl Zddl Zddl Zddl ZddlZddlZyddlmZWn!ek rÝddlmZnXdejjfd„ƒYZdefd„ƒYZd efd „ƒYZd efd „ƒYZd efd„ƒYZdefd„ƒYZeejje eee!e d„Z"eejje eee e d„Z#ee e d„Z$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.pyR3stZonecBsµeZdZejjZddddgZejj e d„Z d„Z d„Z d„Zd „Zd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zed„Zed„Zd„Zejj ed„Z!ejj ed„Z"ejj d„Z#d„Z$ejj d„Z%ejj d„Z&ejj'ejj d„Z(ejj'ejj d„Z)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(sØInitialize 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|tƒstS|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__mscCs£t|ttfƒr-tjj|dƒ}n$t|tjjƒsQtdƒ‚n|j ƒrŸ|j |j ƒs~tdƒ‚n|j rŸ|j |j ƒ}qŸn|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=|jdkrt‚n|jjƒ}yLtjj|jƒ\}}}|jjƒ}|j ƒsrtj j ‚nWntj j ‚nXy7|j}|jjƒ}|j ƒs¿tj 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 r¤tj j ‚n|jj}nX||jjkrÞtj j dƒ‚nyCtjj|jƒ}|jjƒ}|j ƒs tj j ‚nWn tj j d|jƒ‚nXy |j} Wntj j ‚nX|j|ƒ\} } } } }|j| ƒ\}}}}}x“t||d|ƒD]{}| dkrß|t| ƒ}n| dkrþ|t| ƒ}n|dkr|t|ƒ}n|dkr<|t|ƒ}nt|ƒjt| ƒƒ}t|ƒjt|ƒƒ}|jd| |ƒ}| jd||ƒ}tjj||jƒ|_|j}|j|jjƒså|jƒdS|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(RRRÁRÂRlRÉRp( ttextR R R RtRÅRsRfRmtreader((s./usr/lib64/python2.7/site-packages/dns/zone.pyRs"    c CsÁtjdkrt}d} n t}d} t||ƒrf|dkrN|}nt|| ƒ}t} n|dkr{d}nt} z%t ||||||||ƒ} Wd| r¼|j ƒnX| S(s³Read 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 itrUR·sN( RNRORPRRRRQRRRRU( RVR R R RtRÅRsRfRYRZR[tz((s./usr/lib64/python2.7/site-packages/dns/zone.pyt from_file¸s&      c Cs4d}x|D] }|dkri|r1|j}n|jdj}|jdj}|||d|ƒ}nx­|jD]¢}|jj|jƒ} | s³|jƒ} | |j|js@             ÿñÿg  )  6