o
    r¨ÊhŠ|  ã                   @   sê  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZzd dlZW n e	y3   d dl
ZY nw d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ G dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ dejƒZ G dd„ dej!ƒZ"G dd„ dejƒZ#G dd„ de#ƒZ$G dd „ d e#ƒZ%G d!d"„ d"ƒZ&G d#d$„ d$ƒZ'G d%d&„ d&ƒZ(d'd(„ Z)G d)d*„ d*ƒZ*G d+d,„ d,ƒZ+G d-d.„ d.eƒZ,dS )/é    N)Úurllib)Úsha1)Úas_bytes)Ú	as_string)Úasyncore_25)Ú	http_date)Úhttp_server)Ú	producers)Úfilesys)Údefault_handler)Úauth_handlerc                   @   s   e Zd ZdS )ÚNOT_DONE_YETN)Ú__name__Ú
__module__Ú__qualname__© r   r   úA/var/www/html/env/lib/python3.10/site-packages/supervisor/http.pyr      s    r   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )Údeferring_chunked_producera'  A producer that implements the 'chunked' transfer coding for HTTP/1.1.
    Here is a sample usage:
            request['Transfer-Encoding'] = 'chunked'
            request.push (
                    producers.chunked_producer (your_producer)
                    )
            request.done()
    Nc                 C   s   || _ || _d| _d S ©Nçš™™™™™¹?)ÚproducerÚfootersÚdelay)Úselfr   r   r   r   r   Ú__init__)   s   
z#deferring_chunked_producer.__init__c                 C   sj   | j r3| j  ¡ }|tu rtS |r dt|ƒ }t|ƒd | d S d | _ | jr1d dg| j ¡d S dS dS )Nz%xs   
ó   0s   

s   0

ó    )r   Úmorer   Úlenr   r   Újoin)r   ÚdataÚsr   r   r   r   .   s   
zdeferring_chunked_producer.more©N©r   r   r   Ú__doc__r   r   r   r   r   r   r      s    
	r   c                   @   ó    e Zd ZdZdd„ Zdd„ ZdS )Údeferring_composite_producerz$combine a fifo of producers into onec                 C   s   || _ d| _d S r   )r	   r   )r   r	   r   r   r   r   A   s   
z%deferring_composite_producer.__init__c                 C   sJ   t | jƒr#| jd }| ¡ }|tu rtS |r|S | j d¡ t | jƒsdS )Nr   r   )r   r	   r   r   Úpop)r   ÚpÚdr   r   r   r   E   s   


ø
z!deferring_composite_producer.moreNr#   r   r   r   r   r&   ?   s    r&   c                   @   s"   e Zd ZdZddd„Zdd„ ZdS )	Údeferring_globbing_producerzÌ
    'glob' the output from a producer into a particular buffer size.
    helps reduce the number of calls to send().  [this appears to
    gain about 30% performance on requests to a single channel]
    é   c                 C   s   || _ d| _|| _d| _d S )Nr   r   )r   ÚbufferÚbuffer_sizer   )r   r   r-   r   r   r   r   Z   ó   
