Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrIPSpoofAttack = errors.New("ip spoofing attack detected")
)
var (
ErrNoPeerInfo = errors.New("no peer information in context")
)
Functions ¶
This section is empty.
Types ¶
type GRPCRemoteIPParser ¶ added in v1.31.3
type GRPCRemoteIPParser struct {
// contains filtered or unexported fields
}
GRPCRemoteIPParser extracts and validates the client's true IP address from gRPC metadata. This is adapted from the HTTP RemoteIPParser to work with gRPC contexts and metadata.
func NewGRPCRemoteIPParser ¶ added in v1.31.3
func NewGRPCRemoteIPParser(trustedProxies []string) *GRPCRemoteIPParser
NewGRPCRemoteIPParser creates a new GRPCRemoteIPParser with the list of trusted proxies. If the list is empty, it will use the default trusted proxies.
type HTTPRemoteIPParser ¶ added in v1.31.3
type HTTPRemoteIPParser struct {
// contains filtered or unexported fields
}
HTTPRemoteIPParser extracts and validates the client's true IP address from HTTP request headers. This is a port of the Rails code: https://github.com/rails/rails/blob/v8.0.2/actionpack/lib/action_dispatch/middleware/remote_ip.rb#L109-L167
func NewHTTPRemoteIPParser ¶ added in v1.31.3
func NewHTTPRemoteIPParser(trustedProxies []string) *HTTPRemoteIPParser
NewRemoteIPParser creates a new RemoteIPParser with the list of trusted proxies. If the list is empty, it will use the default trusted proxies.
type RemoteIPParser
deprecated
type RemoteIPParser struct {
HTTPRemoteIPParser
}
RemoteIPParser extracts and validates the client's true IP address from HTTP request headers.
Deprecated: This struct added to maintain backwards compatibility and will be removed later. Use HTTPRemoteIPParser instead.
func NewRemoteIPParser
deprecated
func NewRemoteIPParser(trustedProxies []string) *RemoteIPParser
NewRemoteIPParser creates a new RemoteIPParser with the list of trusted proxies. If the list is empty, it will use the default trusted proxies.
Deprecated: This method added to maintain backwards compatibility and will be removed later. Use HTTPRemoteIPParser instead.