
    Ϫf                         d Z ddlZddlZddlZddlmZmZ ddlm	Z	 ddl
mZmZ ddlmZmZ ej                   ej"                  dZ G d d	ej&                        Zd
 Zy)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)internetservice)ServerFactory)logusage)inetd	inetdconf)tcpudpc                   t    e Zd ZdZg dg dgZg dgZ ej                  d ej                  d      i      Z	y)	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
    )rpcrz/etc/rpcz$DEPRECATED. RPC procedure table file)filefz/etc/inetd.confzService configuration file)
nointernalizDon't run internal servicesr   z*.conf)
optActionsN)
__name__
__module____qualname____doc__optParametersoptFlagsr   CompletionsCompleteFilescompData     9/usr/lib/python3/dist-packages/twisted/runner/inetdtap.pyr   r      sG    	 	IFM
 CCH u  V5HU5H5H5R,STHr   r   c                     t        j                         }t        j                         }t	        | d         5 }|j                  |       d d d        |j                  D ]  }|j                  }|j                  j                  d      rt        j                  d       A||j                  fdvr0t        j                  d|j                  d|j                         	 t        |j                        |_        |j$                  (t        j&                  |j                        d	   |_        n	 t        |j$                        |_        |j,                  dk(  rt| d   r|j.                  t0        j2                  vr$t        j                  d|j.                  z          At5               }t0        j2                  |j.                     |_        nt1        j6                  |      }|dk(  r1t9        j:                  |j<                  |      j?                  |       |dk(  stA        d       |S # 1 sw Y   xY w# t        $ r` 	 t        j                   |j                        d   |_        n3# t"        $ r' t        j                  d|j                  z          Y Y <w xY wY w xY w# t        $ r` 	 t)        j*                  |j$                        d   |_        n3# t"        $ r' t        j                  d
|j$                  z          Y Y w xY wY w xY w)Nr   zrpc/z/Skipping rpc service due to lack of rpc support))r
   stream)r   dgramz$Skipping unsupported type/protocol: /   zUnknown user:    zUnknown group: internalr   zUnknown internal service: r
   r   znot supporting UDP)!
appserviceMultiServicer	   	InetdConfopen	parseFileservicesprotocol
startswithr   msg
socketTypeintuser
ValueErrorpwdgetpwnamKeyErrorgroupgetpwuidgrpgetgrnamprogramnamer   internalProtocolsr   InetdFactoryr   	TCPServerportsetServiceParentRuntimeError)configsconfr   r   r.   factorys          r    makeServicerH   0   s   !A D	fVn	 q == 65##&&v.GGEFg(()1VVGG%%w'7'79 	w||,GL == LL6q9GM #GMM 2 ??j(l# ||5#:#::4w||CD#oG$66w||DG((1Guw||W5FFqI344m65n Hu (  	"||GLL9!< (7<<78 	  $'LL$?$BGM GG-=> "sw   H+H8.J$+H58	J!'I*)J!*+JJ!JJ! J!$	L.'KL+LLLLL)r   r:   r5   sockettwisted.applicationr   r   r(   twisted.internet.protocolr   twisted.pythonr   r   twisted.runnerr   r	   IPPROTO_TCPIPPROTO_UDPprotocolDictr   rH   r   r   r    <module>rQ      sP   
  
  ? 3 % + ))&2D2DEUemm U,=r   