class Rex::Ui::Text::Input::Buffer

This class implements input against a socket.

Public Class Methods

new() click to toggle source
# File lib/rex/ui/text/input/buffer.rb, line 23
def initialize
  @sock = BufferSock.new
  @sock.initialize_abstraction
end

Public Instance Methods

close() click to toggle source
# File lib/rex/ui/text/input/buffer.rb, line 28
def close
  @sock.cleanup_abstraction
end
eof?() click to toggle source

Returns whether or not EOF has been reached on stdin.

# File lib/rex/ui/text/input/buffer.rb, line 64
def eof?
  @sock.lsock.closed?
end
fd() click to toggle source

Returns the file descriptor associated with a socket.

# File lib/rex/ui/text/input/buffer.rb, line 71
def fd
  return @sock.rsock
end
gets() click to toggle source

Wait for a line of input to be read from a socket.

# File lib/rex/ui/text/input/buffer.rb, line 43
def gets
  # Initialize the line buffer
  line = ''

  # Read data one byte at a time until we see a LF
  while (true)
    break if line.include?("\n")

    # Read another character of input
    char = @sock.rsock.getc

    # Append this character to the string
    line << char
  end

  return line
end
put(msg, opts={}) click to toggle source
# File lib/rex/ui/text/input/buffer.rb, line 36
def put(msg, opts={})
  @sock.lsock.write(msg)
end
sysread(len = 1) click to toggle source
# File lib/rex/ui/text/input/buffer.rb, line 32
def sysread(len = 1)
  @sock.rsock.sysread(len)
end