Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrIPSpoofAttack = errors.New("ip spoofing attack detected")
)
Functions ¶
This section is empty.
Types ¶
type RemoteIPParser ¶
type RemoteIPParser struct { // TrustedProxies is a list of IP addresses or CIDR ranges that are considered trusted proxies TrustedProxies []string // CheckIPSpoofing enables the IP spoofing check between X-Forwarded-For and Client-IP headers CheckIPSpoofing bool }
RemoteIPParser 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 NewRemoteIPParser ¶
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.
Click to show internal directories.
Click to hide internal directories.