Your IP : 216.73.216.213
B
:��]�
� @ s� d Z ddlZddlZddlZddlmZmZ ddlmZm Z ddl
mZ ddlm
Z
mZ ejejd�ZG dd � d e j�Zd
d� ZdS )z�
Twisted inetd TAP support
The purpose of inetdtap is to provide an inetd-like server, to allow Twisted to
invoke other programs to handle incoming sockets.
This is a useful thing as a "networking swiss army knife" tool, like netcat.
� N)�inetd� inetdconf)�log�usage)�
ServerFactory)�internet�service)�tcp�udpc @ sJ e Zd ZdZddddgdddd ggZd
ddggZejde�d
�id�Z dS )�Optionsz�
To use it, create a file named `sample-inetd.conf` with:
8123 stream tcp wait some_user /bin/cat -
You can then run it as in the following example and port 8123 became an
echo server.
twistd -n inetd -f sample-inetd.conf
Zrpc�rz/etc/rpcz$DEPRECATED. RPC procedure table file�file�fz/etc/inetd.confzService configuration file�
nointernal�izDon't run internal servicesz*.conf)Z
optActionsN)
�__name__�
__module__�__qualname__�__doc__Z
optParametersZoptFlagsr ZCompletionsZ
CompleteFilesZcompData� r r �J/opt/alt/python37/lib64/python3.7/site-packages/twisted/runner/inetdtap.pyr s
r c C s t �� }t�� }t| d ��}|�|� W d Q R X �x�|jD �]�}|j}|j�d�r`t �
d� q<||jfdkr�t �
d|j|jf � q<yt|j
�|_
W nR tk
r� yt�|j
�d |_
W n& tk
r� t �
d|j
� w<Y nX Y nX |jd k�r
t�|j
�d |_nhyt|j�|_W nV tk
�rp yt�|j�d |_W n( tk
�rj t �
d |j � w<Y nX Y nX |jd
k�r�| d �r�q<|jtjk�r�t �
d|j � q<t� }tj|j |_n
t�|�}|d
k�r�t�|j|��|� q<|dkr<t d��q<W |S )Nr
zrpc/z/Skipping rpc service due to lack of rpc support))r �stream)r
Zdgramz)Skipping unsupported type/protocol: %s/%s� zUnknown user: � zUnknown group: Zinternalr zUnknown internal service: r r
znot supporting UDP)!�
appserviceZMultiServicer Z InetdConf�open� parseFileZservices�protocol�
startswithr �msgZ
socketType�int�user�
ValueError�pwd�getpwnam�KeyError�group�getpwuid�grp�getgrnam�program�namer ZinternalProtocolsr ZInetdFactoryr Z TCPServer�portZsetServiceParent�RuntimeError)�config�sZconfr r r �factoryr r r �makeService1 sZ
r1 )r r# r( �socketZtwisted.runnerr r Ztwisted.pythonr r Ztwisted.internet.protocolr Ztwisted.applicationr r r �IPPROTO_TCP�IPPROTO_UDPZprotocolDictr r1 r r r r �<module> s