Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Default = Options{ Headers: []string{ "X-Real-Ip", "X-Forwarded-For", "CF-Connecting-IP", }, PrivateSubnets: []Range{ { Start: net.ParseIP("10.0.0.0"), End: net.ParseIP("10.255.255.255"), }, { Start: net.ParseIP("100.64.0.0"), End: net.ParseIP("100.127.255.255"), }, { Start: net.ParseIP("172.16.0.0"), End: net.ParseIP("172.31.255.255"), }, { Start: net.ParseIP("192.0.0.0"), End: net.ParseIP("192.0.0.255"), }, { Start: net.ParseIP("192.168.0.0"), End: net.ParseIP("192.168.255.255"), }, { Start: net.ParseIP("198.18.0.0"), End: net.ParseIP("198.19.255.255"), }, }, }
Default is an `Options` value with some default headers and private subnets. See `Get` method.
Functions ¶
func GetIPAddress ¶
GetIPAddress returns a valid public IP Address from a collection of IP Addresses and a range of private subnets.
Reports whether a valid IP was found.
Types ¶
type Options ¶
type Options struct { Headers []string `json:"headers" yaml:"Headers" toml:"Headers"` PrivateSubnets []Range `json:"privateSubnets" yaml:"PrivateSubnets" toml:"PrivateSubnets"` }
Options holds the request `Headers` which IP should be fetched from. A header value should be separated by comma if contains more than one ip address. The `PrivateSubnets` field can be used to skip "local" addresses parsed by the `Headers` field.
See `AddHeader`, `AddRange` and `Get` methods.
func (*Options) AddHeader ¶
AddHeader adds a proxy remote address header to "opts". Should be called before any use of `Get`.
Click to show internal directories.
Click to hide internal directories.