1
mirror of https://github.com/jakejarvis/simpip.git synced 2025-04-26 12:58:27 -04:00

🌎 simpip.com

Now powered purely by Cloudflare Workers — try this code on the playground! The ancient PHP version is archived here.

A very, very "simple" web server that returns the visitor's IP address in plaintext...and literally nothing else. Perfect for CLI usage via curl or for automated tasks.

This returns your IPv6 address by default, but to choose one or the other you can use curl flags:

curl simpip.com       # returns IPv6 *OR* IPv4
curl -4 simpip.com    # returns IPv4
curl -6 simpip.com    # returns IPv6, or fails to connect if network is incompatible

Example

In my terminal's dotfiles, I have three aliases:ip4 and ip6 which are self-explanatory, and simply ip which returns both addresses iff your network supports IPv6 — otherwise, IPv6 sliently fails and only your IPv4 address is shown.

alias ip4="curl -4 simpip.com --max-time 1 --proto-default https --silent"
alias ip6="curl -6 simpip.com --max-time 1 --proto-default https --silent"
alias ip="ip6; ip4"

Timeout is set to 1 second via --max-time 1 (otherwise we will get stuck indefinitely trying to connect via IPv6 even if our network doesn't support it) and a secure connection preference is set using --proto-default https. Connection errors (particularly for IPv6) are silenced using --silent, so that the output of ip contains nothing but IP addresses, like so:

jake@macbook:~$ ip4
1.1.1.1

jake@macbook:~$ ip6
2606:4700:4700::1111

jake@macbook:~$ ip
2606:4700:4700::1111
1.1.1.1

License

This project is distributed under the MIT license.

Description
🌎 A very "simple" web server that returns your IP address in plaintext...and literally nothing else.
https://simpip.com/ Readme MIT 292 KiB
Languages
TypeScript 100%