ó Å¥¥Sc@sêdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlZ ddlZ de jjfd„ƒYZde jjfd„ƒYZd„Zd „Zd „Zd „Zd „Zeed ƒr#eanead„Zd„Zd„Zd„Zddddde!e!d„Z"d„Z#d„Z$d„Z%ddddde!d„Z&e j'j(e j)j*dddde+ddddde!e j,j-d„Z.dS(sTalk to a DNS server.iÿÿÿÿ(t generatorsNtUnexpectedSourcecBseZdZRS(sDRaised if a query response comes from an unexpected address or port.(t__name__t __module__t__doc__(((s//usr/lib64/python2.7/site-packages/dns/query.pyR"st BadResponsecBseZdZRS(sBRaised if a query response does not respond to the question asked.(RRR(((s//usr/lib64/python2.7/site-packages/dns/query.pyR&scCs"|dkrdStjƒ|SdS(N(tNonettime(ttimeout((s//usr/lib64/python2.7/site-packages/dns/query.pyt_compute_expiration*s cCsœd}|r|tjO}n|r2|tjO}n|rH|tjO}ntjƒ}|j||ƒ|r†|jt|dƒƒ}n |jƒ}t|ƒS(sqPoll polling backend. @param fd: File descriptor @type fd: int @param readable: Whether to wait for readability @type readable: bool @param writable: Whether to wait for writability @type writable: bool @param timeout: Deadline timeout (expiration time, in seconds) @type timeout: float @return True on success, False on timeout iiè(tselecttPOLLINtPOLLOUTtPOLLERRtpolltregistertlongtbool(tfdtreadabletwritableterrorRt event_masktpollablet event_list((s//usr/lib64/python2.7/site-packages/dns/query.pyt _poll_for0s   c Cs®ggg}}}|r&|g}n|r8|g}n|rJ|g}n|dkrwtj|||ƒ\}} } n!tj||||ƒ\}} } t|pª| pª| ƒS(ssSelect polling backend. @param fd: File descriptor @type fd: int @param readable: Whether to wait for readability @type readable: bool @param writable: Whether to wait for writability @type writable: bool @param timeout: Deadline timeout (expiration time, in seconds) @type timeout: float @return True on success, False on timeout N(RR R( RRRRRtrsettwsettxsettrcounttwcounttxcount((s//usr/lib64/python2.7/site-packages/dns/query.pyt _select_forNs     !!cCsÀt}x³|s»|dkr$d}n+|tjƒ}|dkrOtjj‚ny+t|||||ƒsytjj‚nWn5tjk r±}|j dt j kr²|‚q²nXt }q WdS(Ngi( tFalseRRtdnst exceptiontTimeoutt_polling_backendR RtargsterrnotEINTRtTrue(RRRRt expirationtdoneRte((s//usr/lib64/python2.7/site-packages/dns/query.pyt _wait_forjs     cCs |adS(s# Internal API. Do not use. N(R%(tfn((s//usr/lib64/python2.7/site-packages/dns/query.pyt_set_polling_backend{sRcCst|ttt|ƒdS(N(R-R)R!(tsR*((s//usr/lib64/python2.7/site-packages/dns/query.pyt_wait_for_readable‹scCst|ttt|ƒdS(N(R-R!R)(R0R*((s//usr/lib64/python2.7/site-packages/dns/query.pyt_wait_for_writableŽscCsPtjj||dƒ}tjj||dƒ}||koO|d|dkS(Nii(R"tinett inet_pton(tafta1ta2tn1tn2((s//usr/lib64/python2.7/site-packages/dns/query.pyt_addresses_equal‘scCs|dkr;ytjj|ƒ}Wq;tjj}q;Xn|tjjkr˜||f}|dk sq|dkr|dkr†d}n||f}qni|tjjkr||ddf}|dk sÔ|dkr|dkréd}n||ddf}qn|||fS(Nis0.0.0.0s::(RR"R3taf_for_addresstAF_INETtAF_INET6(R5twheretporttsourcet source_portt destination((s//usr/lib64/python2.7/site-packages/dns/query.pyt_destination_and_source™s$      i5ic Csr|jƒ} t|||||ƒ\}} }tj|tjdƒ} zÙt|ƒ} | jdƒ|dk r}| j|ƒnt| | ƒ| j | | ƒx€t | | ƒ| j dƒ\} } t || | ƒs÷t jj|ƒrû| d| dkrûPn|std| | fƒ‚qqWd| jƒXt jj| d|jd|jd|ƒ}|j|ƒsnt‚n|S( s’Return the response obtained after sending a query via UDP. @param q: the query @type q: dns.message.Message @param where: where to send the message @type where: string containing an IPv4 or IPv6 address @param timeout: The number of seconds to wait before the query times out. If None, the default, wait forever. @type timeout: float @param port: The port to which to send the message. The default is 53. @type port: int @param af: the address family to use. The default is None, which causes the address family to use to be inferred from the form of of where. If the inference attempt fails, AF_INET is used. @type af: int @rtype: dns.message.Message object @param source: source address. The default is the wildcard address. @type source: string @param source_port: The port from which to send the message. The default is 0. @type source_port: int @param ignore_unexpected: If True, ignore responses from unexpected sources. The default is False. @type ignore_unexpected: bool @param one_rr_per_rrset: Put each RR into its own RRset @type one_rr_per_rrset: bool iiÿÿis$got a response from %s instead of %sNtkeyringt request_mactone_rr_per_rrset(tto_wireRCtsockett SOCK_DGRAMR t setblockingRtbindR2tsendtoR1trecvfromR:R"R3t is_multicastRtclosetmessaget from_wireRDtmact is_responseR(tqR>RR?R5R@RAtignore_unexpectedRFtwireRBR0R*t from_addresstr((s//usr/lib64/python2.7/site-packages/dns/query.pytudp¯s8       !  cCshd}x[|dkrct||ƒ|j|ƒ}|dkrFt‚n|t|ƒ}||}q W|S(sßRead the specified number of bytes from sock. Keep trying until we either get the desired amount, or we hit EOF. A Timeout exception will be raised if the operation is not completed by the expiration time. ti(R1trecvtEOFErrortlen(tsocktcountR*R0tn((s//usr/lib64/python2.7/site-packages/dns/query.pyt _net_readës   cCsMd}t|ƒ}x4||krHt||ƒ||j||ƒ7}qWdS(s‘Write the specified data to the socket. A Timeout exception will be raised if the operation is not completed by the expiration time. iN(R]R2tsend(R^tdataR*tcurrenttl((s//usr/lib64/python2.7/site-packages/dns/query.pyt _net_writeûs   cCs„y|j|ƒWnltjk rtjƒd \}}|dtjkr€|dtjkr€|dtjkr€|‚q€nXdS(Nii( tconnectRHRtsystexc_infoR't EINPROGRESSt EWOULDBLOCKtEALREADY(R0taddressttytv((s//usr/lib64/python2.7/site-packages/dns/query.pyt_connectscCsJ|jƒ}t|||||ƒ\}} }tj|tjdƒ} z±t|ƒ} | jdƒ|dk r}| j|ƒnt| | ƒt |ƒ} t j d| ƒ|} t | | | ƒt | d| ƒ}t jd|ƒ\} t | | | ƒ}Wd| jƒXtjj|d|jd|jd|ƒ}|j|ƒsFt‚n|S(s Return the response obtained after sending a query via TCP. @param q: the query @type q: dns.message.Message object @param where: where to send the message @type where: string containing an IPv4 or IPv6 address @param timeout: The number of seconds to wait before the query times out. If None, the default, wait forever. @type timeout: float @param port: The port to which to send the message. The default is 53. @type port: int @param af: the address family to use. The default is None, which causes the address family to use to be inferred from the form of of where. If the inference attempt fails, AF_INET is used. @type af: int @rtype: dns.message.Message object @param source: source address. The default is the wildcard address. @type source: string @param source_port: The port from which to send the message. The default is 0. @type source_port: int @param one_rr_per_rrset: Put each RR into its own RRset @type one_rr_per_rrset: bool is!HiNRDRERF(RGRCRHt SOCK_STREAMR RJRRKRpR]tstructtpackRfRatunpackROR"RPRQRDRRRSR(RTR>RR?R5R@RARFRVRBR0R*RettcpmsgtldataRX((s//usr/lib64/python2.7/site-packages/dns/query.pyttcps,       !  c&csZt|ttfƒr*tjj|ƒ}nt|ttfƒrTtjj|ƒ}ntjj|||ƒ}|tjj kr³tj j|dddd| ƒ}|j j |ƒn|dk rØ|j||d|ƒn|jƒ}t| ||| | ƒ\} }} |rG|tjj kr,tdƒ‚ntj| tjdƒ}ntj| tjdƒ}|jdƒ| dk rˆ|j| ƒnt| ƒ}t||ƒt|ƒ}|rÐt||ƒ|j|ƒn&tjd|ƒ|}t|||ƒt}t }t}d}d}|r/|}tjj!}n d}|}d}t } x|sKt|ƒ}!|!dkst|!|kr}|}!n|r¨t"||ƒ|j#dƒ\}}"n9t$|d |!ƒ}#tj%d|#ƒ\}t$|||!ƒ}tjj&|d |j'd |j(d t d |d|dt d| d|tjj kƒ}$|$j)}t} d}%|dkr|$j* sv|$j*dj|kr‹tj+j,dƒ‚n|$j*d}|j-tjj.krÂtj+j,dƒ‚nd}%|j/ƒ}|tjj kr|dj0| krt }q t }qnx|$j*|%D]õ}|r=tj+j,dƒ‚n|j-tjj.krö|j|krö|r˜|dj0| krtj+j,dƒ‚nt}n|tjj kr´| }n||kr|tjj1ksê|tjj kr|rt }qq|rtjj1}t}qqW|rC|j'rC|$j2 rCtj+j,dƒ‚n|$VqJW|j3ƒdS(s†Return a generator for the responses to a zone transfer. @param where: where to send the message @type where: string containing an IPv4 or IPv6 address @param zone: The name of the zone to transfer @type zone: dns.name.Name object or string @param rdtype: The type of zone transfer. The default is dns.rdatatype.AXFR. @type rdtype: int or string @param rdclass: The class of the zone transfer. The default is dns.rdataclass.IN. @type rdclass: int or string @param timeout: The number of seconds to wait for each response message. If None, the default, wait forever. @type timeout: float @param port: The port to which to send the message. The default is 53. @type port: int @param keyring: The TSIG keyring to use @type keyring: dict @param keyname: The name of the TSIG key to use @type keyname: dns.name.Name object or string @param relativize: If True, all names in the zone will be relativized to the zone origin. It is essential that the relativize setting matches the one specified to dns.zone.from_xfr(). @type relativize: bool @param af: the address family to use. The default is None, which causes the address family to use to be inferred from the form of of where. If the inference attempt fails, AF_INET is used. @type af: int @param lifetime: The total number of seconds to spend doing the transfer. If None, the default, then there is no limit on the time the transfer may take. @type lifetime: float @rtype: generator of dns.message.Message objects. @param source: source address. The default is the wildcard address. @type source: string @param source_port: The port from which to send the message. The default is 0. @type source_port: int @param serial: The SOA serial number to use as the base for an IXFR diff sequence (only meaningful if rdtype == dns.rdatatype.IXFR). @type serial: int @param use_udp: Use UDP (only meaningful for IXFR) @type use_udp: bool @param keyalgorithm: The TSIG algorithm to use; defaults to dns.tsig.default_algorithm @type keyalgorithm: string itINtSOAs. . %u 0 0 0 0t algorithmscannot do a UDP AXFRs!HiÿÿiRDREtxfrtoriginttsig_ctxtmultitfirstRFs No answer or RRset not for qnamesfirst RRset is not an SOAisanswers after final SOAsIXFR base serial mismatchs missing TSIGN(4t isinstancetstrtunicodeR"tnamet from_textt rdatatypeRPt make_querytIXFRtrrsett authoritytappendRtuse_tsigRGRCt ValueErrorRHRIRqRJRKR RpR]R2RbRrRsRfR!R)temptyR1RMRaRtRQRDRRR}tanswerR#t FormErrortrdtypeRytcopytserialtAXFRthad_tsigRO(&R>tzoneRtrdclassRR?RDtkeynamet relativizeR5tlifetimeR@RAR’tuse_udpt keyalgorithmRTRˆRVRBR0R*ReRuR+t delete_modet expecting_SOAt soa_rrsett soa_countR|tonameR}Rt mexpirationRWRvRXt answer_index((s//usr/lib64/python2.7/site-packages/dns/query.pyR{Hs¸5             !        $       (/Rt __future__RR'R RHRrRhRt dns.exceptionR"tdns.inettdns.namet dns.messagetdns.rdataclasst dns.rdatatypeR#t DNSExceptionRRRR RR R-R/thasattrR%R1R2R:RCRR!RYRaRfRpRwR…R“t rdataclassRxR)ttsigtdefault_algorithmR{(((s//usr/lib64/python2.7/site-packages/dns/query.pytsL                      ;   7