
    h                         S r SSKrSSKrSSKrSSKJrJr  SSKJ	r	  SSK
JrJr  SSKJrJr  \R                   \R"                  S.r " S S	\R&                  5      rS
 rg)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                   v    \ rS rSrSr/ SQ/ SQ/r/ SQ/r\R                  " S\R                  " S5      0S9r
S	rg
)Options   z
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)
optActions N)__name__
__module____qualname____firstlineno____doc__optParametersoptFlagsr   CompletionsCompleteFilescompData__static_attributes__r       ^/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/runner/inetdtap.pyr   r      sB    	 	IFM
 CCH  VU5H5H5R,STHr"   r   c                 ~   [         R                  " 5       n[        R                  " 5       n[	        U S   5       nUR                  U5        S S S 5        UR                   GH  nUR                  nUR                  R                  S5      (       a  [        R                  " S5        MH  XTR                  4S;  a4  [        R                  " SUR                  < SUR                  < 35        M   [        UR                  5      Ul        UR$                  c)  [        R&                  " UR                  5      S	   Ul        O [        UR$                  5      Ul        UR,                  S:X  a~  U S   (       a  GM  UR.                  [0        R2                  ;  a&  [        R                  " SUR.                  -   5        GMZ  [5        5       n[0        R2                  UR.                     Ul        O[0        R6                  " U5      nUS:X  a3  [8        R:                  " UR<                  U5      R?                  U5        GM  US:X  d  GM  [A        S5      e   U$ ! , (       d  f       GN	= f! [         ac     [        R                   " UR                  5      S   Ul         GN! ["         a)    [        R                  " SUR                  -   5          GMh  f = ff = f! [         ac     [(        R*                  " UR$                  5      S   Ul         GN! ["         a)    [        R                  " S
UR$                  -   5          GM  f = ff = f)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   r1   factorys          r#   makeServicerK   0   su   !A D	fVn	q 
 ==##&&v..GGEF(()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 !n Hu 
	(  	"||GLL9!< (7<<78	  $'LL$?$BGM GG-=>s_   I-I>K
I
K*(J-KKKK
L<(L-L82L<7L88L<)r   r=   r8   sockettwisted.applicationr   r   r+   twisted.internet.protocolr   twisted.pythonr   r   twisted.runnerr   r	   IPPROTO_TCPIPPROTO_UDPprotocolDictr   rK   r   r"   r#   <module>rT      sP   
  
  ? 3 % + ))&2D2DEUemm U,=r"   