Module: Rex::IO::SocketAbstraction
- Included in:
- DatagramAbstraction, StreamAbstraction
- Defined in:
- lib/rex/io/socket_abstraction.rb
Overview
This class provides an abstraction to a stream based connection through the use of a streaming socketpair.
Defined Under Namespace
Modules: Ext
Instance Attribute Summary collapse
-
#lsock ⇒ Object
readonly
The left side of the stream.
-
#rsock ⇒ Object
readonly
The right side of the stream.
Instance Method Summary collapse
-
#cleanup_abstraction ⇒ Object
This method cleans up the abstraction layer.
-
#close ⇒ Object
Closes both sides of the stream abstraction.
-
#initialize_abstraction ⇒ Object
Override this method to init the abstraction.
-
#localinfo ⇒ Object
Symbolic local information.
-
#peerinfo ⇒ Object
Symbolic peer information.
-
#shutdown(how) ⇒ Object
Shuts down the local side of the stream abstraction.
-
#sysread(length) ⇒ Object
Low-level read from the local side.
-
#syswrite(buffer) ⇒ Object
Low-level write to the local side.
Instance Attribute Details
#lsock ⇒ Object
The left side of the stream.
113 114 115 |
# File 'lib/rex/io/socket_abstraction.rb', line 113 def lsock @lsock end |
#rsock ⇒ Object
The right side of the stream.
117 118 119 |
# File 'lib/rex/io/socket_abstraction.rb', line 117 def rsock @rsock end |
Instance Method Details
#cleanup_abstraction ⇒ Object
This method cleans up the abstraction layer.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rex/io/socket_abstraction.rb', line 56 def cleanup_abstraction lsock.close if lsock and !lsock.closed? monitor_thread.join if monitor_thread&.alive? && monitor_thread&.object_id != Thread.current.object_id rsock.close if rsock and !rsock.closed? self.lsock = nil self.rsock = nil end |
#close ⇒ Object
Closes both sides of the stream abstraction.
91 92 93 94 |
# File 'lib/rex/io/socket_abstraction.rb', line 91 def close cleanup_abstraction super end |
#initialize_abstraction ⇒ Object
Override this method to init the abstraction
49 50 51 |
# File 'lib/rex/io/socket_abstraction.rb', line 49 def initialize_abstraction self.lsock, self.rsock = Rex::Compat.pipe end |
#localinfo ⇒ Object
Symbolic local information.
106 107 108 |
# File 'lib/rex/io/socket_abstraction.rb', line 106 def localinfo 'Local-side of Pipe' end |
#peerinfo ⇒ Object
Symbolic peer information.
99 100 101 |
# File 'lib/rex/io/socket_abstraction.rb', line 99 def peerinfo 'Remote-side of Pipe' end |
#shutdown(how) ⇒ Object
Shuts down the local side of the stream abstraction.
84 85 86 |
# File 'lib/rex/io/socket_abstraction.rb', line 84 def shutdown(how) lsock.shutdown(how) end |
#sysread(length) ⇒ Object
Low-level read from the local side.
77 78 79 |
# File 'lib/rex/io/socket_abstraction.rb', line 77 def sysread(length) lsock.sysread(length) end |
#syswrite(buffer) ⇒ Object
Low-level write to the local side.
70 71 72 |
# File 'lib/rex/io/socket_abstraction.rb', line 70 def syswrite(buffer) lsock.syswrite(buffer) end |