Class: LocalDevelopmentGateway::DatabaseRouter::Tds::TlsByteReader

Inherits:
Object
  • Object
show all
Defined in:
lib/local_development_gateway/database_router/tds/tls_byte_reader.rb

Instance Method Summary collapse

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

Returns:

  • (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

#uint16Object



28
29
30
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 28

def uint16
  read(2).unpack1("n")
end

#uint8Object



24
25
26
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 24

def uint8
  read(1).unpack1("C")
end

#vector16Object



36
37
38
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 36

def vector16
  read(uint16)
end

#vector8Object



32
33
34
# File 'lib/local_development_gateway/database_router/tds/tls_byte_reader.rb', line 32

def vector8
  read(uint8)
end