class RaptorIO::Socket::TCPServer::SSL

TCP server with SSL encryption.

@author Tasos Laskos <tasos_laskos@rapid7.com>

Public Class Methods

new( socket, options = {} ) click to toggle source
Calls superclass method RaptorIO::Socket::new
# File lib/raptor-io/socket/tcp_server/ssl.rb, line 6
def initialize( socket, options = {} )
  #p options[:context].frozen?
  super
  #p options[:context].frozen?

  @context = options[:context]
  if @context.nil?
    @context = OpenSSL::SSL::SSLContext.new( options[:ssl_version] )
    @context.verify_mode = options[:verify_mode]
  end

  @plaintext_socket = socket
  @socket = OpenSSL::SSL::SSLServer.new( socket, @context )
end

Public Instance Methods

accept() click to toggle source

Accepts a client connection.

@see Socket::TCP::SSL.from_openssl @return [RaptorIO::Socket::TCP::SSL]

# File lib/raptor-io/socket/tcp_server/ssl.rb, line 25
def accept
  RaptorIO::Socket::TCP::SSL.from_openssl(@socket.accept)
end
accept_nonblock() click to toggle source

Accepts a client connection without blocking.

@see Socket::TCP::SSL.from_openssl @return [RaptorIO::Socket::TCP::SSL] @raise [IO::WaitWritable]

# File lib/raptor-io/socket/tcp_server/ssl.rb, line 34
def accept_nonblock
  RaptorIO::Socket::TCP::SSL.from_openssl(@socket.accept_nonblock)
end
close() click to toggle source

Close this SSL stream and the underlying socket

@return [void]

# File lib/raptor-io/socket/tcp_server/ssl.rb, line 41
def close
  begin
    @socket.close
  ensure
    if (!@plaintext_socket.closed?)
      @plaintext_socket.close
    end
  end
end