https://github.com/jonhadfield/ip-fetcher
A library and CLI to fetch IP ranges from popular online sources
https://github.com/jonhadfield/ip-fetcher
address aws azure gcp go golang google ips networks oci
Last synced: 7 months ago
JSON representation
A library and CLI to fetch IP ranges from popular online sources
- Host: GitHub
- URL: https://github.com/jonhadfield/ip-fetcher
- Owner: jonhadfield
- License: mit
- Created: 2023-01-01T23:04:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-24T13:15:55.000Z (8 months ago)
- Last Synced: 2024-10-25T15:24:39.282Z (8 months ago)
- Topics: address, aws, azure, gcp, go, golang, google, ips, networks, oci
- Language: Go
- Homepage:
- Size: 985 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ip-fetcher
[](https://pkg.go.dev/github.com/jonhadfield/ip-fetcher)
[](https://goreportcard.com/report/github.com/jonhadfield/ip-fetcher)## about
ip-fetcher is a go library and cli used to retrieve public ip prefixes from popular cloud and hosting providers.
Please raise an issue if you have any issues or suggestions for new providers.## supported providers
- AbuseIPDB
- AWS (Amazon Web Services)
- Bingbot
- Cloudflare
- DigitalOcean
- Fastly
- GCP (Google Cloud Platform)
- Googlebot
- MaxMind GeoIP
- Microsoft Azure## CLI
### install
Download the latest release [here](https://github.com/jonhadfield/ip-fetcher/releases) and then install:
```bash
install /usr/local/bin/ip-fetcher
```
_use: `sudo install` if on linux_### run
```
ip-fetcher
```
for example:
- output aws prefixes to the console: `ip-fetcher aws --stdout`
- save gcp prefixes to a file: `ip-fetcher gcp --file prefixes.json`## API
The following example uses the GCP (Google Cloud Platform) provider.
### installation
```
go get github.com/jonhadfield/ip-fetcher/providers/gcp
```
### basic usage
```
package mainimport (
"fmt"
"github.com/jonhadfield/ip-fetcher/providers/gcp"
)func main() {
g := gcp.New() // initialise client
doc, err := g.Fetch() // fetch prefixes document
if err != nil {
panic(err)
}for _, p := range doc.IPv6Prefixes {
fmt.Printf("%s %s %s\n", p.IPv6Prefix.String(), p.Service, p.Scope)
}
}
```