You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1.6 KiB

ipinfo

Simplified fork of echoip.

A simple service for looking up your IP address.

Usage

Just the business, please:

$ curl example.tld
127.0.0.1

$ http example.tld
127.0.0.1

$ wget -qO- example.tld
127.0.0.1

$ fetch -qo- https://example.tld
127.0.0.1

$ bat -print=b example.tld/ip
127.0.0.1

As JSON:

$ curl -H 'Accept: application/json' example.tld  # or curl example.tld/json
{
  "ip": "127.0.0.1",
  "ip_decimal": 2130706433,
}

Port testing:

$ curl example.tld/port/80
{
  "ip": "127.0.0.1",
  "port": 80,
  "reachable": false
}

Pass the appropriate flag (usually -4 and -6) to your client to switch between IPv4 and IPv6 lookup.

Features

  • Fast
  • Supports IPv6
  • Supports HTTPS
  • Supports common command-line clients (e.g. curl, httpie, ht, wget and fetch)
  • JSON output
  • Port testing
  • All endpoints (except /port) can return information about a custom IP address specified via ?ip= query parameter
  • Open source under the BSD 3-Clause license

Building

You will no doubt want to customize the html, so the best way to build this is to clone the repo, edit the html, and build the binary.

git clone https://github.com/gryffyn/ipinfo

Edit the files in http/html, then run make install, or cd cmd/ipinfo && go build.

Usage

$ echoip -h
Usage of echoip:
  -C int
    	Size of response cache. Set to 0 to disable
  -H value
    	Header to trust for remote IP, if present (e.g. X-Real-IP)
  -l string
    	Listening address (default ":8080")
  -p	Enable port lookup
  -r	Perform reverse hostname lookups