<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>

]]e                 @   s  d  d l  Z  d  d l Z y d  d l Z Wn e k
 rB d Z Yn Xd 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	   Z d
 d   Z d Z d Z d Z d Z Gd d   d e  Z Gd d   d e j e j  Z Gd d   d e j  Z d S)    N   )base_events)compat)	protocols)
transports)loggerc             C   s   |  r t  d   t t d  r? t j   } | s d | _ nL t j t j  } | j t j O_ | j t j	 O_ | j
   t j | _ | S)Nz(Server side SSL needs a valid SSLContextcreate_default_contextF)
ValueErrorhasattrsslr   check_hostnameZ
SSLContextZPROTOCOL_SSLv23optionsZOP_NO_SSLv2ZOP_NO_SSLv3Zset_default_verify_pathsZCERT_REQUIREDverify_mode)server_sideserver_hostname
sslcontext r   -/opt/alt/python35/lib64/python3.5/sslproto.py_create_transport_context   s    
r   c               C   s   t  t d  S)N	MemoryBIO)r
   r   r   r   r   r   _is_sslproto_available%   s    r   Z	UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc               @   s   e  Z d  Z d Z d d d  Z e d d    Z e d d	    Z e d
 d    Z e d d    Z	 d d d  Z
 d d d  Z d d   Z d d d  Z d d d  Z d S)_SSLPipe   i   Nc             C   sj   | |  _  | |  _ | |  _ t |  _ t j   |  _ t j   |  _ d  |  _	 d |  _
 d  |  _ d  |  _ d  S)NF)_context_server_side_server_hostname
_UNWRAPPED_stater   r   	_incoming	_outgoing_sslobj_need_ssldata_handshake_cb_shutdown_cb)selfcontextr   r   r   r   r   __init__D   s    							z_SSLPipe.__init__c             C   s   |  j  S)N)r   )r$   r   r   r   r%   Z   s    z_SSLPipe.contextc             C   s   |  j  S)N)r    )r$   r   r   r   
ssl_object_   s    z_SSLPipe.ssl_objectc             C   s   |  j  S)N)r!   )r$   r   r   r   need_ssldatag   s    z_SSLPipe.need_ssldatac             C   s   |  j  t k S)N)r   _WRAPPED)r$   r   r   r   wrappedm   s    z_SSLPipe.wrappedc             C   s|   |  j  t k r t d   |  j j |  j |  j d |  j d |  j |  _	 t
 |  _  | |  _ |  j d d d \ } } | S)Nz"handshake in progress or completedr   r       only_handshakeT)r   r   RuntimeErrorr   Zwrap_bior   r   r   r   r    _DO_HANDSHAKEr"   feed_ssldata)r$   callbackssldataappdatar   r   r   do_handshakev   s    					z_SSLPipe.do_handshakec             C   sa   |  j  t k r t d   |  j  t k r6 t d   t |  _  | |  _ |  j d  \ } } | S)Nzno security layer presentzshutdown in progressr+   )r   r   r-   	_SHUTDOWNr#   r/   )r$   r0   r1   r2   r   r   r   shutdown   s    			z_SSLPipe.shutdownc             C   s&   |  j  j   |  j d  \ } } d  S)Nr+   )r   Z	write_eofr/   )r$   r1   r2   r   r   r   feed_eof   s    z_SSLPipe.feed_eofFc             C   s  |  j  t k r1 | r! | g } n g  } g  | f Sd |  _ | rP |  j j |  g  } g  } y |  j  t k r |  j j   t |  _  |  j	 r |  j	 d   | r | | f S|  j  t k r x |  j j
 |  j  } | j |  | s Pq Wni |  j  t k r0|  j j   d  |  _ t |  _  |  j rU|  j   n% |  j  t k rU| j |  j j
    Wn t j t j f k
 r} zl t | d d   t j t j t j f k r|  j  t k r|  j	 r|  j	 |    | j t j k |  _ WYd  d  } ~ Xn X|  j j r| j |  j j
    | | f S)NFerrno)r   r   r!   r   writer.   r    r3   r)   r"   readmax_sizeappendr4   Zunwrapr#   r   SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLr7   r   pending)r$   datar,   r2   r1   chunkexcr   r   r   r/      sV    
			
			(z_SSLPipe.feed_ssldatar   c             C   sl  |  j  t k rM | t |  k  r7 | | d   g } n g  } | t |  f Sg  } t |  } x d |  _ y6 | t |  k  r | |  j j | | d    7} Wn| t j k
 r} zY | j	 d k r t j
 | _ | j t j
 t j t j f k r   | j t j
 k |  _ WYd  d  } ~ Xn X|  j j rB| j |  j j    | t |  k s]|  j rb Pqb W| | f S)NFZPROTOCOL_IS_SHUTDOWN)r   r   len