z$deferring_globbing_producer.__init__c                 C   s„   t | jƒ| jk r:| j ¡ }|tu rtS |r1z| j| | _W n ty0   t| jƒt|ƒ | _Y nw nt | jƒ| jk s| j}d| _|S ©Nr   )r   r,   r-   r   r   r   Ú	TypeErrorr   )r   r    Úrr   r   r   r   `   s   
ÿöz deferring_globbing_producer.moreN)r+   r#   r   r   r   r   r*   S   s    
r*   c                   @   r%   )Údeferring_hooked_producerz¨
    A producer that will call <function> when it empties,.
    with an argument of the number of bytes produced.  Useful
    for logging/instrumentation purposes.
    c                 C   s   || _ || _d| _d| _d S )Nr   r   )r   ÚfunctionÚbytesr   )r   r   r3   r   r   r   r   x   r.   z"deferring_hooked_producer.__init__c                 C   sP   | j r&| j  ¡ }|tu rtS |sd | _ |  | j¡ |S |  jt|ƒ7  _|S dS r/   )r   r   r   r3   r4   r   )r   Úresultr   r   r   r   ~   s   
ÿzdeferring_hooked_producer.moreNr#   r   r   r   r   r2   q   s    r2   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )Údeferring_http_requesta   The medusa http_request class uses the default set of producers in
    medusa.producers.  We can't use these because they don't know anything
    about deferred responses, so we override various methods here.  This was
    added to support tail -f like behavior on the logtail handler c           	      O   sN  t  t j| j¡}| ¡ }d}d}d}| jdkr*|dkr'd| vr"d}n;d| d< n6d}n3| jdkrV|d	kr6d}n'd| vrUd
| v rG| d
 dksFd}n| jrSd| d
< d}d}n
d}n| jdu r]d}t |  	¡ ¡}|rjd	| d< |rzt
t| jƒƒ}t||gƒ}n| j d|¡ t| jƒ}t|| jƒ}|r’t|ƒ}| j |¡ d| j_|r¥| j ¡  dS dS )z­ I didn't want to override this, but there's no way around
        it in order to support deferreds - CM

        finalize this transaction - send output to the http channelr   é   z1.0z
keep-alivezContent-Lengthz
Keep-AliveÚ
Connectionz1.1ÚclosezTransfer-EncodingÚchunkedN)r   Ú
get_headerÚ
CONNECTIONÚheaderÚlowerÚversionÚuse_chunkedr	   Úsimple_producerÚbuild_reply_headerr   r&   ÚoutgoingÚinsertr2   Úlogr*   ÚchannelÚpush_with_producerÚcurrent_requestÚclose_when_done)	r   ÚargÚkwÚ
connectionÚclose_itÚwrap_in_chunkingÚglobbingÚoutgoing_headerÚoutgoing_producerr   r   r   Údone“   sb   


€€
ÿÿ
ÿÿzdeferring_http_request.donec              	   C   s\   | j jr| j jd }| j jd }nd}d}| j jj |d||  t ¡ ¡| j| j|f ¡ dS )z‰ We need to override this because UNIX domain sockets return
        an empty string for the addr rather than a (host, port) combination r   r7   Ú	localhostz%d - - [%s] "%s" %d %d
N)	rF   ÚaddrÚserverÚloggerrE   Úlog_date_stringÚtimeÚrequestÚ
reply_code)r   r4   ÚhostÚportr   r   r   rE   æ   s   
ûþzdeferring_http_request.logc                 C   s´  i }ddddœ}t  ¡ }|  ¡ \}}}}|r|| }|r0|d dkr0|dd … }|r0|d dks"d|v r9t |¡}|rA|dd … }| jj}| j ¡ |d	< t	|j
ƒ|d
< |j|d< |j|d< d| j |d< | jj|d< d|d< d| |d< t j t j ||d ¡¡|d< |r‰||d< d|d< | jjrš| jjd |d< nd|d< | jD ]6}	|	 dd¡\}
}|
 ¡ }
| ¡ }|
|v rÁ|rÁ||| |
¡< q¡dd |
 d¡¡ ¡  }
|r×|
|vr×|||
< q¡|S )NÚCONTENT_LENGTHÚCONTENT_TYPEÚCONNECTION_TYPE)zcontent-lengthzcontent-typerL   r   ú/r7   ú%ÚREQUEST_METHODÚSERVER_PORTÚSERVER_NAMEÚSERVER_SOFTWAREzHTTP/ÚSERVER_PROTOCOLzchannel.creation_timeÚ ÚSCRIPT_NAMEÚ	PATH_INFOÚPATH_TRANSLATEDÚQUERY_STRINGzCGI/1.1ÚGATEWAY_INTERFACEÚREMOTE_ADDRz	127.0.0.1ú:zHTTP_%sÚ_ú-)ÚosÚgetcwdÚ	split_urir   ÚunquoterF   rU   ÚcommandÚupperÚstrr\   Úserver_nameÚSERVER_IDENTr?   Úcreation_timeÚpathÚnormpathr   rT   r=   Úsplitr>   ÚstripÚget)r   ÚenvÚ
header2envÚworkdirr{   ÚparamsÚqueryÚfragmentrU   r=   ÚkeyÚvaluer   r   r   Úcgi_environmentú   sZ   þÿ



ÿ
€z&deferring_http_request.cgi_environmentc                 C   sÂ   dddœ}|   ¡ }| d¡dv s| d¡dkrd}nd	}d
|v r.|d
  ¡ }t |¡\}}n
|d  ¡ }|d }|du sB|| |krE|}n|d | }d||f }|dd… dkr_|dd… }|S )z• Functionality that medusa's http request doesn't have; set an
        attribute named 'server_url' on the request based on the Host: header
        Ú80Ú443)ÚhttpÚhttpsÚHTTPS)ÚonÚONÚSERVER_PORT_SECUREÚ1rŒ   r‹   Ú	HTTP_HOSTrd   rc   Nrn   z%s://%séÿÿÿÿr`   )rˆ   r   r~   r   Ú	splitport)r   Údefault_portÚenvironÚprotocolr[   Úhostnamer\   Ú
server_urlr   r   r   Úget_server_url/  s$   
z%deferring_http_request.get_server_urlN)r   r   r   r$   rR   rE   rˆ   rš   r   r   r   r   r6   �   s    S5r6   c                   @   s2   e Zd ZdZdZdZd
dd„Zdd„ Zdd	„ ZdS )Údeferring_http_channeli   r   Nc                 C   sL   |d u rt   ¡ }| jr || j }|| jks|dk r|| _dS dS tj | ¡S )Nr   TF)rX   r   Úlast_writable_checkr   Úhttp_channelÚwritable)r   ÚnowÚelapsedr   r   r   rž   U  s   
zdeferring_http_channel.writablec                 C   s¨   	 t | jƒrQ| j ¡ }|du r| js| j ¡  |  ¡  dS t|tƒr0| j ¡  |  j|7  _dS | ¡ }|t	u r>|j
| _
dS |rK| j| | _d| _
dS | j ¡  ndS q)z Implement deferreds r7   NF)r   Úproducer_fifoÚfirstÚac_out_bufferr'   r9   Ú
isinstancer4   r   r   r   )r   r(   r    r   r   r   Úrefill_bufferd  s.   




äz$deferring_http_channel.refill_bufferc                 C   s¾  | j r
| j  ¡  dS t| jƒ}d| _| d¡}|r)|d s)|dd… }|r)|d r|s1|  ¡  dS |d }t |¡\}}}t |dd… ¡}t 	|¡\}}d|v rb|r]t 
|¡d | }nt 
|¡}t| |||||ƒ}	| j ¡  | jj ¡  |du r‹|  dt|ƒ d	¡ |	 d
¡ dS | jjD ]H}
|
 |	¡r×z|	| _ |
 |	¡ W  dS    | jj ¡  t ¡ \\}}}}}}| j d||||f d	¡ z
