%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/
Upload File :
Create Path :
Current File : //opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyc

�
�ac@s�ddlZddlZddlZddlZddlZddlmZmZddlm	Z	ddl
mZddlm
Z
ed�\ZZdefd��YZd	e	e
fd
��YZdS(i����N(treactortdefer(tDatagramProtocol(tTYPE_SERVER(tNBNSitNetBIOSTimeoutcBseZdZRS(sfRaised in NBNSProtocol via Deferred.errback method when queryName method has timeout waiting for reply(t__name__t
__module__t__doc__(((sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyR
stNBNSProtocolcBskeZejd�Zedd�Zd�Zd�Zdddd�Z	ddd	�Z
d
�Zd�ZRS(sNMB.NBNSProtocolicCsl||_i|_tj||�|_|jrU|jj�jtjtj	d�ntj
d|j�dS(s�
        Instantiate a NBNSProtocol instance.

        This automatically calls reactor.listenUDP method to start listening for incoming packets, so you **must not** call the listenUDP method again.

        :param boolean broadcast: A boolean flag to indicate if we should setup the listening UDP port in broadcast mode
        :param integer listen_port: Specifies the UDP port number to bind to for listening. If zero, OS will automatically select a free port number.
        iN(t	broadcasttpending_trnsRt	listenUDPt	transportt	getHandlet
setsockopttsockett
SOL_SOCKETtSO_BROADCASTt	callLatertcleanupPendingTrns(tselfR
tlisten_port((sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyt__init__s				%c
Cs�|\}}|j|�\}}||jkr|jj|�\}}}	|tkro|j|�\}}n|	j|�ndS(N(tdecodePacketRtpopt
NAME_QUERYtdecodeIPQueryPackettcallback(
Rtdatat	from_infothosttportttrn_idtrett_tiptd((sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pytdatagramReceived"scCs#|jj�j|||f�dS(N(R
Rtsendto(RRR$R ((sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pytwrite.sti�icCs�tjdd�}x.trB|jj|�s1Pq|dd@}qW|j||�}|jrn|rnd}n|s�|jjd�n|j	|||�t
j�}tj�|||f|j|<|S(sX
        Send a query on the network and hopes that if machine matching the *name* will reply with its IP address.

        :param string ip: If the NBNSProtocol instance was instianted with broadcast=True, then this parameter can be an empty string. We will leave it to the OS to determine an appropriate broadcast address.
                          If the NBNSProtocol instance was instianted with broadcast=False, then you should provide a target IP to send the query.
        :param integer port: The NetBIOS-NS port (IANA standard defines this port to be 137). You should not touch this parameter unless you know what you are doing.
        :param integer/float timeout: Number of seconds to wait for a reply, after which the returned Deferred instance will be called with a NetBIOSTimeout exception.
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a list of IP addresses in dotted notation (aaa.bbb.ccc.ddd).
                 On timeout, the errback function will be called with a Failure instance wrapping around a NetBIOSTimeout exception
        ii��s<broadcast>sQqueryName: ip parameter is empty. OS might not transmit this query to the network(
trandomtrandinttTrueRthas_keytprepareNameQueryR
tlogtwarningR(RtDeferredttime(RtnameR$R ttimeoutR!RR%((sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyt	queryName2s		 cs�tjdd�}x.trB|jj|�s1Pq|dd@}qW|j|�}|j|||�tj��tj�}|j	�j
��fd�}|j|�tj�|t
|f|j|<�S(sU
        Send a query to the machine with *ip* and hopes that the machine will reply back with its name.

        The implementation of this function is contributed by Jason Anderson.

        :param string ip: If the NBNSProtocol instance was instianted with broadcast=True, then this parameter can be an empty string. We will leave it to the OS to determine an appropriate broadcast address.
                          If the NBNSProtocol instance was instianted with broadcast=False, then you should provide a target IP to send the query.
        :param integer port: The NetBIOS-NS port (IANA standard defines this port to be 137). You should not touch this parameter unless you know what you are doing.
        :param integer/float timeout: Number of seconds to wait for a reply, after which the method will return None
        :return: A *twisted.internet.defer.Deferred* instance. The callback function will be called with a list of names of the machine at *ip*.
                 On timeout, the errback function will be called with a Failure instance wrapping around a NetBIOSTimeout exception
        ii��cs8|dk	r4�jtd�td�|���ndS(NcSs|dS(Ni((ts((sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyt<lambda>mR)cSs|dtkS(Ni(R(R6((sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyR7mR)(tNoneRtmaptfilter(R"(R%(sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyt	stripCodeks(R*R+R,RR-tprepareNetNameQueryR(RR1t
addErrbackterrbacktaddCallbackR2R(RR$R R4R!Rtd2R;((R%sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pytqueryIPForNamePs
	
 cCstj|�dS(N(RtstopProtocol(R((sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyRBsscsltj��t�fd��jj��}�fd�}t||��jrhtjd�j�ndS(Ncs|\}\}}}|�kS(N((t.0R!texpiry_timeR3R%(tnow(sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyR7zscsD|\}\}}}�j|=y|jt|��WnnXdS(N(RR>R(titemR!RDR3R%(R(sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pytexpire_item}s
i(	R2R:Rt	iteritemsR9R
RRR(RtexpiredRG((RERsH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyRvs!
	(
RRtloggingt	getLoggerR/R,RR&R(R5RARBR(((sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyR	s		#	(tosRJR*RR2ttwisted.internetRRttwisted.internet.protocolRt
nmb_constantsRtbaseRtrangetIP_QUERYRt	ExceptionRR	(((sH/opt/plesk/python/2.7/lib/python2.7/site-packages/nmb/NetBIOSProtocol.pyt<module>s<

Zerion Mini Shell 1.0