+
    Dfj&                         R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ]! ]P                  4       ! R R]P                  4      4       t
R# )z
The parent class for all the SSH Channels.  Currently implemented channels
are session, direct-tcp, and forwarded-tcp.

Maintainer: Paul Swartz
)implementer)
interfaces)Logger)logc                      a  ] tR t^t o Rt]! 4       tRtRR ltV 3R lR lt	V 3R lR lt
R tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tV 3R ltRtV tR# )
SSHChannelaF  
A class that represents a multiplexed channel over an SSH connection.
The channel has a local window which is the maximum amount of data it will
receive, and a remote which is the maximum amount of data the remote side
will accept.  There is also a maximum packet size for any individual data
packet going each way.

@ivar name: the name of the channel.
@type name: L{bytes}
@ivar localWindowSize: the maximum size of the local window in bytes.
@type localWindowSize: L{int}
@ivar localWindowLeft: how many bytes are left in the local window.
@type localWindowLeft: L{int}
@ivar localMaxPacket: the maximum size of packet we will accept in bytes.
@type localMaxPacket: L{int}
@ivar remoteWindowLeft: how many bytes are left in the remote window.
@type remoteWindowLeft: L{int}
@ivar remoteMaxPacket: the maximum size of a packet the remote side will
    accept in bytes.
@type remoteMaxPacket: L{int}
@ivar conn: the connection this channel is multiplexed through.
@type conn: L{SSHConnection}
@ivar data: any data to send to the other side when the channel is
    requested.
@type data: L{bytes}
@ivar avatar: an avatar for the logged-in user (if a server channel)
@ivar localClosed: True if we aren't accepting more data.
@type localClosed: L{bool}
@ivar remoteClosed: True if the other side isn't accepting more data.
@type remoteClosed: L{bool}
Nc                   T;'       g    R V n         V P                   V n        T;'       g    RV n        W0n        W@n        ^V n        WPn        W`n        Wpn        RV n	        RV n
        . V n        ^ V n        ^ V n        ^ V n        RV n        R# )i   i       N)localWindowSizelocalWindowLeftlocalMaxPacketremoteWindowLeftremoteMaxPacket
areWritingconndataavatarspecificDatabufextBufclosinglocalClosedremoteClosedid)selflocalWindowr   remoteWindowr   r   r   r   s   &&&&&&&&;/usr/lib/python3/dist-packages/twisted/conch/ssh/channel.py__init__SSHChannel.__init__9   s      +44f#33,55 ,.		r	   c                    < V ^8  d   QhRS[ /#    return)str)format__classdict__s   "r   __annotate__SSHChannel.__annotate__T   s     0 0 0r	   c                @    V P                  4       P                  R 4      # )ascii)	__bytes__decoder   s   &r   __str__SSHChannel.__str__T   s    ~~&&w//r	   c                    < V ^8  d   QhRS[ /# r!   bytes)r%   r&   s   "r   r'   r(   W   s     
 
5 
r	   c                n    V P                   pV'       g   RpRVV P                  V P                  3,          # )z4
Return a byte string representation of the channel
s   Nones   <SSHChannel %b (lw %d rw %d)>)namer   r   )r   r4   s   & r   r+   SSHChannel.__bytes__W   s<     yyD/  !!3
 
 	
r	   c                   V P                   R J;'       d    \        V P                   4      ;'       g    RpV P                  '       d   V P                  P                  R4      pMRpRV RV RV P                  P                  4        2# )Nunknownr*   NonezSSHChannel z (z) on )r   r$   r4   r,   r   	logPrefix)r   r   r4   s   &  r   r9   SSHChannel.logPrefixe   sq    ggT!22c$''l@@y99999##G,DDTF"RDdii.A.A.C-DEEr	   c                <    V P                   P                  R4       R# )z
Called when the channel is opened.  specificData is any data that the
other side sent us when opening the channel.

@type specificData: L{bytes}
zchannel openN_loginfo)r   r   s   &&r   channelOpenSSHChannel.channelOpenm   s     			~&r	   c                @    V P                   P                  RVR7       R# )z
Called when the open failed for some reason.
reason.desc is a string descrption, reason.code the SSH error code.

@type reason: L{error.ConchError}
z(other side refused open
reason: {reason})reasonN)r=   error)r   rB   s   &&r   
openFailedSSHChannel.openFailedv   s     			CFSr	   c                   V P                   V,           V n         V P                  '       g*   V P                  '       g   RV n        V P                  4        V P                  '       d%   V P                  pRV n        V P                  V4       V P                  '       d2   V P                  p. V n        V F  w  r1V P                  W14       K  	  R# R# )zt
Called when bytes are added to the remote window.  By default it clears
the data buffers.

@type data:    L{bytes}
Tr	   N)r   r   r   startWritingr   writer   writeExtended)r   r   btypes   &&  r   addWindowBytesSSHChannel.addWindowBytes   s     !% 5 5 <t|||"DO888ADHJJqM;;;ADK
""4.   r	   c                    VP                  RR4      P                  R4      p\        V RV,           R4      pV'       d	   V! V4      # V P                  P	                  RVR7       ^ # )a
  
Called when a request is sent to this channel.  By default it delegates
to self.request_<requestType>.
If this function returns true, the request succeeded, otherwise it
failed.

@type requestType:  L{bytes}
@type data:         L{bytes}
@rtype:             L{bool}
   -   _r*   request_Nz#unhandled request for {requestType})requestType)replacer,   getattrr=   r>   )r   rR   r   foofs   &&&  r   requestReceivedSSHChannel.requestReceived   sX     !!$-44W=D*s*D1T7N		<+Vr	   c                @    V P                   P                  RVR7       R# )z4
Called when we receive data.

@type data: L{bytes}
zgot data {data})r   Nr=   debugr   r   s   &&r   dataReceivedSSHChannel.dataReceived   s     			)5r	   c                @    V P                   P                  RWR7       R# )zo
Called when we receive extended data (usually standard error).

@type dataType: L{int}
@type data:     L{str}
z%got extended data {dataType} {data!r})dataTyper   NrZ   r   r`   r   s   &&&r   extReceivedSSHChannel.extReceived   s     			3h 	 	
r	   c                <    V P                   P                  R4       R# )z4
Called when the other side will send no more data.
z
remote eofNr<   r-   s   &r   eofReceivedSSHChannel.eofReceived   s     			|$r	   c                \    V P                   P                  R4       V P                  4        R# )z4
Called when the other side has closed the channel.
zremote closeN)r=   r>   loseConnectionr-   s   &r   closeReceivedSSHChannel.closeReceived   s      			~&r	   c                <    V P                   P                  R4       R# )zp
Called when the channel is closed.  This means that both our side and
the remote side have closed the channel.
closedNr<   r-   s   &r   rl   SSHChannel.closed   s    
 			x r	   c                R   V P                   '       d   V ;P                   V,          un         R# \        V4      pW P                  8  dF   VRV P                   WP                  R uqn         ^ V n        V P	                  4        V P                  pV P
                  pV P                  P                  p\        ^ W#4      pV F  pV! WWfV,            4       K  	  V ;P                  V,          un        V P                  '       d'   V P                   '       g   V P                  4        R# R# R# )z
