Module: RTunnel::ConnectionId
- Included in:
- Server
- Defined in:
- lib/rtunnel/connection_id.rb
Overview
Unique ID generation functionality.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.new_cipher ⇒ Object
6 7 8 9 10 11 |
# File 'lib/rtunnel/connection_id.rb', line 6 def self.new_cipher cipher = OpenSSL::Cipher::Cipher.new 'aes-128-ecb' cipher.encrypt cipher.key, cipher.iv = cipher.random_key, cipher.random_iv cipher end |
.new_counter ⇒ Object
13 14 15 |
# File 'lib/rtunnel/connection_id.rb', line 13 def self.new_counter '0' * 16 end |
Instance Method Details
#new_connection_id ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/rtunnel/connection_id.rb', line 17 def new_connection_id @session_id_cipher ||= RTunnel::ConnectionId.new_cipher @session_id_counter ||= RTunnel::ConnectionId.new_counter connection_id = @session_id_cipher.update @session_id_counter @session_id_counter.succ! Base64.encode64(connection_id).strip end |