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

Returns a new instance of SSLServer.



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

def initialize(server, ctx)
  @tcp_server = Socket.try_convert(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



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/celluloid/io/ssl_server.rb', line 19

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