U
    
W[ª  ã                   @   sz   d Z ddlZddlmZmZmZ ddlmZmZ ddl	m
Z
 e
je
je
je
je
jdœZG dd„ deƒZG d	d
„ d
eƒZdS )z‰
Twisted inetd.

Maintainer: Andrew Bennetts

Future Plans: Bugfixes.  Specifically for UDP and Sun-RPC, which don't work
correctly yet.
é    N)ÚprocessÚreactorÚfdesc)ÚProtocolÚServerFactory)Úwire)ZechoZchargenÚdiscardZdaytimeÚtimec                   @   s   e Zd ZdZdd„ ZdS )ÚInetdProtocolzDForks a child process on connectionMade, passing the socket as fd 0.c                 C   s¼   | j  ¡ }||dœ}| jjr,| jj ¡ |d< t |¡ d|krLt |d ¡ | jj}|j}|j}|t	 
¡ krpd }|t	 ¡ kr€d }t d |j|jt	jd d |||¡	 t | j ¡ t | j ¡ d S )N)r   é   é   )Z	transportÚfilenoÚfactoryÚ
stderrFiler   ZsetBlockingÚserviceÚuserÚgroupÚosÚgetuidÚgetgidr   ZProcessZprogramZprogramArgsÚenvironr   ZremoveReaderZremoveWriter)ÚselfZsockFDZchildFDsr   ZuidÚgid© r   ú6/usr/lib/python3/dist-packages/twisted/runner/inetd.pyÚconnectionMade"   s.    


    ÿzInetdProtocol.connectionMadeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r
       s   r
   c                   @   s   e Zd ZeZdZdd„ ZdS )ÚInetdFactoryNc                 C   s
   || _ d S )N)r   )r   r   r   r   r   Ú__init__E   s    zInetdFactory.__init__)r   r   r   r
   Zprotocolr   r!   r   r   r   r   r    A   s   r    )r   r   Ztwisted.internetr   r   r   Ztwisted.internet.protocolr   r   Ztwisted.protocolsr   ZEchoZChargenZDiscardZDaytimeZTimeZinternalProtocolsr
   r    r   r   r   r   Ú<module>   s   	û	!