Class: Openas2::Remote::Connection
- Inherits:
-
Object
- Object
- Openas2::Remote::Connection
- Defined in:
- lib/openas2/remote/connection.rb
Instance Attribute Summary collapse
-
#socket ⇒ Object
Returns the value of attribute socket.
-
#ssl_context ⇒ Object
Returns the value of attribute ssl_context.
-
#ssl_socket ⇒ Object
Returns the value of attribute ssl_socket.
Instance Method Summary collapse
- #close ⇒ Object
- #connect ⇒ Object
- #gets ⇒ Object
-
#initialize(host = 'localhost', port = 4321, ciphers = []) ⇒ Connection
constructor
A new instance of Connection.
- #puts(s) ⇒ Object
- #readlines ⇒ Object
Constructor Details
#initialize(host = 'localhost', port = 4321, ciphers = []) ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/openas2/remote/connection.rb', line 10 def initialize(host='localhost', port=4321, ciphers=[]) @socket = TCPSocket.new(host, port) @ssl_context = OpenSSL::SSL::SSLContext.new if OpenSSL::OPENSSL_VERSION.match('1.1') ciphers << ["ADH-AES256-SHA@SECLEVEL=0", "TLSv1/SSLv3", 256, 256] else ciphers << ["ADH-AES256-SHA", "TLSv1/SSLv3", 256, 256] end @ssl_context.ciphers = ciphers @ssl_context.max_version = OpenSSL::SSL::TLS1_2_VERSION end |
Instance Attribute Details
#socket ⇒ Object
Returns the value of attribute socket.
8 9 10 |
# File 'lib/openas2/remote/connection.rb', line 8 def socket @socket end |
#ssl_context ⇒ Object
Returns the value of attribute ssl_context.
8 9 10 |
# File 'lib/openas2/remote/connection.rb', line 8 def ssl_context @ssl_context end |
#ssl_socket ⇒ Object
Returns the value of attribute ssl_socket.
8 9 10 |
# File 'lib/openas2/remote/connection.rb', line 8 def ssl_socket @ssl_socket end |
Instance Method Details
#close ⇒ Object
42 43 44 |
# File 'lib/openas2/remote/connection.rb', line 42 def close @ssl_socket.close end |
#connect ⇒ Object
24 25 26 27 28 |
# File 'lib/openas2/remote/connection.rb', line 24 def connect @ssl_socket = OpenSSL::SSL::SSLSocket.new(@socket, @ssl_context) @ssl_socket.sync_close = true @ssl_socket.connect end |
#gets ⇒ Object
38 39 40 |
# File 'lib/openas2/remote/connection.rb', line 38 def gets @ssl_socket.gets end |
#puts(s) ⇒ Object
34 35 36 |
# File 'lib/openas2/remote/connection.rb', line 34 def puts(s) @ssl_socket.puts(s) end |
#readlines ⇒ Object
30 31 32 |
# File 'lib/openas2/remote/connection.rb', line 30 def readlines @ssl_socket.readlines end |