You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

errors.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package proxyprotocol
  4. import "fmt"
  5. // ErrBadHeader is an error demonstrating a bad proxy header
  6. type ErrBadHeader struct {
  7. Header []byte
  8. }
  9. func (e *ErrBadHeader) Error() string {
  10. return fmt.Sprintf("Unexpected proxy header: %v", e.Header)
  11. }
  12. // ErrBadAddressType is an error demonstrating a bad proxy header with bad Address type
  13. type ErrBadAddressType struct {
  14. Address string
  15. }
  16. func (e *ErrBadAddressType) Error() string {
  17. return fmt.Sprintf("Unexpected proxy header address type: %s", e.Address)
  18. }
  19. // ErrBadRemote is an error demonstrating a bad proxy header with bad Remote
  20. type ErrBadRemote struct {
  21. IP string
  22. Port string
  23. }
  24. func (e *ErrBadRemote) Error() string {
  25. return fmt.Sprintf("Unexpected proxy header remote IP and port: %s %s", e.IP, e.Port)
  26. }
  27. // ErrBadLocal is an error demonstrating a bad proxy header with bad Local
  28. type ErrBadLocal struct {
  29. IP string
  30. Port string
  31. }
  32. func (e *ErrBadLocal) Error() string {
  33. return fmt.Sprintf("Unexpected proxy header local IP and port: %s %s", e.IP, e.Port)
  34. }