{"modulePath":"github.com/panzerdev/ipfilter","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package ipfilter\n\n## Functions\n\n```go\nfunc Setup(c *caddy.Controller) error\n```\nSetup parses the ipfilter configuration and returns the middleware handler.\n\n## Types\n\n```go\ntype ByLength []string\n```\nByLength sorts strings by length and alphabetically (if same length)\n\n```go\nfunc (s ByLength) Len() int\n```\n\n```go\nfunc (s ByLength) Less(i, j int) bool\n```\n\n```go\nfunc (s ByLength) Swap(i, j int)\n```\n\n```go\ntype IPFConfig struct {\n\tPaths     []IPPath\n\tDBHandler *maxminddb.Reader // Database's handler if it gets opened.\n}\n```\nIPFConfig holds the configuration for the ipfilter middleware.\n\n```go\ntype IPFilter struct {\n\tNext   httpserver.Handler\n\tConfig IPFConfig\n}\n```\nIPFilter is a middleware for filtering clients based on their ip or country's ISO code.\n\n```go\nfunc (ipf IPFilter) PrefixDirBlocked(clientIP net.IP, path IPPath) bool\n```\nPrefixDirBlocked takes an IP and a path and decides to allow or block based on prefix\\_dir.\n\n```go\nfunc (ipf IPFilter) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)\n```\n\n```go\nfunc (ipf IPFilter) ShouldAllow(path IPPath, r *http.Request) (bool, string, error)\n```\nShouldAllow takes a path and a request and decides if it should be allowed\n\n```go\ntype IPPath struct {\n\tPathScopes   []string\n\tBlockPage    string\n\tCountryCodes []string\n\tPrefixDir    string\n\tNets         []*net.IPNet\n\tIsBlock      bool\n\tStrict       bool\n}\n```\nIPPath holds the configuration of a single ipfilter block.\n\n```go\ntype OnlyCountry struct {\n\tCountry struct {\n\t\tISOCode string `maxminddb:\"iso_code\"`\n\t} `maxminddb:\"country\"`\n}\n```\nOnlyCountry is used to fetch only the country's code from 'mmdb'.\n\n```go\ntype Status struct {\n\t// contains filtered or unexported fields\n}\n```\nStatus is used to keep track of the status of the request.\n\n```go\nfunc (s *Status) Any() bool\n```\nAny returns 'true' if we have a match on a country code or an IP in range.\n\n","path":"github.com/panzerdev/ipfilter","name":"ipfilter","synopsis":"","isRedistributable":true}
