class Async::IO::SSLEndpoint

Attributes

endpoint[R]
options[R]

Public Class Methods

new(endpoint, **options) click to toggle source
Calls superclass method Async::IO::Endpoint::new
# File lib/async/io/ssl_endpoint.rb, line 29
def initialize(endpoint, **options)
        super(**options)
        
        @endpoint = endpoint
        
        if ssl_context = options[:ssl_context]
                @context = build_context(ssl_context)
        else
                @context = nil
        end
end

Public Instance Methods

address() click to toggle source
# File lib/async/io/ssl_endpoint.rb, line 45
def address
        @endpoint.address
end
bind() { |ssl_server| ... } click to toggle source

Connect to the underlying endpoint and establish a SSL connection. @yield [Socket] the socket which is being connected @return [Socket] the connected socket

# File lib/async/io/ssl_endpoint.rb, line 78
def bind
        if block_given?
                @endpoint.bind do |server|
                        yield SSLServer.new(server, context)
                end
        else
                return SSLServer.new(@endpoint.bind, context)
        end
end
build_context(context = OpenSSL::SSL::SSLContext.new) click to toggle source
# File lib/async/io/ssl_endpoint.rb, line 60
def build_context(context = OpenSSL::SSL::SSLContext.new)
        if params = self.params
                context.set_params(params)
        end
        
        context.setup
        context.freeze
        
        return context
end
connect(&block) click to toggle source

Connect to the underlying endpoint and establish a SSL connection. @yield [Socket] the socket which is being connected @return [Socket] the connected socket

# File lib/async/io/ssl_endpoint.rb, line 91
def connect(&block)
        SSLSocket.connect(@endpoint.connect, context, hostname, &block)
end
context() click to toggle source
# File lib/async/io/ssl_endpoint.rb, line 71
def context
        @context ||= build_context
end
each() { |class.new(endpoint, **options)| ... } click to toggle source
# File lib/async/io/ssl_endpoint.rb, line 95
def each
        return to_enum unless block_given?
        
        @endpoint.each do |endpoint|
                yield self.class.new(endpoint, **@options)
        end
end
hostname() click to toggle source
# File lib/async/io/ssl_endpoint.rb, line 49
def hostname
        @options[:hostname] || @endpoint.hostname
end
params() click to toggle source
# File lib/async/io/ssl_endpoint.rb, line 56
def params
        @options[:ssl_params]
end
to_s() click to toggle source
# File lib/async/io/ssl_endpoint.rb, line 41
def to_s
        "\#<#{self.class} #{@endpoint}>"
end