+
    üÐj   ã                   ó<  € R t ^ RIt^ RIHtHt ^ RIHtHt ^ RIH	t	H
t
  ! R R]P                  4      t ! R R]P                  4      t ! R	 R
]4      t ! R R]4      t ! R R]P                  4      tR t ! R R]P&                  4      tR t]tR t]tR tR tR# )z¯
This module contains the implementation of the TCP forwarding, which allows
clients and servers to forward arbitrary TCP data across the connection.

Maintainer: Paul Swartz
N)ÚchannelÚcommon)ÚprotocolÚreactor)ÚHostnameEndpointÚconnectProtocolc                   ó,   a € ] tR t^t o R tR tRtV tR# )ÚSSHListenForwardingFactoryc                ó*   € Wn         W n        W0n        R # ©N©ÚconnÚhostportÚklass)ÚselfÚ
connectionr   r   s   &&&&Ú>/usr/lib/python3/dist-packages/twisted/conch/ssh/forwarding.pyÚ__init__Ú#SSHListenForwardingFactory.__init__   s   € ØŒ	Ø ŒØŽ
ó    c                óò   € V P                  V P                  R 7      p\        V4      pW2n        VP                  VP
                  3p\        V P                  V4      pV P                  P                  W%4       V# ))r   )	r   r   ÚSSHForwardingClientÚclientÚhostÚportÚpackOpen_direct_tcpipr   ÚopenChannel)r   Úaddrr   r   Ú	addrTupleÚchannelOpenDatas   &&    r   ÚbuildProtocolÚ(SSHListenForwardingFactory.buildProtocol   s^   € Ø—*‘* $§)¡)�*Ó,ˆÜ$ WÓ-ˆØŒØ—Y‘Y §	¡	Ð*ˆ	Ü/°·±¸yÓIˆØ�	‰	×Ñ˜gÔ7Øˆr   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r    Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r	   r	      s   ø‡ € ò÷
ð r   r	   c                   ó>   a € ] tR t^#t o R tR tR tR tR tRt	V t
R# )ÚSSHListenForwardingChannelc                ó  € V P                   P                  R V P                  R7       \        V P                  P
                  4      ^8”  d/   V P                  P
                  R,          pV P                  V4       RV P                  n        R# )zopened forwarding channel {id}©Úidºé   NNr   N)Ú_logÚinfor.   Úlenr   ÚbufÚwrite)r   ÚspecificDataÚbs   && r   ÚchannelOpenÚ&SSHListenForwardingChannel.channelOpen$   sX   € Ø�	‰	�‰Ð7¸D¿G¹GˆÔDÜˆt�{‰{�‰Ó !Ô#Ø—‘—‘ Õ#ˆAØ�J‰J�qŒMØˆ�‰Žr   c                ó&   € V P                  4        R # r   )Úclosed©r   Úreasons   &&r   Ú
openFailedÚ%SSHListenForwardingChannel.openFailed+   s   € Ø�‰Žr   c                óP   € V P                   P                  P                  V4       R # r   )r   Ú	transportr5   ©r   Údatas   &&r   ÚdataReceivedÚ'SSHListenForwardingChannel.dataReceived.   s   € Ø�‰×Ñ×#Ñ# DÖ)r   c                óN   € V P                   P                  P                  4        R # r   )r   rA   ÚloseConnection©r   s   &r   ÚeofReceivedÚ&SSHListenForwardingChannel.eofReceived1   s   € Ø�‰×Ñ×,Ñ,Ö.r   c                óÈ   € \        V R 4      '       dP   V P                  P                  RV P                  R7       V P                  P
                  P                  4        V =R# R# )r   z%closing local forwarding channel {id}r-   N)Úhasattrr1   r2   r.   r   rA   rG   rH   s   &r   r;   Ú!SSHListenForwardingChannel.closed4   sH   € Ü�4˜×"Ò"Ø�I‰I�N‰NÐBÀtÇwÁwˆNÔOØ�K‰K×!Ñ!×0Ñ0Ô2Ø’ñ #r   © N)r"   r#   r$   r%   r8   r>   rD   rI   r;   r&   r'   r(   s   @r   r+   r+   #   s#   ø‡ € òòò*ò/÷ð r   r+   c                   ó   € ] tR t^;tRtRtR# )Ú SSHListenClientForwardingChannels   direct-tcpiprN   N©r"   r#   r$   r%   Únamer&   rN   r   r   rP   rP   ;   s   † Ø„Dr   rP   c                   ó   € ] tR t^?tRtRtR# )Ú SSHListenServerForwardingChannels   forwarded-tcpiprN   NrQ   rN   r   r   rT   rT   ?   s   † Ø„Dr   rT   c                   óL   a € ] tR t^Ct o Rt]tR tR tR t	R t
