alexandregv / cfip

Given an IP address, tells if this is a Cloudflare IP. Eg: https://api.code.express/cfip/104.31.122.34

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 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/<ip_address> Eg.

$ curl http://localhost:8080/cfip/104.31.122.34
{"ip": "104.31.122.34", "cloudflare_ip": "true"}

Also works for IPv6, eg.

cfip server on localhost checking IPv6 address

As a standalone binary

cfip can be used as a standalone binary as well. Simply invoke as follows:

$ ./cfip 104.31.122.34
{"ip": "104.31.122.34", "cloudflare_ip": "true"}

About

Given an IP address, tells if this is a Cloudflare IP. Eg: https://api.code.express/cfip/104.31.122.34

License:GNU General Public License v3.0


Languages

Language:Go 90.9%Language:Makefile 9.1%