Sha256: ea84b77a62ad29aa05ca5eb1353e9e1e48c5419bb11a012301ee6781d496d431

Contents?: true

Size: 860 Bytes

Versions: 3

Compression:

Stored size: 860 Bytes

Contents

require 'socket'

module Celluloid
  module IO
    # SSLServer wraps a TCPServer to provide immediate SSL accept
    class SSLServer
      extend Forwardable
      def_delegators :@tcp_server, :listen, :shutdown, :close, :closed?, :to_io, :evented?

      attr_accessor :start_immediately
      attr_reader :tcp_server

      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

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
celluloid-io-0.13.1 lib/celluloid/io/ssl_server.rb
celluloid-io-0.13.0 lib/celluloid/io/ssl_server.rb
celluloid-io-0.13.0.pre2 lib/celluloid/io/ssl_server.rb