Class: Krakow::ConnectionFeatures::Ssl::Io
- Inherits:
-
Object
- Object
- Krakow::ConnectionFeatures::Ssl::Io
- Defined in:
- lib/krakow/connection_features/ssl.rb
Overview
SSL-able IO
Instance Attribute Summary collapse
-
#_socket ⇒ Object
readonly
Returns the value of attribute _socket.
Instance Method Summary collapse
-
#initialize(io, args = {}) ⇒ Io
constructor
Create new SSL-able IO.
-
#method_missing(*args) ⇒ Object
Proxy to underlying socket.
-
#recv(len) ⇒ String
Receive bytes from the IO.
Constructor Details
#initialize(io, args = {}) ⇒ Io
Create new SSL-able IO
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/krakow/connection_features/ssl.rb', line 19 def initialize(io, args={}) ssl_socket_arguments = [io] if(args[:ssl_context]) validate_ssl_args!(args[:ssl_context]) context = OpenSSL::SSL::SSLContext.new context.cert = OpenSSL::X509::Certificate.new(File.open(args[:ssl_context][:certificate])) context.key = OpenSSL::PKey::RSA.new(File.open(args[:ssl_context][:key])) ssl_socket_arguments << context end @_socket = Celluloid::IO::SSLSocket.new(*ssl_socket_arguments) _socket.sync = true _socket.connect end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
Proxy to underlying socket
37 38 39 |
# File 'lib/krakow/connection_features/ssl.rb', line 37 def method_missing(*args) _socket.send(*args) end |
Instance Attribute Details
#_socket ⇒ Object (readonly)
Returns the value of attribute _socket.
11 12 13 |
# File 'lib/krakow/connection_features/ssl.rb', line 11 def _socket @_socket end |
Instance Method Details
#recv(len) ⇒ String
Receive bytes from the IO
45 46 47 48 49 50 51 |
# File 'lib/krakow/connection_features/ssl.rb', line 45 def recv(len) str = readpartial(len) if(len > str.length) str << sysread(len - str.length) end str end |