Class: Rex::Proto::Ssh::ChannelFD
- Inherits:
-
Object
- Object
- Rex::Proto::Ssh::ChannelFD
- Includes:
- IO::Stream, IOMergeAbstraction
- Defined in:
- lib/rex/proto/ssh/connection.rb
Overview
Emulate a single bidirectional IO using the clients Connections Channels IOs
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#channel ⇒ HrrRbSsh::Connection::Channel
Expose a Channel from the Connection.
- #cid ⇒ Object
- #cid=(chan_id) ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#fd_rd ⇒ IO
Provide a selectable filedescriptor open for reading.
-
#fd_wr(fd = :stdout) ⇒ IO
Provide a selectable filedescriptor open for writing.
-
#initialize(parent, chan_id = nil) ⇒ ChannelFD
constructor
A new instance of ChannelFD.
- #inspect ⇒ Object
Methods included from IOMergeAbstraction
#has_read_data?, #read, #write
Constructor Details
#initialize(parent, chan_id = nil) ⇒ ChannelFD
Returns a new instance of ChannelFD.
270 271 272 |
# File 'lib/rex/proto/ssh/connection.rb', line 270 def initialize(parent, chan_id = nil) @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
301 302 303 |
# File 'lib/rex/proto/ssh/connection.rb', line 301 def parent @parent end |
Instance Method Details
#channel ⇒ HrrRbSsh::Connection::Channel
Expose a Channel from the Connection
333 334 335 |
# File 'lib/rex/proto/ssh/connection.rb', line 333 def channel @parent.connection.channels[cid] end |
#cid ⇒ Object
287 288 289 290 291 292 |
# File 'lib/rex/proto/ssh/connection.rb', line 287 def cid if @cid.nil? @cid = @parent.connection.open_channel_keys.first end @cid end |
#cid=(chan_id) ⇒ Object
294 295 296 297 298 299 300 |
# File 'lib/rex/proto/ssh/connection.rb', line 294 def cid=(chan_id) if @parent.connection.open_channel_keys.include?(chan_id) @cid = chan_id else raise "Invalid Channel ID passed to #{self.inspect}" end end |
#close ⇒ Object
278 279 280 281 |
# File 'lib/rex/proto/ssh/connection.rb', line 278 def close super @parent.close unless @parent.closed? end |
#closed? ⇒ Boolean
283 284 285 |
# File 'lib/rex/proto/ssh/connection.rb', line 283 def closed? super and @parent.closed? end |
#fd_rd ⇒ IO
Provide a selectable filedescriptor open for reading
309 310 311 312 313 314 |
# File 'lib/rex/proto/ssh/connection.rb', line 309 def fd_rd begin channel.io[0] rescue end end |
#fd_wr(fd = :stdout) ⇒ IO
Provide a selectable filedescriptor open for writing
322 323 324 325 326 327 |
# File 'lib/rex/proto/ssh/connection.rb', line 322 def fd_wr(fd = :stdout) begin channel.io[(fd == :stderr ? 2 : 1)] rescue end end |
#inspect ⇒ Object
274 275 276 |
# File 'lib/rex/proto/ssh/connection.rb', line 274 def inspect "#{super}/#{@parent.inspect}" end |