
    \d                         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dS )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                   n    e Zd ZdZg dg dgZg dgZ ej        d ej        d          i          Z	dS )	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     7lib/python3.11/site-packages/twisted/runner/inetdtap.pyr   r      sm        	 	 	IHHFFFM
 CBBCH u V5HU5H5R5R,STTTHHHr   r   c                    t          j                    }t          j                    }t	          | d                   5 }|                    |           d d d            n# 1 swxY w Y   |j        D ]a}|j        }|j                            d          rt          j
        d           9||j        fdvr%t          j
        d|j        d|j                   i	 t          |j                  |_        nc# t          $ rV 	 t          j        |j                  d         |_        n-# t"          $ r  t          j
        d|j        z              Y Y w xY wY nw xY w|j        %t          j        |j                  d	         |_        n	 t          |j                  |_        nd# t          $ rW 	 t)          j        |j                  d         |_        n.# t"          $ r! t          j
        d
|j        z              Y Y w xY wY nw xY w|j        dk    rf| d         r|j        t0          j        vrt          j
        d|j        z              t5                      }t0          j        |j                 |_        nt1          j        |          }|dk    r/t9          j        |j        |                              |           L|dk    rtA          d          c|S )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 65#&&v.. 	GEFFFg()1VVVGG%%%w'7'79   	w|,,GLL 	 	 	"|GL99!<   (7<7888 	 = L66q9GMM #GM 2 2   $'L$?$?$BGMM   G-=>>>HH "M ?j((l#  |5#:::4w|CDDD#ooG$6w|DG(11Guw|W55FFqIIII3444 Hs}   AA"%A"C44
E?$D$#E$&E
EEEEF
G?)$GG?&G94G?8G99G?>G?)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      s   
  


 



  ? ? ? ? ? ? ? ? 3 3 3 3 3 3 % % % % % % % % + + + + + + + + )&2DEEU U U U Uem U U U,= = = = =r   