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



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

def address
  specification.address
end

#bind(&block) ⇒ Object



183
184
185
186
187
# File 'lib/async/io/endpoint.rb', line 183

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

#connect(&block) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/async/io/endpoint.rb', line 189

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



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/async/io/endpoint.rb', line 166

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



158
159
160
# File 'lib/async/io/endpoint.rb', line 158

def hostname
  options[:hostname]
end

#paramsObject



162
163
164
# File 'lib/async/io/endpoint.rb', line 162

def params
  options[:ssl_params]
end