Class: Async::IO::SSLEndpoint
- Defined in:
- lib/async/io/ssl_endpoint.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#bind {|Socket| ... } ⇒ Socket
Connect to the underlying endpoint and establish a SSL connection.
- #build_context(context = ::OpenSSL::SSL::SSLContext.new) ⇒ Object
-
#connect {|Socket| ... } ⇒ Socket
Connect to the underlying endpoint and establish a SSL connection.
- #context ⇒ Object
- #each ⇒ Object
- #hostname ⇒ Object
-
#initialize(endpoint, **options) ⇒ SSLEndpoint
constructor
A new instance of SSLEndpoint.
- #params ⇒ Object
- #to_s ⇒ Object
Methods inherited from Endpoint
#accept, each, parse, #reuse_port, socket, ssl, tcp, #timeout, try_convert, udp, unix
Constructor Details
#initialize(endpoint, **options) ⇒ SSLEndpoint
Returns a new instance of SSLEndpoint.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/async/io/ssl_endpoint.rb', line 27 def initialize(endpoint, **) super(**) @endpoint = endpoint if ssl_context = [:ssl_context] @context = build_context(ssl_context) else @context = nil end end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
47 48 49 |
# File 'lib/async/io/ssl_endpoint.rb', line 47 def endpoint @endpoint end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
48 49 50 |
# File 'lib/async/io/ssl_endpoint.rb', line 48 def @options end |
Instance Method Details
#bind {|Socket| ... } ⇒ Socket
Connect to the underlying endpoint and establish a SSL connection.
72 73 74 75 76 77 78 79 80 |
# File 'lib/async/io/ssl_endpoint.rb', line 72 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) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/async/io/ssl_endpoint.rb', line 54 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.
85 86 87 |
# File 'lib/async/io/ssl_endpoint.rb', line 85 def connect(&block) SSLSocket.connect(@endpoint.connect, context, hostname, &block) end |
#context ⇒ Object
65 66 67 |
# File 'lib/async/io/ssl_endpoint.rb', line 65 def context @context ||= build_context end |
#each ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/async/io/ssl_endpoint.rb', line 89 def each return to_enum unless block_given? @endpoint.each do |endpoint| yield self.class.new(endpoint, @options) end end |
#hostname ⇒ Object
43 44 45 |
# File 'lib/async/io/ssl_endpoint.rb', line 43 def hostname @options[:hostname] || @endpoint.hostname end |
#params ⇒ Object
50 51 52 |
# File 'lib/async/io/ssl_endpoint.rb', line 50 def params @options[:ssl_params] end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/async/io/ssl_endpoint.rb', line 39 def to_s "\#<#{self.class} #{@endpoint}>" end |