SSL — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::Socket::SSLPrivate

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Wrapper for TLS sockets.

Constant Summary

Constants inherited from Mongo::Socket

SSL_ERROR, TIMEOUT_ERROR, TIMEOUT_PACK, WRITE_CHUNK_SIZE

Instance Attribute Summary collapse

Attributes inherited from Mongo::Socket

#family, #options, #socket, #timeout

Instance Method Summarycollapse

Methods inherited from Mongo::Socket

#alive?, #close, #connectable?, #connection_address, #connection_generation, #eof?, #gets, #monitor?, #read, #summary, #write

Constructor Details

#initialize(host, port, host_name, timeout, family, options = {}) ⇒ SSL

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes a new TLS socket.

103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 # File 'lib/mongo/socket/ssl.rb', line 103 def initialize(host, port, host_name, timeout, family, options = {}) super(timeout, options) @host, @port, @host_name = host, port, host_name @context = create_context(options) @family = family @tcp_socket = ::Socket.new(family, SOCK_STREAM, 0) begin @tcp_socket.setsockopt(IPPROTO_TCP, TCP_NODELAY, 1) set_socket_options(@tcp_socket) run_tls_context_hooks connect! rescue @tcp_socket.close raise end end

Instance Attribute Details

#context ⇒ SSLContext

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns context The TLS context.

122 123 124 # File 'lib/mongo/socket/ssl.rb', line 122 def context @context end

#host ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns host The host to connect to.

125 126 127 # File 'lib/mongo/socket/ssl.rb', line 125 def host @host end

#host_name ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns host_name The original host name.

128 129 130 # File 'lib/mongo/socket/ssl.rb', line 128 def host_name @host_name end

#port ⇒ Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns port The port to connect to.

131 132 133 # File 'lib/mongo/socket/ssl.rb', line 131 def port @port end

Instance Method Details

#readbyte ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Read a single byte from the socket.

187 188 189 190 191 192 # File 'lib/mongo/socket/ssl.rb', line 187 def readbyte map_exceptions do byte = socket.read(1).bytes.to_a[0] byte.nil? ? raise(EOFError) : byte end end