memoryviewr!   r    r8   r   r<   reasonr?   r7   r@   rA   r   rB   r;   r9   )r$   rC   offsetr1   viewrE   r   r   r   feed_appdata   s2    	$(z_SSLPipe.feed_appdatai   )__name__
__module____qualname__r:   r&   propertyr%   r'   r(   r*   r3   r5   r6   r/   rK   r   r   r   r   r   0   s   	
Jr   c               @   s   e  Z d  Z d d   Z d d d  Z d d   Z d d	   Z d
 d   Z d d   Z e	 j
 rl d d   Z d d   Z d d   Z d d d d  Z d d   Z d d   Z d d   Z d d   Z d S)_SSLProtocolTransportc             C   s(   | |  _  | |  _ | |  _ d |  _ d  S)NF)_loop_ssl_protocol_app_protocol_closed)r$   loopZssl_protocolapp_protocolr   r   r   r&   )  s    			z_SSLProtocolTransport.__init__Nc             C   s   |  j  j | |  S)N)rR   _get_extra_info)r$   namedefaultr   r   r   get_extra_info0  s    z$_SSLProtocolTransport.get_extra_infoc             C   s   | |  _  d  S)N)rS   )r$   protocolr   r   r   set_protocol4  s    z"_SSLProtocolTransport.set_protocolc             C   s   |  j  S)N)rS   )r$   r   r   r   get_protocol7  s    z"_SSLProtocolTransport.get_protocolc             C   s   |  j  S)N)rT   )r$   r   r   r   
is_closing:  s    z _SSLProtocolTransport.is_closingc             C   s   d |  _  |  j j   d  S)NT)rT   rR   _start_shutdown)r$   r   r   r   close=  s    	z_SSLProtocolTransport.closec             C   s+   |  j  s' t j d |  t  |  j   d  S)Nzunclosed transport %r)rT   warningswarnResourceWarningr`   )r$   r   r   r   __del__L  s    	z_SSLProtocolTransport.__del__c             C   s   |  j  j j   d  S)N)rR   
_transportpause_reading)r$   r   r   r   rf   Q  s    z#_SSLProtocolTransport.pause_readingc             C   s   |  j  j j   d  S)N)rR   re   resume_reading)r$   r   r   r   rg   Y  s    z$_SSLProtocolTransport.resume_readingc             C   s   |  j  j j | |  d  S)N)rR   re   set_write_buffer_limits)r$   highlowr   r   r   rh   a  s    z-_SSLProtocolTransport.set_write_buffer_limitsc             C   s   |  j  j j   S)N)rR   re   get_write_buffer_size)r$   r   r   r   rk   v  s    z+_SSLProtocolTransport.get_write_buffer_sizec             C   sT   t  | t t t f  s6 t d j t |  j    | s@ d  S|  j j	 |  d  S)Nz/data: expecting a bytes-like instance, got {!r})