|	 d¡ W Y  dS    Y Y  dS q�|	 d¡ dS )z™ We only override this to use 'deferring_http_request' class
        instead of the normal http_request class; it sucks to need to override
        this r   z
r   r7   Nra   ú?zBad HTTP request: %sÚerroré�  z'Server Error: %s, %s: file: %s line: %siô  é”  )rH   Úfound_terminatorr   Ú	in_bufferr}   rI   r   Úcrack_requestÚjoin_headersÚ
splitqueryrt   r6   Úrequest_counterÚ	incrementrU   Útotal_requestsÚlog_infoÚreprr§   ÚhandlersÚmatchÚhandle_requestÚ
exceptionsÚasyncoreÚcompact_traceback)r   r=   ÚlinesrY   ru   Úurir?   ÚrpathÚrqueryr1   ÚhÚfileÚfunÚlineÚtÚvÚtbinfor   r   r   rª   „  sh   

û
ÿ


ôÿ
ÿýþîz'deferring_http_channel.found_terminatorr"   )	r   r   r   Úac_out_buffer_sizer   rœ   rž   r¥   rª   r   r   r   r   r›   L  s    
 r›   c                   @   s.   e Zd ZeZdZdd„ Zdd„ Zd	dd„ZdS )
Úsupervisor_http_serverNc                 C   s^   ddl m} |s| tj¡}| |¡}|| _tj | ¡ |  	|¡ g | _
| d¡ |  ¡  dS )zj Override __init__ to do logger setup earlier so it can
        go to our logger object instead of stdout r   ©rV   N)Úsupervisor.medusarV   Úfile_loggerÚsysÚstdoutÚunresolving_loggerr¸   Ú
dispatcherr   Ú
set_socketr´   ÚsetblockingÚset_reuse_addr)r   ÚsockÚlogger_objectrV   r   r   r   ÚprebindØ  s   


