-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/hgext/zeroconf/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyc


\,Tc@swdZdZdZdZddlZddlZddlZddlZddlZddl	Z	ddl
Z
dddgZd	ed
<dZ
dZd
ZdZdZdZdZdZddZdZdZdZd	ZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$d Z%d!Z&d"Z'd#Z(dZ)dZ*dZ+dZ,d Z-d$Z.d%Z/d&Z0d'Z1d(Z2d)Z3d*Z4d+Z5d,Z6d-Z7d.Z8dZ9d/Z:d0Z;d"Z<id1e"6d2e#6d3e$6d4e%6d5e&6d6e'6Z=id7e*6d8e+6d9e,6d:e-6d;e.6d<e/6d=e06d>e16d?e26d@e36dAe46dBe56dCe66dDe76dEe86dFe96dGe:6dHe;6d6e<6Z>dIZ?dJe@fdKYZAdLe@fdMYZBdNe@fdOYZCdPe@fdQYZDdRe@fdSYZEdTe@fdUYZFdVeFfdWYZGdXeHfdYYZIdZeIfd[YZJd\eIfd]YZKd^eKfd_YZLd`eKfdaYZMdbeKfdcYZNddeKfdeYZOdfeKfdgYZPdheHfdiYZQdjeHfdkYZRdleHfdmYZSdnejTfdoYZUdpeHfdqYZVdrejTfdsYZWdejTfdtYZXdeHfduYZYdeHfdvYZZe[dwkrsdxGeGHeZZ\dyGHidzd{6d|d76d}d~6Z]eYddej^ddd	d	e]Z_dGHe\j`e_dGHdGHdGeae\jbddGHdGHdGHdGeae\jbddGHdGHdGHe\jce_dGHe\jdndS(s Multicast DNS Service Discovery for Python, v0.12
    Copyright (C) 2003, Paul Scott-Murphy

    This module provides a framework for the use of DNS Service Discovery
    using IP multicast.  It has been tested against the JRendezvous
    implementation from <a href="http://strangeberry.com">StrangeBerry</a>,
    and against the mDNSResponder from Mac OS X 10.3.8.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, see
    <http://www.gnu.org/licenses/>.

