Class: Async::IO::SecureEndpoint

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/async/io/endpoint.rb

Instance Attribute Summary

Attributes inherited from Endpoint

#options, #specification

Instance Method Summary collapse

Methods inherited from Endpoint

#accept, each, #initialize, parse, #socket_domain, #socket_protocol, #socket_type, ssl, tcp, #to_sockaddr, udp, unix

Constructor Details

This class inherits a constructor from Async::IO::Endpoint

Instance Method Details

#addressObject



146
147
148
# File 'lib/async/io/endpoint.rb', line 146

def address
  specification.address
end

#bind(&block) ⇒ Object



175
176
177
178
179
# File 'lib/async/io/endpoint.rb', line 175

def bind(&block)
  specification.bind do |server|
    yield SSLServer.new(server, context)
  end
end

#connect(&block) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/async/io/endpoint.rb', line 181

def connect(&block)
  specification.connect do |socket|
    ssl_socket = SSLSocket.connect_socket(socket, context)
    
    # Used for SNI:
    if hostname = self.hostname
      ssl_socket.hostname = hostname
    end
    
    ssl_socket.connect
    
    yield ssl_socket
  end
end

#contextObject



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/async/io/endpoint.rb', line 158

def context
  if context = options[:ssl_context]
    if params = self.params
      context = context.dup
      context.set_params(params)
    end
  else
    context = ::OpenSSL::SSL::SSLContext.new
    
    if params = self.params
      context.set_params(params)
    end
  end
  
  return context
end

#hostnameObject



150
151
152
# File 'lib/async/io/endpoint.rb', line 150

def hostname
  options[:hostname]
end

#paramsObject



154
155
156
# File 'lib/async/io/endpoint.rb', line 154

def params
  options[:ssl_params]
end