+
    Dfj                     
   R t ^ RIt^ RIHt ^ RIHt ^ RIHtHt ^t	Rt
 ! R R]4      t ! R R]4      t ! R	 R
]4      t ! R R]4      t ! R R]P                   4      t ! R R4      t ! R R]P                   4      t. ROtR# )z 
Ident protocol implementation.
N)defer)basic)failurelogc                   :   a  ] tR t^t o RtRtV 3R lR ltRtV tR# )
IdentErrorz3
Can't determine connection owner; reason unknown.
zUNKNOWN-ERRORc                    < V ^8  d   QhRS[ /# )   return)str)format__classdict__s   "9/usr/lib/python3/dist-packages/twisted/protocols/ident.py__annotate__IdentError.__annotate__   s     % % %    c                    V P                   # N)identDescriptionselfs   &r   __str__IdentError.__str__   s    $$$r    N)	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classdictcell__r   s   @r   r   r      s      '% %r   r   c                       ] tR t^tRtRtRtR# )NoUserzu
The connection specified by the port pair is not currently in use or
currently not owned by an identifiable entity.
zNO-USERr   Nr   r   r   r   r   r   r   r   r   r   r#   r#      s    
 !r   r#   c                       ] tR t^'tRtRtRtR# )InvalidPorta  
Either the local or foreign port was improperly specified. This should
be returned if either or both of the port ids were out of range (TCP
port numbers are from 1-65535), negative integers, reals or in any
fashion not recognized as a non-negative integer.
zINVALID-PORTr   Nr$   r   r   r   r&   r&   '   s     &r   r&   c                       ] tR t^2tRtRtRtR# )
HiddenUserzy
The server was able to identify the user of this port, but the
information was not returned at the request of the user.
zHIDDEN-USERr   Nr$   r   r   r   r(   r(   2   s    
 %r   r(   c                   H   a  ] tR t^;t o RtR tR tR tR tR t	R t
RtV tR	# )
IdentServera  
The Identification Protocol (a.k.a., "ident", a.k.a., "the Ident
Protocol") provides a means to determine the identity of a user of a
particular TCP connection. Given a TCP port number pair, it returns a
character string which identifies the owner of that connection on the
server's system.

Server authors should subclass this class and override the lookup method.
The default implementation returns an UNKNOWN-ERROR response for every
query.
c                   VP                  R 4      p\        V4      ^8w  d   V P                  4        R#  \        \        V4      w  r4\
        Tu;8:  d   \        8:  d1   M M-\
        Tu;8:  d   \        8:  d   M MV P                  W44       R# V P                  \        P                  ! \        4       4      W44       R#   \         d    T P                  4         R# i ; i),N)splitleninvalidQuerymapint	_MIN_PORT	_MAX_PORT
validQuery	_ebLookupr   Failurer&   
ValueError)r   linepartsportOnServerportOnClients   &&   r   lineReceivedIdentServer.lineReceivedH   s    

3u:?-0e_*
 ::!\>Y>OOL?NN6  $!!#$s   B> >CCc                :    V P                   P                  4        R # r   )	transportloseConnectionr   s   &r   r/   IdentServer.invalidQuery\   s    %%'r   c                H   V P                   P                  4       P                  V3pV P                   P                  4       P                  V3p\        P
                  ! V P                  W44      P                  V P                  W4      P                  V P                  W4       R# )z
Called when a valid query is received to look up and deliver the
response.

@param portOnServer: The server port from the query.
@param portOnClient: The client port from the query.
N)r?   getHosthostgetPeerr   maybeDeferredlookupaddCallback	_cbLookup
addErrbackr5   )r   r:   r;   
serverAddr
clientAddrs   &&&  r   r4   IdentServer.validQuery_   sv     ^^++-22L@
^^++-22L@
DKK@LLNNL	

*T^^\
@r   c                B    Vw  rEV P                  R W#WE3,          4       R# )z%d, %d : USERID : %s : %sN)sendLine)r   resultsportcportsysNameuserIds   &&&&  r   rI   IdentServer._cbLookupm   s!    "1U74SSTr   c                   VP                   ! \        4      '       d'   V P                  R W#VP                  3,          4       R# \        P
                  ! V4       V P                  R W#\        VP                  4      3,          4       R# )z%d, %d : ERROR : %sN)checkr   rO   valuer   err)r   r   rQ   rR   s   &&&&r   r5   IdentServer._ebLookupq   sZ    ==$$MM/52OOPGGGMM%z'--7P(QQr   c                    \        4       h)a  
Lookup user information about the specified address pair.

Return value should be a two-tuple of system name and username.
Acceptable values for the system name may be found online at::

    U{http://www.iana.org/assignments/operating-system-names}

This method may also raise any IdentError subclass (or IdentError
itself) to indicate user information will not be provided for the
given query.

A Deferred may also be returned.

@param serverAddress: A two-tuple representing the server endpoint
of the address being queried.  The first element is a string holding
a dotted-quad IP address.  The second element is an integer
representing the port.

@param clientAddress: Like I{serverAddress}, but represents the
client endpoint of the address being queried.
r   )r   serverAddressclientAddresss   &&&r   rG   IdentServer.lookupz   s    . lr   r   N)r   r   r   r   r   r<   r/   r4   rI   r5   rG   r   r    r!   s   @r   r*   r*   ;   s/     
((AU r   r*   c                      a  ] tR t^t o RtRt ^ RIHt ]3R ltAR t
R tR	 tR
 tR tRtV tR#   ]	 d	    RR lt L#i ; i)ProcServerMixinzDImplements lookup() to grab entries for responses from /proc/net/tcpLINUX)getpwuidc                     V! V4      ^ ,          # )    r   r   uidrc   s   &&&r   getUsernameProcServerMixin.getUsername   s    C=##r   Nc                    \        4       hr   r\   rf   s   &&&r   rh   ri      s
    ,r   c              #     "   \        R 4      ;_uu_ 4       pVP                  4        V F  pVP                  4       x  K  	  RRR4       R#   + '       g   i     R# ; i5i)z/proc/net/tcpN)openreadlinestrip)r   fLs   &  r   entriesProcServerMixin.entries   s>     /""aJJLggi  #"""s   A ,A
