Sha256: a2989eb1d6121285c3542775f2811e5566424246447070c86e5cedf1f2be87d0

Contents?: true

Size: 849 Bytes

Versions: 14

Compression:

Stored size: 849 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

      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

14 entries across 14 versions & 1 rubygems

Version Path
celluloid-io-0.17.1 lib/celluloid/io/ssl_server.rb
celluloid-io-0.17.0 lib/celluloid/io/ssl_server.rb
celluloid-io-0.16.5.pre0 lib/celluloid/io/ssl_server.rb
celluloid-io-0.16.2 lib/celluloid/io/ssl_server.rb
celluloid-io-0.16.1 lib/celluloid/io/ssl_server.rb
celluloid-io-0.16.0 lib/celluloid/io/ssl_server.rb
celluloid-io-0.16.0.pre2 lib/celluloid/io/ssl_server.rb
celluloid-io-0.16.0.pre lib/celluloid/io/ssl_server.rb
celluloid-io-0.15.0 lib/celluloid/io/ssl_server.rb
celluloid-io-0.15.0.pre2 lib/celluloid/io/ssl_server.rb
celluloid-io-0.15.0.pre lib/celluloid/io/ssl_server.rb
celluloid-io-0.14.1 lib/celluloid/io/ssl_server.rb
celluloid-io-0.14.0 lib/celluloid/io/ssl_server.rb
celluloid-io-0.14.0.pre lib/celluloid/io/ssl_server.rb