https://github.com/codeexpress/cfip
Given an IP address, tells if this is a Cloudflare IP. Eg: https://api.code.express/cfip/104.31.122.34
https://github.com/codeexpress/cfip
cloudflare go golang
Last synced: about 1 month ago
JSON representation
Given an IP address, tells if this is a Cloudflare IP. Eg: https://api.code.express/cfip/104.31.122.34
- Host: GitHub
- URL: https://github.com/codeexpress/cfip
- Owner: codeexpress
- License: gpl-3.0
- Created: 2019-06-15T08:05:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-13T22:45:28.000Z (almost 4 years ago)
- Last Synced: 2024-06-19T19:40:05.173Z (over 1 year ago)
- Topics: cloudflare, go, golang
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Is a given IP a Cloudflare IP address?
`cfip` is a script that checks if a given IP address is a Cloudflare IP address. It can be run as:
- a standlone tool
- a HTTP API
## Cloud
`cfip` runs as a API endpoint on api.code.express. To check IPv4 and IPv6 addresses respectively. Invoke it as follows following:
https://api.code.express/cfip/104.31.122.34
https://api.code.express/cfip/2606:4700:30::681b:804b
Please do not use this for production use cases or cause undue load on the server. If you need a more stable api, download and run a local copy by following the instructions below.
## Download
### Latest Releases
`cfip` is available for 32/64 bit linux, OS X and Windows systems.
Latest versions can be downloaded from the
[Release](https://github.com/codeexpress/cfip/releases) tab above.
### Build from source
This is a golang project with no dependencies. Assuming you have golang compiler installed,
the following will build the binary from scratch
```
$ git clone https://github.com/codeexpress/cfip
$ cd cfif
$ go build
```
## Usage
### As a HTTP API
`cfip` is best used as a HTTP api listening on localhost. One downloaded, run this to start the server:
```
$ ./cfip -s 8080
```
Then, to check an IP address, use curl or browser to open a URL eg. `curl http://localhost:8080/cfip/`
Eg.
```sh
$ curl http://localhost:8080/cfip/104.31.122.34
{"ip": "104.31.122.34", "cloudflare_ip": "true"}
```
Also works for IPv6, eg.

### As a standalone binary
`cfip` can be used as a standalone binary as well. Simply invoke as follows:
```sh
$ ./cfip 104.31.122.34
{"ip": "104.31.122.34", "cloudflare_ip": "true"}
```