
    tf                         d dl Z d dlmZ d dlmZ d dlZd dlmZ d dlmZ dZ	dde
dee         d	efd
Zdej        j        d	efdZd Zde
d	efdZdS )    N)Popen)Optional)sleep)TransportDetails)r   peer2strtransport_channel_idcreate_transport_details	is_serverchannel_id_typereturnc                    |dS |dvr"t          d                    |                    |                     d          }|t          d          t          |d          st          d          |                    d	
          }t          |          t          k    rdS t          j                    }|	                    |           |
                                }|S )a  
    Application-layer user authentication protocols are vulnerable to generic
    credential forwarding attacks, where an authentication credential sent by
    a client C to a server M may then be used by M to impersonate C at another
    server S. To prevent such credential forwarding attacks, modern authentication
    protocols rely on channel bindings. For example, WAMP-cryptosign can use
    the tls-unique channel identifier provided by the TLS layer to strongly bind
    authentication credentials to the underlying channel, so that a credential
    received on one TLS channel cannot be forwarded on another.

    :param transport: The asyncio TLS transport to extract the TLS channel ID from.
    :param is_server: Flag indicating the transport is for a server.
    :param channel_id_type: TLS channel ID type, currently only "tls-unique" is supported.
    :returns: The TLS channel id (32 bytes).
    Ns                                    )
tls-uniquezinvalid channel ID type {}
ssl_objectzUTLS transport channel_id for tls-unique requested, but ssl_obj not found on transportget_channel_bindingz_TLS transport channel_id for tls-unique requested, but get_channel_binding not found on ssl_objr   )cb_type)	Exceptionformatget_extra_infohasattrr   typebyteshashlibsha256updatedigest)	transportr
   r   ssl_objtls_finished_msgm
channel_ids          T/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/autobahn/asyncio/util.pyr   r   +   s      | n,,4;;OLLMMM&&|44Goppp7122 {yzzz &99,9OO&&|N	!"""XXZZ
    r   c                 .   	 |                      d          }t          |t                    r:t          |          dk    rdnd}d                    |d         |d         |          S t          |t
                    rd                    |          S d	                    |          S #  Y nxY w	 |                      d
          }d                    |j                  S #  Y nxY w	 |                      d          }d                    |          S #  Y nxY wdS )Npeername         ztcp{2}:{0}:{1}r      zunix:{0}z?:{0}
subprocessz
process:{}pipezpipe:{}unknown)r   
isinstancetuplelenr   strpid)r   peerip_verprocr*   s        r!   r   r   V   s&   
''
33dE"" 	(d))q..QQaF#**47DGVDDDc"" 	($$T***>>$'''..|<<""48,,,''//%%% 9s0   A#B% &)B% B% %B)-.C C $)D Dc            	      z    ddl m g d} t          t          d t	          fd|                               } | S )Nr   )
serializer)CBORSerializerMsgPackSerializerUBJSONSerializerJsonSerializerc                     | S N )xs    r!   <lambda>z!get_serializers.<locals>.<lambda>z   s     r"   c                 H    t          |           rt          |           nd S r;   )r   getattr)sr5   s    r!   r>   z!get_serializers.<locals>.<lambda>z   s.    SZ[eghSiSi :9Q9O9O9O48 r"   )autobahn.wampr5   listfiltermap)serializersr5   s    @r!   get_serializersrG   v   sn    ((((((___Kvkk3 09 09 09 09:E,G ,G H H I IKr"   c           	          t          |           }|                     dd           d u}|r"dt          | |d          i}t          j        }d }ni }t          j        }d }t          j        }t          |||||||          S )Npeercertr   )channel_typechannel_framingr1   r
   	is_securer    	peer_cert)r   r   r   r   CHANNEL_TYPE_TLSCHANNEL_TYPE_TCPCHANNEL_FRAMING_WEBSOCKET)r   r
   r1   rL   r    rJ   rM   rK   s           r!   r	   r	      s    ID ((T::$FI 	.y)\RR

 (8		
'8	&@O!%i'1YH H H Hr"   r;   )r   r)   r   typingr   asyncior   autobahn.wamp.typesr   __allboolr/   r   r   
transportsBaseTransportr   rG   r	   r<   r"   r!   <module>rX      s	  6                     0 0 0 0 0 0	( (t (hsm (_d ( ( ( (V*8 S    @  H4 H<L H H H H H Hr"   