isinstancebytes	bytearrayrG   	TypeErrorformattyperL   rR   _write_appdata)r$   rC   r   r   r   r8   z  s    	z_SSLProtocolTransport.writec             C   s   d S)NFr   )r$   r   r   r   can_write_eof  s    z#_SSLProtocolTransport.can_write_eofc             C   s   |  j  j   d  S)N)rR   _abort)r$   r   r   r   abort  s    z_SSLProtocolTransport.abort)rL   rM   rN   r&   rZ   r\   r]   r^   r`   r   ZPY34rd   rf   rg   rh   rk   r8   rs   ru   r   r   r   r   rP   &  s   	rP   c               @   s   e  Z d  Z d d d d d  Z d d d  Z d d	   Z d
 d   Z d d   Z d d   Z d d   Z	 d d   Z
 d d d  Z d d   Z d d   Z d d   Z d d   Z d d   Z d  d! d"  Z d# d$   Z d% d&   Z d S)'SSLProtocolFNTc             C   s   t  d  k r t d   | s- t | |  } | |  _ | rO | rO | |  _ n	 d  |  _ | |  _ t d |  |  _ t j	   |  _
 d |  _ | |  _ | |  _ | |  _ t |  j |  |  j  |  _ d  |  _ d |  _ d |  _ d |  _ d  |  _ | |  _ d  S)Nzstdlib ssl module not availabler   r   F)r   r-   r   r   r   _sslcontextdict_extracollectionsdeque_write_backlog_write_buffer_size_waiterrQ   rS   rP   _app_transport_sslpipe_session_established_in_handshake_in_shutdownre   _call_connection_made)r$   rU   rV   r   waiterr   r   Zcall_connection_mader   r   r   r&     s.    													zSSLProtocol.__init__c             C   s^   |  j  d  k r d  S|  j  j   sQ | d  k	 rA |  j  j |  n |  j  j d   d  |  _  d  S)N)r~   	cancelledset_exception
set_result)r$   rE   r   r   r   _wakeup_waiter  s    zSSLProtocol._wakeup_waiterc             C   s5   | |  _  t |  j |  j |  j  |  _ |  j   d  S)N)re   r   rw   r   r   r   _start_handshake)r$   	transportr   r   r   connection_made  s
    		zSSLProtocol.connection_madec             C   sN   |  j  r+ d |  _  |  j j |  j j |  d  |  _ d  |  _ |  j |  d  S)NF)r   rQ   	call_soonrS   connection_lostre   r   r   )r$   rE   r   r   r   r     s    				zSSLProtocol.connection_lostc             C   s   |  j  j   d  S)N)rS   pause_writing)r$   r   r   r   r     s    zSSLProtocol.pause_writingc             C   s   |  j  j   d  S)N)rS   resume_writing)r$   r   r   r   r     s    zSSLProtocol.resume_writingc             C   s   y |  j  j |  \ } } Wna t j k
 r } z> |  j j   r_ t j d |  | j | j	  |  j
   d  SWYd  d  } ~ Xn Xx | D] } |  j j |  q Wx2 | D]* } | r |  j j |  q |  j   Pq Wd  S)Nz%r: SSL error %s (reason %s))r   r/   r   r<   rQ   	get_debugr   warningr7   rH   rt   re   r8   rS   data_receivedr_   )r$   rC   r1   r2   erD   r   r   r   r     s    	

