module Nova::Starbound::Protocol::Encryption
The encryption used in the protocol.
Attributes
encryption_provider[W]
The provider used to encrypt the body.
@return [Encryptor]
Public Class Methods
new()
click to toggle source
Initialize the encryption.
Calls superclass method
# File lib/nova/starbound/protocol/encryption.rb, line 14 def initialize @encryption_provider = Encryptors::Plaintext.new super() end
Public Instance Methods
encryption_provider()
click to toggle source
Gets the encryption provider.
@raise [NoEncryptionError] if {#state} isn’t handshake,
the encryption provider returns true on {Encryptor.plaintext?}, and +:allow_plaintext+ is false.
@return [Encryptor]
# File lib/nova/starbound/protocol/encryption.rb, line 26 def encryption_provider raise NoEncryptionError if @encryption_provider.class.plaintext? && !should_allow_plaintext? @encryption_provider end
Private Instance Methods
should_allow_plaintext?()
click to toggle source
Whether or not plaintext is acceptable. Checks the state to see if it’s :handshake
and the :allow_plaintext
option to return true or false.
@return [Boolean]
# File lib/nova/starbound/protocol/encryption.rb, line 41 def should_allow_plaintext? state == :handshake || options.fetch(:allow_plaintext, false) end