Class: ECHConfig
- Inherits:
-
Object
- Object
- ECHConfig
- Extended by:
- T::Sig
- Defined in:
- lib/ech_config/version.rb,
lib/ech_config.rb,
lib/ech_config.rb
Overview
typed: strict frozen_string_literal: true
Defined Under Namespace
Classes: DecodeError, ECHConfigContents, Error, UnsupportedVersion
Constant Summary collapse
- VERSION =
'0.0.3'
Instance Attribute Summary collapse
-
#echconfig_contents ⇒ Object
readonly
Returns the value of attribute echconfig_contents.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #encode ⇒ Object
-
#initialize(version, echconfig_contents) ⇒ ECHConfig
constructor
A new instance of ECHConfig.
Constructor Details
#initialize(version, echconfig_contents) ⇒ ECHConfig
Returns a new instance of ECHConfig.
24 25 26 27 28 29 30 31 |
# File 'lib/ech_config.rb', line 24 def initialize(version, echconfig_contents) v = version.unpack1('n') # https://author-tools.ietf.org/iddiff?url2=draft-ietf-tls-esni-11.txt#context-3 raise ::ECHConfig::UnsupportedVersion unless v > "\xfe\x0a".unpack1('n') && v <= "\xfe\x0d".unpack1('n') @version = version @echconfig_contents = echconfig_contents end |
Instance Attribute Details
#echconfig_contents ⇒ Object (readonly)
Returns the value of attribute echconfig_contents.
17 18 19 |
# File 'lib/ech_config.rb', line 17 def echconfig_contents @echconfig_contents end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
17 18 19 |
# File 'lib/ech_config.rb', line 17 def version @version end |
Class Method Details
.decode_vectors(octet) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ech_config.rb', line 40 def self.decode_vectors(octet) i = 0 echconfigs = [] while i < octet.length raise ::ECHConfig::DecodeError if i + 4 > octet.length version = octet.slice(i, 2) raise ::ECHConfig::DecodeError if version.nil? length = octet.slice(i + 2, 2)&.unpack1('n') i += 4 raise ::ECHConfig::DecodeError if i + length > octet.length echconfig_contents = ECHConfigContents.decode(octet.slice(i, length) || '') i += length echconfigs << new(version, echconfig_contents) end raise ::ECHConfig::DecodeError if i != octet.length echconfigs end |
Instance Method Details
#encode ⇒ Object
34 35 36 |
# File 'lib/ech_config.rb', line 34 def encode @version + @echconfig_contents.encode.then { |s| [s.length].pack('n') + s } end |