zsupervisor_http_server.prebindc                 C   sr   ddl m} ddlm} |  d¡ |ƒ | _|ƒ | _|ƒ | _|ƒ | _|ƒ | _	|  
d|t t ¡ ¡| j| jf ¡ d S )Nr   )Úcounter)ÚVERSION_STRINGé   z2Medusa (V%s) started at %s
	Hostname: %s
	Port:%s
)Úsupervisor.medusa.counterrÔ   Úsupervisor.medusa.http_serverrÕ   ÚlistenÚtotal_clientsr±   r·   Ú	bytes_outÚbytes_inr²   rX   Úctimerx   r\   )r   rÔ   rÕ   r   r   r   Úpostbindë  s"   
üýÿzsupervisor_http_server.postbindÚinfoc                 C   s,   d}t | dd ƒd ur| j}| j ||¡ d S )Nrg   Úip)Úgetattrrà   rV   rE   )r   ÚmessageÚtyperà   r   r   r   r²     s   zsupervisor_http_server.log_info)rß   )	r   r   r   r›   Úchannel_classrà   rÓ   rÞ   r²   r   r   r   r   rÆ   Ô  s    rÆ   c                   @   s   e Zd ZdZdd„ ZdS )Úsupervisor_af_inet_http_serverz+ AF_INET version of supervisor HTTP server c                 C   sÂ   || _ || _t tjtj¡}|  ||¡ |  ||f¡ |s=|  dd¡ t ¡ }zt 	|¡}W n tj
y<   td| ƒ‚w z
t |¡d | _W n tj
yZ   |  dd¡ || _Y nw |  ¡  d S )NzComputing default hostnameÚwarningzØCould not determine IP address for hostname %s, please try setting an explicit IP address in the "port" setting of your [inet_http_server] section.  For example, instead of "port = 9001", try "port = 127.0.0.1:9001."r   zCannot do reverse lookup)rà   r\   ÚsocketÚAF_INETÚSOCK_STREAMrÓ   Úbindr²   ÚgethostnameÚgethostbynamer§   Ú
ValueErrorÚgethostbyaddrrx   rÞ   )r   rà   r\   rÒ   rÑ   r˜   r   r   r   r     s0   üÿÿ
þz'supervisor_af_inet_http_server.__init__N)r   r   r   r$   r   r   r   r   r   rå   	  s    rå   c                   @   r%   )Úsupervisor_af_unix_http_serverz+ AF_UNIX version of supervisor HTTP server c           
      C   sØ  || _ || _d|t ¡ f }zt |¡ W n	 ty   Y nw 	 t tjtj¡}z©| 	|¡ t 
||¡ zt ||¡ W nF ty‚   |  |¡}|rPt tj¡‚d| }tj |¡ zt |¡ W n   Y | ¡  t d¡ Y W zt |¡ W q ty�   Y qw w zt ||d |d ¡ W n) ty¹ }	 z|	jd tjkr´d}t||t|ƒt t ¡ ¡d f ƒ‚‚ d }	~	ww |  ||¡ W zt |¡ W n tyÑ   Y nw zt |¡ W w  tyâ   Y w w d| _|   ¡  d S )Nz%s.%dr7   zUnlinking stale socket %s
g333333Ó?r   zŸNot permitted to chown %s to uid/gid %s; adjust "sockchown" value in config file or on command line to values that the current user (%s) can successfully chownz<unix domain socket>)!rà   r\   rq   ÚgetpidÚunlinkÚOSErrorrç   ÚAF_UNIXré   rê   ÚchmodÚlinkÚ	checkusedr§   ÚerrnoÚ
EADDRINUSErÊ   ÚstderrÚwriter9   rX   ÚsleepÚchownÚargsÚEPERMrí   r³   ÚpwdÚgetpwuidÚgeteuidrÓ   rx   rÞ   )
r   Ú
socketnameÚ	sockchmodÚ	sockchownrÒ   ÚtempnamerÑ   ÚusedÚmsgÚwhyr   r   r   r   *  s€   ÿ


ÿØÿÿþ€óÿþÿz'supervisor_af_unix_http_server.__init__c                 C   sX   t   t jt j¡}z| |¡ | tdƒ¡ | d¡ | ¡  W dS  t jy+   Y dS w )NzGET / HTTP/1.0

r7   FT)	rç   ró   ré   ÚconnectÚsendr   Úrecvr9   r§   )r   r  r!   r   r   r   rö   q  s   