R tR tRtV tR	# )
ÚSSHConnectForwardingChannela³  
Channel used for handling server side forwarding request.
It acts as a client for the remote forwarding destination.

@ivar hostport: C{(host, port)} requested by client as forwarding
    destination.
@type hostport: L{tuple} or a C{sequence}

@ivar client: Protocol connected to the forwarding destination.
@type client: L{protocol.Protocol}

@ivar clientBuf: Data received while forwarding channel is not yet
    connected.
@type clientBuf: L{bytes}

@var  _reactor: Reactor used for TCP connections.
@type _reactor: A reactor.

@ivar _channelOpenDeferred: Deferred used in testing to check the
    result of C{channelOpen}.
@type _channelOpenDeferred: L{twisted.internet.defer.Deferred}
c                óv   € \         P                  P                  ! V .VO5/ VB  Wn        R V n        RV n        R # )Nr   )r   Ú
SSHChannelr   r   r   Ú	clientBuf)r   r   ÚargsÚkws   &&*,r   r   Ú$SSHConnectForwardingChannel.__init__]   s3   € Ü×Ñ×#Ò# DÐ6¨4Ò6°2Ò6Ø ŒØˆŒØˆŽr   c                óz  € V P                   P                  RV P                  ^ ,          V P                  ^,          R7       \        V P                  V P                  ^ ,          V P                  ^,          4      p\        V\        V 4      4      pVP                  V P                  V P                  4       W0n
        R# )ú
See: L{channel.SSHChannel}
zconnecting to {host}:{port}©r   r   N)r1   r2   r   r   Ú_reactorr   r   ÚaddCallbacksÚ
_setClientÚ_closeÚ_channelOpenDeferred)r   r6   ÚepÚds   &&  r   r8   Ú'SSHConnectForwardingChannel.channelOpenc   s‡   € ð 	�	‰	�‰Ø)°·±¸aÕ0@ÀtÇ}Á}ÐUVÕGWð 	ô 	
ô ˜dŸm™m¨T¯]©]¸1Õ-=¸t¿}¹}ÈQÕ?OÓPˆÜ˜BÔ 3°DÓ 9Ó:ˆØ	�‰�t—‘¨¯©Ô4Ø$%Ö!r   c                óâ  € Wn         V P                  P                  RV P                  ^ ,          V P                  ^,          R7       V P                  '       d7   V P                   P
                  P                  V P                  4       RV n        V P                   P                  R,          '       d-   V P                  V P                   P                  R,          4       RV P                   n        R# )z¸
Called when the connection was established to the forwarding
destination.

