§
    Ètº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m	Z	 ddl
mZmZmZmZ ddlmZ ddlmZmZmZmZmZmZmZmZ  G d„ d	ej        ¦  «        Zd
„ Z G d„ dej        ¦  «        Zd„ ZdS )z9
Support for creating a service which runs a web server.
é    N)ÚserviceÚstrports)Ú
interfacesÚreactor)Ú	deprecateÚreflectÚ
threadpoolÚusage)Úpb)ÚdemoÚdistribÚresourceÚscriptÚserverÚstaticÚtwcgiÚwsgic                   ó€  — e Zd ZdZdZg d¢g d¢g d¢gZg d¢g d¢gZe                     dd	d
ej	        j
        ›d�dz   g¦  «          ej         ej        d¦  «         ej        d¦  «         ej        d¦  «        dœ¬¦  «        ZdZd„ Zd„ ZeZd„ Zd„ Zd„ ZeZd„ ZeZd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZeZd„ Z d„ Z!d „ Z"d!„ Z#d"S )#ÚOptionszB
    Define the options accepted by the I{twistd web} plugin.
    z[web options])ÚlogfileÚlNz/Path to web CLF (Combined Log Format) log file.)ÚcertificateÚcú
server.pemz=(DEPRECATED: use --listen) SSL certificate to use for HTTPS. )ÚprivkeyÚkr   z<(DEPRECATED: use --listen) SSL certificate to use for HTTPS.)ÚnotracebacksÚnzY(DEPRECATED: Tracebacks are disabled by default. See --enable-tracebacks to turn them on.)údisplay-tracebacksÚ z�Show uncaught exceptions during rendering tracebacks to the client. WARNING: This may be a security risk and expose private data!Úpersonalr    zsInstead of generating a webserver, generate a ResourcePublisher which listens on  the port given by --listen, or ~/ú zif --listen is not specified.z*.logz*.pem)r   r   r   )Ú
optActionsz‡This starts a webserver.  If you specify no arguments, it will be a
demo webserver that has the Test class from twisted.web.demo in it.c                 ó€   — t           j                             | ¦  «         g | d<   d | d<   g | d<   g | d<   d x| d<   | d<   d S )NÚindexesÚrootÚextraHeadersÚportsÚportÚhttps)r
   r   Ú__init__©Úselfs    úN/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/web/tap.pyr+   zOptions.__init__X   sS   € ÝŒ×Ò˜tÑ$Ô$Ð$ØˆˆY‰ØˆˆV‰Ø!ˆˆ^ÑØˆˆW‰Ø'+Ð+ˆˆV‰�t˜G‘}�}�}ó    c           	      ó¦   — t          j        | j        t          j        dddd¦  «        ¦  «        }t          j        |t          d¬¦  «         || d<   dS )	zh
        (DEPRECATED: use --listen)
        Strports description of port to start the server on
        ÚTwistedé   é   r   é   ©ÚcategoryÚ
