9?GddlmZddlZddlZddlZddlmZmZmZm Z ddl m Z  ddl Z ddl Z n#e$rdZ dZ YnwxYwddlmZGddejZGdd eZGd d eZdS) ) annotationsN)DictListOptionalUnion) ParseResult) ProtocolErrorc|eZdZejddZejdd Zejdd ZejddZejddZ ejddZ ejdZ ejdZ ejdZ ejd dZejdZdS)! Transporturir buffer_sizeintconnect_timeoutc KdS)z Connects to a server using the implemented transport. The uri passed is of type ParseResult that can be obtained calling urllib.parse.urlparse. N)selfr r rs r/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/nats/aio/transport.pyconnectzTransport.connect Union[str, ParseResult] ssl_contextssl.SSLContextc KdS)a$ connect_tls is similar to connect except it tries to connect to a secure endpoint, using the provided ssl context. The uri can be provided as string in case the hostname differs from the uri hostname, in case it was provided as 'tls_hostname' on the options. Nr)rr rr rs r connect_tlszTransport.connect_tlss  rpayloadbytescdS)zj Write bytes to underlying transport. Needs a call to drain() to be successfully written. Nrrrs rwritezTransport.write+ r List[bytes]cdS)z Writes a list of bytes, one by one, to the underlying transport. Needs a call to drain() to be successfully written. Nrrs r writelineszTransport.writelines2s rreturnc KdS)z Reads a sequence of bytes from the underlying transport, up to buffer_size. The buffer_size is ignored in case the transport carries already frames entire messages (i.e. websocket). Nrrr s rreadzTransport.read:rrc KdS)z\ Reads one whole frame of bytes (or message) from the underlying transport. Nrrs rreadlinezTransport.readlineB rc KdS)zb Flushes the bytes queued for transmission when calling write() and writelines(). Nrr*s rdrainzTransport.drainIr,rc KdS)zD Waits until the connection is successfully closed. Nrr*s r wait_closedzTransport.wait_closedPr,rcdS)z2 Closes the underlying transport. Nrr*s rclosezTransport.closeWr!rboolcdS)z< Returns if underlying transport is at eof. Nrr*s rat_eofzTransport.at_eof^r!rcdS)ze Returns if the transport was initialized, either by calling connect of connect_tls. Nrr*s r__bool__zTransport.__bool__er!rNr rr rrrr rrrr rrr)rr)rr")r rr%r)r%r)r%r3)__name__ __module__ __qualname__abcabstractmethodrrr r$r(r+r.r0r2r5r7rrrr r s                                                      rr c\eZdZdZddZdd ZdZdZddZdZ dZ dZ dZ dZ dZdS) TcpTransportc>d|_d|_d|_d|_dSN)_bare_io_reader _io_reader_bare_io_writer _io_writerr*s r__init__zTcpTransport.__init__ns$?C:>?C:>rr rr rrcKtjtj|j|j||d{V\}}|x|_|_|x|_|_dS)N)hostportlimit) asynciowait_foropen_connectionhostnamerJrCrDrErF)rr r rrws rrzTcpTransport.connectts%  #\X!             1232t122trrrrr%Nonec K|jsJt|jdtj}tj|}tj|jj||t|tr|n|j }tj ||d{V}tj |||tj} || c|_|_dS)N.connect must be called first)server_hostname)rFtyper:rL StreamReaderStreamReaderProtocolget_running_loop start_tls transport isinstancestrrOrM StreamWriterrD) rr rr rreaderprotocoltransport_futurer[writers rrzTcpTransport.connect_tlssUU4::#6 U U UUU%''/77"355?? O %  #-c3#7#7ICCS\ @  "*+;_MMMMMMMM %i67C[C]C]^^+16(rc6|j|SrB)rFr rs rr zTcpTransport.writes$$W---rc6|j|SrB)rFr$rs rr$zTcpTransport.writeliness))'222rcK|jsJt|jd|j|d{VS)NrT)rDrVr:r(r's rr(zTcpTransport.readsUUU4::#6 U U UUU_))+666666666rcDK|jd{VSrB)rDr+r*s rr+zTcpTransport.readlines,_--/////////rcDK|jd{VSrB)rFr.r*s rr.zTcpTransport.drains,_**,,,,,,,,,rcDK|jd{VSrB)rFr0r*s rr0zTcpTransport.wait_closeds,_00222222222rc4|jSrB)rFr2r*s rr2zTcpTransport.closes$$&&&rc4|jSrB)rDr5r*s rr5zTcpTransport.at_eofs%%'''rcRt|jot|jSrB)r3rFrDr*s rr7zTcpTransport.__bool__s!DO$$>do)>)>>rNr8) r rrrr rrrr%rRr r)r:r;r<rGrrr r$r(r+r.r0r2r5r7rrrr@r@ms??? 3333&::::....3337777000---333'''(((?????rr@cfeZdZdddZdd ZddZdZdZddZdZ dZ dZ dZ dZ dZdZdS)WebSocketTransportN ws_headersOptional[Dict[str, List[str]]]ctstdd|_tj|_t j|_t j|_ d|_ ||_ dS)NzPCould not import aiohttp transport, please install it with `pip install aiohttp`) aiohttp ImportError_ws ClientSession_clientrLQueue_pendingFuture _close_task _using_tls _ws_headers)rros rrGzWebSocketTransport.__init__sc rpqq q>B.5.C.E.E   ">++*.%rr rr rrcK|}|j|||d{V|_d|_dS)N)timeoutheadersF)_get_custom_headersrv ws_connectgeturlrtr{)rr r rrs rrzWebSocketTransport.connects[**,,00`g0hhhhhhhhrrrrc:K|jr$|jjs|jrdStd|}|jt|tr|n| |||d{V|_d|_dS)Nzws: cannot upgrade to TLS)sslr~rT) rtclosedr{r rrvrr\r]r)rr rr rrs rrzWebSocketTransport.connect_tlss 8 =DHO =  ;<< <**,,00c3'' 9CCSZZ\\# 1         rc:|j|dSrB)rx put_nowaitrs rr zWebSocketTransport.writes   )))))rc:|D]}||dSrB)r )rrmessages rr$zWebSocketTransport.writeliness0  G JJw      rc:K|d{VSrB)r+r's rr(zWebSocketTransport.reads&]]__$$$$$$$rcK|jd{V}|jtjjkrdS|jS)Nr)rtreceiverVrr WSMsgTypeCLOSEDdata)rrs rr+zWebSocketTransport.readlinesKX%%'''''''' 9)0 0 03yrcK|jsT|j}|j|d{V|jRdSdSrB)rxempty get_nowaitrt send_bytes)rrs rr.zWebSocketTransport.drains-%%'' /m..00G(%%g.. . . . . . . .-%%'' / / / / /rcK|jd{V|jr|jd{Vdx|_|_dSrB)rzrvr2rtr*s rr0zWebSocketTransport.wait_closedsc < ',$$&& & & & & & & &"&&4<<)@)@ ,2244 % %LD&&$'' %$$AFF4OOOO$FC(( %tV$$$ rrB)rorpr8r9rl)r:r;r<rGrrr r$r(r+r.r0r2r5r7rrrrrnrns&&&&&    ****   %%%%/// ''' AAA """     rrn) __future__rr=rLrtypingrrrr urllib.parserrrrrs nats.errorsr ABCr r@rnrrrrsh""""""  ............$$$$$$NNNGIII&%%%%%W W W W W W W W tK?K?K?K?K?9K?K?K?\XXXXXXXXXXs / ;;