sPaul Scott-Murphys!paul at scott dash murphy dot coms0.12iNtZeroconftServiceInfotServiceBrowserit_GLOBAL_DONEi}iiiis224.0.0.251ii5i<ii#iiiii@i iiiiiiiiiiiii	i
iii
iiii!tintcstchthstnonetanytatnstmdtmftcnametsoatmbtmgtmrtnulltwkstptrthinfotminfotmxttxttquadatsrvcCstjdS(s#Current system time in millisecondsi(ttime(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytcurrentTimeMillisstNonLocalNameExceptioncBseZRS((t__name__t
__module__(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRstNonUniqueNameExceptioncBseZRS((RR (((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR!stNamePartTooLongExceptioncBseZRS((RR (((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR"stAbstractMethodExceptioncBseZRS((RR (((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR#stBadTypeInNameExceptioncBseZRS((RR (((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR$st
BadDomainNamecBseZdZRS(cCstj|d|dS(Nsat position %s(t	Exceptiont__init__(tselftpos((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR's(RR R'(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR%stBadDomainNameCircularcBseZRS((RR (((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR*stDNSEntrycBsDeZdZdZdZdZdZdZdZRS(sA DNS entrycCsHtj||_||_||_|t@|_|t@dk|_dS(Ni(	tstringtlowertkeytnamettypet_CLASS_MASKtclazzt
_CLASS_UNIQUEtunique(R(R/R0R2((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR's
		
cCsGt|trC|j|jkoB|j|jkoB|j|jkSdS(s&Equality test on name, type, and classi(t
isinstanceR+R/R0R2(R(tother((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt__eq__s4cCs|j|S(sNon-equality test(R7(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt__ne__scCs)yt|SWntk
r$d|SXdS(sClass accessors?(%s)N(t_CLASSEStKeyError(R(R2((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytgetClazzs
cCs)yt|SWntk
r$d|SXdS(s
Type accessors?(%s)N(t_TYPESR:(R(R0((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytgetTypes
cCsd||j|j|j|jf}|jrA|d7}n
|d7}||j7}|dk	ru|d|7}n
|d7}|S(s1String representation with additional informations%s[%s,%ss-unique,t,s,%s]t]N(R=R0R;R2R4R/tNone(R(thdrR6tresult((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyttoStrings+	



(	RR t__doc__R'R7R8R;R=RC(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR+s					tDNSQuestioncBs)eZdZdZdZdZRS(sA DNS question entrycCs8|jdst|ntj||||dS(Ns.local.(tendswithRR+R'(R(R/R0R2((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR'scCsC|j|jkoB|j|jks3|jtkoB|j|jkS(s6Returns true if the question is answered by the record(R2R0t	_TYPE_ANYR/(R(trec((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt
answeredByscCstj|ddS(sString representationtquestionN(R+RCR@(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt__repr__s(RR RDR'RIRK(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyREs		t	DNSRecordcBsqeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
RS(s.A DNS record - like a DNS entry, but has a TTLcCs/tj||||||_t|_dS(N(R+R'tttlRtcreated(R(R/R0R2RM((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR's	cCs#t|trtj||SdS(sTests equality as per DNSRecordi(R5RLR+R7(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR7!scCs+x$|jD]}|j|r
dSq
WdS(s^Returns true if any answer in a message can suffice for the
		information held in this record.ii(tanswerstsuppressedByAnswer(R(tmsgtrecord((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytsuppressedBy'scCs*||kr&|j|jdkr&dSdS(sqReturns true if another record has same name, type and class,
		and if its TTL is at least half of this record's.iii(RM(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRP/s"cCs|j||jdS(sRReturns the time at which this record will have expired
		by a certain percentage.i
(RNRM(R(tpercent((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytgetExpirationTime6scCstd|jd|dS(s%Returns the remaining TTL in seconds.iidi(tmaxRU(R(tnow((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytgetRemainingTTL;scCs|jd|kS(s(Returns true if this record has expired.id(RU(R(RW((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt	isExpired?scCs|jd|kS(s9Returns true if this record is at least half way expired.i2(RU(R(RW((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytisStaleCscCs|j|_|j|_dS(sDSets this record's TTL and created time to that of
		another record.N(RNRM(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytresetTTLGscCs
tdS(sAbstract methodN(R#(R(tout((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytwriteMscCs5d|j|jt|f}tj|d|S(s1String representation with additional informations%s/%s,%sRR(RMRXRR+RC(R(R6targ((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRCQs"(RR RDR'R7RSRPRURXRYRZR[R]RC(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRLs										t
DNSAddresscBs2eZdZdZdZdZdZRS(sA DNS address recordcCs&tj|||||||_dS(N(RLR'taddress(R(R/R0R2RMR`((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR'YscCs |j|jt|jdS(s'Used in constructing an outgoing packetN(twriteStringR`tlen(R(R\((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR]]scCs#t|tr|j|jkSdS(sTests equality on addressi(R5R_R`(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR7ascCs0ytj|jSWntk
r+|jSXdS(sString representationN(tsockett	inet_ntoaR`R&(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRKgs
(RR RDR'R]R7RK(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR_Vs
			tDNSHinfocBs2eZdZdZdZdZdZRS(sA DNS host information recordcCs/tj|||||||_||_dS(N(RLR'tcputos(R(R/R0R2RMRfRg((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR'qs	cCs<|j|jt|j|j|jt|jdS(s'Used in constructing an outgoing packetN(RaRfRbRg(R(R\((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR]vscCs5t|tr1|j|jko0|j|jkSdS(sTests equality on cpu and osi(R5ReRfRg(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR7{s"cCs|jd|jS(sString representationt (RfRg(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRKs(RR RDR'R]R7RK(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRens
			t
DNSPointercBs2eZdZdZdZdZdZRS(sA DNS pointer recordcCs&tj|||||||_dS(N(RLR'talias(R(R/R0R2RMRj((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR'scCs|j|jdS(s'Used in constructing an outgoing packetN(t	writeNameRj(R(R\((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR]scCs#t|tr|j|jkSdS(sTests equality on aliasi(R5RiRj(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR7scCs|j|jS(sString representation(RCRj(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRKs(RR RDR'R]R7RK(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRis
			tDNSTextcBs2eZdZdZdZdZdZRS(sA DNS text recordcCs&tj|||||||_dS(N(RLR'ttext(R(R/R0R2RMRm((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR'scCs |j|jt|jdS(s'Used in constructing an outgoing packetN(RaRmRb(R(R\((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR]scCs#t|tr|j|jkSdS(sTests equality on texti(R5RlRm(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR7scCsAt|jdkr-|j|jd dS|j|jSdS(sString representationi
is...N(RbRmRC(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRKs(RR RDR'R]R7RK(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRls
			t
DNSServicecBs2eZdZdZdZdZdZRS(sA DNS service recordc		CsAtj|||||||_||_||_||_dS(N(RLR'tprioritytweighttporttserver(	R(R/R0R2RMRoRpRqRr((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR's
			cCsD|j|j|j|j|j|j|j|jdS(s'Used in constructing an outgoing packetN(t
writeShortRoRpRqRkRr(R(R\((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR]scCsYt|trU|j|jkoT|j|jkoT|j|jkoT|j|jkSdS(s3Tests equality on priority, weight, port and serveri(R5RnRoRpRqRr(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR7sFcCs|jd|j|jfS(sString representations%s:%s(RCRrRq(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRKs(RR RDR'R]R7RK(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRns
			tDNSIncomingcBszeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZRS(
s/Object representation of an incoming DNS packetcCsjd|_||_g|_g|_d|_d|_d|_d|_|j|j	|j
dS(s/Constructor from string holding bytes of packetiN(toffsettdatat	questionsROtnumQuestionst
numAnswerstnumAuthoritiestnumAdditionalst
readHeadert
readQuestionst
readOthers(R(Rv((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR's								

cCsd}tj|}tj||j|j|j|!}|j|7_|d|_|d|_|d|_|d|_|d|_	|d|_
dS(	sReads header portion of packets!HHHHHHiiiiiiN(tstructtcalcsizetunpackRvRutidtflagsRxRyRzR{(R(tformattlengthtinfo((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR|s&




cCsd}tj|}xtd|jD]}|j}tj||j|j|j|!}|j|7_y.t||d|d}|j	j
|Wq(tk
rq(Xq(WdS(s!Reads questions section of packets!HHiiN(RRtrangeRxtreadNameRRvRuRERwtappendR(R(RRtiR/RRJ((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR}s&
cCsRd}tj|}tj||j|j|j|!}|j|7_|dS(s Reads an integer from the packets!Ii(RRRRvRu(R(RRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytreadInts
&cCs2t|j|j}|jd7_|j|S(s(Reads a character string from the packeti(tordRvRut
readString(R(R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytreadCharacterStringscCs`dt|d}tj|}tj||j|j|j|!}|j|7_|dS(s0Reads a string of a given length from the packett!tsi(tstrRRRRvRu(R(RbRRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR
s
&cCsRd}tj|}tj||j|j|j|!}|j|7_|dS(s'Reads an unsigned short from the packets!Hi(RRRRvRu(R(RRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytreadUnsignedShorts
&c
Csrd}tj|}|j|j|j}x?td|D].}|j}tj||j|j	|j	|!}|j	|7_	d}|dtkrt||d|d|d|j
d}n|dtks|dtkrt||d|d|d|j}n5|dtkrZt||d|d|d|j
|d}n|dtkrt||d|d|d|j|j|j|j}n|dtkrt||d|d|d|j|j}nS|dtkr8t||d|d|d|j
d}n|j	|d7_	|dk	r<|jj|q<q<WdS(	sDReads the answers, authorities and additionals section of the packets!HHiHiiiiiiN(RRRyRzR{RRRRvRuR@t_TYPE_AR_Rt_TYPE_CNAMEt	_TYPE_PTRRit	_TYPE_TXTRlt	_TYPE_SRVRnRt_TYPE_HINFOReRt
_TYPE_AAAAROR(R(RRtnRtdomainRRH((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR~s.&0 -4H60
cCs|jt@tkS(sReturns true if this is a query(Rt_FLAGS_QR_MASKt_FLAGS_QR_QUERY(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytisQuery?scCs|jt@tkS(s"Returns true if this is a response(RRt_FLAGS_QR_RESPONSE(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt
isResponseCscCs|j|||!jdS(s6Reads a UTF-8 string of a given length from the packetsutf-8(Rvtdecode(R(RuRb((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytreadUTFGscCs6d}|j}d}|}xtrt|j|}|d7}|dkrQPn|d@}|dkrdj||j||df}||7}q|dkr|dkr|d}n|d@d>t|j|B}||krt|n|}qt|qW|dkr)||_n	||_|S(	s#Reads a domain name from the packettiiiit.i?i(RutTrueRRvtjoinRR*R%(R(RBtofftnexttfirstRbtt((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRKs2		

%

		(RR RDR'R|R}RRRRR~RRRR(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRts								%			tDNSOutgoingcBseZdZddZdZdZdZdZdZdZ	d	Z
d
ZdZdZ
d
ZdZdZdZdZRS(s+Object representation of an outgoing packeticCsgd|_d|_||_||_i|_g|_d|_g|_g|_g|_	g|_
dS(Nii(tfinishedRt	multicastRtnamesRvtsizeRwROtauthoritiestadditionals(R(RR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR'ps										cCs|jj|dS(sAdds a questionN(RwR(R(RR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytaddQuestion~scCs&|j|s"|j|dndS(sAdds an answeriN(RStaddAnswerAtTime(R(tinpRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt	addAnswerscCsH|dk	rD|dks(|j|rD|jj||fqDndS(s6Adds an answer if if does not expire by a certain timeiN(R@RYROR(R(RRRW((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRscCs|jj|dS(sAdds an authoritative answerN(RR(R(RR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytaddAuthoritativeAnswerscCs|jj|dS(sAdds an additional answerN(RR(R(RR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytaddAdditionalAnswerscCs;d}|jjtj|t||jd7_dS(s"Writes a single byte to the packets!ciN(RvRRtpacktchrR(R(tvalueR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt	writeBytes"cCs8d}|jj|tj|||jd7_dS(s=Inserts an unsigned short in a certain position in the packets!HiN(RvtinsertRRR(R(tindexRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytinsertShortscCs5d}|jjtj|||jd7_dS(s&Writes an unsigned short to the packets!HiN(RvRRRR(R(RR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRsscCs;d}|jjtj|t||jd7_dS(s(Writes an unsigned integer to the packets!IiN(RvRRRtintR(R(RR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytwriteInts"cCsCdt|d}|jjtj|||j|7_dS(sWrites a string to the packetRRN(RRvRRRR(R(RRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRascCsQ|jd}t|}|dkr0tn|j||j||dS(s5Writes a UTF-8 string of a given length to the packetsutf-8i@N(tencodeRbR"RRa(R(RtutfstrR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytwriteUTFs	
cCsy|j|}Wnytk
r|j|j|<|jd}|ddkr]|d }nx|D]}|j|qdW|jddSX|j|d?dB|j|dS(s"Writes a domain name to the packetRiRiNii(RR:RtsplitRR(R(R/Rtpartstpart((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRks



cCs4|j|j|j|j|j|jdS(sWrites a question to the packetN(RkR/RsR0R2(R(RJ((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt
writeQuestionscCs|j|j|j|j|jrI|jrI|j|jtBn|j|j|dkrx|j|j	n|j|j
|t|j}|j
d7_
|j||j
d8_
tdj|j|}|j||dS(sJWrites a record (answer, authoritative answer, additional) to
		the packetiiRN(RkR/RsR0R4RR2R3RRMRXRbRvRR]RR(R(RRRWRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytwriteRecords
cCs^|jsNd|_x|jD]}|j|qWx'|jD]\}}|j||q=Wx!|jD]}|j|dqgWx!|jD]}|j|dqW|jdt|j|jdt|j|jdt|j|jdt|j|jd|j	|j
r8|jddqN|jd|jndj|j
S(suReturns a string containing the packet's bytes

		No further parts should be added to the packet once this
		is done.iiR(RRwRRORRRRRbRRRRRv(R(RJtanswerRt	authorityt
additional((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytpackets&			(RR RDR'RRRRRRRRsRRaRRkRRR(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRms"															tDNSCachecBsMeZdZdZdZdZdZdZdZdZ	RS(sA cache of DNS entriescCs
i|_dS(N(tcache(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR'scCsMy|j|j}Wn%tk
r;g}|j|j<nX|j|dS(s
Adds an entryN(RR.R:R(R(tentrytlist((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytadds

cCs9y!|j|j}|j|Wntk
r4nXdS(sRemoves an entryN(RR.tremoveR:(R(RR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs

cCsDy%|j|j}||j|SWnttfk
r?dSXdS(sHGets an entry by key.  Will return None if there is no
		matching entry.N(RR.RR:t
ValueErrorR@(R(RR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytget%s
cCst|||}|j|S(sLGets an entry by details.  Will return None if there is
		no matching entry.(R+R(R(R/R0R2R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytgetByDetails.scCs(y|j|SWntk
r#gSXdS(s5Returns a list of entries whose key matches the name.N(RR:(R(R/((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytentriesWithName4s
cCs<d}yt||jjSWntk
r7gSXdS(sReturns a list of all entriescSs||S(N((txty((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR=sN(treduceRtvaluesR&(R(R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytentries;s
	
(
RR RDR'RRRRRR(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs							tEnginecBsDeZdZdZdZdZdZdZdZRS(sNAn engine wraps read access to sockets, allowing objects that
	need to receive data from sockets to be called back when the
	sockets are ready.

	A reader needs a handle_read() method, which is called when the socket
	it is interested in is ready for reading.

	Writers are not implemented here, because we only send short
	packets.
	cCsHtjj|||_i|_d|_tj|_|jdS(Ni(	t	threadingtThreadR'tzeroconftreadersttimeoutt	Conditiont	conditiontstart(R(R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR'Ps			cCsxtds|j}t|dkr^|jj|jj|j|jjqy|tj|gg|j\}}}xQ|D]I}y|j	|j
Wqtk
rtdstj
qqXqWWqtk
rqXqWdS(NRi(tglobalst
getReadersRbRtacquiretwaitRtreleasetselectRthandle_readR&t	tracebackt	print_exc(R(trstrrtwrterRc((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytrunXs 
$



cCs-|jj|jj}|jj|S(N(RRRtkeysR(R(RB((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRns

cCs8|jj||j|<|jj|jjdS(N(RRRtnotifyR(R(treaderRc((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt	addReaderts


cCs5|jj|j|=|jj|jjdS(N(RRRRR(R(Rc((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt	delReaderzs


cCs+|jj|jj|jjdS(N(RRRR(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs

(	RR RDR'RRRRR(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRDs
					tListenercBs eZdZdZdZRS(s(A Listener is used by this module to listen on the multicast
	group to which DNS messages are sent, allowing the implementation
	to cache information as it arrives.

	It requires registration with an Engine object in order to have
	the read() method called when a socket is available for reading.cCs)||_|jjj||jjdS(N(RtengineRRc(R(R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR's	cCs|jjjt\}\}}||_t|}|jr|tkrg|jj|t	tq|t
kr|jj||||jj|t	tqn|jj|dS(N(RRctrecvfromt_MAX_MSG_ABSOLUTERvRtRt
_MDNS_PORTthandleQueryt
_MDNS_ADDRt	_DNS_PORTthandleResponse(R(RvtaddrRqRQ((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs!	(RR RDR'R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs	tReapercBs eZdZdZdZRS(sKA Reaper is used by this module to remove cache entries that
	have expired.cCs'tjj|||_|jdS(N(RRR'RR(R(R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR's	cCsxtr|jjdtdr*dSt}xR|jjjD]>}|j|rF|jj|||jjj	|qFqFWqWdS(Ni
iRi'(
RRRRRRRRYtupdateRecordR(R(RWRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs	
	(RR RDR'R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs	cBs2eZdZdZdZdZdZRS(sUsed to browse for a service of a specific type.

	The listener object will have its addService() and
	removeService() methods called when this browser
	discovers changes in the services availability.cCstjj|||_||_||_i|_t|_t	|_
g|_d|_|jj
|t|jtt|jdS(s%Creates a browser for a specific typeiN(RRR'RR0tlistenertservicesRtnextTimet
_BROWSER_TIMEtdelayRtdonetaddListenerRERt	_CLASS_INR(R(RR0R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR's							"csjtkrjjkrj|}yijjj}|s_|jn9jjj=fd}jj	|dSWnRt
k
r|sjjj<fd}jj	|qnXjd}|jkr|_qndS(s|Callback invoked by Zeroconf when new information arrives.

		Updates information required by browser in the Zeroconf cache.csjj|jjS(N(Rt
removeServiceR0Rj(R(RRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt<lambda>sNcsjj|jjS(N(Rt
addServiceR0Rj(R(RRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR
siK(
R0RR/RYRRjR-R[RRR&RUR(R(RRWRRtexpiredt	oldrecordtcallbacktexpires((RRR(s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs$!
cCsd|_|jjdS(Ni(R	Rt	notifyAll(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytcancels	cCsvxotrqd}t}t|jdkrV|j|krV|jj|j|ntdsl|j	rpdSt}|j|kr(t
t}|jt
|jttx9|jjD](}|j|s|j||qqW|jj|||j|_td|jd|_nt|jdkrR|jjd}n|dk	r||jqqWdS(NiRiiii N(RR@RRbRRRRRR	RRRRER0RRRRRYRtsendRtmintpop(R(teventRWR\RR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs*		$	(RR RDR'RRR(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs
			cBseZdZdddddddZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZRS(sService informationic		Csz|j|stn||_||_||_||_||_||_|r`||_n	||_|j	|dS(sCreate a service description.

		type: fully qualified service type name
		name: fully qualified service name
		address: IP address as unsigned short, network byte order
		port: port that the service runs on
		weight: weight of the service
		priority: priority of the service
		properties: dictionary of properties (or a string holding the bytes for the text field)
		server: fully qualified name for service host (defaults to name)N(
RFR$R0R/R`RqRpRoRrt
setProperties(	R(R0R/R`RqRpRot
propertiesRr((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR's								cCst|tr||_g}d}x|D]}||}|dkrPd}nEt|trh|}n-t|tr|rd}qd}nd}|jdj||fq+Wx>|D]6}dj|tj	dt
t||f}qW||_n	||_dS(s7Sets properties and text of this info from a dictionaryRttruetfalset=s!cN(
R5tdictRR@RRRRRRRRbRm(R(RRRBR.Rtsuffixtitem((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR%s(	

				 
4cCsZ||_y&i}t|}d}g}xL||krxt||}|d7}|j||||!||7}q-Wx|D]}|jd}|dkr|}	d}
nI|| }	||d}
|
dkrd}
n|
dks|
rd}
n|	r|j|	dkr|
||	<qqW||_Wn$tk
rUt	j
d|_nXdS(s+Sets properties and text given a text fieldiiRiRRN(RmRbRRtfindRR@RR&RR(R(RmRBtendRtstrsRRteindexR.R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytsetText?s8	

	
		


cCs|jS(s
Type accessor(R0(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR=dscCsT|jdk	rM|jjd|jrM|jt|jt|jd S|jS(s
Name accessorRiN(R0R@R/RFRb(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytgetNamehs(%cCs|jS(sAddress accessor(R`(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt
getAddressnscCs|jS(s
Port accessor(Rq(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytgetPortrscCs|jS(sPriority accessor(Ro(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytgetPriorityvscCs|jS(sWeight accessor(Rp(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt	getWeightzscCs|jS(sProperties accessor(R(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt
getProperties~scCs|jS(s
Text accessor(Rm(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytgetTextscCs|jS(sServer accessor(Rr(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt	getServerscCs|dk	r|j|r|jtkrO|j|jkr|j|_qq|jtkr|j|jkr|j|_|j|_|j	|_	|j
|_
|j|||jj
|jttqq|jtkr|j|jkr|j|jqqndS(s-Updates service information from a DNS recordN(R@RYR0RR/RrR`RRqRpRoRRRRRR%Rm(R(RRWRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs.c	Cst}t}||}||}d}z|j|t|jttxu|jdks{|j	dks{|j
dkr||krdS||krtt}|j
t|jtt|j|jj|jtt||j
t|jtt|j|jj|jtt||jdk	rx|j
t|jtt|j|jj|jtt|n|j|||}|d}n|jt|||t}qNWd}Wd|j|X|S(suReturns true if the service could be discovered on the
		network, and updates this object with details discovered.
		iiiN(Rt_LISTENER_TIMER
RER/RGRRrR@R`RmRRRRRRRRRRRRtremoveListener(	R(RRRWRRtlastRBR\((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytrequests6	

0%%(




cCs#t|tr|j|jkSdS(sTests equality of service namei(R5RR/(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR7scCs|j|S(sNon-equality test(R7(R(R6((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR8scCsd|jtj|j|jf}|jdkrD|d7}n:t|jdkri||j7}n||jd d7}|d7}|S(sString representationsservice[%s,%s:%s,R@iis...R?N(R/RcRdR'RqRmR@Rb(R(RB((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRKs(

N(RR RDR@R'RR%R=R&R'R(R)R*R+R,R-RR1R7R8RK(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs$		%											#		cBseZdZddZdZdZdZdZddZ	dZ
d	Zed
Z
dZdZd
ZdZdZdZdZdZeedZdZRS(s{Implementation of Zeroconf Multicast DNS Service Discovery

	Supports registration, unregistration, queries and browsing.
	cCsdtd<|dkr4tjtj|_n	||_dtf|_tjtjtj	|_y<|jj
tjtjd|jj
tjtj
dWntk
rnX|jj
tjtjd|jj
tjtjdy|jj|jWntk
rnX|jj
tjtjtjttjdg|_g|_i|_i|_t|_tj|_t||_ t!||_"t#||_$dS(srCreates an instance of the Zeroconf class, establishing
		multicast communications, listening and reaping threads.iRRiis0.0.0.0N(%RR@Rct
gethostbynametgethostnametintfRtgrouptAF_INETt
SOCK_DGRAMt
setsockoptt
SOL_SOCKETtSO_REUSEADDRtSO_REUSEPORTR&tSOL_IPtIP_MULTICAST_TTLtIP_MULTICAST_LOOPtbindtIP_ADD_MEMBERSHIPt	inet_atonRt	listenerstbrowsersRtservicetypesRRRRRRRRRRtreaper(R(tbindaddress((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR's6
	 

2				cCs|jjdS(Ns	127.0.0.1(R4t
startswith(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt
isLoopbackscCs|jjdS(Ns169.254.(R4RG(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytisLinklocalscCs2|jj|jj|d|jjdS(sLCalling thread waits for a given number of milliseconds or
		until notified.iN(RRRR(R(R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs
cCs+|jj|jj|jjdS(sNotifies all waiting threadsN(RRRR(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs

icCs)t||}|j||r%|SdS(sReturns network's service information for a particular
		name and type, or None if no service matches by the timeout,
		which defaults to 3 seconds.N(RR1R@(R(R0R/RR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytgetServiceInfoscCs-|j||jjt|||dS(sAdds a listener for a particular service type.  This object
		will then have its updateRecord method called when information
		arrives for that type.N(tremoveServiceListenerRCRR(R(R0R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytaddServiceListener(s
cCs7x0|jD]%}|j|kr
|j~q
q
WdS(s<Removes a listener from the set that is currently listening.N(RCRR(R(Rtbrowser((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRK/s
c
Cs|j|||j|jj<|jj|jrQ|j|jcd7<nd|j|j<t}|}d}x+|dkr||kr|j||t}qynt	t
tB}|jt
|jtt||jd|jt|jtt||j|j|j|jd|jt|jtt||jd|jr|jt|jtt||jdn|j||d7}|t7}qyWdS(sRegisters service information to the network with a default TTL
		of 60 seconds.  Zeroconf will then respond to requests for
		information for that service.  The name of the service may be
		changed if needed to make it unique on the network.iiiN(tcheckServiceRR/R-RDthas_keyR0RRRRt	_FLAGS_AARRiRRRnRRoRpRqRrRlRRmR`R_RRt_REGISTER_TIME(R(RRMRWRRR\((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytregisterService6s,
		(:(	+

c
CsyS|j|jj=|j|jdkrE|j|jcd8<n
|j|j=Wntk
rfnXt}|}d}x+|dkr||kr|j||t}qntt	t
B}|jt|jt
td|jd|jt|jttd|j|j|j|jd|jt|jttd|jd|jr|jt|jttd|jdn|j||d7}|t7}qWdS(sUnregister a service.iiiN(RR/R-RDR0R:RRRRRPRRiRRRnRRoRpRqRlRRmR`R_RrRRt_UNREGISTER_TIME(R(RRWRRR\((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytunregisterServiceSs0
		(:(	+

cCsyt|jdkrut}|}d}xH|dkrq||kre|j||t}q-ntttB}x|jjD]}|jt	|j
ttd|j
d|jt|j
ttd|j|j|j|jd|jt|j
ttd|jd|jr|jt|jttd|jdqqW|j||d7}|t7}q-WndS(s#Unregister all registered services.iiiN(RbRRRRRRPRRRiR0RRR/RnRRoRpRqRrRlRRmR`R_RRRS(R(RWRRR\R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pytunregisterAllServicesos&		(:(	/

cCst}|}d}xg|dkr~x|jj|jD]}|jtkr:|j|r:|j|jkr:|jjddkr|jd|j	d|j
d|j|_|j|dStq:q:W||kr|j
||t}qntttB}||_|jt|jtt|jt|jttt|j|j||d7}|t7}qWdS(	shChecks the network for a unique service name, modifying the
		ServiceInfo passed in if it is not unique.iiRs.[t:s].Ni(RRRR0RRYRjR/R!R`RqRNR!RRRRPtdebugRRERRRit_DNS_TTLRt_CHECK_TIME(R(RRWRRRRR\((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRNs,	1-

		%

cCst}|jj||dk	r}xU|jj|jD];}|j|r;|j|r;|j	|||q;q;Wn|j
dS(sAdds a listener for a given question.  The listener will have
		its updateRecord method called when information is available to
		answer the question.N(RRBRR@RRR/RIRYRR(R(RRJRWRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR
s	cCs6y|jj||jWntk
r1nXdS(sRemoves a listener.N(RBRRR&(R(R((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR/s

cCs5x$|jD]}|j|||q
W|jdS(sHUsed to notify listeners of new information that has updated
		a record.N(RBRR(R(RWRHR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRscCst}x|jD]}|j|}||jjkr|rV|jj|q|jj|}|dk	r|j||}qn|jj	||j
||qWdS(sfDeal with incoming response packets.  All answers
		are held in the cache, and listeners are notified.N(RRORYRRRRR@R[RR(R(RQRWRRRR((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs	
cCsad}|tkrItttBd}x!|jD]}|j|q/Wnx|jD]}|jtkrN|j	dkrx[|j
jD]G}|dkrtttB}n|j|t
dttt|qWnxJ|jjD]b}|j	|jkr|dkrtttB}n|j|t
|jttt|j	qqWqSy|dkrptttB}n|jtks|jtkrxa|jjD]M}|j|j	jkr|j|t|j	tttBt|jqqWn|jj|j	jd}|swSn|jtks:|jtkr{|j|t|j	tttBt|j|j|j|jn|jtks|jtkr|j|t |j	tttBt|j!n|jtkr|j"t|jtttBt|jnWqSt#k
r!t$j%qSXqSW|dk	r]|j&r]|j'|_'|j(|||ndS(sEDeal with incoming query packets.  Provides a response if
		possible.is_services._dns-sd._udp.local.N()R@RRRRPRwRR0RR/RDRRRiRRXRRRRGRrR-R_R3R`RRRnRoRpRqRRlRmRR&RRRORR(R(RQRRqR\RJtstypetservice((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRsL)26A/0
cCs>y&|jj|jd||fWntk
r9nXdS(sSends an outgoing packet.iN(RctsendtoRR&(R(R\RRq((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs&
cCstddkrdtd<|j|jj|j|jjtjtjtj	t
tj	d|jjndS(sXEnds the background threads, and prevent this instance from
		servicing further queries.Riis0.0.0.0N(RRRRRURcR8R<tIP_DROP_MEMBERSHIPRARtclose(R(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyR^
s



2N(RR RDR@R'RHRIRRRJRLRKRXRRRTRURNR
R/RRRRRRR^(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyRs(/															3
t__main__s3Multicast DNS Service Discovery for Python, versions'1. Testing registration of a service...s0.10tversions
test values
another valuetbs_http._tcp.local.s!My Service Name._http._tcp.local.s	127.0.0.1is   Registering service...s   Registration done.s*2. Testing query of service information...s   Getting ZOE service:sZOE._http._tcp.local.s   Query done.s"3. Testing query of own service...s   Getting self:s/4. Testing unregister of service information...s   Unregister done.(eRDt
__author__t	__email__t__version__R,RRRcRRRt__all__RRSRYRQR.RRRRRXt_MAX_MSG_TYPICALRRRRRPt	_FLAGS_TCt	_FLAGS_RDt	_FLAGS_RAt_FLAGS_Zt	_FLAGS_ADt	_FLAGS_CDRt	_CLASS_CSt	_CLASS_CHt	_CLASS_HSt_CLASS_NONEt
_CLASS_ANYR1R3Rt_TYPE_NSt_TYPE_MDt_TYPE_MFRt	_TYPE_SOAt_TYPE_MBt_TYPE_MGt_TYPE_MRt
_TYPE_NULLt	_TYPE_WKSRRt_TYPE_MINFOt_TYPE_MXRRRRGR9R<RR&RR!R"R#R$R%R*tobjectR+RERLR_ReRiRlRnRtRRRRRRRRRRtrtdescRARRRRRJRTR^(((s;/usr/lib/python2.7/dist-packages/hgext/zeroconf/Zeroconf.pyt<module>s6





	0=5AOA		'



Copyright © 2017 || Recoded By Mr.Bumblebee