error.go 809 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (c) 2018, Open Systems AG. All rights reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style license
  4. // that can be found in the LICENSE file in the root of the source
  5. // tree.
  6. package ja3
  7. import "fmt"
  8. // Error types
  9. const (
  10. LengthErr string = "length check %v failed"
  11. ContentTypeErr string = "content type not matching"
  12. VersionErr string = "version check %v failed"
  13. HandshakeTypeErr string = "handshake type not matching"
  14. SNITypeErr string = "SNI type not supported"
  15. )
  16. // ParseError can be encountered while parsing a segment
  17. type ParseError struct {
  18. errType string
  19. check int
  20. }
  21. func (e *ParseError) Error() string {
  22. if e.errType == LengthErr || e.errType == VersionErr {
  23. return fmt.Sprintf(e.errType, e.check)
  24. }
  25. return fmt.Sprint(e.errType)
  26. }