ýÿz(supervisor_af_unix_http_server.checkusedN)r   r   r   r$   r   rö   r   r   r   r   rï   '  s    Grï   c                   @   sD   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )Útail_f_producerc                 C   sB   t  |¡| _|| _d| _|  ¡  |  ¡ }||kr|| | _d S d S r   )ÚweakrefÚrefrY   Úfilenamer   Ú_openÚ_fsizeÚsz)r   rY   r  Úheadr  r   r   r   r   ~  s   ÿztail_f_producer.__init__c                 C   s   |   ¡  d S r"   )Ú_close©r   r   r   r   Ú__del__ˆ  s   ztail_f_producer.__del__c              	   C   s|   |   ¡  z|  ¡ }W n ttfy   Y dS w || j }|dk r%d| _dS |dkr<| j | d¡ | j |¡}|| _|S tS )Nr   r   z==> File truncated <==
é   )	Ú_followr  rò   rí   r  r¿   ÚseekÚreadr   )r   ÚnewszÚbytes_addedr4   r   r   r   r   ‹  s    þ
ztail_f_producer.morec                 C   s0   t | jdƒ| _t | j ¡ ¡tj | _d| _	d S )NÚrbr   )
Úopenr  r¿   rq   ÚfstatÚfilenoÚstatÚST_INOÚinor  r  r   r   r   r  �  s   
ztail_f_producer._openc                 C   s   | j  ¡  d S r"   )r¿   r9   r  r   r   r   r  ¢  ó   ztail_f_producer._closec              	   C   sR   zt  | j¡tj }W n ttfy   Y d S w | j|kr'|  ¡  |  ¡  d S d S r"   )	rq   r!  r  r"  rò   rí   r#  r  r  )r   r#  r   r   r   r  ¥  s   þ
þztail_f_producer._followc                 C   s   t  | j ¡ ¡tj S r"   )rq   r  r¿   r   r!  ÚST_SIZEr  r   r   r   r  °  s   ztail_f_producer._fsizeN)
r   r   r   r   r  r   r  r  r  r  r   r   r   r   r  }  s    
r  c                   @   ó,   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	S )
Úlogtail_handlerzLogtail HTTP Request Handlerz/logtailc                 C   ó
   || _ d S r"   ©Úsupervisord©r   r*  r   r   r   r   ·  ó   
zlogtail_handler.__init__c                 C   ó   |j  | j¡S r"   ©r»   Ú
startswithr{   ©r   rY   r   r   r   rµ   º  r$  zlogtail_handler.matchc                 C   s„  |j dkr| d¡ d S | ¡ \}}}}d|v rt |¡}|r3|d dkr3|dd … }|r3|d dks%| dd¡\}}z
| dd¡\}}W n tyR   |}d}Y nw ddlm}	 |	|ƒ\}
}| j	j
 |
