/usr/lib/python3/dist-packages/twisted/protocols/__pycache__
Edit: /usr/lib/python3/dist-packages/twisted/protocols/__pycache__/ident.cpython-310.pyc (8711B)
o
b @ s d Z ddlZddlmZ ddlmZ ddlmZmZ dZ dZ
G dd d eZG d
d deZ
G dd
d
eZG dd deZG dd dejZG dd dZG dd dejZg dZdS )z
Ident protocol implementation.
N)defer)basic)failurelog i c @ s" e Zd ZdZdZdefddZdS )
IdentErrorz;
Can't determine connection owner; reason unknown.
z
UNKNOWN-ERRORreturnc C s | j S N)identDescriptionself r
9/usr/lib/python3/dist-packages/twisted/protocols/ident.py__str__ zIdentError.__str__N)__name__
__module____qualname____doc__r
strr r
r
r
r r s r c @ e Zd ZdZdZdS )NoUserz
The connection specified by the port pair is not currently in use or
currently not owned by an identifiable entity.
zNO-USERNr r r r r
r
r
r
r r r c @ 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.
zINVALID-PORTNr r
r
r
r r ' s r c @ r )
HiddenUserz
The server was able to identify the user of this port, but the
information was not returned at the request of the user.
zHIDDEN-USERNr r
r
r
r r 2 r r c @ s@ e Zd ZdZdd Zdd Zdd Zdd Zd
d Zdd
Z dS )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 C s | d}t|dkr| d S z tt|\}}W n ty( | Y d S w t| kr3tkrIn nt| kr?tkrIn n| || d S | t
t || d S )N, )
splitleninvalidQuerymapint
ValueError _MIN_PORT _MAX_PORT
validQuery _ebLookupr Failurer )r linepartsportOnServerportOnClientr
r
r lineReceivedH s
zIdentServer.lineReceivedc C s | j d S r ) transportloseConnectionr r
r
r r! \ s zIdentServer.invalidQueryc C sL | j j|f}| j j|f}t| j||| j|| | j
|| dS )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/ getHosthostgetPeerr
maybeDeferredlookupaddCallback _cbLookup
addErrbackr( )r r, r-
serverAddr
clientAddrr
r
r r' _ s zIdentServer.validQueryc C s" |\}}| d||||f d S )Nz%d, %d : USERID : %s : %s)sendLine)r resultsportcportsysNameuserIdr
r
r r7 m s zIdentServer._cbLookupc C sL | tr| d|||jf d S t| | d||t|jf d S )Nz%d, %d : ERROR : %s)checkr r; valuer err)r r r= r> r
r
r r( q s
zIdentServer._ebLookupc C t )aq
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
clientAddressr
r
r r5 z s zIdentServer.lookupN)
r r r r r. r! r' r7 r( r5 r
r
r
r r ; s r c @ sx e Zd ZdZdZzddlmZ efddZ[W n ey% dddZY nw d d
Z dd Z
d
d Zdd Zdd Z
dS )ProcServerMixinzDImplements lookup() to grab entries for responses from /proc/net/tcpLINUXr )getpwuidc C s ||d S Nr r
r uidrJ r
r
r getUsername s zProcServerMixin.getUsernameNc C rD r rE rL r
r
r rN r c c sL t d}| |D ]}| V qW d d S 1 sw Y d S )Nz
/proc/net/tcp)openreadlinestrip)r fLr
r
r entries s
"zProcServerMixin.entriesc
C s&