Class: Async::IO::SSLEndpoint
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Endpoint
#accept, #bound, composite, #connected, each, #linger, #local_address, parse, #reuse_address, #reuse_port, socket, ssl, tcp, #timeout, try_convert, udp, unix, #with
Constructor Details
#initialize(endpoint, **options) ⇒ SSLEndpoint
Returns a new instance of SSLEndpoint.
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/async/io/ssl_endpoint.rb', line 13
def initialize(endpoint, **options)
super(**options)
@endpoint = endpoint
if ssl_context = options[:ssl_context]
@context = build_context(ssl_context)
else
@context = nil
end
end
|
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
37
38
39
|
# File 'lib/async/io/ssl_endpoint.rb', line 37
def endpoint
@endpoint
end
|
#options ⇒ Object
Returns the value of attribute options.
38
39
40
|
# File 'lib/async/io/ssl_endpoint.rb', line 38
def options
@options
end
|
Instance Method Details
#address ⇒ Object
29
30
31
|
# File 'lib/async/io/ssl_endpoint.rb', line 29
def address
@endpoint.address
end
|
#bind {|Socket| ... } ⇒ Socket
Connect to the underlying endpoint and establish a SSL connection.
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/async/io/ssl_endpoint.rb', line 62
def bind
if block_given?
@endpoint.bind do |server|
yield SSLServer.new(server, context)
end
else
@endpoint.bind.map do |server|
SSLServer.new(server, context)
end
end
end
|
#build_context(context = OpenSSL::SSL::SSLContext.new) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/async/io/ssl_endpoint.rb', line 44
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 {|Socket| ... } ⇒ Socket
Connect to the underlying endpoint and establish a SSL connection.
77
78
79
|
# File 'lib/async/io/ssl_endpoint.rb', line 77
def connect(&block)
SSLSocket.connect(@endpoint.connect, context, hostname, &block)
end
|
#context ⇒ Object
55
56
57
|
# File 'lib/async/io/ssl_endpoint.rb', line 55
def context
@context ||= build_context
end
|
#each ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/async/io/ssl_endpoint.rb', line 81
def each
return to_enum unless block_given?
@endpoint.each do |endpoint|
yield self.class.new(endpoint, **@options)
end
end
|
#hostname ⇒ Object
33
34
35
|
# File 'lib/async/io/ssl_endpoint.rb', line 33
def hostname
@options[:hostname] || @endpoint.hostname
end
|
#params ⇒ Object
40
41
42
|
# File 'lib/async/io/ssl_endpoint.rb', line 40
def params
@options[:ssl_params]
end
|
#to_s ⇒ Object
25
26
27
|
# File 'lib/async/io/ssl_endpoint.rb', line 25
def to_s
"\#<#{self.class} #{@endpoint}>"
end
|