module SSLScan::Socket::Comm
This mixin provides the basic interface that a derived class must implement in order to be a compatible comm class. The base comm class also supports registering event handlers that can be notified when sockets are being created and have been created. This allows code to extend sockets on creation from the single point that they are created.
Public Class Methods
Creates a compatible socket based on the supplied uniform parameters.
# File lib/ssl_scan/socket/comm.rb, line 46 def self.create(param) raise NotImplementedError end
Public Instance Methods
Indicates whether or not this comm can be chained with other chainable comms. This is particularly important for things like Proxy Comms that can be proxied through one another. The semantics of this are currently undefined and will probably need some more thought.
# File lib/ssl_scan/socket/comm.rb, line 56 def chainable? false end
Deregisters a previously registered event handler.
# File lib/ssl_scan/socket/comm.rb, line 76 def deregister_event_handler(handler) if (handlers) handlers.delete(handler) end end
Enumerates each registered event handler so that they can be notified of an event.
# File lib/ssl_scan/socket/comm.rb, line 86 def each_event_handler(&block) if (handlers) handlers.each(&block) end end
Notifies handlers of the before socket create event.
# File lib/ssl_scan/socket/comm.rb, line 95 def notify_before_socket_create(comm, param) each_event_handler() { |handler| handler.on_before_socket_create(comm, param) } end
Notifies handlers of the socket created event.
# File lib/ssl_scan/socket/comm.rb, line 104 def notify_socket_created(comm, sock, param) each_event_handler() { |handler| handler.on_socket_created(comm, sock, param) } end
Registers an event handler that implements the SSLScan::Socket::Comm::Event interface in at least some fashion. Event handlers are notified when sockets are created through the Comm
instance that they register against.
# File lib/ssl_scan/socket/comm.rb, line 65 def register_event_handler(handler) if (handlers == nil) self.handlers = [] end self.handlers << handler end