Module: Ronin::Network::Mixins::UNIX
Overview
Adds UNIX Socket convenience methods and connection parameters to a class.
Defines the following parameters:
path
(String
) - UNIX Socket path.
Class Method Summary collapse
-
.path ⇒ Object
UNIX path.
-
.path=(value) ⇒ Object
UNIX path.
Instance Method Summary collapse
-
#path ⇒ Object
UNIX path.
-
#path=(value) ⇒ Object
UNIX path.
-
#unix_accept {|client| ... } ⇒ Object
protected
Opens a UNIX socket specified by the
path
parameter, accepts a connection, then closes the socket. -
#unix_connect {|socket| ... } ⇒ UNIXSocket
protected
Connects to a UNIX socket specified by the
path
parameter. -
#unix_connect_and_send(data) {|socket| ... } ⇒ UNIXSocket
protected
Creates a new UNIXSocket object, connected to the
path
parameter. -
#unix_send(data) ⇒ true
protected
Connects to the UNIX socket, specified by the
path
parameter, sends the given data and then disconnects. -
#unix_server {|server| ... } ⇒ UNIXServer
protected
Opens a UNIX socket, listening on the
path
parameter. -
#unix_server_loop {|client| ... } ⇒ Object
protected
Opens a UNIX socket specified by the
path
parameter, accepts connections in a loop. -
#unix_server_session {|server| ... } ⇒ nil
protected
Opens a UNIX socket temporarily, listening on the
path
parameter. -
#unix_session {|socket| ... } ⇒ Object
protected
Creates a UNIX session to the host and port specified by the
host
andport
parameters.
Methods included from Mixin
Methods included from UNIX
Class Method Details
Instance Method Details
#path ⇒ Object
UNIX path
40 41 |
# File 'lib/ronin/network/mixins/unix.rb', line 40 parameter :path, :type => String, :description => 'UNIX Socket path' |
#path=(value) ⇒ Object
UNIX path
40 41 |
# File 'lib/ronin/network/mixins/unix.rb', line 40 parameter :path, :type => String, :description => 'UNIX Socket path' |
#unix_accept {|client| ... } ⇒ Object (protected)
Opens a UNIX socket specified by the path
parameter,
accepts a connection, then closes the socket.
228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/ronin/network/mixins/unix.rb', line 228 def unix_accept print_info "Listening on #{self.path} ..." super(self.path) do |client| print_info "Client connected to #{self.path}" yield client if block_given? print_info "Client disconnecting from #{self.path} ..." end print_info "Closed #{self.path}" return nil end |
#unix_connect {|socket| ... } ⇒ UNIXSocket (protected)
Connects to a UNIX socket specified by the path
parameter.
64 65 66 67 68 |
# File 'lib/ronin/network/mixins/unix.rb', line 64 def unix_connect(&block) print_info "Connecting to #{self.path} ..." super(self.path,&block) end |
#unix_connect_and_send(data) {|socket| ... } ⇒ UNIXSocket (protected)
Creates a new UNIXSocket object, connected to the path
parameter.
The given data will then be written to the newly created UNIXSocket.
90 91 92 93 94 95 |
# File 'lib/ronin/network/mixins/unix.rb', line 90 def unix_connect_and_send(data,&block) print_info "Connecting to #{self.path} ..." print_debug "Sending data: #{data.inspect}" return super(data,self.path,&block) end |
#unix_send(data) ⇒ true (protected)
Connects to the UNIX socket, specified by the path
parameter,
sends the given data and then disconnects.
144 145 146 147 148 149 150 151 152 |
# File 'lib/ronin/network/mixins/unix.rb', line 144 def unix_send(data) print_info "Connecting to #{self.path} ..." print_debug "Sending data: #{data.inspect}" super(data,self.path,&block) print_info "Disconnected from #{self.path}" return true end |
#unix_server {|server| ... } ⇒ UNIXServer (protected)
Opens a UNIX socket, listening on the path
parameter.
173 174 175 176 177 |
# File 'lib/ronin/network/mixins/unix.rb', line 173 def unix_server(&block) print_info "Listening on #{self.path} ..." return super(self.path,&block) end |
#unix_server_loop {|client| ... } ⇒ Object (protected)
Opens a UNIX socket specified by the path
parameter,
accepts connections in a loop.
262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/ronin/network/mixins/unix.rb', line 262 def unix_server_loop print_info "Listening on #{self.path} ..." super(self.path) do |client| print_info "Client connected: #{self.path}" yield client if block_given? print_info "Client disconnecting: #{self.path} ..." end print_info "Closed #{self.path}" return nil end |
#unix_server_session {|server| ... } ⇒ nil (protected)
Opens a UNIX socket temporarily, listening on the path
parameter.
200 201 202 203 204 205 206 207 |
# File 'lib/ronin/network/mixins/unix.rb', line 200 def unix_server_session(&block) print_info "Listening on #{self.path} ..." super(self.path,&block) print_info "Closed #{self.path}" return nil end |
#unix_session {|socket| ... } ⇒ Object (protected)
Creates a UNIX session to the host and port specified by the
host
and port
parameters. If the local_host
and local_port
parameters are set, they will be used for the local host and port
of the UNIX connection.
114 115 116 117 118 119 120 121 |
# File 'lib/ronin/network/mixins/unix.rb', line 114 def unix_session(&block) print_info "Connecting to #{self.path} ..." super(self.host,&block) print_info "Disconnected from #{self.path}" return nil end |