Sha256: 8cba0696d3565c269a2743a3c14b5b6785d4c9dbb526e1132d9f22591d9d48df

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

module Dap
   module Filter

      #
      # Decode a Google Quic VersionsRequest probe response
      #
      class FilterDecodeGquicVersionsResult
        include BaseDecoder

        #
        # Decode an GQUIC ( Google Quic) versions probe response
        #
        # @param data [String] Binary string containing raw response from server
        # @return [Hash] containing all GQUIC versions supported else nil
        #
        def decode(data)
           return unless data
           # need to skip 9 bytes and assume at least one valid version Q044
           if data.length > 9 + 4 && (data.length - 9) % 4
              versions = []
              i = 9
              step = 4
              while i < data.length 
                 version = data[i..i+4-1]
                 # Versions start with the letter Q
                 if data[i] == 'Q'
                    versions.push(version)
                 end
                 i = i + step
              end
              if versions.length > 0
                 # examples show versions in descending order, but in case its not reverse sort
                 info = {'versions' => versions.sort.reverse}
                 return info
              end
           end
        end
      end
   end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dap-0.1.23 lib/dap/filter/gquic.rb