Write some data to the channel.  If there is not enough remote window
available, buffer until it is.  Otherwise, split the data into
packets of length remoteMaxPacket and send them.

@type data: L{bytes}
N)r   lenr   r   stopWritingr   r   sendDataranger   rh   )r   r   toprmprH   roffsets   &&     r   rH   SSHChannel.write   s     888HHH$i&&&,t,,-**,- D(  DO''C""		""!SF$Vsl34 $<<<! !)<r	   c                `   V P                   '       df   V P                   R,          ^ ,          V8X  d)   V P                   R,          ^;;,          V,          uu&   R# V P                   P                  W.4       R# \        V4      V P                  8  d=   VRV P                   WV P                  R ..uq n         ^ V n        V P                  4        \        V4      V P                  8  d]   V P                  P                  WVRV P                   4       W P                  R pV ;P                  V P                  ,          un        Kv  V'       d?   V P                  P                  WV4       V ;P                  \        V4      ,          un        V P                  '       d   V P                  4        R# R# )z
Send extended data to this channel.  If there is not enough remote
window available, buffer until there is.  Otherwise, split the data
into packets of length remoteMaxPacket and send them.

@type dataType: L{int}
@type data:     L{bytes}
N)r   appendro   r   r   rp   r   r   sendExtendedDatar   rh   ra   s   &&&r   rI   SSHChannel.writeExtended   sS    ;;;{{2q!X-B"d*"  ""H#34t9t,,,,t,,-!6!6!89:; D+  DO$i$...II&&tt<Rd>R>R7ST,,./D!!T%9%99!II&&tt<!!SY.!<<<! r	   c                F    V P                  RP                  V4      4       R# )zj
Part of the Transport interface.  Write a list of strings to the
channel.

@type data: C{list} of L{str}
r	   N)rH   joinr\   s   &&r   writeSequenceSSHChannel.writeSequence
  s     	

388D>"r	   c                    ^V n         V P                  '       g2   V P                  '       g   V P                  P	                  V 4       R# R# R# )zZ
Close the channel if there is no buferred data.  Otherwise, note the
request and return.
N)r   r   r   r   	sendCloser-   s   &r   rh   SSHChannel.loseConnection  s5    
 xxxII% !,xr	   c                J    V P                   P                  P                  4       # )zm
See: L{ITransport.getPeer}

@return: The remote address of this connection.
@rtype: L{SSHTransportAddress}.
)r   	transportgetPeerr-   s   &r   r   SSHChannel.getPeer       yy""**,,r	   c                J    V P                   P                  P                  4       # )zy
See: L{ITransport.getHost}

@return: An address describing this side of the connection.
@rtype: L{SSHTransportAddress}.
)r   r   getHostr-   s   &r   r   SSHChannel.getHost%  r   r	   c                    R# )zo
Called when the remote buffer is full, as a hint to stop writing.
This can be ignored, but it can be helpful.
N r-   s   &r   rp   SSHChannel.stopWriting.      r	   c                    R# )zM
Called when the remote buffer has more room, as a hint to continue
writing.
Nr   r-   s   &r   rG   SSHChannel.startWriting4  r   r	   c                &   < V ^8  d   Qh/ S[ ;R&   # )r"   r4   r1   )r%   r&   s   "r   r'   r(      s     F G r	   )r   r   r   r   r   r   r   r   r   r   r   r
   r   r   r   r   )    r   r   r   NNN) __name__
__module____qualname____firstlineno____doc__r   r=   r4   r   r.   r+   r9   r?   rD   rL   rW   r]   rb   re   ri   rl   rH   rI   r   rh   r   r   rp   rG   __annotate_func____static_attributes____classdictcell__)r&   s   @r   r   r      s     @ 8DD60 0
 
F'T/*$6	
%!":"@#&--A	  r	   r   N)r   zope.interfacer   twisted.internetr   twisted.loggerr   twisted.pythonr   
ITransportr   r   r	   r   <module>r      sE   
 ' ' !  Z""#c c $cr	   