gitea源码

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 "Unexpected proxy header address type: " + 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. }