func (t *TLSHandshakeRecord) decodeFromBytes(h TLSRecordHeader, data []byte, df gopacket.DecodeFeedback) error {
	// TLS Record Header
	t.ContentType = h.ContentType
	t.Version = h.Version
	t.Length = h.Length

	current := 0

	current = current + 1
	if data[0] != 0x1 {
		return nil
	}

	t.HandshakeType = TLSHandshakeClientHello

	// Skip over another length
	current += 3
	// Skip over protocolversion
	current += 2
	// Skip over random number
	current += 4 + 28

	// Skip over session ID
	sessionIDLength := int(data[current])
	current += 1
	current += sessionIDLength

	cipherSuiteLength := (int(data[current]) << 8) + int(data[current+1])
	current += 2
	current += cipherSuiteLength

	compressionMethodLength := int(data[current])
	current += 1
	current += compressionMethodLength

	if current > len(data) {
		return nil
	}

	current += 2

	hostname := ""
	for current < len(data) && hostname == "" {
		extensionType := (int(data[current]) << 8) + int(data[current+1])
		current += 2

		extensionDataLength := (int(data[current]) << 8) + int(data[current+1])
		current += 2

		if extensionType == 0 {

			// Skip over number of names as we're assuming there's just one
			current += 2

			nameType := data[current]
			current += 1
			if nameType != 0 {
				return nil
			}
			nameLen := (int(data[current]) << 8) + int(data[current+1])
			current += 2
			hostname = string(data[current : current+nameLen])
		}

		current += extensionDataLength
	}
	if hostname == "" {
		return nil
	}

	t.ServerName = hostname

	return nil
}
// DecodeFromBytes decodes the slice into the TLS struct.
DecodeFromBytes decodes the slice into the TLS struct.
// DecodeFromBytes decodes the slice into the TLS struct .
func (t *TLSHandshakeRecord) decodeFromBytes(h TLSRecordHeader, data []byte, df gopacket.DecodeFeedback) error {
	t.ContentType = h.ContentType
	t.Version = h.Version
	t.Length = h.Length
	current := 0
	current = current + 1
	if data[0] != 0x1 {
		return nil
	}
	t.HandshakeType = TLSHandshakeClientHello
	current += 3
	current += 2
	current += 4 + 28
	sessionIDLength := int(data[current])
	current += 1
	current += sessionIDLength
	cipherSuiteLength := (int(data[current]) << 8) + int(data[current+1])
	current += 2
	current += cipherSuiteLength
	compressionMethodLength := int(data[current])
	current += 1
	current += compressionMethodLength
	if current > len(data) {
		return nil
	}
	current += 2
	hostname := ""
	for current < len(data) && hostname == "" {
		extensionType := (int(data[current]) << 8) + int(data[current+1])
		current += 2
		extensionDataLength := (int(data[current]) << 8) + int(data[current+1])
		current += 2
		if extensionType == 0 {
			current += 2
			nameType := data[current]
			current += 1
			if nameType != 0 {
				return nil
			}
			nameLen := (int(data[current]) << 8) + int(data[current+1])
			current += 2
			hostname = string(data[current : current+nameLen])
		}
		current += extensionDataLength
	}
	if hostname == "" {
		return nil
	}
	t.ServerName = hostname
	return nil
}
func ( t * TLSHandshakeRecord ) decodeFromBytes ( h TLSRecordHeader , data [ ] byte , df gopacket . DecodeFeedback ) error { t . ContentType = h . ContentType t . Version = h . Version t . Length = h . Length current := 0 current = current + 1 if data [ 0 ] != 0x1 { return nil } t . HandshakeType = TLSHandshakeClientHello current += 3 current += 2 current += 4 + 28 sessionIDLength := int ( data [ current ] ) current += 1 current += sessionIDLength cipherSuiteLength := ( int ( data [ current ] ) << 8 ) + int ( data [ current + 1 ] ) current += 2 current += cipherSuiteLength compressionMethodLength := int ( data [ current ] ) current += 1 current += compressionMethodLength if current > len ( data ) { return nil } current += 2 hostname := " " for current < len ( data ) && hostname == " " { extensionType := ( int ( data [ current ] ) << 8 ) + int ( data [ current + 1 ] ) current += 2 extensionDataLength := ( int ( data [ current ] ) << 8 ) + int ( data [ current + 1 ] ) current += 2 if extensionType == 0 { current += 2 nameType := data [ current ] current += 1 if nameType != 0 { return nil } nameLen := ( int ( data [ current ] ) << 8 ) + int ( data [ current + 1 ] ) current += 2 hostname = string ( data [ current : current + nameLen ] ) } current += extensionDataLength } if hostname == " " { return nil } t . ServerName = hostname return nil }
DecodeFromBytes decodes the slice into the TLS struct.
DecodeFromBytes decodes the slice into the TLS struct .
// TLS Record Header // Skip over another length // Skip over protocolversion // Skip over random number // Skip over session ID // Skip over number of names as we're assuming there's just one