@param client: Client protocol connected to the forwarding destination.
@type  client: L{protocol.Protocol}
zconnected to {host}:{port}r_   Nr/   r   )r   r1   r2   r   rY   rA   r5   r4   )r   r   s   &&r   rb   Ú&SSHConnectForwardingChannel._setCliento   s�   € ð ŒØ�	‰	�‰Ø(¨t¯}©}¸QÕ/?ÀdÇmÁmÐTUÕFVð 	ô 	
ð �>�>ˆ>Ø�K‰K×!Ñ!×'Ñ'¨¯©Ô7Ø!ˆDŒNØ�;‰;�?‰?˜2×ÔØ�J‰J�t—{‘{—‘ rÕ*Ô+Øˆ�‰Žr   c                ó¨   € V P                   P                  RV P                  ^ ,          V P                  ^,          VR7       V P                  4        R# )z�
Called when failed to connect to the forwarding destination.

@param reason: Reason why connection failed.
@type  reason: L{twisted.python.failure.Failure}
z,failed to connect to {host}:{port}: {reason})r   r   r=   N)r1   Úerrorr   rG   r<   s   &&r   rc   Ú"SSHConnectForwardingChannel._close‚   sE   € ð 	�	‰	�‰Ø:Ø—‘˜qÕ!Ø—‘˜qÕ!Øð	 	ô 	
ð 	×ÑÖr   c                óª   € V P                   '       d(   V P                   P                  P                  V4       R# V ;P                  V,          un        R# )r^   N)r   rA   r5   rY   rB   s   &&r   rD   Ú(SSHConnectForwardingChannel.dataReceived‘   s3   € ð �;�;ˆ;Ø�K‰K×!Ñ!×'Ñ'¨Ö-à�NŠN˜dÕ"�Nr   c                ó   € V P                   '       d|   V P                  P                  RV P                  R7       V P                   P                  '       d   V P                  4        V P                   P                  P                  4        V = R# R# )r^   z%closed remote forwarding channel {id}r-   N)r   r1   r2   r.   r   rG   rA   rH   s   &r   r;   Ú"SSHConnectForwardingChannel.closedš   sb   € ð �;�;ˆ;Ø�I‰I�N‰NÐBÀtÇwÁwˆNÔOØ�{‰{×"×"Ð"Ø×#Ñ#Ô%Ø�K‰K×!Ñ!×0Ñ0Ô2Ø’ñ r   )rd   r   rY   r   N)r"   r#   r$   r%   Ú__doc__r   r`   r   r8   rb   rc   rD   r;   r&   r'   r(   s   @r   rV   rV   C   s4   ø‡ € ñð. €Hòò
&òò&ò#÷	ð 	r   rV   c                 ó:   € \        V4      w  rE\        VV VVR 7      # ))ÚremoteWindowÚremoteMaxPacketÚavatar)ÚunpackOpen_direct_tcpiprV   )rs   rt   rC   ru   ÚremoteHPÚorigHPs   &&&&  r   ÚopenConnectForwardingClientry   ¦   s(   € Ü.¨tÓ4Ñ€HÜ&ØØ!Ø'Øô	ð r   c                   ó2   a € ] tR t^°t o R tR tR tRtV tR# )r   c                ó    € Wn         R V n        R# )ó    N)r   r4   )r   r   s   &&r   r   ÚSSHForwardingClient.__init__±   s   € ØŒØˆŽr   c                ó–   € V P                   '       d   V ;P                   V,          un         R # V P                  P                  V4       R # r   )r4   r   r5   rB   s   &&r   rD   Ú SSHForwardingClient.dataReceivedµ   s+   € Ø�8�8ˆ8Ø�HŠH˜Õ�Hà�L‰L×Ñ˜tÖ$r   c                óp   € V P                   '       d$   V P                   P                  4        R V n         R # R # r   )r   rG   r<   s   &&r   ÚconnectionLostÚ"SSHForwardingClient.connectionLost»   s'   € Ø�<�<ˆ<Ø�L‰L×'Ñ'Ô)ØˆDŽLñ r   )r4   r   N)	r"   r#   r$   r%   r   rD   r�   r&   r'   r(   s   @r   r   r   °   s   ø‡ € òò%÷ ð  r   r   c                ó†  € V w  r#Vw  rE\        V\        4      '       d   VP                  R4      p\        V\        4      '       d   VP                  R4      p\        P                  ! V4      \
        P                  ! RV4      ,           p\        P                  ! V4      \
        P                  ! RV4      ,           pWg,           # )zû
Pack the data suitable for sending in a CHANNEL_OPEN packet.

@type destination: L{tuple}
@param destination: A tuple of the (host, port) of the destination host.

@type source: L{tuple}
@param source: A tuple of the (host, port) of the source host.
úutf-8ú>L)Ú
isinstanceÚstrÚencoder   ÚNSÚstructÚpack)ÚdestinationÚsourceÚconnHostÚconnPortÚorigHostÚorigPortr   Úorigs   &&      r   r   r   Á   sŽ   € ð 'Ñ€XØ!Ñ€XÜ�(œC× Ò Ø—?‘? 7Ó+ˆÜ�(œC× Ò Ø—?‘? 7Ó+ˆÜ�9Š9�XÓ¤§¢¨T°8Ó!<Õ<€DÜ�9Š9�XÓ¤§¢¨T°8Ó!<Õ<€DØ�;Ðr   c                óÐ  € \         P                  ! V 4      w  r\        V\        4      '       d   VP	                  R4      p\        \        P                  ! RVR,          4      ^ ,          4      p\         P                  ! VR,          4      w  rB\        V\        4      '       d   VP	                  R4      p\        \        P                  ! RVR,          4      ^ ,          4      pW3WE33# )z#Unpack the data to a usable format.r„   r…   ºNé   N:r•   NN©r   ÚgetNSr†   ÚbytesÚdecodeÚintrŠ   Úunpack)rC   rŽ   Úrestr�   r�   r‘   s   &     r   rv   rv   Ù   s©   € ä—\’\ $Ó'�N€HÜ�(œE×"Ò"Ø—?‘? 7Ó+ˆÜ”6—=’=  t¨B¥xÓ0°Õ3Ó4€HÜ—\’\ $ r¥(Ó+�N€HÜ�(œE×"Ò"Ø—?‘? 7Ó+ˆÜ”6—=’=  t¨B¥xÓ0°Õ3Ó4€HØÐ (Ð!5Ð5Ð5r   c                ón   € V w  r\         P                  ! V4      \        P                  ! RV4      ,           # )zf
Pack the data for tcpip forwarding.

@param peer: A tuple of the (host, port) .
@type peer: L{tuple}
r…   )r   r‰   rŠ   r‹   )Úpeerr   r   s   &  r   ÚpackGlobal_tcpip_forwardrŸ   é   s)   € ð �L€TÜ�9Š9�T‹?œVŸ[š[¨¨tÓ4Õ4Ð4r   c                 óâ   € \         P                  ! V 4      w  r\        V\        4      '       d   VP	                  R 4      p\        \        P                  ! RVR,          4      ^ ,          4      pW3# )r„   r…   r”   r–   )rC   r   rœ   r   s   &   r   ÚunpackGlobal_tcpip_forwardr¡   ô   sS   € Ü—’˜dÓ#�J€DÜ�$œ×ÒØ�{‰{˜7Ó#ˆÜŒv�}Š}˜T 4¨¥8Ó,¨QÕ/Ó0€DØˆ:Ðr   )rq   rŠ   Útwisted.conch.sshr   r   Útwisted.internetr   r   Útwisted.internet.endpointsr   r   ÚFactoryr	   rX   r+   rP   rT   rV   ry   ÚProtocolr   r   ÚpackOpen_forwarded_tcpiprv   ÚunpackOpen_forwarded_tcpiprŸ   r¡   rN   r   r   Ú<module>r©      s«   ðñó ç -ß .ß Hô ×!1Ñ!1ô ô  ×!3Ñ!3ô ô0Ð'Aô ôÐ'Aô ô` '×"4Ñ"4ô `òFô ˜(×+Ñ+ô  ò"ð* 1Ð ò
6ð 5Ð ò5òñr   