LPc@sZdZddlZddlZddlZddlZddlmZmZmZm Z ddlm Z ddl m Z dZda dadZdZd Zd efd YZd Zded ZedZdZdZe je dee jejdee jejdee jedee je dedS(sdiscover and advertise repositories on the local network Zeroconf-enabled repositories will be announced in a network without the need to configure a server or a service. They can be discovered without knowing their actual IP address. To allow other people to discover your repository using run :hg:`serve` in your repository:: $ cd test $ hg serve You can discover Zeroconf-enabled repositories by running :hg:`paths`:: $ hg paths zc-test = http://example.com:8000/test iN(tuithgtencodingtdispatch(t extensions(tservertinternalcCsy=tjtjtj}|jd|jd}|SWntjk rSnXyAtjtjdd}|jd rd|kr|SWn#tj tj fk rd}nXy=tjtjtj}|jd |jd}|SWntjk rnX|S( Ns1.0.0.1iis127.t:s 127.0.0.1i(s1.0.0.1i(s1.0.0.1i( tsockettAF_INETt SOCK_DGRAMtconnectt getsocknameterrort gethostbyaddrt gethostnamet startswithtgaierrortherror(tstiptdumbip((s;/sys/lib/python2.7/site-packages/hgext/zeroconf/__init__.pytgetip)s*   cCs,tsCt}|jdr"dStj|atj|antjjdd}|d}d||f}tj d|dd|d |d i|d 6d |d 6dtdddd}tj |tj d|dd|d |d i|d 6d |d 6dtdddd}tj |dS(Ns127.t.is.locals%s-%ss_http._tcp.local.s._http._tcp.local.Rtportt propertiest descriptiont/tpathtaddresstweighttprioritys_hg._tcp.local.s._hg._tcp.local.( RRRRt inet_atontlocaliptZeroconfRtsplitt ServiceInfotregisterService(tnametdescRRRthostnamethosttsvc((s;/sys/lib/python2.7/site-packages/hgext/zeroconf/__init__.pytpublishFs2         c Csg|||}|j}y |j}Wntk r|jpStjj|jj}|jj j dddj d}|jj j dd|}t ||||nX|j j dddj dd} x|D]\} }|j j } | jtjj|ddtjj| }| | j d}| j dd|}t ||||qW|S(NtwebtprefixtRRs.hgthgrc(RtrepostAttributeErrortreponametosRtbasenametrepotrootRtconfigtstripR+tcopyt readconfigtjoin( t create_serverRtappthttpdRR0R&RR'R-R5tu((s;/sys/lib/python2.7/site-packages/hgext/zeroconf/__init__.pytzc_create_serverhs$   !$%tlistenercBs#eZdZdZdZRS(cCs i|_dS(N(tfound(tself((s;/sys/lib/python2.7/site-packages/hgext/zeroconf/__init__.pyt__init__scCs,t||jkr(|jt|=ndS(N(treprRB(RCRttypeR&((s;/sys/lib/python2.7/site-packages/hgext/zeroconf/__init__.pyt removeServicescCs#|j|||jt|s,$ "  "