zSSLProtocol.data_receivedc          
   C   sp   z[ |  j  j   r" t j d |   |  j t  |  j sZ |  j j   } | rZ t j	 d  Wd  |  j
 j   Xd  S)Nz%r received EOFz?returning true from eof_received() has no effect when using ssl)rQ   r   r   debugr   ConnectionResetErrorr   rS   eof_receivedr   re   r`   )r$   Z	keep_openr   r   r   r     s    	zSSLProtocol.eof_receivedc             C   sD   | |  j  k r |  j  | S|  j d  k	 r< |  j j | |  S| Sd  S)N)ry   re   rZ   )r$   rX   rY   r   r   r   rW     s
    zSSLProtocol._get_extra_infoc             C   s=   |  j  r d  S|  j r# |  j   n d |  _  |  j d  d  S)NTr+   )r   r   rt   rr   )r$   r   r   r   r_   &  s    			zSSLProtocol._start_shutdownc             C   s9   |  j  j | d f  |  j t |  7_ |  j   d  S)Nr   )r|   r;   r}   rF   _process_write_backlog)r$   rC   r   r   r   rr   /  s    zSSLProtocol._write_appdatac             C   sm   |  j  j   r4 t j d |   |  j  j   |  _ n	 d  |  _ d |  _ |  j j d  |  j  j	 |  j
  d  S)Nz%r starts SSL handshakeTr+   r   )r+   r   )rQ   r   r   r   time_handshake_start_timer   r|   r;   r   r   )r$   r   r   r   r   4  s    		zSSLProtocol._start_handshakec             C   s  d |  _  |  j j } ye | d  k	 r* |  | j   } t |  j d  sy |  j ry |  j j t j	 k ry t j
 | |  j  Wn t k
 r!} z |  j j   r t | t j  r t j d |  d d n t j d |  d d |  j j   t | t  r|  j |  d  S  WYd  d  } ~ Xn X|  j j   r^|  j j   |  j } t j d |  | d  |  j j d	 | d
 | j   d | j   d |  |  j r|  j j |  j   |  j   d |  _! |  j j" |  j#  d  S)NFr   z5%r: SSL handshake failed on verifying the certificateexc_infoTz%r: SSL handshake failedz%r: SSL handshake took %.1f msg     @@peercertciphercompressionr'   )$r   r   r'   Zgetpeercertr
   rw   r   r   r   Z	CERT_NONEZmatch_hostnameBaseExceptionrQ   r   rl   r=   r   r   re   r`   	Exceptionr   r   r   r   ry   updater   r   r   rS   r   r   r   r   r   )r$   Zhandshake_excZsslobjr   rE   Zdtr   r   r   _on_handshake_complete@  sD    					
	z"SSLProtocol._on_handshake_completec             C   s  |  j  d  k r d  Syxt t |  j   D] } |  j d \ } } | ri |  j j | |  \ } } n? | r |  j j |  j  } d } n |  j j |  j	  } d } x | D] } |  j  j
 |  q W| t |  k  r| | f |  j d <|  j  j r|  j  j   P|  j d =|  j t |  8_ q, WWn` t k
 r} z@ |  j rZ|  j |  n |  j | d  t | t  s|  WYd  d  } ~ Xn Xd  S)Nr   r   zFatal error on SSL transport)re   rangerF   r|   r   rK   r3   r   r5   	_finalizer8   Z_pausedrg   r}   r   r   _fatal_errorrl   r   )r$   irC   rI   r1   rD   rE   r   r   r   r   t  s8    		
	z"SSLProtocol._process_write_backlogzFatal error on transportc          	   C   s   t  | t j  r= |  j j   rh t j d |  | d d n+ |  j j d | d | d |  j d |  i  |  j r |  j j	 |  d  S)Nz%r: %sr   Tmessage	exceptionr   r[   )
rl   r   Z_FATAL_ERROR_IGNORErQ   r   r   r   Zcall_exception_handlerre   Z_force_close)r$   rE   r   r   r   r   r     s    			zSSLProtocol._fatal_errorc             C   s)   d  |  _  |  j d  k	 r% |  j j   d  S)N)r   re   r`   )r$   r   r   r   r     s    	zSSLProtocol._finalizec          
   C   s2   z  |  j  d  k	 r |  j  j   Wd  |  j   Xd  S)N)re   ru   r   )r$   r   r   r   rt     s    zSSLProtocol._abort)rL   rM   rN   r&   r   r   r   r   r   r   r   rW   r_   rr   r   r   r   r   r   rt   r   r   r   r   rv     s$   #
	4,rv   )rz   ra   r   ImportError r   r   r   r   logr   r   r   r   r.   r)   r4   objectr   Z_FlowControlMixinZ	TransportrP   ZProtocolrv   r   r   r   r   <module>   s(   n