Class: Celluloid::IO::SSLServer

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/celluloid/io/ssl_server.rb

Overview

SSLServer wraps a TCPServer to provide immediate SSL accept

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, ctx) ⇒ SSLServer


13
14
15
16
17
18
19
20
# File 'lib/celluloid/io/ssl_server.rb', line 13

def initialize(server, ctx)
  if server.is_a?(::TCPServer)
    server = Celluloid::IO::TCPServer.from_ruby_server(server)
  end
  @tcp_server = server
  @ctx = ctx
  @start_immediately = true
end

Instance Attribute Details

#start_immediatelyObject

Returns the value of attribute start_immediately


10
11
12
# File 'lib/celluloid/io/ssl_server.rb', line 10

def start_immediately
  @start_immediately
end

#tcp_serverObject (readonly)

Returns the value of attribute tcp_server


11
12
13
# File 'lib/celluloid/io/ssl_server.rb', line 11

def tcp_server
  @tcp_server
end

Instance Method Details

#acceptObject


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/celluloid/io/ssl_server.rb', line 22

def accept
  sock = @tcp_server.accept
  begin
    ssl = Celluloid::IO::SSLSocket.new(sock, @ctx)
    ssl.accept if @start_immediately
    ssl
  rescue OpenSSL::SSL::SSLError
    sock.close
    raise
  end
end