code.gitea.io/gitea@v1.19.3/modules/proxyprotocol/errors.go (about)

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