https://github.com/bwplotka/go-ipfilter
Tiny Golang lib for IP filtering. (e.g private only)
https://github.com/bwplotka/go-ipfilter
filter go golang ip ipfiltering
Last synced: 6 months ago
JSON representation
Tiny Golang lib for IP filtering. (e.g private only)
- Host: GitHub
- URL: https://github.com/bwplotka/go-ipfilter
- Owner: bwplotka
- License: apache-2.0
- Created: 2017-07-20T10:24:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-20T13:43:15.000Z (over 8 years ago)
- Last Synced: 2025-02-09T23:16:18.559Z (12 months ago)
- Topics: filter, go, golang, ip, ipfiltering
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IP Filter
[](https://travis-ci.org/Bplotka/go-ipfilter)
Tiny Golang lib for IP filtering.
This is helpful to restrict access to some endpoints on public service (e.g debug endpoints)
### Well, why not just use proper auth (e.g basic, oidc, oauth2)?
Because some endpoints are problematic to hide using auth, like debug or metrics endpoints.
## Usage
Filters are in a form of Bool conditions that takes IP in a form of `net.IP`
```go
type Condition func(net.IP) bool
````
You can chain multiple conditions with some logic using `ipfilter.OR(...)` `ipfilter.AND(...)`
This package also contain useful [HTTP middleware integration](./http/middleware.go).