stacklevelr)   N)r   ÚgetDeprecationWarningStringÚopt_portÚincrementalÚVersionÚwarningsÚwarnÚDeprecationWarning©r-   r)   Úmsgs      r.   r9   zOptions.opt_port`   sU   € õ
 Ô3ØŒM�;Ô.¨y¸"¸aÀÑCÔCñ
ô 
ˆõ 	Œ�cÕ$6À1ÐEÑEÔEÐEØˆˆV‰ˆˆr/   c           	      ó¦   — t          j        | j        t          j        dddd¦  «        ¦  «        }t          j        |t          d¬¦  «         || d<   dS )	zW
        (DEPRECATED: use --listen)
        Port to listen on for Secure HTTP.
        r1   r2   r3   r   r4   r5   r*   N)r   r8   Ú	opt_httpsr:   r;   r<   r=   r>   r?   s      r.   rB   zOptions.opt_httpsm   sU   € õ
 Ô3ØŒN�KÔ/°	¸2¸qÀ!ÑDÔDñ
ô 
ˆõ 	Œ�cÕ$6À1ÐEÑEÔEÐEØˆˆW‰ˆˆr/   c                 ó<   — | d                               |¦  «         dS )zi
        Add an strports description of port to start the server on.
        [default: tcp:8080]
        r(   N©Úappend)r-   r)   s     r.   Ú
opt_listenzOptions.opt_listenx   s"   € ð
 	ˆWŒ×Ò˜TÑ"Ô"Ð"Ð"Ð"r/   c                 ó<   — | d                               |¦  «         dS )zr
        Add the name of a file used to check for directory indexes.
        [default: index, index.html]
        r%   NrD   )r-   Ú	indexNames     r.   Ú	opt_indexzOptions.opt_index   s"   € ð
 	ˆYŒ×Ò˜yÑ)Ô)Ð)Ð)Ð)r/   c                 ó2   — t          j        ¦   «         | d<   dS )zc
        Makes a server with ~/public_html and ~/.twistd-web-pb support for
        users.
        r&   N)r   ÚUserDirectoryr,   s    r.   Úopt_userzOptions.opt_userˆ   s   € õ
 Ô,Ñ.Ô.ˆˆV‰ˆˆr/   c                 óê   — t          j        t          j                             |¦  «        ¦  «        | d<   t
          j        t
          j        dœ| d         _        t          j
        | d         j        d<   dS )zö
        <path> is either a specific file or a directory to be set as the root
        of the web server. Use this if you have a directory full of HTML, cgi,
        epy, or rpy files or any other files that you want to be served up raw.
        r&   )z.epyz.rpyz.cgiN)r   ÚFileÚosÚpathÚabspathr   ÚPythonScriptÚResourceScriptÚ
processorsr   Ú	CGIScript)r-   rP   s     r.   Úopt_pathzOptions.opt_path‘   s_   € õ ”{¥2¤7§?¢?°4Ñ#8Ô#8Ñ9Ô9ˆˆV‰åÔ'ÝÔ)ð#
ð #
ˆˆVŒÔõ +0¬/ˆˆVŒÔ Ñ'Ð'Ð'r/   c                 óä   — t          | d         t          j        ¦  «        st          j        d¦  «        ‚|                     dd¦  «        \  }}t          j        |¦  «        | d         j        |<   dS )zh
        `ext=class' where `class' is added as a Processor for files ending
        with `ext'.
        r&   z*You can only use --processor after --path.ú=é   N)	Ú
isinstancer   rN   r
   Ú
UsageErrorÚsplitr   Ú
namedClassrT   )r-   ÚprocÚextÚklasss       r.   Úopt_processorzOptions.opt_processorž   sh   € õ
 ˜$˜vœ,­¬Ñ4Ô4ð 	QÝÔ"Ð#OÑPÔPÐPØ—Z’Z  QÑ'Ô'‰
ˆˆUÝ'.Ô'9¸%Ñ'@Ô'@ˆˆVŒÔ Ñ$Ð$Ð$r/   c                 óH   — t          j        |¦  «        } |¦   «         | d<   dS )zN
        Create a Resource subclass with a zero-argument constructor.
        r&   N)r   r]   )r-   Ú	classNameÚclassObjs      r.   Ú	opt_classzOptions.opt_class¨   s'   € õ Ô% iÑ0Ô0ˆØ�x‘z”zˆˆV‰ˆˆr/   c                 ó4   — t          j        |¦  «        | d<   dS )zP
        An .rpy file to be used as the root resource of the webserver.
        r&   N)r   ÚResourceScriptWrapper)r-   Únames     r.   Úopt_resource_scriptzOptions.opt_resource_script¯   s   € õ Ô3°DÑ9Ô9ˆˆV‰ˆˆr/   c                 óT  — 	 t          j        |¦  «        }n,# t          t          f$ r t	          j        d|›�¦  «        ‚w xY wt          j        ¦   «         }t          j	        |j
        ¦  «         t          j        dd|j        ¦  «         t          j        t          ||¦  «        | d<   dS )zo
        The FQPN of a WSGI application object to serve as the root resource of
        the webserver.
        zNo such WSGI application: ÚafterÚshutdownr&   N)r   ÚnamedAnyÚAttributeErrorÚ
ValueErrorr
   r[   r	   Ú
ThreadPoolr   ÚcallWhenRunningÚstartÚaddSystemEventTriggerÚstopr   ÚWSGIResource)r-   rh   ÚapplicationÚpools       r.   Úopt_wsgizOptions.opt_wsgiµ   s¬   € ð
	JÝ!Ô*¨4Ñ0Ô0ˆKˆKøÝ¥
Ð+ð 	Jð 	Jð 	JÝÔ"Ð#HÀÐ#HÐ#HÑIÔIÐIð	JøøøåÔ$Ñ&Ô&ˆÝÔ ¤
Ñ+Ô+Ð+ÝÔ% g¨z¸4¼9ÑEÔEÐEÝÔ(­°$¸ÑDÔDˆˆV‰ˆˆs	   ‚ —)A c                 óˆ   — t          | d         t          j        ¦  «        st          j        d¦  «        ‚|| d         _        dS )zA
        Specify the default mime-type for static files.
        r&   z*You can only use --mime_type after --path.N)rZ   r   rN   r
   r[   ÚdefaultType)r-   rz   s     r.   Úopt_mime_typezOptions.opt_mime_typeÃ   sA   € õ ˜$˜vœ,­¬Ñ4Ô4ð 	QÝÔ"Ð#OÑPÔPÐPØ#.ˆˆVŒÔ Ð Ð r/   c                 ó¤   — t          | d         t          j        ¦  «        st          j        d¦  «        ‚| d                              d¦  «         dS )zT
        Specify whether or not a request for 'foo' should return 'foo.ext'
        r&   z1You can only use --allow_ignore_ext after --path.Ú*N©rZ   r   rN   r
   r[   Ú	ignoreExtr,   s    r.   Úopt_allow_ignore_extzOptions.opt_allow_ignore_extÍ   sT   € õ ˜$˜vœ,­¬Ñ4Ô4ð 	ÝÔ"ØFñô ð ð 	ˆVŒ×Ò˜sÑ#Ô#Ð#Ð#Ð#r/   c                 ó¤   — t          | d         t          j        ¦  «        st          j        d¦  «        ‚| d                              |¦  «         dS )zT
        Specify an extension to ignore.  These will be processed in order.
        r&   z+You can only use --ignore_ext after --path.Nr~   )r-   r_   s     r.   Úopt_ignore_extzOptions.opt_ignore_ext×   sM   € õ ˜$˜vœ,­¬Ñ4Ô4ð 	UÝÔ"Ð#SÑTÔTÐTØˆVŒ×Ò˜sÑ#Ô#Ð#Ð#Ð#r/   c                 óº   — |                      dd¦  «        \  }}| d                              |                     ¦   «         |                     ¦   «         f¦  «         dS )z
        Specify an additional header to be included in all responses. Specified
        as "HeaderName: HeaderValue".
        ú:rY   r'   N)r\   rE   Ústrip)r-   Úheaderrh   Úvalues       r.   Úopt_add_headerzOptions.opt_add_headerß   sO   € ð
 —l’l 3¨Ñ*Ô*‰ˆˆeØˆ^Ô×#Ò# T§Z¢Z¡\¤\°5·;²;±=´=Ð$AÑBÔBÐBÐBÐBr/   c                 ó´  — | d         �!| d                               | d         ¦  «         | d         �|	 t          j        d¦  «         n"# t          $ r t	          j        d¦  «        ‚w xY wd                     | d         | d         | d	         ¦  «        }| d                               |¦  «         t          | d         ¦  «        d
k    r‘| d         rlt          j	         
                    t          j	                             dt          j        j        ¦  «        ¦  «        }| d                               d|z   ¦  «         dS | d                               d¦  «         dS dS )a@  
        Set up conditional defaults and check for dependencies.

        If SSL is not available but an HTTPS server was configured, raise a
        L{UsageError} indicating that this is not possible.

        If no server port was supplied, select a default appropriate for the
        other options supplied.
        r)   Nr(   r*   zOpenSSL.SSLzSSL support not installedz$ssl:port={}:privateKey={}:certKey={}r   r   r   r!   ú~zunix:ztcp:8080)rE   r   ÚnamedModuleÚImportErrorr
   r[   ÚformatÚlenrO   rP   Ú
expanduserÚjoinr   rK   ÚuserSocketName)r-   Ú
sslStrportrP   s      r.   ÚpostOptionszOptions.postOptionsç   sb  € ð �Œ<Ð#Ø�ŒM× Ò   f¤Ñ.Ô.Ð.Ø�Œ=Ð$ðDÝÔ# MÑ2Ô2Ð2Ð2øÝð Dð Dð DÝÔ&Ð'BÑCÔCÐCðDøøøà?×FÒFØ�W”Ø�Y”Ø�]Ô#ñô ˆJð
 �ŒM× Ò  Ñ,Ô,Ð,Ýˆt�GŒ}ÑÔ Ò"Ð"Ø�JÔð 1Ý”w×)Ò)Ý”G—L’L ¥gÔ&;Ô&JÑKÔKñô �ð �W”×$Ò$ W¨t¡^Ñ4Ô4Ð4Ð4Ð4à�W”×$Ò$ ZÑ0Ô0Ð0Ð0Ð0ð #Ð"s   ³A ÁA'N)$Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚsynopsisÚoptParametersÚoptFlagsrE   r   rK   r‘   r
   ÚCompletionsÚCompleteFilesÚcompDataÚlongdescr+   r9   Úopt_prB   rF   rI   Úopt_irL   Úopt_urV   ra   re   ri   rx   r{   Úopt_mr€   r‚   rˆ   r“   © r/   r.   r   r      s3  € € € € € ðð ð €Hð 	RÐQÐQð	
ð 	
ð 	
ð	
ð 	
ð 	
ð€Mð"	
ð 	
ð 	
ð	
ð 	
ð 	
ð€Hð( ‡O‚OàØˆBð %,Ô$9Ô$HÐ$HÐ$HðKð .ñ.ð	
ñ	ô 	ð 	ð !ˆuÔ à*�uÔ*¨7Ñ3Ô3Ø.˜5Ô.¨wÑ7Ô7Ø*�uÔ*¨7Ñ3Ô3ð
ð 
ðñ ô €HðG€Hð,ð ,ð ,ð	ð 	ð 	ð €Eð	ð 	ð 	ð#ð #ð #ð*ð *ð *ð €Eð/ð /ð /ð €Eð:ð :ð :ðAð Að Að"ð "ð "ð:ð :ð :ðEð Eð Eð/ð /ð /ð €Eð$ð $ð $ð$ð $ð $ðCð Cð Cð1ð 1ð 1ð 1ð 1r/   r   c                 óN   — t          j        t          j        | ¦  «        ¦  «        S )zÈ
    Create and return a factory which will respond to I{distrib} requests
    against the given site.

    @type site: L{twisted.web.server.Site}
    @rtype: L{twisted.internet.protocol.Factory}
    )r   ÚPBServerFactoryr   ÚResourcePublisher)Úsites    r.   ÚmakePersonalServerFactoryr¨     s    € õ Ô�gÔ7¸Ñ=Ô=Ñ>Ô>Ð>r/   c                   ó   — e Zd Zd„ Zd„ ZdS )Ú_AddHeadersResourcec                 ó"   — || _         || _        d S ©N)Ú_originalResourceÚ_headers)r-   ÚoriginalResourceÚheaderss      r.   r+   z_AddHeadersResource.__init__  s   € Ø!1ˆÔØˆŒˆˆr/   c                 óˆ   — | j         D ] \  }}|j                             ||¦  «         Œ!| j                             ||¦  «        S r¬   )r®   ÚresponseHeadersÚaddRawHeaderr­   ÚgetChildWithDefault)r-   rh   Úrequestr   Úvs        r.   r´   z'_AddHeadersResource.getChildWithDefault  sL   € Ø”Mð 	7ð 	7‰DˆAˆqØÔ#×0Ò0°°AÑ6Ô6Ð6Ð6ØÔ%×9Ò9¸$ÀÑHÔHÐHr/   N)r”   r•   r–   r+   r´   r£   r/   r.   rª   rª     s7   € € € € € ð ð  ð  ðIð Ið Ið Ið Ir/   rª   c           	      ó(  — t          j        ¦   «         }| d         r$| d         }| d         r| d         | d         _        nt          j        ¦   «         }t          |t          j        ¦  «        r%|j         	                    t          j        |¦  «         | d         rt          || d         ¦  «        }| d         rt          j        || d         ¬¦  «        }nt          j        |¦  «        }| d         rd|_        | d         rFt!          j        d	t%          j        d
ddd¦  «        ¦  «        }t)          j        |t,          d¬¦  «         | d         rt/          |¦  «        }| d         D ],}t1          j         ||¦  «        }|                     |¦  «         Œ-|S )Nr&   r%   r'   r   )ÚlogPathr   Tr   z--notracebacksr1   é   é   r   r4   r5   r!   r(   )r   ÚMultiServiceÚ
indexNamesr   ÚTestrZ   r   rN   ÚregistryÚsetComponentr   ÚIServiceCollectionrª   r   ÚSiteÚdisplayTracebacksr   Ú_getDeprecationWarningStringr:   r;   r<   r=   r>   r¨   r   ÚsetServiceParent)ÚconfigÚsr&   r§   r@   r)   Úsvcs          r.   ÚmakeServicerÈ     s�  € ÝÔÑÔ€AØˆf„~ð Ø�fŒ~ˆØ�)Ôð 	:Ø(.¨yÔ(9ˆF�6ŒNÔ%øõ Œy‰{Œ{ˆå�$�œÑ$Ô$ð EØŒ×"Ò"¥:Ô#@À!ÑDÔDÐDàˆnÔð AÝ" 4¨°Ô)?Ñ@Ô@ˆàˆiÔð !ÝŒ{˜4¨°	Ô):Ð;Ñ;Ô;ˆˆåŒ{˜4Ñ Ô ˆàÐ"Ô#ð &Ø!%ˆÔð ˆnÔð FÝÔ4Ø�kÔ1°)¸RÀÀAÑFÔFñ
ô 
ˆõ 	Œ�cÕ$6À1ÐEÑEÔEÐEàˆjÔð /Ý(¨Ñ.Ô.ˆØ�w”ð  ð  ˆÝÔ˜t TÑ*Ô*ˆØ×Ò˜QÑÔÐÐØ€Hr/   )r—   rO   r<   r:   Útwisted.applicationr   r   Útwisted.internetr   r   Útwisted.pythonr   r   r	   r
   Útwisted.spreadr   Útwisted.webr   r   r   r   r   r   r   r   r   r¨   ÚResourcerª   rÈ   r£   r/   r.   ú<module>rÏ      sc  ðð
ð ð
 
€	€	€	Ø €€€à Ð Ð Ð à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø Ð Ð Ð Ð Ð Ø TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ Tðo1ð o1ð o1ð o1ð o1ˆeŒmñ o1ô o1ð o1ðd?ð ?ð ?ðIð Ið Ið Ið I˜(Ô+ñ Iô Ið Ið$ð $ð $ð $ð $r/   