U mf @sFddlZddlZddlmZmZmZddlZddlZGdddZ dS)N)IteratorOptionalTuplec@seZdZd(eedddZedddZeedd d Zd)eed d dZedddZ edddZ edddZ edddZ edddZ eedddZd*eddddd Zedd!d"d#Zejeedd$d%Zejedd&d'ZdS)+Parserr)wirecurrentcCs0||_d|_t|j|_|r&||||_dSNr)rrlenendseekfurthest)selfrrr6/opt/hc_python/lib/python3.8/site-packages/dns/wire.py__init__ s   zParser.__init__)returncCs |j|jSN)r rr rrr remainingszParser.remaining)sizercCsX|dks t||kr tjj|j|j|j|}|j|7_t|j|j|_|Sr) AssertionErrorrdns exception FormErrorrrmaxr )r routputrrr get_bytess  zParser.get_bytes) length_sizercCst||d}||S)Nbigint from_bytesr)r rlengthrrrget_counted_bytes szParser.get_counted_bytescCs||Sr)rrrrrr get_remaining$szParser.get_remainingcCstd|ddS)Nz!Brrstructunpackrrrrr get_uint8'szParser.get_uint8cCstd|ddS)Nz!Hrr&rrrr get_uint16*szParser.get_uint16cCstd|ddS)Nz!Irr&rrrr get_uint32-szParser.get_uint32cCst|ddS)Nrr rrrr get_uint480szParser.get_uint48)formatrcCst||t|Sr)r'r(rcalcsize)r r0rrr get_struct3szParser.get_structNz dns.name.Name)originrcCstj|}|r||}|Sr)rnameZfrom_wire_parserZ relativize)r r3r4rrrget_name6s  zParser.get_name)wherercCs$|dks||jkrtjj||_dSr)r rrrr)r r6rrrr <sz Parser.seekccs^|dks t||kr tjj|j}z*|j||_dV|j|jkrNtjjW5||_XdSr)rrrrrr r)r rZ saved_endrrr restrict_toCs     zParser.restrict_toccsz dVW5|j|_XdSr)r rrrrrrestore_furthestTs zParser.restore_furthest)r)r)N)__name__ __module__ __qualname__bytesr!rrrr$r%r)r+r-r/strrr2rr5r contextlibcontextmanagerrr7r8rrrrr s  r) r>r'typingrrrZ dns.exceptionrZdns.namerrrrrs