2005-05-31 12:56:36 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'socket'
|
|
|
|
|
|
|
|
module Rex
|
|
|
|
module IO
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# StreamAbstraction
|
|
|
|
# -----------------
|
|
|
|
#
|
|
|
|
# This class provides an abstraction to a stream based
|
|
|
|
# connection through the use of a streaming socketpair.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
module StreamAbstraction
|
|
|
|
|
2005-07-19 04:21:15 +00:00
|
|
|
#
|
2005-05-31 12:56:36 +00:00
|
|
|
# Creates a streaming socket pair
|
2005-07-19 04:21:15 +00:00
|
|
|
#
|
2005-05-31 12:56:36 +00:00
|
|
|
def initialize_abstraction
|
|
|
|
self.lsock, self.rsock = ::Socket.pair(::Socket::AF_UNIX,
|
|
|
|
::Socket::SOCK_STREAM, 0)
|
|
|
|
end
|
|
|
|
|
2005-07-26 04:08:01 +00:00
|
|
|
#
|
|
|
|
# Cleans up the abstraction layer
|
|
|
|
#
|
|
|
|
def cleanup_abstraction
|
|
|
|
self.lsock.close if (self.lsock)
|
|
|
|
self.rsock.close if (self.rsock)
|
|
|
|
|
|
|
|
self.lsock = nil
|
|
|
|
self.rsock = nil
|
|
|
|
end
|
|
|
|
|
2005-05-31 12:56:36 +00:00
|
|
|
attr_reader :lsock, :rsock
|
|
|
|
protected
|
|
|
|
attr_writer :lsock, :rsock
|
|
|
|
end
|
|
|
|
|
|
|
|
end; end
|