{"modulePath":"github.com/andrewbytecoder/nmq","version":"v0.0.0-20261028105650-d8b0a59c570e","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package ip\n\n## Types\n\n```go\ntype Checker struct {\n\t// contains filtered or unexported fields\n}\n```\nChecker allows to check that addresses are in a trusted IPS\n\n```go\nfunc NewChecker(trustedIPs []string) (*Checker, error)\n```\nNewChecker builds a new Checker given a list of CIDR-Strings to trusted IPs.\n\n```go\nfunc (ip *Checker) Contains(addr string) (bool, error)\n```\n\n```go\nfunc (ip *Checker) ContainsIP(addr net.IP) bool\n```\n\n```go\nfunc (ip *Checker) IsAuthorized(addr string) error\n```\nIsAuthorized checks if provided request is authorized by the trusted IPs.\n\n```go\ntype DepthStrategy struct {\n\tDepth int\n\t// IPv6Subnet instructs the strategy to return the first IP of the subnet where IP belongs.\n\tIPv6Subnet *int\n}\n```\nDepthStrategy a strategy based on the depth inside the X-Forwarded-For from right to left.\n\n```go\nfunc (s *DepthStrategy) GetIP(req *http.Request) string\n```\nGetIP returns the selected IP.\n\n```go\ntype PoolStrategy struct {\n\tChecker *Checker\n}\n```\nPoolStrategy is a strategy based on an IP Checker. It allows to check whether addresses are in a given pool of IPs.\n\n```go\nfunc (s *PoolStrategy) GetIP(req *http.Request) string\n```\nGetIP checks the list of Forwarded IPs (most recent first) against the Checker pool of IPs. It returns the first IP that is not in the pool, or the empty string otherwise.\n\n```go\ntype RemoteAddrStrategy struct {\n\t// IPv6Subnet instructs the strategy to return the first IP of the subnet where IP belongs.\n\tIPv6Subnet *int\n}\n```\nRemoteAddrStrategy a strategy that always return the remote address.\n\n```go\nfunc (s *RemoteAddrStrategy) GetIP(req *http.Request) string\n```\nGetIP returns the selected IP.\n\n```go\ntype Strategy interface {\n\tGetIP(req *http.Request) string\n}\n```\nStrategy a strategy for IP selection.\n\n","path":"github.com/andrewbytecoder/nmq/plugins/proxy/ip","name":"ip","synopsis":"","isRedistributable":true}
