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.
254 255 256 |
# File 'lib/rex/proto/ssh/connection.rb', line 254 def initialize(parent, chan_id = nil) @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
285 286 287 |
# File 'lib/rex/proto/ssh/connection.rb', line 285 def parent @parent end |
Instance Method Details
#channel ⇒ HrrRbSsh::Connection::Channel
Expose a Channel from the Connection
319 320 321 |
# File 'lib/rex/proto/ssh/connection.rb', line 319 def channel @parent.connection.channels[cid] end |
#cid ⇒ Object
271 272 273 274 275 276 |
# File 'lib/rex/proto/ssh/connection.rb', line 271 def cid if @cid.nil? @cid = @parent.connection.open_channel_keys.first end @cid end |
#cid=(chan_id) ⇒ Object
278 279 280 281 282 283 284 |
# File 'lib/rex/proto/ssh/connection.rb', line 278 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
262 263 264 265 |
# File 'lib/rex/proto/ssh/connection.rb', line 262 def close super @parent.close unless @parent.closed? end |
#closed? ⇒ Boolean
267 268 269 |
# File 'lib/rex/proto/ssh/connection.rb', line 267 def closed? super and @parent.closed? end |
#fd_rd ⇒ IO
Provide a selectable filedescriptor open for reading
293 294 295 296 297 298 299 |
# File 'lib/rex/proto/ssh/connection.rb', line 293 def fd_rd begin channel.io[0] rescue => e elog(e) end end |
#fd_wr(fd = :stdout) ⇒ IO
Provide a selectable filedescriptor open for writing
307 308 309 310 311 312 313 |
# File 'lib/rex/proto/ssh/connection.rb', line 307 def fd_wr(fd = :stdout) begin channel.io[(fd == :stderr ? 2 : 1)] rescue => e elog(e) end end |
#inspect ⇒ Object
258 259 260 |
# File 'lib/rex/proto/ssh/connection.rb', line 258 def inspect "#{super}/#{@parent.inspect}" end |