A A		A c                    R P                  \        \        \        P                  ! R\        P
                  ! R\        V^4      4      4      4      4      # ).4Bz=L)joinr0   r   structunpackpackr1   )r   hexstrs   &&r   dottedQuadFromHexString'ProcServerMixin.dottedQuadFromHexString   s9    xxV]]4T3vr?)KLM
 	
r   c                h    VP                  R 4      w  r#V P                  V4      p\        V^4      pW#3# ):)r-   r{   r1   )r   packedaddrports   &&  r   unpackAddressProcServerMixin.unpackAddress   s5    \\#&
++D14}zr   c                    VP                  4       P                  4       pV P                  V^,          4      w  r4V P                  V^,          4      w  rV\        V^,          4      pW43WV3V3#    )rn   r-   r   r1   )r   r8   r9   	localAddr	localPort
remoteAddr
remotePortrg   s   &&      r   	parseLineProcServerMixin.parseLine   sd    

""$#11%(;	!%!3!3E!H!=
%(m%
'?DDr   c                    V P                  4        FS  pV P                  V4      w  rEpWR8X  g   K  V^,          V^,          8X  g   K6  V P                  V P                  V4      3u # 	  \	        4       hr   )rq   r   SYSTEM_NAMErh   r#   )r   r]   r^   entr   r   rg   s   &&&    r   rG   ProcServerMixin.lookup   s`    <<>C)-)<&I3*y|}Q?O/O(($*:*:3*?@@ "
 hr   r   r   )r   r   r   r   r   r   pwdrc   rh   ImportErrorrq   r{   r   r   rG   r   r    r!   s   @r   ra   ra      sW     NK
 ,4 	$  

E ;  	s   1 A A ra   c                   J   a  ] tR t^t o ]]]]3tR t	R t
R tR tR tRtV tR# )IdentClientc                    . V n         R # r   queriesr   s   &r   __init__IdentClient.__init__   s	    r   c                0   V P                   P                  \        P                  ! 4       W34       \	        V P                   4      ^8  d   V P                   R,          ^ ,          # V P                  RW3,          4       V P                   R,          ^ ,          # )z;
Lookup user information about the specified address pair.
%d, %d)r   appendr   Deferredr.   rO   )r   r:   r;   s   &&&r   rG   IdentClient.lookup   so     	U^^-|JKt||q <<#A&&h,!==>||B""r   c                ~   V P                   '       g   \        P                  ! R V: 24       R# V P                   P                  ^ 4      w  p pV P	                  W!4       V P                   '       dM   V P                  RV P                   ^ ,          ^,          V P                   ^ ,          ^,          3,          4       R# R# )zUnexpected server response: r   N)r   r   msgpopparseResponserO   )r   r8   d_s   &&  r   r<   IdentClient.lineReceived   s    |||GG24(;<ll&&q)GAq!q'|||h$,,q/!*<dll1oa>P)QQR r   c                |    V P                    F$  pV^ ,          P                  \        V4      4       K&  	  . V n         R# )re   N)r   errbackr   )r   reasonqs   && r   connectionLostIdentClient.connectionLost   s,    AaDLLF+, r   c                   VP                  R ^4      p\        V4      ^8w  d   VP                  \        V4      4       R# \	        \
        P                  V4      w  rEpVR8X  d[   V P                   F.  pVP                  V8X  g   K  VP                  V! V4      4        R# 	  VP                  \        V4      4       R# VP                  WV34       R# )r~   ERRORN)
r-   r.   r   r   r0   r   rn   
errorTypesr   callback)r   deferredr8   r9   portstypeaddInfoets   &&&     r   r   IdentClient.parseResponse   s    

3"u:?Z-.#&syy%#8 Ew//B**g5 ((D2 *   D!12!!4/2r   r   N)r   r   r   r   r   r#   r&   r(   r   r   rG   r<   r   r   r   r    r!   s   @r   r   r      s2     fk:>J	#S
3 3r   r   i  )r   r#   r&   r(   r*   r   ra   )r   rw   twisted.internetr   twisted.protocolsr   twisted.pythonr   r   r2   r3   	Exceptionr   r#   r&   r(   LineOnlyReceiverr*   ra   r   __all__r   r   r   <module>r      s   
  " # '		% %!Z !&* &% %V%(( Vr/ /d,3%(( ,3^r   