¡}|d u rq| d	¡ d S |j |¡}|d u r‚| d	¡ d S t|jd
| d ƒ}|d u s•tj |¡sœ| d	¡ d S t |¡tj }t |¡|d< d|d< d|d< | t||dƒ¡ | ¡  d S )NÚGETr¨   ra   r   r`   r7   rË   )Úsplit_namespecr©   z
%s_logfileúLast-Modifiedútext/plain;charset=utf-8úContent-TypeÚnozX-Accel-BufferingrÖ   )ru   r§   rs   r   rt   r}   rí   Úsupervisor.optionsr2  r*  Úprocess_groupsr   Ú	processesrá   Úconfigrq   r{   Úexistsr!  ÚST_MTIMEr   Úbuild_http_dateÚpushr  rR   )r   rY   r{   rƒ   r„   r…   Úprocess_name_and_channelÚprocess_namerF   r2  Ú
group_nameÚgroupÚprocessÚlogfileÚmtimer   r   r   r¶   ½  sH   


ÿý


zlogtail_handler.handle_requestN©r   r   r   ÚIDENTr{   r   rµ   r¶   r   r   r   r   r'  ³  ó    r'  c                   @   r&  )
Úmainlogtail_handlerz!Main Logtail HTTP Request Handlerz/mainlogtailc                 C   r(  r"   r)  r+  r   r   r   r   ü  r,  zmainlogtail_handler.__init__c                 C   r-  r"   r.  r0  r   r   r   rµ   ÿ  r$  zmainlogtail_handler.matchc                 C   sˆ   |j dkr| d¡ d S | jjj}|d u stj |¡s"| d¡ d S t |¡tj	 }t
 |¡|d< d|d< | t||dƒ¡ | ¡  d S )Nr1  r¨   r©   r3  r4  r5  rÖ   )ru   r§   r*  ÚoptionsrD  rq   r{   r;  r!  r<  r   r=  r>  r  rR   )r   rY   rD  rE  r   r   r   r¶     s   



z"mainlogtail_handler.handle_requestNrF  r   r   r   r   rI  ø  rH  rI  c                  C   s6  g }t | jƒ}| jD �]}|d }|tjkr'|d |d }}t|||d�}n |tjkrA|d }	|d }
|d }t|	|
||d�}ntd| ƒ‚d	d
l	m
} d	dl	m} d	dlm} g }| jD ]2\}}}z
||fi |¤Ž}W n   t ¡ }| j |¡ td| ƒ‚| ||f¡ | j d| ¡ q^| d||ƒf¡ |||ƒ}t|ƒ}t|ƒ}||ƒ}tj tj t¡¡}tj |d¡}t |¡}t |¡}|d }|d }|rî||i}t||ƒ}t||ƒ}t||ƒ}t||ƒ}t||ƒ}n
| j  d|d  ¡ | !|¡ | !|¡ | !|¡ | !|¡ | !|¡ | ||f¡ q
|S )NÚfamilyr[   r\   )rÒ   r¿   rô   rü   zCannot determine socket type %rr   )Úsupervisor_xmlrpc_handler)ÚSystemNamespaceRPCInterface)Úsupervisor_ui_handlerzCould not make %s rpc interfacezRPC interface %r initializedÚsystemÚuiÚusernameÚpasswordz:Server %r running without any HTTP authentication checkingÚsection)"Ú
LogWrapperrV   Úserver_configsrç   rè   rå   ró   rï   rí   Úsupervisor.xmlrpcrL  rM  Úsupervisor.webrN  Úrpcinterface_factoriesÚ	tracebackÚ
format_excÚwarnÚappendrß   r'  rI  rq   r{   ÚabspathÚdirnameÚ__file__r   r
   Úos_filesystemr   Úsupervisor_auth_handlerÚcriticalÚinstall_handler) rJ  r*  ÚserversÚwrapperr:  rK  r[   r\   Úhsr  r  r  rL  rM  rN  ÚsubinterfacesÚnameÚfactoryr)   ÚinstÚtbÚxmlrpchandlerÚtailhandlerÚmaintailhandlerÚ	uihandlerÚhereÚtemplatedirÚ
filesystemÚdefaulthandlerrQ  rR  Úusersr   r   r   Úmake_http_servers  s|   

ÿ
ÿÿ






ÿÿ




ru  c                   @   r%   )rT  z\Receives log messages from the Medusa servers and forwards
    them to the Supervisor loggerc                 C   r(  r"   rÇ   )r   rV   r   r   r   r   f  r,  zLogWrapper.__init__c                 C   sB   |  d¡r|dd… }d| ¡ v r| j |¡ dS | j |¡ dS )z¼Medusa servers call this method.  There is no log level so
        we have to sniff the message.  We want "Server Error" messages
        from medusa.http_server logged as errors at least.Ú
Nr“   r§   )Úendswithr>   rV   r§   Útrace)r   r  r   r   r   rE   i  s
   
zLogWrapper.logN)r   r   r   r$   r   rE   r   r   r   r   rT  c  s    rT  c                   @   s   e Zd Zdd„ Zdd„ ZdS )Úencrypted_dictionary_authorizerc                 C   r(  r"   )Údict)r   rz  r   r   r   r   u  r,  z(encrypted_dictionary_authorizer.__init__c                 C   sR   |\}}|| j v r'| j | }| d¡r#tt|ƒƒ ¡ }|dd … |kS ||kS dS )Nz{SHA}é   F)rz  r/  r   r   Ú	hexdigest)r   Ú	auth_inforQ  rR  Ústored_passwordÚpassword_hashr   r   r   Ú	authorizex  s   


z)encrypted_dictionary_authorizer.authorizeN)r   r   r   r   r€  r   r   r   r   ry  t  s    ry  c                   @   s   e Zd Zddd„ZdS )ra  Údefaultc                 C   s   t  | |||¡ t|ƒ| _d S r"   )r   r   ry  Ú
authorizer)r   rz  ÚhandlerÚrealmr   r   r   r   …  s   z supervisor_auth_handler.__init__N)r�  )r   r   r   r   r   r   r   r   ra  „  s    ra  )-rq   r!  rX   rÊ   rç   r÷   r  rY  rÿ   ÚImportErrorÚgetpassÚsupervisor.compatr   r   r   r   rÈ   r   r¸   r   r   r	   r
   r   Úsupervisor.medusa.auth_handlerr   r   r   r&   r*   r2   Úhttp_requestr6   r�   r›   rÆ   rå   rï   r  r'  rI  ru  rT  ry  ra  r   r   r   r   Ú<module>   sV    ÿ  @ 	5V6E"I