module SSLScan::Socket::TcpServer

This class provides methods for interacting with a TCP server. It implements the SSLScan::IO::StreamServer interface.

Public Class Methods

create(hash = {}) click to toggle source

Creates the server using the supplied hash.

# File lib/ssl_scan/socket/tcp_server.rb, line 22
def self.create(hash = {})
  hash['Proto'] = 'tcp'
  hash['Server'] = true
  self.create_param(SSLScan::Socket::Parameters.from_hash(hash))
end
create_param(param) click to toggle source

Wrapper around the base class' creation method that automatically sets the parameter's protocol to TCP and sets the server flag to true.

# File lib/ssl_scan/socket/tcp_server.rb, line 32
def self.create_param(param)
  param.proto  = 'tcp'
  param.server = true
  SSLScan::Socket.create_param(param)
end

Public Instance Methods

accept(opts = {}) click to toggle source

Accepts a child connection.

Calls superclass method
# File lib/ssl_scan/socket/tcp_server.rb, line 41
def accept(opts = {})
  t = super()

  # jRuby compatibility
  if t.respond_to?('[]')
    t = t[0]
  end

  if (t)
    t.extend(SSLScan::Socket::Tcp)
    t.context = self.context

    pn = t.getpeername

    t.peerhost = pn[1]
    t.peerport = pn[2]
  end

  t
end