Class: LocalDevelopmentGateway::DatabaseRouter::Tds::TlsByteReader
- Inherits:
-
Object
- Object
- LocalDevelopmentGateway::DatabaseRouter::Tds::TlsByteReader
- Defined in:
- lib/local_development_gateway/database_router/tds/tls_byte_reader.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(bytes) ⇒ TlsByteReader
constructor
A new instance of TlsByteReader.
- #read(length) ⇒ Object
- #uint16 ⇒ Object
- #uint8 ⇒ Object
- #vector16 ⇒ Object
- #vector8 ⇒ Object
Constructor Details
#initialize(bytes) ⇒ TlsByteReader
Returns a new instance of TlsByteReader.
5 6 7 8 |
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 5 def initialize(bytes) @bytes = bytes @offset = 0 end |
Instance Method Details
#empty? ⇒ Boolean
10 11 12 |
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 10 def empty? @offset == @bytes.bytesize end |
#read(length) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 14 def read(length) if length.negative? || @offset + length > @bytes.bytesize raise Error, "Invalid TLS ClientHello" end value = @bytes.byteslice(@offset, length) @offset += length value end |
#uint16 ⇒ Object
28 29 30 |
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 28 def uint16 read(2).unpack1("n") end |
#uint8 ⇒ Object
24 25 26 |
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 24 def uint8 read(1).unpack1("C") end |
#vector16 ⇒ Object
36 37 38 |
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 36 def vector16 read(uint16) end |
#vector8 ⇒ Object
32 33 34 |
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 32 def vector8 read(uint8) end |